Search This Blog

Wednesday, February 3, 2021

Oracle EBS R12 CO Extension for Attachment Mandatory in SSHR Review Page

Read this below blog to have a overview how the CO Extension works.

http://mogalafzal.blogspot.com/2016/03/21-oaf-co-extension.html


Requirement: 

To make the attachments mandatory in the review page for certain EIT and SIT Transactions, not all.

Created lookup value with the Function_name as lookup_code to validate attachments required. Attached procedures and images of lookups for reference.


1.

Page: /oracle/apps/per/selfservice/review/webui/ReviewPG
Controller: ReviewCO --> ReviewCOEx

Create new project with package name: xxcust.oracle.apps.per.selfservice.review.webui

import the folder from the java top :  oracle.apps.per.selfservice.review.webui.ReviewCO (class file)


2.

Write below code in PFR in your extend of ReviewCO as ReviewCOEx java file.


public void processFormRequest(OAPageContext oapagecontext, OAWebBean oawebbean) {
        

      OAApplicationModule oaapplicationmodule = oapagecontext.getApplicationModule(oawebbean);
         // throw new OAException("under sql exception"+oapagecontext.getParameter("OAFunc"),OAException.INFORMATION);
 OADBTransactionImpl txn = (OADBTransactionImpl)oapagecontext.getRootApplicationModule().getOADBTransaction();      
        
        //getting the function id name and comparing it with our lookup values to check if required Y or N
          String outParamValue = null;  
      CallableStatement callableStatement =      
        txn.createCallableStatement("begin P_GET_TXN_NAME_YN(:1, :2); end;",OADBTransaction.DEFAULT);      
      try {     
          callableStatement.setString(1,oapagecontext.getParameter("OAFunc"));// "HR_EIT_VS_SS"
        callableStatement.registerOutParameter(2, Types.VARCHAR);  
        
        
        callableStatement.execute();  
        outParamValue = callableStatement.getString(2);  
        callableStatement.close();  
      } catch (SQLException sqle) {  
        
            throw new OAException("under sql exception"+sqle,OAException.ERROR);
      }  
      
          OADBTransactionImpl txn2 = (OADBTransactionImpl)oapagecontext.getRootApplicationModule().getOADBTransaction();
          OAMessageAttachmentLinkBean uploadBean = (OAMessageAttachmentLinkBean)oawebbean.findChildRecursive("AttachmentLink");
          String ssdn = (String)uploadBean.getAttributeValue(oapagecontext.getRenderingContext(), TEXT_ATTR);
          
          //getting the status of the Attachments as None for no attachments, but for arabic it is issue, so we are using lookup values for arabic ex: 'La shai' as 'None' in description.
          String outParamValue2 = null;  
          CallableStatement callableStatement2 =
          txn2.createCallableStatement("begin P_GET_ATTACH_STATUS(:1, :2); end;",OADBTransaction.DEFAULT);
          try {
          callableStatement2.setString(1,ssdn);
          callableStatement2.registerOutParameter(2, Types.VARCHAR);
          
          
          callableStatement2.execute();
          outParamValue2 = callableStatement2.getString(2);
          callableStatement2.close();
          } catch (SQLException sqle2) {
          
            throw new OAException("under sql exception"+sqle2,OAException.ERROR);
          }
       
          /* For testing the outputs
           if (oapagecontext.getParameter("HrSubmit")!= null) {
             throw new OAException("ssdn.trim " + ssdn.trim() + "  outParamValue " +outParamValue + "  outParamValue2 " +outParamValue2 ,OAException.ERROR);
          }
              //throw new OAException("outParamValue " +outParamValue,OAException.ERROR);          }
       */
          if ("Y".equals(outParamValue)){
     if (oapagecontext.getParameter("HrSubmit")!= null)
      {
     // OAMessageAttachmentLinkBean uploadBean = (OAMessageAttachmentLinkBean)oawebbean.findChildRecursive("AttachmentLink");
     // String ssdn = (String)uploadBean.getAttributeValue(oapagecontext.getRenderingContext(), TEXT_ATTR);
         //throw new OAException("ssdn.trim " + ssdn.trim(),OAException.ERROR);
      if ("None".equals(outParamValue2 )  )//|| "View".equals(ssdn.trim()) )//|| "?? ???".contains(ssdn.trim()))
      {
//      throw new OAException("There is no attachment kindly click on add button and browse your attachment",OAException.ERROR);
          throw new OAException("PER", "FUJ_ATTACHMENT_MAND", null, OAException.ERROR, null);

       //   throw new OAException("outParamValue2 " + outParamValue2 + "  outParamValue " +outParamValue ,OAException.ERROR);
      }
      else
      {
      
      super.processFormRequest(oapagecontext, oawebbean);
      }
      }
      else
      {
      //System.out.println("There exists an attachment to the expense claim. The process will now continue");
      super.processFormRequest(oapagecontext, oawebbean);
      }
      }
      else
      {
          super.processFormRequest(oapagecontext, oawebbean);
          //throw new OAException("output value is "+outParamValue,OAException.ERROR);
      }   
          
      }


3.




4 . 

Personlization

5. Move the class folder to the java_top and test the same.

6. for any update in the java code, change the name of the file ex: ReviewCOEx to ReviewCOEx2 or 3 and so on, run/make the code run

and then repeat the step 4,5.

7. Procedures 

CREATE OR REPLACE PROCEDURE APPS.P_GET_TXN_NAME_YN
(P_TXN_NAME VARCHAR2,
P_OUTPUT OUT VARCHAR2)
AS
BEGIN
SELECT 'Y'
INTO P_OUTPUT
 FROM FND_LOOKUP_VALUES
WHERE LOOKUP_TYPE = 'FUJ_SSHR_ATTACH_REQUIRED'
AND LANGUAGE = 'US'
AND LOOKUP_CODE = P_TXN_NAME;
/*SELECT 'Y'
INTO P_OUTPUT
FROM OAF_TEST
WHERE TXN_NAME = P_TXN_NAME;*/
EXCEPTION WHEN OTHERS THEN
P_OUTPUT := 'N';
END;
/


DECLARE
A VARCHAR2(200);
BEGIN
--P_GET_ATTACH_STATUS('?? ???',A);
P_GET_ATTACH_STATUS('None',A);
DBMS_OUTPUT.PUT_LINE(A);
END;

CREATE OR REPLACE PROCEDURE APPS.P_GET_ATTACH_STATUS
(P_TXN_NAME VARCHAR2,
P_OUTPUT OUT VARCHAR2)
AS
BEGIN
SELECT DESCRIPTION
INTO P_OUTPUT
 FROM FND_LOOKUP_VALUES
WHERE LOOKUP_TYPE = 'FUJ_SSHR_VALID_COEX'
AND LANGUAGE = 'US'
AND LOOKUP_CODE = UPPER(TRIM(P_TXN_NAME));
/*SELECT 'Y'
INTO P_OUTPUT
FROM OAF_TEST
WHERE TXN_NAME = P_TXN_NAME;*/
EXCEPTION WHEN OTHERS THEN
P_OUTPUT := 'N';
END;
/

Wednesday, January 6, 2021

Oracle Apps R12 create AR Receipt as On Account using api AR_RECEIPT_API_PUB.Create_Apply_on_acc

 --CREATE OR REPLACE PROCEDURE F_OB_TEST AS
declare
--p_count number;
g_request_id            NUMBER := fnd_global.conc_request_id;
p_amount number ;
p_receipt_date date := to_date('29-dec-2020'); --> change in prod
p_rec_mthd number := 332091;
--p_trx_number TRX_NUMBER_TYPE;
--p_trx_amount TRX_AMT_TYPE;
 P_TRX_NUMBER                   APPS.TRX_NUMBER_TYPE := APPS.TRX_NUMBER_TYPE();
 P_TRX_AMOUNT                   APPS.TRX_AMT_TYPE := APPS.TRX_AMT_TYPE();
p_remittance_bank_account_id    NUMBER  := 112771;
p_customer_number varchar2(240);-- := '41';
p_UserName varchar2(240) := 'EG_AFZ';
W_Status varchar2(2000) ;
W_Message varchar2(2000) ;
P_COMMENTS varchar2(240) := 'OB';
p_receipt_number varchar2(240);
retcode VARCHAR(240);

        l_msg_count                        NUMBER;
        l_count                            NUMBER;
        --l_receipt_Number                NUMBER;
        l_msg_data                           VARCHAR2 (32767);
        p_count                            NUMBER;
        l_error_mesg                       VARCHAR2 (32767);               
        l_error_code                       VARCHAR2 (32767);
        l_org_type                         VARCHAR2(32767) := NULL;
        l_org_name                         VARCHAR2(32767) := NULL;
        ln_org_id                          NUMBER:=NULL;
        l_user_id                      NUMBER ;--
        l_resp_id                      NUMBER := 523322; --
        l_resp_appl_id                 NUMBER := 222;
        l_org_id                       NUMBER := 18113;
        --l_receipt_method_id            NUMBER := 7025; --METHOD_NAME = FM ??? ??? ?????
        --p_receipt_method_id             NUMBER := 7025; --Cash Operation; --check this later
        currency_code                      VARCHAR2(3):='AED';
        l_customer_id                      NUMBER;
        l_site_use_id                      NUMBER;
        l_exist                            VARCHAR2(32767) := 'N';
        l_ErrFlag                          VARCHAR2(32767) := 'N';
        l_ErrMsg                           VARCHAR2(32767) := NULL;
        l_cash_receipt_id                  NUMBER;
        l_receipt_number                   VARCHAR2(32767);
        p_attribute_rec                    AR_RECEIPT_API_PUB.ATTRIBUTE_REC_TYPE;
        app_attribute_rec                  AR_RECEIPT_API_PUB.ATTRIBUTE_REC_TYPE;
        l_CustAcctId                       NUMBER;
        l_customer_trx_id                  NUMBER;
        l_status                           VARCHAR2(32767);
        l_mesg                             VARCHAR2(32767);
        l_cr_id                            NUMBER;
        l_return_status                    VARCHAR2(32767);
        l_payment_schedule_id             NUMBER;
        l_receipt_number1                 NUMBER;
        l_due_amt                        NUMBER;    
        l_receipt_cnt                    NUMBER;
        l_trx_applied_details           VARCHAR2(2000) := '';
                      
                      
cursor c1 is

select * from
XXOB_FNCE --custom table
where TXN_MODE = 'On Account Receipts '
AND CUST_NUMBER IS NOT NULL
--AND AMOUNT > '0'
AND ATTRIBUTE2 IS NULL
AND TXN_NUMBER  NOT IN ('OB_F1-7')--,'OB_F1-3')
;
                      
        BEGIN
FOR I IN C1 LOOP        
            BEGIN
                SELECT user_id
                INTO l_user_id
                FROM fnd_user
                WHERE user_name= p_UserName;
                EXCEPTION
                WHEN OTHERS THEN
                --l_user_id:=2605;
                l_ErrFlag := 'Y';
                l_ErrMsg  := l_ErrMsg || ' - ' || SQLERRM;
            END;
       

/*-----------------------------------
                -- Apps Initialize
--------------------------------------*/        
                fnd_global.apps_initialize(l_user_id,l_resp_id,l_resp_id,0);
               mo_global.set_policy_context('S',l_org_id);
                mo_global.init ('AR');

                 BEGIN
                    SELECT
                    hca.cust_account_id
                    INTO
                    l_CustAcctId
                    FROM  
                    hz_cust_accounts_all hca
                    ,hz_parties  hp
                    WHERE
                    hp.party_id=hca.party_id
                    AND  hca.account_number =I.CUST_NUMBER
                    AND hca.status = 'A'
                    AND rownum = 1
                         ;
                EXCEPTION
                         WHEN OTHERS THEN
                          l_ErrFlag := 'Y';
                          l_ErrMsg:='Customer Does Not Exists';
                          retcode:=0;----------Added on 21-aug-2017 Requested by NBF.
                          ---l_ErrMsg  := l_ErrMsg || ' - ' || SQLERRM;
                          l_ErrMsg  := l_ErrMsg || ' - ' || SQLERRM;
                          W_Status:='Failure';
                                                          W_Message:=l_ErrMsg||'_'||'APPLY API';
                          FND_FILE.PUT_LINE(FND_FILE.LOG,
                                            'ERROR: while fetching Customer_Number for Cust Ref '  || ' ' || SQLERRM);

                     END;
                     fnd_file.put_line(fnd_file.log,'Customer_Number' ||p_Customer_Number);
                     fnd_file.put_line(fnd_file.log,'l_CustAcctId'  ||l_CustAcctId);
                    DBMS_OUTPUT.PUT_LINE('l_CustAcctId'||l_CustAcctId);
                            
                IF l_CustAcctId >0 THEN
                                    BEGIN
                                                SELECT c.site_use_id
                                                 ---a.cust_account_id,
                                                --- e.address1,
                                                ---e.address2,
                                                 ---e.address3,
                                                --- e.address4,
                                                 --e.postal_code,
                                                --- e.province,
                                                -- e.state,
                                                --- country
                                                INTO
                                                 l_site_use_id
                                                 FROM hz_cust_accounts a,
                                                 hz_cust_acct_sites_all b,
                                                 hz_cust_site_uses_all c,
                                                 hz_party_sites d,
                                                 hz_locations e
                                                 WHERE a.cust_account_id = b.cust_account_id
                                                 AND b.cust_acct_site_id = c.cust_acct_site_id
                                                 AND b.party_site_id = d.party_site_id
                                                 AND d.location_id = e.location_id
                                                 AND c.site_use_code = 'BILL_TO'
                                                 AND c.status = 'A'
                                                 AND b.org_id = c.org_id
                                                 AND b.org_id =l_org_id
                                                 AND rownum = 1
                                                 AND a.cust_account_id=l_CustAcctId;
                                                EXCEPTION
                                                         WHEN OTHERS THEN
                                                          l_ErrFlag := 'Y';
                                                          l_ErrMsg:='Customer Sits is having Issue';
                                                          retcode:=0;----------Added on 21-aug-2017 Requested by NBF.
                                                          l_ErrMsg  := l_ErrMsg || ' - ' || SQLERRM;
                                                          W_Status:='Failure';
                                                          W_Message:=l_ErrMsg||'_'||'APPLY API';
                                                          FND_FILE.PUT_LINE(FND_FILE.LOG,
                                                                            'ERROR: while fetching Bill To '|| ' ' || SQLERRM);
                                    END;
                
                DBMS_OUTPUT.PUT_LINE('l_org_id'||l_org_id);
                DBMS_OUTPUT.PUT_LINE('l_site_use_id'||l_site_use_id);
                
/******************************************************************************************************
                -----------END OF Bill To Validations
******************************************************************************************************/
                    IF l_site_use_id> 0 THEN ---Commented by Rakesh 23-Aug-217
                    
                    
                    p_attribute_rec.ATTRIBUTE5          := '1';
                
               


    BEGIN
                        --l_receipt_Number := 'XX-11';
                            DBMS_OUTPUT.PUT_LINE('Calling Create Cash');
                            
                                BEGIN

                                     AR_RECEIPT_API_PUB.Create_Apply_on_acc
                                                                   ( p_api_version       => 1.0,
                                                                     p_init_msg_list     => FND_API.G_TRUE,
                                                                     p_commit            => FND_API.G_TRUE,
                                                                     p_validation_level  => FND_API.G_VALID_LEVEL_FULL,
                                                                     x_return_status     => l_return_status,
                                                                     x_msg_count         => l_msg_count,
                                                                     x_msg_data          => l_msg_data,
                                                                     p_currency_code     => 'AED',
                                                                     p_amount            => ABS(i.amount),
                                                                     p_receipt_number    => i.txn_number,
                                                                     p_receipt_date      =>  TO_DATE('29-dec-2020'),
                                                                     p_gl_date           => TO_DATE('29-dec-2020'),
                                                                     --p_customer_number   => v_customer_number,
                                                                     p_customer_id                 => l_CustAcctId,
                                                                     p_receipt_method_id => p_rec_mthd,
                                                                     p_org_id            => l_org_id,
                                                                     p_cr_id             => l_cr_id,
                                                                     p_attribute_rec            =>p_attribute_rec
                                                                       );
                                    DBMS_OUTPUT.PUT_LINE('STATUS '||l_return_status||' x_msg_count '||l_msg_count||' x_msg_data '||l_msg_data);
                                    IF l_return_status = 'S' THEN
                                       DBMS_OUTPUT.put_line('Receipt Creation and apply on account is Sucessful :');
                                    ELSE
                                       DBMS_OUTPUT.put_line('Message count ' || L_msg_count);
                                       IF L_msg_count = 1 THEN
                                          DBMS_OUTPUT.put_line('v_msg_data '||L_msg_data);
                                       ELSIF L_msg_count > 1 THEN
                                       LOOP
                                          p_count := p_count+1;
                                          L_msg_data := FND_MSG_PUB.Get(FND_MSG_PUB.G_NEXT,FND_API.G_FALSE);
                                          IF l_msg_data IS NULL THEN
                                          EXIT;
                                          END IF;
                                          DBMS_OUTPUT.put_line('Message' || p_count ||'---'||L_msg_data);
                                          END LOOP;
                                          END IF;
                                    END IF;
                                    END;
                                   -- end if;
                                COMMIT;
                        UPDATE XXOB_FNCE
                        SET ATTRIBUTE2 = l_return_status
                        WHERE TXN_NUMBER = I.TXN_NUMBER;
                        COMMIT;
                                                
                            END;
                            ------------END OF create cash
                        --    END IF; --EXIST
                        --    END IF;----l_receipt_cnt
                            ELSE
                            W_Status:='Failure';
                            W_Message:=l_ErrMsg||'_'||'Customer_SITE Does Not Exist';
                            retcode:=0;------------Added on 21-aug-2017 Requested by NBF.---Commented by Rakesh 23-Aug-217
                                DBMS_OUTPUT.put_line ('retcode ' || retcode);
                    END IF; ---l_site_use_id---Commented by Rakesh 23-Aug-217
                            
                    ELSE
                    W_Status:='Failure';
                    W_Message:=l_ErrMsg||'_'||'Customer_Number Does Not Exist';
                    retcode:=0;----------Added on 21-aug-2017 Requested by NBF.
                    DBMS_OUTPUT.put_line ('W_Status ' || W_Status);
                    DBMS_OUTPUT.put_line ('W_Message ' || W_Message);
                    DBMS_OUTPUT.put_line ('retcode ' || retcode);
                    
                    END IF; ---l_CustAcctId
                --arp_standard.disable_debug;
                END LOOP;
                END ;--create_rece
            --    END ; --
/

Monday, December 14, 2020

Oracle Workflow to show html table in the Message Notification

  1. Create the package, body as attached.

  1. Attribute

cid:image001.png@01D6D218.4735E210


  1. Function, message, attribute under it. 


cid:image006.jpg@01D6D218.7532CD40



  1. Attribute under message.

cid:image004.png@01D6D218.4735E210


4. Using attribute in Message Body

cid:image005.png@01D6D218.4735E210



Package: 

CREATE OR REPLACE PACKAGE APPS.XX_BODY_TXN_INFO_DOC_PKG
as
PROCEDURE XX_create_DOC_WF----for action history
(
document_id     IN              VARCHAR2,
display_type    IN              VARCHAR2,
DOCUMENT        IN OUT NOCOPY   VARCHAR2,
DOCUMENT_TYPE   IN OUT NOCOPY   VARCHAR2
);
PROCEDURE XX_DOC_CALL  --for calling
(itemtype in varchar2,
ITEMKEY IN VARCHAR2,
actid in number,
FUNCMODE IN VARCHAR2,
resultout out varchar2) ;

end;

--Package  Body
/


CREATE OR REPLACE PACKAGE BODY APPS.XX_BODY_TXN_INFO_DOC_PKG
as
--for history
PROCEDURE XX_create_DOC_WF
(
document_id     IN              VARCHAR2,
DISPLAY_TYPE    IN              VARCHAR2,
DOCUMENT        IN OUT NOCOPY   VARCHAR2,
document_type   IN OUT NOCOPY   VARCHAR2
)
IS
lv_details             VARCHAR2 (32767);
V_ITEMKEY          VARCHAR2(100);
amount number;

CURSOR CUR_QUALITF
IS


SELECT LINE_NUM,
    ASSET_NUMBER ,
    ENTITY,
    DEPARTMENT,
    UNITS,
    ASSET_DESCRIPTION,
    TAG_NUMBER,
    PO_NUMBER,
    SUPPLIER_NAME,
    ASSET_COST,
    ACCUMULATED_DEP,
    NET_BOOK_VALUE,
    ASSET_LIFE,
    DATE_PLACEDIN_SERVICE,
    ASSET_ID
FROM  XX_TABLE_APPROVALS_L
  WHERE DISPOSAL_ID = document_id
 ORDER BY LINE_NUM ASC;


BEGIN
/* TABLE HEADER*/
lv_details :=      lv_details
--|| '<h4> '
--|| 'Asset Details'
--|| '</H4>'
|| '<table border = "5" BORDERCOLOR="#B9D1EA"> <tr>'
--||'<b><caption align="left" BORDERCOLOR="#B9D1EA">Transaction Details</caption></b>' --if space in caption its coming in next line
|| '<th> '
|| 'Line'
|| '</th>'
|| '<th>'
|| 'Asset Number'
|| '</th>'
|| '</th>'
|| '<th>'
|| 'Entity'
|| '</th>'
|| '<th>'
|| 'Department'
|| '</th>'
|| '<th>'
|| 'Units'
|| '</th>'
|| '<th>'
|| 'Descriptin'
|| '</th>'
|| '<th>'
|| 'Tag Number'
|| '</th>'
|| '<th>'
|| 'PO Number'
|| '</th>'
|| '<th>'
|| 'Supplier Name'
|| '</th>'
|| '<th>'
|| 'Asset Cost'
|| '</th>'
|| '<th>'
|| 'Accumulated Dep'
|| '</th>'
|| '<th>'
|| 'NetBook Value'
|| '</th>'
|| '<th>'
|| 'Asset LIfe'
|| '</th>'
|| '<th>'
|| 'DatePlaceIn Service'
|| '</th>'
;

FOR CUR_QUALITF_REC IN CUR_QUALITF
loop
/*TABLE BODY */
lv_details:=        lv_details
|| '<tr>'
|| '<td>'
|| CUR_QUALITF_REC.LINE_NUM
|| '</td>'
|| '<td>'
|| CUR_QUALITF_REC.ASSET_NUMBER
|| '</td>'
|| '<td>'
|| CUR_QUALITF_REC.ENTITY
|| '</td>'
|| '<td>'
|| CUR_QUALITF_REC.DEPARTMENT
|| '</td>'
|| '<td>'
|| CUR_QUALITF_REC.UNITS
|| '</td>'
|| '<td>'
|| CUR_QUALITF_REC.ASSET_DESCRIPTION
|| '</td>'
|| '<td>'
|| CUR_QUALITF_REC.TAG_NUMBER
|| '</td>'
|| '<td>'
|| CUR_QUALITF_REC.PO_NUMBER
|| '</td>'
|| '<td>'
|| CUR_QUALITF_REC.SUPPLIER_NAME
|| '</td>'
|| '<td>'
|| CUR_QUALITF_REC.ASSET_COST
|| '</td>'
|| '<td>'
|| CUR_QUALITF_REC.ACCUMULATED_DEP
|| '</td>'
|| '<td>'
|| CUR_QUALITF_REC.NET_BOOK_VALUE
|| '</td>'
|| '<td>'
|| CUR_QUALITF_REC.ASSET_LIFE
|| '</td>'
|| '<td>'
|| CUR_QUALITF_REC.DATE_PLACEDIN_SERVICE
|| '</td>'
|| '</tr>'
;

--INSERT INTO TESTA VALUES(1,2,3);

end loop;

document :=LV_DETAILS||'</table>';

/*We have to determine document_type which is nothing but the mime type
document_type := 'image/jpg; name=filename.jpg';
Depending on the extension of the document the MIME type is determined. For simplicity
we are hard coding here*/
--—      document_type := 'application/pdf;name=test.pdf' ;  /* This syntax is used for PDF type of attachments */

document_type := 'text/html';

EXCEPTION
WHEN OTHERS
THEN
document := '<H4>Error ' || SQLERRM || '</H4>';

END;

PROCEDURE XX_DOC_CALL
(
itemtype in varchar2,
ITEMKEY IN VARCHAR2,
actid in number,
funcmode in varchar2,
resultout out varchar2
)
IS
V_DOCUMENT_ID CLOB;
v_itemkey  NUMBER;

BEGIN
V_DOCUMENT_ID :='PLSQL:XX_BODY_TXN_INFO_DOC_PKG.XX_create_DOC_WF/' || ITEMKEY;

/*Setting Value to the Document Type Attribute */

wf_engine.setitemattrtext (itemtype      => itemtype,
itemkey       => itemkey,
ANAME         => 'BODY_TXN_DET_INFO',
avalue        => V_DOCUMENT_ID
);

end;
end XX_BODY_TXN_INFO_DOC_PKG;
/

Monday, November 30, 2020

Oracle Workflow Attachments to shown in Notifications

     Create new Attribute XX1 with type document


    Add one more new attribute to the Message  #ATTACHMENTS
        Default value Attribute XX1

While creation/running the workflow add the atribute value as below:

              wf_engine.setItemAttrText(itemtype =>itemtype,
             itemkey =>itemkey,
             aname =>'XXASS_ATTACH',
             avalue=>'FND:entity=XXASSET_DISPOSAL'||'&'||'pk1name=DISPOSAL_ID'||'&'||'pk1value='||crec.header_id
             ) ;
             


The value for 'entity' can be obtained from DATA_OBJECT_CODE in FND_DOCUMENT_ENTITIES.

The value for 'pk1name' can be obtained from PK1_COLUMN in FND_DOCUMENT_ENTITIES.
The value for 'pk1value' can be obtained from PK1_VALUE in FND_ATTACHED_DOCUMENTS.     

Wednesday, September 9, 2020

Add New Responsibility , Menu Exclusions from others responsibility in Oracle Apps R12

1. Creating New Responsibility

2. Menu Exclusions to copy into new Responsibility from existing. 

 


1.

 

DECLARE

v_rowid varchar2(500);

BEGIN

fnd_responsibility_pkg.insert_row

( x_rowid => v_rowid,

x_responsibility_id => fnd_responsibility_s.NEXTVAL,

x_application_id => 201, -- Cash Management

x_web_host_name => NULL,

x_web_agent_name => NULL,

x_data_group_application_id => 201, -- Cash Management

x_data_group_id => 0, -- Standard

x_menu_id => 68071, -- CE_CASH_MANAGER

x_start_date => SYSDATE,

x_end_date => NULL,

x_group_application_id => 201,

x_request_group_id => 129,

x_version => 4,

x_responsibility_key => 'TEST_RESPONSIBILITY2',

x_responsibility_name => 'Test Responsibility2',

x_description => 'Responsibility for testing',

x_creation_date => SYSDATE,

x_created_by => -1,

x_last_update_date => SYSDATE,

x_last_updated_by => -1,

x_last_update_login => -1

);

EXCEPTION WHEN OTHERS THEN

DBMS_OUTPUT.PUT_LINE(SQLERRM);

END;

commit;


2. Adding menu exclusions..


DECLARE

v_resp_id number := 52634; --pass here the new responsibility_id

   CURSOR c1

   IS

   

     SELECT

application_id, responsibility_id, action_id,

                      rule_type,

                      last_updated_by, last_update_date, creation_date,

                      created_by, last_update_login

                      FROM fnd_resp_functions

                      WHERE RESPONSIBILITY_ID = 50626; --getting all the menu exlusions from existing

                      

BEGIN

   FOR i IN c1

   LOOP

      BEGIN

         DBMS_OUTPUT.put_line ('Processing');

         INSERT INTO fnd_resp_functions

                     (application_id, responsibility_id, action_id,

                      rule_type,

                      last_updated_by, last_update_date, creation_date,

                      created_by, last_update_login

                     )

              VALUES (i.application_id, v_resp_id, i.action_id,

                      i.rule_type,

                      2605, SYSDATE, SYSDATE,

                      2605, -1

                     );

      EXCEPTION

         WHEN OTHERS

         THEN

            DBMS_OUTPUT.put_line (SQLERRM);

      END;

   END LOOP;

EXCEPTION

   WHEN OTHERS

   THEN

      DBMS_OUTPUT.put_line ('Completed');

END; 

Friday, May 8, 2020

Update fnd_user all user passwords in clone Oracle Apps r12


DECLARE
l_unenc_pwd VARCHAR2(1000);
CURSOR c1 IS
SELECT *
FROM fnd_user fu 
WHERE fu.user_name='MOGALAFZAL'--comment this line to get all users.
;
BEGIN
FOR I IN c1 LOOP
l_unenc_pwd:=dbms_random.string('x',6);
fnd_user_pkg.UpdateUser(x_user_name=>'001C.ARNAUD@GMAIL.COM'
                       ,x_owner=>'SEED'
                       ,x_unencrypted_password=>
l_unenc_pwd--'12345'
                       ,x_password_date=>to_date('2', 'J')
                       ,x_user_guid=>I.user_GUID
                       );
COMMIT;                      
END LOOP;                                           
END;


Other useful random:
select TRUNC(DBMS_RANDOM.value(1,10)) from dual;

Positive Integers:
select abs(dbms_random.random) from dual --> for updating mobile number, EID


Friday, May 1, 2020

Updating Translations for lookups in Oracle Apps R12


The below code with update the Transalation of Lookups.
Example: Arabic Translation.

First you need to upload lookups normally using the below link.
https://mogalafzal.blogspot.com/2020/05/uploading-lookups-in-oracle-apps-r12.html


/*
1. set the language you want to update.

alter session set NLS_LANGUAGE ='ARABIC';--'ARABIC' AMERICAN

select userenv('lang') from dual

COMMIT

2. custom interface table.

    CREATE TABLE XXLOOKUP_CODES_AR
    (LOOKUP_CODE VARCHAR2(30),
     MEANING_EN VARCHAR2(240),
     MEANING_AR VARCHAR2(240),
     DESCRIPTION_EN VARCHAR2(240),
     DESCRIPTION_AR VARCHAR2(240),
     ATTRIBUTE1 VARCHAR2(240),
     ATTRIBUTE2 VARCHAR2(240))
   
     alter table xxlookup_codes_ar
add (lkp_err_msg varchar2(240))

update xxlookup_codes_ar
set lkp_process_flag_ar = 'N';

SELECT * FROM xxlookup_codes_ar

SELECT * FROM FND_LOOKUP_VALUES_VL
WHERE LOOKUP_TYPE = 'TESTA'

*/



DECLARE
   CURSOR get_lookup_details
   IS
 
      SELECT ltype.application_id,
             ltype.customization_level,
             ltype.creation_date,
             ltype.created_by,
             ltype.last_update_date,
             ltype.last_updated_by,
             ltype.last_update_login,
             tl.lookup_type,
             tl.security_group_id,
             tl.view_application_id,
             tl.description,
             tl.meaning
        FROM fnd_lookup_types_tl tl, fnd_lookup_types ltype
       WHERE     ltype.lookup_type = 'FFZA_LICENSE_TYPE'
             AND ltype.lookup_type = tl.lookup_type
             AND language = 'US';

   CURSOR get_value
   IS
 

      SELECT DISTINCT
             lookup_code,
             meaning_en,
             meaning_ar,
             description_en, description_ar,lkp_err_msg,lkp_process_flag_ar
        FROM xxlookup_codes_ar
       WHERE     lkp_process_flag_ar = 'N'   
       and lookup_code <> '58'
       --AND LENGTH(substr(meaning_ar,1,80)) > 60
     
       ;

   l_err_msg   VARCHAR2 (1000) := NULL;
   l_db_nls_language       VARCHAR2 (500) := NULL;
   l_db_nls_language2 varchar2(30) := 'ARABIC';
   L_USERNAME VARCHAR2(30) := 'EG_AFZAL'; --USERNAME
BEGIN
   FOR i IN get_lookup_details
   LOOP
      FOR j IN get_value
      LOOP
         BEGIN
            fnd_lookup_values_pkg.translate_row (
               x_lookup_type           => i.lookup_type,
               x_security_group_id     => i.security_group_id,
               x_view_application_id   => i.view_application_id,
               x_owner                 => L_USERNAME, --> User NAME
               x_meaning               => j.meaning_ar,
               x_description           => j.description_ar,
               x_lookup_code           => j.lookup_code,
               X_LAST_UPDATE_DATE      => NULL,--TO_DATE('4/22/2020 9:20:58 PM'),
               X_CUSTOM_MODE            => 'FORCE');

            UPDATE xxlookup_codes_ar --> Stagging Table to Log Status
               SET lkp_process_flag_ar = 'Y', lkp_err_msg = NULL
             WHERE lookup_code = j.lookup_code;

            COMMIT;
         EXCEPTION
            WHEN OTHERS
            THEN
               l_err_msg := SQLERRM;

               UPDATE xxlookup_codes_ar
                  SET lkp_process_flag_ar = 'N', lkp_err_msg = l_err_msg
                 WHERE lookup_code = j.lookup_code;

               COMMIT;
         END;
      END LOOP;
   END LOOP;
EXCEPTION
   WHEN OTHERS
   THEN
      DBMS_OUTPUT.put_line ('Main Exception: ' || SQLERRM);
END;