Monday, October 8, 2018

Function


 XXPCL_DOCUMENT_ATTACHED(APA.INVOICE_ID) Doc_Attached,

-------------------------------------------------------------------------------------------------------
CREATE OR REPLACE FUNCTION APPS.XXPCL_DOCUMENT_ATTACHED (
   P_INVOICE_ID IN NUMBER)
   RETURN VARCHAR
AS
   V_TITLE         VARCHAR2 (4000);
   V_DESCRIPTION   VARCHAR2 (4000);
   V_ENTITY_NAME   VARCHAR2 (4000);

   --V_COUNT NUMBER:=0;

   CURSOR C1
   IS
      SELECT TITLE --|| DECODE (DT.DESCRIPTION, NULL, NULL, ' - ' || DT.DESCRIPTION)
             || ' - ' || d.FILE_NAME DOC_REF
        --AD.SEQ_NUM, DCT.USER_NAME, DT.TITLE, DT.DESCRIPTION, AD.ENTITY_NAME, DAT.USER_NAME, d.FILE_NAME, AD.ATTACHED_DOCUMENT_ID, DET.USER_ENTITY_NAME,
        --DAT.NAME, D.DOCUMENT_ID, AD.PK1_VALUE, D.MEDIA_ID, D.URL, DBMS_LOB.SUBSTR(L.file_data,1,10) file_data
        FROM FND_DOCUMENT_DATATYPES DAT,
             FND_DOCUMENT_ENTITIES_TL DET,
             FND_DOCUMENTS_TL DT,
             FND_DOCUMENTS D,
             FND_DOCUMENT_CATEGORIES_TL DCT,
             FND_ATTACHED_DOCUMENTS AD,
             FND_LOBS L
       WHERE     D.DOCUMENT_ID = AD.DOCUMENT_ID
             AND DT.DOCUMENT_ID = D.DOCUMENT_ID
             AND DCT.CATEGORY_ID = D.CATEGORY_ID
             AND D.DATATYPE_ID = DAT.DATATYPE_ID
             AND AD.ENTITY_NAME = DET.DATA_OBJECT_CODE
             AND L.FILE_ID = D.MEDIA_ID
             AND DT.TITLE IS NOT NULL
             --and TITLE='JV 5492a'
             AND AD.ATTACHED_DOCUMENT_ID<>843450
             AND PK1_VALUE =to_char( P_INVOICE_ID)                            --270952
             AND DAT.name IN ('FILE');
             --and Ad.ENTITY_NAME not in ('AP_CHECKS','AP_INVOICES','GL_JE_HEADERS');

   A_COUNT         NUMBER := 1;
   --FIRST_REF VARCHAR2(100);
   FINAL_REF       VARCHAR2 (4000);
BEGIN
   FOR I IN C1
   LOOP
      IF A_COUNT = 1
      THEN
         FINAL_REF := I.DOC_REF;
         A_COUNT := A_COUNT + 1;
      ELSE
         FINAL_REF := FINAL_REF || ' / ' || I.DOC_REF;
      END IF;
   END LOOP;

   RETURN (FINAL_REF);
EXCEPTION
   WHEN OTHERS   THEN      RETURN (NULL);
END;
/

----------------------------------------------------------------------------------------------

 XXPCL_CREATE_BY_NAME(APA.created_by )  CREATED_BY_NAME

--------------------------------------------------------------------------------------------


CREATE OR REPLACE function APPS.XXPCL_CREATE_BY_NAME(P_USER_ID IN NUMBER) RETURN VARCHAR as

V_user_name VARCHAR2(100);
V_EMPLOYEE_ID VARCHAR2(100);
V_FULL_NAME VARCHAR2(100);

BEGIN

select user_name, EMPLOYEE_ID
INTO V_user_name, V_EMPLOYEE_ID
from fnd_user
where user_id = P_USER_ID -- 3480
;

IF V_EMPLOYEE_ID IS NOT NULL THEN

select FULL_NAME
INTO V_FULL_NAME
from per_people_f A
where PERSON_ID = V_EMPLOYEE_ID ---1948
;

RETURN(V_FULL_NAME);

ELSE

RETURN (V_user_name);

END IF;


EXCEPTION WHEN OTHERS THEN RETURN(NULL);

END;
/
---------------------------------------------------------------------------------------------------------
  XXPCL_CREATE_BY_EMP_NO(APA.created_by) CREATED_EMP_NO
---------------------------------------------------------------------------------------------------

CREATE OR REPLACE function APPS.XXPCL_CREATE_BY_EMP_NO(P_USER_ID IN NUMBER) RETURN VARCHAR as

V_user_name VARCHAR2(100);
V_EMPLOYEE_ID VARCHAR2(100);
V_FULL_NAME VARCHAR2(100);

BEGIN

select user_name, EMPLOYEE_ID
INTO V_user_name, V_EMPLOYEE_ID
from fnd_user
where user_id = P_USER_ID -- 3480
;

IF V_EMPLOYEE_ID IS NOT NULL THEN

select EMPLOYEE_NUMBER
INTO V_FULL_NAME
from per_people_f A
where PERSON_ID = V_EMPLOYEE_ID ---1948
;

RETURN(V_FULL_NAME);

ELSE

RETURN (V_user_name);

END IF;


EXCEPTION WHEN OTHERS THEN RETURN(NULL);

END;
/


------------------------------------------------------------------------------------------------------
XXPCL_GET_ACCOUNT_DESC( aid.dist_code_combination_id) ACCOUNT_DESC
--------------------------------------------------------------------------------------------------------

CREATE OR REPLACE FUNCTION APPS.XXPCL_get_account_desc (
   p_ccc_id   IN   NUMBER)
   RETURN CHAR
IS
   CURSOR cur_segments (
      p_ccc_id   IN   NUMBER)
   IS
      SELECT *
      FROM   gl_code_combinations
      WHERE  code_combination_id = p_ccc_id;

   lv_all_desc                   VARCHAR2 (1000);
   lv_desc1                      VARCHAR2 (100);
   lv_desc2                      VARCHAR2 (100);
   lv_desc3                      VARCHAR2 (200);
   lv_desc4                      VARCHAR2 (200);
   lv_desc5                      VARCHAR2 (100);
   lv_desc6                      VARCHAR2 (100);
   lv_desc7                      VARCHAR2 (100);
   lv_desc8                      VARCHAR2 (100);
   lv_desc9                      VARCHAR2 (100);
   lv_desc10                     VARCHAR2 (100);
   lv_desc11                     VARCHAR2 (100);
   
   v_error                       VARCHAR2 (2000);
BEGIN
   FOR rec_segments IN cur_segments (p_ccc_id)
   LOOP
      BEGIN
         SELECT ffvt.description
         INTO   lv_desc1
         FROM   fnd_flex_value_sets ffvs
               ,fnd_flex_values ffv
               ,fnd_flex_values_tl ffvt
         WHERE  1 = 1
         AND    ffvs.flex_value_set_id = ffv.flex_value_set_id
         AND    ffv.flex_value_id = ffvt.flex_value_id
         AND    ffvs.flex_value_set_name LIKE 'PFCCL Company'
         AND    ffv.flex_value = rec_segments.segment1;
      END;

--
      BEGIN
         SELECT ffvt.description
         INTO   lv_desc2
         FROM   fnd_flex_value_sets ffvs
               ,fnd_flex_values ffv
               ,fnd_flex_values_tl ffvt
         WHERE  1 = 1
         AND    ffvs.flex_value_set_id = ffv.flex_value_set_id
         AND    ffv.flex_value_id = ffvt.flex_value_id
         AND    ffvs.flex_value_set_name LIKE 'PFCCL MIS'
         AND    ffv.flex_value = rec_segments.segment2;
      END;

--
      BEGIN
         SELECT ffvt.description
         INTO   lv_desc3
         FROM   fnd_flex_value_sets ffvs
               ,fnd_flex_values ffv
               ,fnd_flex_values_tl ffvt
         WHERE  1 = 1
         AND    ffvs.flex_value_set_id = ffv.flex_value_set_id
         AND    ffv.flex_value_id = ffvt.flex_value_id
         AND    ffvs.flex_value_set_name LIKE 'PFCCL Account'
         AND    ffv.flex_value = rec_segments.segment3;
      END;

--
      BEGIN
         SELECT ffvt.description
         INTO   lv_desc4
         FROM   fnd_flex_value_sets ffvs
               ,fnd_flex_values ffv
               ,fnd_flex_values_tl ffvt
         WHERE  1 = 1
         AND    ffvs.flex_value_set_id = ffv.flex_value_set_id
         AND    ffv.flex_value_id = ffvt.flex_value_id
         AND    ffvs.flex_value_set_name LIKE 'PFCCL Company'
         AND    ffv.flex_value = rec_segments.segment4;
      END;

--
      BEGIN
         SELECT ffvt.description
         INTO   lv_desc5
         FROM   fnd_flex_value_sets ffvs
               ,fnd_flex_values ffv
               ,fnd_flex_values_tl ffvt
         WHERE  1 = 1
         AND    ffvs.flex_value_set_id = ffv.flex_value_set_id
         AND    ffv.flex_value_id = ffvt.flex_value_id
         AND    ffvs.flex_value_set_name LIKE 'PFCCL Future'
         AND    ffv.flex_value = rec_segments.segment5;
      END;


      lv_all_desc := lv_desc1 || '-' || lv_desc2 || '-' || lv_desc3 || '-'
                     || lv_desc4 || '-' || lv_desc5;
--
   END LOOP;

--
   DBMS_OUTPUT.put_line ('Function Returns -  ' || lv_all_desc);
  -- insert into ss_test51(id,msg)values(100,'Function end' ||lv_all_desc);
--
   RETURN lv_all_desc;
EXCEPTION
   WHEN OTHERS THEN
      v_error := substr(SQLERRM, 0, 200);
      DBMS_OUTPUT.put_line ('Function end with Error -  ' || v_error);
      --insert into ss_test51(id,msg)values(100,'Function end with Error -  ' || v_error);
      return v_error;
END;
/

----------------------------------------------------------------------------------------------------------
XXPCL_GET_ACCT_DESC( 3,GCC.code_combination_id) ACCT_DESC

----------------------------------------------------------------------------------------------------------

CREATE OR REPLACE FUNCTION APPS.XXPCL_GET_ACCT_DESC (
   P_SEGMENT_LOC IN NUMBER,
   p_ccc_id   IN   NUMBER)
   RETURN CHAR
IS
   CURSOR cur_segments (
      p_ccc_id   IN   NUMBER)
   IS
   
      SELECT *
      FROM   gl_code_combinations
      WHERE  code_combination_id = p_ccc_id;

   lv_all_desc                   VARCHAR2 (1000);
   lv_desc1                      VARCHAR2 (100);
   lv_desc2                      VARCHAR2 (100);
   lv_desc3                      VARCHAR2 (200);
   lv_desc4                      VARCHAR2 (200);
   lv_desc5                      VARCHAR2 (100);
   lv_desc6                      VARCHAR2 (100);
   lv_desc7                      VARCHAR2 (100);
   lv_desc8                      VARCHAR2 (100);
   lv_desc9                      VARCHAR2 (100);
   lv_desc10                     VARCHAR2 (100);
   lv_desc11                     VARCHAR2 (100);
   
   v_error                       VARCHAR2 (2000);
BEGIN
   FOR rec_segments IN cur_segments (p_ccc_id)
   LOOP
      BEGIN
         SELECT ffvt.description
         INTO   lv_desc1
         FROM   fnd_flex_value_sets ffvs
               ,fnd_flex_values ffv
               ,fnd_flex_values_tl ffvt
         WHERE  1 = 1
         AND    ffvs.flex_value_set_id = ffv.flex_value_set_id
         AND    ffv.flex_value_id = ffvt.flex_value_id
         AND    ffvs.flex_value_set_name LIKE 'PFCCL Company'
         AND    ffv.flex_value = rec_segments.segment1;
      END;

--
      BEGIN
         SELECT ffvt.description
         INTO   lv_desc2
         FROM   fnd_flex_value_sets ffvs
               ,fnd_flex_values ffv
               ,fnd_flex_values_tl ffvt
         WHERE  1 = 1
         AND    ffvs.flex_value_set_id = ffv.flex_value_set_id
         AND    ffv.flex_value_id = ffvt.flex_value_id
         AND    ffvs.flex_value_set_name LIKE 'PFCCL MIS'
         AND    ffv.flex_value = rec_segments.segment2;
      END;

--
      BEGIN
         SELECT ffvt.description
         INTO   lv_desc3
         FROM   fnd_flex_value_sets ffvs
               ,fnd_flex_values ffv
               ,fnd_flex_values_tl ffvt
         WHERE  1 = 1
         AND    ffvs.flex_value_set_id = ffv.flex_value_set_id
         AND    ffv.flex_value_id = ffvt.flex_value_id
         AND    ffvs.flex_value_set_name LIKE 'PFCCL Account'
         AND    ffv.flex_value = rec_segments.segment3;
      END;

--
      BEGIN
         SELECT ffvt.description
         INTO   lv_desc4
         FROM   fnd_flex_value_sets ffvs
               ,fnd_flex_values ffv
               ,fnd_flex_values_tl ffvt
         WHERE  1 = 1
         AND    ffvs.flex_value_set_id = ffv.flex_value_set_id
         AND    ffv.flex_value_id = ffvt.flex_value_id
         AND    ffvs.flex_value_set_name LIKE 'PFCCL Company'
         AND    ffv.flex_value = rec_segments.segment4;
      END;

--
      BEGIN
         SELECT ffvt.description
         INTO   lv_desc5
         FROM   fnd_flex_value_sets ffvs
               ,fnd_flex_values ffv
               ,fnd_flex_values_tl ffvt
         WHERE  1 = 1
         AND    ffvs.flex_value_set_id = ffv.flex_value_set_id
         AND    ffv.flex_value_id = ffvt.flex_value_id
         AND    ffvs.flex_value_set_name LIKE 'PFCCL Future'
         AND    ffv.flex_value = rec_segments.segment5;
      END;


      lv_all_desc := lv_desc1 || '-' || lv_desc2 || '-' || lv_desc3 || '-'
                     || lv_desc4 || '-' || lv_desc5;
                     
        IF    P_SEGMENT_LOC = 1 THEN
            RETURN(lv_desc1);
        ELSIF P_SEGMENT_LOC = 2 THEN
            RETURN(lv_desc2);
        ELSIF P_SEGMENT_LOC = 3 THEN
            RETURN(lv_desc3);     
        ELSIF P_SEGMENT_LOC = 4 THEN
            RETURN(lv_desc4);
        ELSIF P_SEGMENT_LOC = 5 THEN
            RETURN(lv_desc5);        
        ELSE RETURN(lv_all_desc);
        END IF;
                  
   END LOOP;

--
   DBMS_OUTPUT.put_line ('Function Returns -  ' || lv_all_desc);
  -- insert into ss_test51(id,msg)values(100,'Function end' ||lv_all_desc);
--
   RETURN lv_all_desc;
EXCEPTION
   WHEN OTHERS THEN
      v_error := substr(SQLERRM, 0, 200);
      DBMS_OUTPUT.put_line ('Function end with Error -  ' || v_error);
      --insert into ss_test51(id,msg)values(100,'Function end with Error -  ' || v_error);
      return v_error;
END;
/

----------------------------------Convert value in word-----------------------
fnd_file.put_line (fnd_file.output,'<DIGIT_TO_WORD>' ||digit_to_word1(V_TOTAL_DR ) || '</DIGIT_TO_WORD>' );

-----------------------------------------------------------------------------------------------------------------

CREATE OR REPLACE function APPS.digit_to_word1(net_amount number) return char is
 p_word varchar2(500);
 p_int  varchar2(480);
 p_dec Varchar2(100);
 p_pos number ;
begin
select
decode(substr(lpad(trunc(net_amount),9,'0'),1,2),
0,null,to_char(to_date(substr(lpad(trunc(net_amount),9,'0'),1,
2),'J'),'Jsp')|| ' Crores ' )
||
decode(substr(lpad(trunc(net_amount),9,'0'),3,2),
0,null,to_char(to_date(substr(lpad(trunc(net_amount),9,'0'),3,
2),'J'),'Jsp')|| ' Lakhs ' )
|| decode(substr(lpad(trunc(net_amount),9,'0'),5,2),
0,null,to_char(to_date(substr(lpad(trunc(net_amount),9,'0'),5,
2),'J'),'Jsp')|| ' Thousand ' )
|| decode(substr(lpad(trunc(net_amount),9,'0'),7,1),
0,null,to_char(to_date(substr(lpad(trunc(net_amount),9,'0'),7,1),'J'),'Jsp')|| ' Hundred ' )
|| decode(substr(lpad(trunc(net_amount),9,'0'),8),0,null,to_char(to_date(substr(lpad(trunc(net_amount),9,'0'),8),'J'),'Jsp')
)
    into p_int
    from dual;
  p_dec :=dec_word(net_amount);
  IF trunc(net_amount) =0 then
    IF P_dec is not null then
       p_dec := p_dec||' Paise ';
       return(p_dec||' Only ');
    else
        return(null);
    END IF;
  elsif  trunc(net_amount) >0 then
      IF P_dec is not null then
         p_dec := p_dec||' Paise ';
       return('Rupees '||p_int||' '||' and '||p_dec||' Only ');
     else
       return('Rupees '||p_int||' Only ');
  END IF;
  END if;
  end;
/

-----------------------------------------------------------

Customer data with email and phone no.

How to find the Customer data with email and phone no. 

  SELECT DISTINCT HP.PARTY_ID,
                  HP.PARTY_NAME CUSTOMER_NAME,
                  HP.PARTY_NUMBER,
                  HCA.CUST_ACCOUNT_ID,
                  HCA.ACCOUNT_NUMBER,
                  NAME ORG_NAME,
                  HCAS.CUST_ACCT_SITE_ID,
                  HPS.PARTY_SITE_NUMBER,
                  HCSU.SITE_USE_CODE,
                  HL.ADDRESS1,
                  HL.ADDRESS2,
                  HL.ADDRESS3,
                  HL.ADDRESS4,
                  HL.CITY,
                  HL.POSTAL_CODE,
                  HL.STATE,
                  HL.PROVINCE,
                  HL.COUNTY,
                  HL.COUNTRY,
                  HL.ADDRESS_STYLE,
                  APPS.XXPCL_CON_EMAIL_MO (1, HPS.PARTY_SITE_ID) EMAIL,
                  APPS.XXPCL_CON_EMAIL_MO (2, HPS.PARTY_SITE_ID) PHONE
    FROM APPS.HZ_PARTIES HP,
         APPS.HZ_PARTY_SITES HPS,
         APPS.HZ_CUST_ACCOUNTS_ALL HCA,
         APPS.HZ_CUST_ACCT_SITES_ALL HCAS,
         APPS.HZ_CUST_SITE_USES_ALL HCSU,
         APPS.HZ_LOCATIONS HL,
         APPS.HR_OPERATING_UNITS HR
   WHERE     1 = 1
         AND HCAS.ORG_ID = HR.ORGANIZATION_ID
         --AND SET_OF_BOOKS_ID = 2121
         AND HP.PARTY_ID = HCA.PARTY_ID
         AND HCA.CUST_ACCOUNT_ID = HCAS.CUST_ACCOUNT_ID(+)
         AND HPS.PARTY_SITE_ID(+) = HCAS.PARTY_SITE_ID
         AND HCAS.CUST_ACCT_SITE_ID = HCSU.CUST_ACCT_SITE_ID
         AND HPS.LOCATION_ID = HL.LOCATION_ID(+)
         AND HP.STATUS = 'A'         
         AND HCAS.STATUS = 'A'

ORDER BY HP.PARTY_NAME

------------------------------------------Function details------------------------

Note :-  Function name :-----XXPCL_CON_EMAIL_MO

CREATE OR REPLACE FUNCTION APPS.XXPCL_CON_EMAIL_MO (P_NO_ID NUMBER ,P_PARTY_SITE_ID NUMBER) RETURN VARCHAR2
AS

-- FUNCTION NAME --XXPCL_CON_EMAIL_MO
 --Techical Israr
 --Technical.israr@gmail.com 05-oct-2018

V_EMAIL_ADDRESS VARCHAR2(100);
V_PHONE_NUMBER VARCHAR2(100);

V_COUNT NUMBER := 1;

CURSOR C1 IS
SELECT hcp.email_address,HPS.PARTY_SITE_ID
       from  hz_parties hz,
          hz_party_sites hps,
          hz_contact_points hcp
where 1=1
and  hz.party_id=hps.party_id
and  hps.party_site_id=hcp.owner_table_id
and HCP.status='A'
AND CONTACT_POINT_TYPE='EMAIL'
AND hps.party_site_id=P_PARTY_SITE_ID;
--and hz.party_id=494220


CURSOR C2
IS
 SELECT A.PHONE_NUMBER
          FROM HZ_CONTACT_POINTS A
         WHERE 1 = 1 AND A.status = 'A' AND A.CONTACT_POINT_TYPE = 'PHONE' AND A.OWNER_TABLE_ID=P_PARTY_SITE_ID;

BEGIN

    FOR I IN C1 LOOP

        IF V_COUNT = 1 THEN
         
         
            V_EMAIL_ADDRESS:= I.EMAIL_ADDRESS;
        --    V_PHONE_NUMBER:=I.PHONE_NUMBER;
       
            V_COUNT:= V_COUNT+1;
         
        ELSE
         
         
            V_EMAIL_ADDRESS:= V_EMAIL_ADDRESS||' / '||I.EMAIL_ADDRESS;
          --  V_PHONE_NUMBER:=V_PHONE_NUMBER||' / '||I.PHONE_NUMBER;
                     
        END IF;
     
          END LOOP;
             

 
     
        FOR J IN C2
         LOOP

        IF V_COUNT = 1 THEN
         
         
            --V_EMAIL_ADDRESS:= I.EMAIL_ADDRESS;
            V_PHONE_NUMBER:=J.PHONE_NUMBER;
       
            V_COUNT:= V_COUNT+1;
         
        ELSE
         
         
            --V_EMAIL_ADDRESS:= V_EMAIL_ADDRESS||' / '||I.EMAIL_ADDRESS;
            V_PHONE_NUMBER:=V_PHONE_NUMBER||' / '||J.PHONE_NUMBER;
                     
        END IF;           


     END LOOP;
    IF P_NO_ID =1 THEN
    RETURN     V_EMAIL_ADDRESS;
 
        ELSIF P_NO_ID =2 THEN
    RETURN     V_PHONE_NUMBER;
 
ELSE RETURN NULL;
END IF;

EXCEPTION WHEN OTHERS THEN RETURN NULL;
END;
/

Customer Data with Bank Report

How to find the customer data with bank details

CREATE OR REPLACE PROCEDURE APPS.XXPCL_CUST_DETAILS_PROC(
RETCODE OUT VARCHAR2,
ERRBUF OUT VARCHAR2,
P_ORG_ID                      IN VARCHAR2,
P_PARTY_ID       IN VARCHAR2,
P_PARTY_NUMBER IN VARCHAR2
--P1_FROM_DATE             IN VARCHAR2,
--P1_TO_DATE                 IN VARCHAR2
)
AS

--P_FROM_DATE DATE;
--P_TO_DATE DATE;
P_V_COUNT  NUMBER;

--*==================================================+
--| PACKAGE XXPCL_CUST_DETAILS_PROC
--+--------------------------------------------------------------------------+
--| DESCRIPTION This package is used to designed for xml for L trial
--|           
--+--------------------------------------------------------------------------+
--| HISTORY
--| Author              | Date              | DESCRIPTION
--+--------------------------------------------------------------------------+
--| Technical Israr| 16-AUG-2018| 1.0
-- Technical.israr@gmail.com

--+==================================================*/

---  Customer information with email and mobile no.--------
--CURSOR C1 IS
--
--  SELECT DISTINCT HP.PARTY_ID,
--                  HP.PARTY_NAME CUSTOMER_NAME,
--                  HP.PARTY_NUMBER,
--                  HCA.CUST_ACCOUNT_ID,
--                  HCA.ACCOUNT_NUMBER,
--                  NAME ORG_NAME,
--                  HCAS.CUST_ACCT_SITE_ID,
--                  HPS.PARTY_SITE_NUMBER,
--                  HCSU.SITE_USE_CODE,
--                  HL.ADDRESS1,
--                  HL.ADDRESS2,
--                  HL.ADDRESS3,
--                  HL.ADDRESS4,
--                  HL.CITY,
--                  HL.POSTAL_CODE,
--                  HL.STATE,
--                  HL.PROVINCE,
--                  HL.COUNTY,
--                  HL.COUNTRY,
--                  HL.ADDRESS_STYLE,
--                  APPS.XXPCL_CON_EMAIL_MO (1, HPS.PARTY_SITE_ID) EMAIL,
--                  APPS.XXPCL_CON_EMAIL_MO (2, HPS.PARTY_SITE_ID) PHONE
--    FROM APPS.HZ_PARTIES HP,
--         APPS.HZ_PARTY_SITES HPS,
--         APPS.HZ_CUST_ACCOUNTS_ALL HCA,
--         APPS.HZ_CUST_ACCT_SITES_ALL HCAS,
--         APPS.HZ_CUST_SITE_USES_ALL HCSU,
--         APPS.HZ_LOCATIONS HL,
--         APPS.HR_OPERATING_UNITS HR
--   WHERE     1 = 1
--         AND HCAS.ORG_ID = HR.ORGANIZATION_ID
--         AND SET_OF_BOOKS_ID = 2121
--         AND HP.PARTY_ID = HCA.PARTY_ID
--         AND HCA.CUST_ACCOUNT_ID = HCAS.CUST_ACCOUNT_ID(+)
--         AND HPS.PARTY_SITE_ID(+) = HCAS.PARTY_SITE_ID
--         AND HCAS.CUST_ACCT_SITE_ID = HCSU.CUST_ACCT_SITE_ID
--         AND HPS.LOCATION_ID = HL.LOCATION_ID(+)
--         AND HP.STATUS = 'A'         
--         AND HCAS.STATUS = 'A'
-- AND HCAS.ORG_ID = NVL (P_ORG_ID, HCAS.ORG_ID)
--         AND HP.PARTY_ID = NVL (P_PARTY_ID, HP.PARTY_ID)
--         AND HP.PARTY_NUMBER =NVL(P_PARTY_NUMBER,HP.PARTY_NUMBER)   
--ORDER BY HP.PARTY_NAME;

CURSOR C2 IS
SELECT DISTINCT HP.PARTY_ID,HPS.PARTY_SITE_ID,
                  HP.PARTY_NAME "CUSTOMER_NAME",
                  HP.PARTY_NUMBER CUSTOMER_NUM,
                  NAME ORG_NAME,
                  HCAS.ATTRIBUTE1 GST_NUM,
                  PAN_NO,
                  HL.ADDRESS1, HL.ADDRESS2, HL.ADDRESS3, HL.ADDRESS4, HL.CITY, HL.POSTAL_CODE,  HL.STATE,
                  --HCP1.PHONE_NUMBER,HCP.EMAIL_ADDRESS,
                  XXPCL_CON_EMAIL_MO(1,HPS.PARTY_SITE_ID) EMAIL_ADDRESS,
                  XXPCL_CON_EMAIL_MO(2,HPS.PARTY_SITE_ID) PHONE_NUMBER,
                  IEBA.BANK_NAME,
                  IEBA.BANK_ACCOUNT_NUMBER,
                  IEBA.BRANCH_NUMBER,IEBA.BANK_BRANCH_NAME,IEBA.BANK_NUMBER,IEBA.DESCRIPTION
    FROM HZ_PARTIES HP,
         HZ_PARTY_SITES HPS,
         HZ_CUST_ACCOUNTS_ALL HCA,
         HZ_CUST_ACCT_SITES_ALL HCAS,
         HZ_CUST_SITE_USES_ALL HCSU,
         HZ_LOCATIONS HL,
         JAI_CMN_CUS_ADDRESSES JCCA,
         HR_OPERATING_UNITS HR,
         APPS.IBY_PAYEE_ASSIGNED_BANKACCT_V IPAB,
         IBY_ACCOUNT_OWNERS IAO,
         IBY_EXT_BANK_ACCOUNTS_V IEBA
   WHERE     1 = 1
         AND HP.PARTY_ID = HCA.PARTY_ID
         AND JCCA.CUSTOMER_ID(+)= HCAS.CUST_ACCOUNT_ID
         AND HR.SET_OF_BOOKS_ID = 2121
         AND HR.ORGANIZATION_ID = HCAS.ORG_ID
         AND HCA.CUST_ACCOUNT_ID = HCAS.CUST_ACCOUNT_ID(+)
         AND HPS.PARTY_SITE_ID = HCAS.PARTY_SITE_ID
         AND HCAS.CUST_ACCT_SITE_ID = HCSU.CUST_ACCT_SITE_ID
         AND HP.STATUS = 'A'
         AND HPS.STATUS = 'A'
         AND HPS.LOCATION_ID = HL.LOCATION_ID(+)
         AND HP.PARTY_ID=IAO.ACCOUNT_OWNER_PARTY_ID(+)
          AND HPS.PARTY_SITE_ID=IPAB.PARTY_SITE_ID(+)
           AND IPAB.PARTY_SITE_ID IS NULL
       --AND IPAB.EXT_BANK_ACCOUNT_ID = IEBA.EXT_BANK_ACCOUNT_ID
         AND IAO.EXT_BANK_ACCOUNT_ID=IEBA.EXT_BANK_ACCOUNT_ID(+)
         AND IEBA.BANK_NUMBER(+)='PFC BANK'
         AND  IEBA.end_date is null
         AND IAO.END_DATE IS NULL
        AND HCAS.ORG_ID = NVL (P_ORG_ID, HCAS.ORG_ID)
       AND HP.PARTY_ID = NVL ( P_PARTY_ID, HP.PARTY_ID)  --445064,494271
        AND HP.PARTY_NUMBER =NVL(P_PARTY_NUMBER,HP.PARTY_NUMBER)     
        --AND HP.PARTY_ID  IN(4705 ,497248)
       -- ORDER BY HP.PARTY_NAME;       
UNION
SELECT DISTINCT HP.PARTY_ID,HPS.PARTY_SITE_ID,
                  HP.PARTY_NAME "CUSTOMER_NAME",
                  HP.PARTY_NUMBER CUSTOMER_NUM,
                  NAME ORG_NAME,
                  HCAS.ATTRIBUTE1 GST_NUM,
                  PAN_NO,
                  HL.ADDRESS1, HL.ADDRESS2, HL.ADDRESS3, HL.ADDRESS4, HL.CITY, HL.POSTAL_CODE,  HL.STATE,
                  --HCP1.PHONE_NUMBER,HCP.EMAIL_ADDRESS,
                  XXPCL_CON_EMAIL_MO(1,HPS.PARTY_SITE_ID) EMAIL_ADDRESS,
                  XXPCL_CON_EMAIL_MO(2,HPS.PARTY_SITE_ID) PHONE_NUMBER,
                NULL,--  IEBA.BANK_NAME,
                  NULL,--IEBA.BANK_ACCOUNT_NUMBER,
                 -- IEBA.BRANCH_NUMBER,IEBA.BANK_BRANCH_NAME,IEBA.BANK_NUMBER,IEBA.DESCRIPTION
                  NULL,NULL,NULL,NULL
    FROM HZ_PARTIES HP,
         HZ_PARTY_SITES HPS,
         HZ_CUST_ACCOUNTS_ALL HCA,
         HZ_CUST_ACCT_SITES_ALL HCAS,
         HZ_CUST_SITE_USES_ALL HCSU,
         HZ_LOCATIONS HL,
         JAI_CMN_CUS_ADDRESSES JCCA,
         HR_OPERATING_UNITS HR,
         IBY_ACCOUNT_OWNERS IAO,
         IBY_EXT_BANK_ACCOUNTS_V IEBA
   WHERE     1 = 1
         AND HP.PARTY_ID = HCA.PARTY_ID
         AND JCCA.CUSTOMER_ID(+)= HCAS.CUST_ACCOUNT_ID
         AND HR.SET_OF_BOOKS_ID = 2121
         AND HR.ORGANIZATION_ID = HCAS.ORG_ID
         AND HCA.CUST_ACCOUNT_ID = HCAS.CUST_ACCOUNT_ID(+)
         AND HPS.PARTY_SITE_ID = HCAS.PARTY_SITE_ID
         AND HCAS.CUST_ACCT_SITE_ID = HCSU.CUST_ACCT_SITE_ID
         AND HP.STATUS = 'A'
         AND HPS.STATUS = 'A'
         AND HPS.LOCATION_ID = HL.LOCATION_ID(+)
         AND HP.PARTY_ID=IAO.ACCOUNT_OWNER_PARTY_ID(+)
         -- AND HPS.PARTY_SITE_ID=IPAB.PARTY_SITE_ID(+)
      -- and IPAB.PARTY_SITE_ID is null
       --AND IPAB.EXT_BANK_ACCOUNT_ID = IEBA.EXT_BANK_ACCOUNT_ID
       AND EXISTS (Select 1 from     APPS.IBY_PAYEE_ASSIGNED_BANKACCT_V IPAB WHERE IPAB.PARTY_SITE_ID(+)=HPS.PARTY_SITE_ID)
         AND IAO.EXT_BANK_ACCOUNT_ID=IEBA.EXT_BANK_ACCOUNT_ID(+)
         AND IEBA.BANK_NUMBER(+)='PFC BANK'
         AND  IEBA.end_date is null
         AND HCAS.ORG_ID = NVL (P_ORG_ID, HCAS.ORG_ID)
        AND HP.PARTY_ID = NVL ( P_PARTY_ID, HP.PARTY_ID)
        AND HP.PARTY_NUMBER =NVL(P_PARTY_NUMBER,HP.PARTY_NUMBER)     
        -- AND HP.PARTY_ID  IN(4705 ,497248)
        ORDER BY 3;

--SELECT DISTINCT HP.PARTY_ID,HPS.PARTY_SITE_ID,
--                  HP.PARTY_NAME "CUSTOMER_NAME",
--                  HP.PARTY_NUMBER CUSTOMER_NUM,
--                  NAME ORG_NAME,
--                  HCAS.ATTRIBUTE1 GST_NUM,
--                  PAN_NO,
--                  HL.ADDRESS1, HL.ADDRESS2, HL.ADDRESS3, HL.ADDRESS4, HL.CITY, HL.POSTAL_CODE,  HL.STATE,HCP1.PHONE_NUMBER,HCP.EMAIL_ADDRESS,
--                  IEBA.BANK_NAME,
--                  IEBA.BANK_ACCOUNT_NUMBER,
--                  IEBA.BRANCH_NUMBER,IEBA.BANK_BRANCH_NAME,IEBA.BANK_NUMBER,IEBA.DESCRIPTION
--    FROM HZ_PARTIES HP,
--         HZ_PARTY_SITES HPS,
--         HZ_CUST_ACCOUNTS_ALL HCA,
--         HZ_CUST_ACCT_SITES_ALL HCAS,
--         HZ_CUST_SITE_USES_ALL HCSU,
--         HZ_LOCATIONS HL,
--         HZ_CONTACT_POINTS HCP,
--         HZ_CONTACT_POINTS HCP1,
--         JAI_CMN_CUS_ADDRESSES JCCA,
--         HR_OPERATING_UNITS HR,
--         IBY_ACCOUNT_OWNERS IAO,
--         IBY_EXT_BANK_ACCOUNTS_V IEBA
--   WHERE     1 = 1
--         AND HP.PARTY_ID = HCA.PARTY_ID
--         AND JCCA.CUSTOMER_ID(+)= HCAS.CUST_ACCOUNT_ID
--         AND HR.SET_OF_BOOKS_ID = 2121
--         AND HR.ORGANIZATION_ID = HCAS.ORG_ID
--         AND HCA.CUST_ACCOUNT_ID = HCAS.CUST_ACCOUNT_ID(+)
--         AND HPS.PARTY_SITE_ID = HCAS.PARTY_SITE_ID
--         AND HCAS.CUST_ACCT_SITE_ID = HCSU.CUST_ACCT_SITE_ID
--         AND HP.STATUS = 'A'
--         AND HPS.STATUS = 'A'
--         AND HCAS.STATUS = 'A'   
--         AND   HCP.STATUS='A'
--         AND   HCP1.STATUS='A' 
--         AND HCP.OWNER_TABLE_ID(+)=HPS.PARTY_SITE_ID
--         AND HCP.CONTACT_POINT_TYPE(+)='EMAIL'       
--         AND HCP1.OWNER_TABLE_ID(+)=HPS.PARTY_SITE_ID
--         AND HCP1.CONTACT_POINT_TYPE(+)='PHONE'
--         AND HPS.LOCATION_ID = HL.LOCATION_ID(+)
--         AND HP.PARTY_ID=IAO.ACCOUNT_OWNER_PARTY_ID(+)
--         AND IAO.EXT_BANK_ACCOUNT_ID=IEBA.EXT_BANK_ACCOUNT_ID(+)
--         AND BANK_NUMBER(+)='PFC BANK'
--         AND HCAS.ORG_ID = NVL (P_ORG_ID, HCAS.ORG_ID)
--         AND HP.PARTY_ID = NVL (P_PARTY_ID, HP.PARTY_ID)
--         AND HP.PARTY_NUMBER =NVL(P_PARTY_NUMBER,HP.PARTY_NUMBER)       
--         ORDER BY HP.PARTY_NAME;
       
   BEGIN
--      select  FND_DATE.CANONICAL_TO_DATE(P1_FROM_DATE), FND_DATE.CANONICAL_TO_DATE(P1_TO_DATE) INTO P_FROM_DATE, P_TO_DATE   from dual;
--   
--      fnd_file.put_line (fnd_file.log,'P1_FROM_DATE :-  '||P1_FROM_DATE);
--      fnd_file.put_line (fnd_file.log,'P1_TO_DATE :-  '||P1_TO_DATE);
--      fnd_file.put_line (fnd_file.log,'AS_ON_DATE:-  '||P_FROM_DATE);
--      fnd_file.put_line (fnd_file.log,'AS_ON_DATE:-  '||P_TO_DATE);
-- 
      fnd_file.put_line (fnd_file.output, '<?xml version="1.0"?>');
      fnd_file.put_line (fnd_file.output, '<PCL_VD_DT>');
--       fnd_file.put_line (fnd_file.output,'<p_from_date>' || p_from_date || '</p_from_date>' );
--      fnd_file.put_line (fnd_file.output,'<p_to_date>' || p_to_date || '</p_to_date>' );
 

      FOR I IN C2 LOOP
         fnd_file.put_line (fnd_file.output, '<VD_HEADER>');
         fnd_file.put_line (fnd_file.output,'<PARTY_ID>' || I.PARTY_ID || '</PARTY_ID>' );
        fnd_file.put_line (fnd_file.output,'<PARTY_SITE_ID>' || I.PARTY_SITE_ID || '</PARTY_SITE_ID>' );
       
         fnd_file.put_line (fnd_file.output,'<CUSTOMER_NAME>' || trim(REPLACE (I.CUSTOMER_NAME, '&', '&' || 'amp;')) || '</CUSTOMER_NAME>' );             
         fnd_file.put_line (fnd_file.output,'<CUSTOMER_NUM>' || I.CUSTOMER_NUM || '</CUSTOMER_NUM>' );
         fnd_file.put_line (fnd_file.output,'<ORG_NAME>' || trim(REPLACE (I.ORG_NAME, '&', '&' || 'amp;')) || '</ORG_NAME>' );

         fnd_file.put_line (fnd_file.output,'<GST_NUM>' || trim(REPLACE (I.GST_NUM, '&', '&' || 'amp;')) || '</GST_NUM>' );   
         fnd_file.put_line (fnd_file.output,'<PAN_NO>' || I.PAN_NO || '</PAN_NO>' );
         fnd_file.put_line (fnd_file.output,'<ADDRESS1>' ||  trim(REPLACE (I.ADDRESS1, '&', '&' || 'amp;'))  || '</ADDRESS1>' );
         fnd_file.put_line (fnd_file.output,'<ADDRESS2>' ||  trim(REPLACE (I.ADDRESS2, '&', '&' || 'amp;'))  || '</ADDRESS2>' );
         fnd_file.put_line (fnd_file.output,'<ADDRESS3>' ||  trim(REPLACE (I.ADDRESS3, '&', '&' || 'amp;'))  || '</ADDRESS3>' );
         fnd_file.put_line (fnd_file.output,'<POSTAL_CODE>' || I.POSTAL_CODE || '</POSTAL_CODE>' );
       
         fnd_file.put_line (fnd_file.output,'<CITY>' ||  trim(REPLACE (I.CITY, '&', '&' || 'amp;'))  || '</CITY>' );
         fnd_file.put_line (fnd_file.output,'<STATE>' ||  trim(REPLACE (I.STATE, '&', '&' || 'amp;'))  || '</STATE>' );
       
         fnd_file.put_line (fnd_file.output,'<PHONE_NUMBER>' || I.PHONE_NUMBER || '</PHONE_NUMBER>' );           
         fnd_file.put_line (fnd_file.output,'<EMAIL_ADDRESS>' ||  trim(REPLACE (I.EMAIL_ADDRESS, '&', '&' || 'amp;'))  || '</EMAIL_ADDRESS>' );
       
         --BANK DETAILS
         fnd_file.put_line (fnd_file.output,'<BANK_NAME>' ||  trim(REPLACE (I.BANK_NAME, '&', '&' || 'amp;'))  || '</BANK_NAME>' );
         fnd_file.put_line (fnd_file.output,'<BANK_ACCOUNT_NUMBER>' ||  trim(REPLACE (I.BANK_ACCOUNT_NUMBER, '&', '&' || 'amp;'))  || '</BANK_ACCOUNT_NUMBER>' );
         fnd_file.put_line (fnd_file.output,'<BRANCH_NUMBER>' ||  trim(REPLACE (I.BRANCH_NUMBER, '&', '&' || 'amp;'))  || '</BRANCH_NUMBER>' );
         fnd_file.put_line (fnd_file.output,'<BANK_BRANCH_NAME>' ||  trim(REPLACE (I.BANK_BRANCH_NAME, '&', '&' || 'amp;'))  || '</BANK_BRANCH_NAME>' );
         fnd_file.put_line (fnd_file.output,'<BANK_NUMBER>' || I.BANK_NUMBER || '</BANK_NUMBER>' );
         fnd_file.put_line (fnd_file.output,'<DESCRIPTION>' ||  trim(REPLACE (I.DESCRIPTION, '&', '&' || 'amp;'))  || '</DESCRIPTION>' );
     
     P_V_COUNT:=1;
       fnd_file.put_line (fnd_file.output, '</VD_HEADER>');
      END LOOP;
      fnd_file.put_line (fnd_file.output, '</PCL_VD_DT>');
      EXCEPTION WHEN OTHERS THEN fnd_file.put_line (fnd_file.LOG, 'Entered INTO exception' || SQLCODE || SQLERRM  );

END;

/


----------------------------------------

------------------------------------------Function details------------------------

Note :-  Function name :-----XXPCL_CON_EMAIL_MO

CREATE OR REPLACE FUNCTION APPS.XXPCL_CON_EMAIL_MO (P_NO_ID NUMBER ,P_PARTY_SITE_ID NUMBER) RETURN VARCHAR2
AS

-- FUNCTION NAME --XXPCL_CON_EMAIL_MO
 --Techical Israr
 --Technical.israr@gmail.com 05-oct-2018

V_EMAIL_ADDRESS VARCHAR2(100);
V_PHONE_NUMBER VARCHAR2(100);

V_COUNT NUMBER := 1;

CURSOR C1 IS
SELECT hcp.email_address,HPS.PARTY_SITE_ID
       from  hz_parties hz,
          hz_party_sites hps,
          hz_contact_points hcp
where 1=1
and  hz.party_id=hps.party_id
and  hps.party_site_id=hcp.owner_table_id
and HCP.status='A'
AND CONTACT_POINT_TYPE='EMAIL'
AND hps.party_site_id=P_PARTY_SITE_ID;
--and hz.party_id=494220


CURSOR C2
IS
 SELECT A.PHONE_NUMBER
          FROM HZ_CONTACT_POINTS A
         WHERE 1 = 1 AND A.status = 'A' AND A.CONTACT_POINT_TYPE = 'PHONE' AND A.OWNER_TABLE_ID=P_PARTY_SITE_ID;

BEGIN

    FOR I IN C1 LOOP

        IF V_COUNT = 1 THEN
           
           
            V_EMAIL_ADDRESS:= I.EMAIL_ADDRESS;
        --    V_PHONE_NUMBER:=I.PHONE_NUMBER;
         
            V_COUNT:= V_COUNT+1;
           
        ELSE
           
           
            V_EMAIL_ADDRESS:= V_EMAIL_ADDRESS||' / '||I.EMAIL_ADDRESS;
          --  V_PHONE_NUMBER:=V_PHONE_NUMBER||' / '||I.PHONE_NUMBER;
                     
        END IF;
       
          END LOOP;
               

 
       
        FOR J IN C2
         LOOP

        IF V_COUNT = 1 THEN
           
           
            --V_EMAIL_ADDRESS:= I.EMAIL_ADDRESS;
            V_PHONE_NUMBER:=J.PHONE_NUMBER;
         
            V_COUNT:= V_COUNT+1;
           
        ELSE
           
           
            --V_EMAIL_ADDRESS:= V_EMAIL_ADDRESS||' / '||I.EMAIL_ADDRESS;
            V_PHONE_NUMBER:=V_PHONE_NUMBER||' / '||J.PHONE_NUMBER;
                     
        END IF;           

 
     END LOOP;
    IF P_NO_ID =1 THEN
    RETURN     V_EMAIL_ADDRESS;
   
        ELSIF P_NO_ID =2 THEN
    RETURN     V_PHONE_NUMBER;
   
ELSE RETURN NULL;
END IF;

EXCEPTION WHEN OTHERS THEN RETURN NULL;
END;
/

Wednesday, October 3, 2018

GL Interface Code

How to create the GL Interface in oracle apps

1. Create the staging table

CREATE TABLE XXWIPRO_STG
(
   STATUS                  VARCHAR2 (50),
   SET_OF_BOOKS_ID         NUMBER (15),
   USER_JE_SOURCE_NAME     VARCHAR2 (25),
   USER_JE_CATEGORY_NAME   VARCHAR2 (25),
   CURRENCY_CODE           VARCHAR2 (15),
   ACTUAL_FLAG             CHAR (1),
   ACCOUNTING_DATE         DATE,
   DATE_CREATED            DATE,
   CREATED_BY              NUMBER (15),
   ENTERED_DR              NUMBER,
   ENTERED_CR              NUMBER,
   ACCOUNTED_DR            NUMBER,
   ACCOUNTED_CR            NUMBER,
   SEGMENT1                VARCHAR2 (25),
   SEGMENT2                VARCHAR2 (25),
   SEGMENT3                VARCHAR2 (25),
   SEGMENT4                VARCHAR2 (25),
   SEGMENT5                VARCHAR2 (25)

);

Output :-  Table created.

2. Insert the data in XXWIRPO_STG

insert into XXWIPRO_STG values('NEW',2121,'Manual' ,'Adjustment','INR','A','03-OCT-2018' ,'03-OCT-2018' , 787,12,12,12,12,'1001','000','400102','000','000');

OUTPUT:-



3. Create the Package :-

CREATE OR REPLACE PACKAGE XXWIPRO_GL_INT_PKG
IS
PROCEDURE XXWIPRO_GL_INT_PROC(ERRBUF OUT VARCHAR2,RETCODE OUT VARCHAR2);

----Create the package for specificaton ----
---- techical israr         technical.israr@gmail.com 


END;

OUTPUT  :-  Package created.

----------------------------------------------------------------------------------------------------------------

4.  Create the Package Body :-

CREATE OR REPLACE PACKAGE BODY XXWIPRO_GL_INT_PKG
IS
   PROCEDURE XXWIPRO_GL_INT_PROC (ERRBUF OUT VARCHAR2, RETCODE OUT VARCHAR2)
   IS
      ----Create the package body ----
      ---- techical israr         technical.israr@gmail.com

      CURSOR GL_CUR
      IS
         SELECT STATUS,
                SET_OF_BOOKS_ID,
                USER_JE_SOURCE_NAME,
                USER_JE_CATEGORY_NAME,
                CURRENCY_CODE,
                ACTUAL_FLAG,
                ACCOUNTING_DATE,
                DATE_CREATED,
                CREATED_BY,
                ENTERED_DR,
                ENTERED_CR,
                ACCOUNTED_DR,
                ACCOUNTED_CR,
                SEGMENT1,
                SEGMENT2,
                SEGMENT3,
                SEGMENT4,
                SEGMENT5
           FROM XXWIPRO_STG;

      V_STATUS                  VARCHAR2 (50);
      V_SOB_ID                  NUMBER (15);
      V_USER_JE_SOURCE_NAME     VARCHAR2 (25);
      V_USER_JE_CATEGORY_NAME   VARCHAR2 (25);
      V_CUR_CODE                VARCHAR2 (15);
      V_ACTUAL_FLAG             VARCHAR2 (1);
      V_ERR_FLAG                VARCHAR2 (2);
      V_FLAG                    VARCHAR2 (2);
   BEGIN
      FOR REC IN GL_CUR
      LOOP
         V_FLAG := 'A';
         V_ERR_FLAG := 'A';

         BEGIN
            SELECT DISTINCT STATUS
              INTO V_STATUS
              FROM XXWIPRO_STG
             WHERE STATUS = 'NEW';
         EXCEPTION
            WHEN NO_DATA_FOUND
            THEN
               V_STATUS := NULL;
               V_FLAG := 'E';
               V_ERR_FLAG := 'E';
               FND_FILE.
                PUT_LINE (FND_FILE.LOG,
                          'The status is not correct so change the status');
               FND_FILE.
                PUT_LINE (FND_FILE.LOG, 'The data is inserting' || V_STATUS);
         END;

         BEGIN
            SELECT SET_OF_BOOKS_ID
              INTO V_SOB_ID
              FROM XXWIPRO_STG
             WHERE SET_OF_BOOKS_ID = REC.SET_OF_BOOKS_ID;
         EXCEPTION
            WHEN NO_DATA_FOUND
            THEN
               V_SOB_ID := NULL;
               V_FLAG := 'E';
               V_ERR_FLAG := 'E';
               FND_FILE.
                PUT_LINE (FND_FILE.LOG,
                          'The SOB is not correct change SOB ID');
         END;

         FND_FILE.
          PUT_LINE (FND_FILE.LOG, 'The data is inserting' || V_SOB_ID);

         BEGIN
            SELECT USER_JE_SOURCE_NAME
              INTO V_USER_JE_SOURCE_NAME
              FROM GL_JE_SOURCES
             WHERE USER_JE_SOURCE_NAME = REC.USER_JE_SOURCE_NAME;
         EXCEPTION
            WHEN NO_DATA_FOUND
            THEN
               V_USER_JE_SOURCE_NAME := NULL;
               V_FLAG := 'E';
               V_ERR_FLAG := 'E';
               FND_FILE.
                PUT_LINE (FND_FILE.LOG,
                          'The SOURCE NAME is not correct change It');
         END;

         FND_FILE.
          PUT_LINE (FND_FILE.LOG,
                    'The data inserting is' || V_USER_JE_SOURCE_NAME);

         BEGIN
            SELECT USER_JE_CATEGORY_NAME
              INTO V_USER_JE_CATEGORY_NAME
              FROM GL_JE_CATEGORIES
             WHERE USER_JE_CATEGORY_NAME = REC.USER_JE_CATEGORY_NAME;
         EXCEPTION
            WHEN NO_DATA_FOUND
            THEN
               V_USER_JE_CATEGORY_NAME := NULL;
               V_FLAG := 'E';
               V_ERR_FLAG := 'E';
               FND_FILE.
                PUT_LINE (FND_FILE.LOG,
                          'The Category name is not correct Change it');
               FND_FILE.
                PUT_LINE (FND_FILE.LOG,
                          'The data inserting is' || V_USER_JE_CATEGORY_NAME);
         END;

         BEGIN
            SELECT CURRENCY_CODE
              INTO V_CUR_CODE
              FROM FND_CURRENCIES
             WHERE CURRENCY_CODE = REC.CURRENCY_CODE;
         EXCEPTION
            WHEN NO_DATA_FOUND
            THEN
               V_CUR_CODE := NULL;
               V_FLAG := 'E';
               V_ERR_FLAG := 'E';
               FND_FILE.
                PUT_LINE (FND_FILE.LOG, 'The Currency code is not correct ');
         END;

         FND_FILE.
          PUT_LINE (FND_FILE.LOG, 'The data inserting is' || V_CUR_CODE);

         BEGIN
            SELECT ACTUAL_FLAG
              INTO V_ACTUAL_FLAG
              FROM XXWIPRO_STG
             WHERE ACTUAL_FLAG IN ('A', 'B', 'E');
         EXCEPTION
            WHEN NO_DATA_FOUND
            THEN
               V_ACTUAL_FLAG := NULL;
               V_FLAG := 'E';
               V_ERR_FLAG := 'E';
               FND_FILE.PUT_LINE (FND_FILE.LOG, 'The Flag is not correct');
         END;

         FND_FILE.
          PUT_LINE (FND_FILE.LOG,
                    'The data inserting is... ' || V_ACTUAL_FLAG);

         IF V_FLAG = 'A'
         THEN
            INSERT INTO GL_INTERFACE (STATUS,
                                      SET_OF_BOOKS_ID,
                                      USER_JE_SOURCE_NAME,
                                      USER_JE_CATEGORY_NAME,
                                      CURRENCY_CODE,
                                      ACTUAL_FLAG,
                                      ACCOUNTING_DATE,
                                      DATE_CREATED,
                                      CREATED_BY,
                                      ENTERED_DR,
                                      ENTERED_CR,
                                      ACCOUNTED_DR,
                                      ACCOUNTED_CR,
                                      SEGMENT1,
                                      SEGMENT2,
                                      SEGMENT3,
                                      SEGMENT4,
                                      SEGMENT5)
                 VALUES (V_STATUS,
                         V_SOB_ID,
                         V_USER_JE_SOURCE_NAME,
                         V_USER_JE_CATEGORY_NAME,
                         V_CUR_CODE,
                         V_ACTUAL_FLAG,
                         REC.ACCOUNTING_DATE,
                         REC.DATE_CREATED,
                         786,
                         REC.ENTERED_DR,
                         REC.ENTERED_CR,
                         REC.ACCOUNTED_DR,
                         REC.ACCOUNTED_CR,
                         REC.SEGMENT1,
                         REC.SEGMENT2,
                         REC.SEGMENT3,
                         REC.SEGMENT4,
                         REC.SEGMENT5);
         END IF;

         V_FLAG := NULL;
         V_ERR_FLAG := NULL;
      END LOOP;

      COMMIT;
   END;
END XXWIPRO_GL_INT_PKG;
/

OUTPUT :- Package body created.

---------------------------------------------------------

5.  Create the executable program with short_name and executable_file_name

Note:- 1. Short_Name                   = user define (XXWIP_GL_INT_F)

            2. Executable_file_name   = package_name.procedure_name
                                                           XXWIPRO_GL_INT_PKG.XXWIPRO_GL_INT_PROC



7. Create the Concurrent program 



Note :- there no parameters in this concurrent program

8. Wipro GL interface program assign in any Request Group with User responsibility 



 9. Run the WIPRO GL INTERFACE PROGRAM with attached user responsibility 









10.  now check the record in GL_Interface table 

select * from gl_interface

Let me know if any query

Thanks
Technical Israr

Monday, October 1, 2018

AR Tables with joins


Joins  AR TRANSACTION AND RECEIPTS TO GL WITH JOINS STEP BY STEP IN SIMPLE WAY

                 
            AR TRANSACTONS TABLES

SELECT * FROM  RA_CUSTOMER_TRX_ALL
WHERE 1=1
AND TRX_NUMBER=10223 --and customer_trx_id=7943

SELECT * FROM  RA_CUSTOMER_TRX_LINES_ALL
WHERE CUSTOMER_TRX_ID=7943  --customer_trx_id=7943,CUSTOMER_TRX_LINE_ID 7964

SELECT * FROM RA_CUST_TRX_LINE_GL_DIST_ALL
WHERE CUSTOMER_TRX_LINE_ID =7964    --CUST_TRX_LINE_GL_DIST_ID=17399

                        AR RECEIPTS TABLES

SELECT * FROM  AR_RECEIVABLE_APPLICATIONS_ALL
WHERE APPLIED_CUSTOMER_TRX_ID =7943

SELECT * FROM  AR_CASH_RECEIPTS_ALL
WHERE CASH_RECEIPT_ID=139154   --PAY_FROM_CUSTOMER=10513


                        HZ PARTY TABLES IN AR

SELECT * FROM  HZ_CUST_ACCT_SITES_ALL
WHERE CUST_ACCOUNT_ID=10513  --party_site_id=448147

SELECT * FROM  HZ_PARTY_SITES
WHERE PARTY_SITE_ID=448147 --party_id=498171

SELECT * FROM  HZ_PARTIES
WHERE PARTY_ID=498171

                        XLA TABLES

SELECT * FROM   XLA.XLA_TRANSACTION_ENTITIES
WHERE SOURCE_ID_INT_1=7943  --entity_code=TRANSACTIONS,application_id=222

SELECT * FROM  XLA.XLA_AE_HEADERS
WHERE ENTITY_ID=1302589  --ae_header_id=1402447

SELECT * FROM  XLA.XLA_AE_LINES
WHERE AE_HEADER_ID=1402447    --gl_sl_link_id in(2729789,2729790)


                          GL TABLES                   

SELECT * FROM  GL_IMPORT_REFERENCES
WHERE GL_SL_LINK_ID IN(2729789,2729790)  --je_header_id=1759126, je_batch_id=1238537, je_header_id=1238537

SELECT * FROM  GL_JE_HEADERS
WHERE JE_HEADER_ID=1238537

SELECT * FROM  GL_JE_LINES
WHERE JE_HEADER_ID=1238537

P2P Tables with joins


P2P Cycle technical flow step by step with joins in simple way


    REQUISITION TABLES
       
SELECT * FROM  PO_REQUISITION_HEADERS_ALL
WHERE segment1=1100004-- requisition_header_id=61

SELECT * FROM  PO_REQUISITION_LINES_ALL
WHERE REQUISITION_HEADER_ID=61  --REQUISITION_LINE_ID=101,requisition_header_id=61

SELECT * FROM  PO_REQUISITION_LINES_ALL
WHERE REQUISITION_LINE_ID=101    --REQUISITION_HEADER_ID=61

SELECT * FROM  PO_REQ_DISTRIBUTIONS_ALL
WHERE REQUISITION_LINE_ID=101  --distributon_id=94

                PO TABLES

SELECT * FROM  PO_DISTRIBUTIONS_ALL
WHERE PO_HEADER_ID=92 -- --PO_HEADER_ID=92, PO_LINE_ID=373 , po_distribution_id=80

SELECT * FROM  PO_LINES_ALL
WHERE PO_HEADER_ID=92  --PO_HEADER_ID=92, PO_LINE_ID=373

SELECT * FROM  PO_HEADERS_ALL
WHERE SEGMENT1=1100061 --po_header_id=92

          RECEIPTS TABLES

SELECT * FROM  RCV_TRANSACTIONS
WHERE PO_DISTRIBUTION_ID=80 -- shipment_header_id=3025 , PO_HEADER_ID=92, PO_LINE_ID=373

SELECT * FROM  RCV_SHIPMENT_HEADERS
WHERE SHIPMENT_HEADER_ID=3025   --SHIPMENT_LINE_ID=3028

SELECT * FROM  RCV_SHIPMENT_LINES
WHERE SHIPMENT_HEADER_ID=3025    --SHIPMENT_LINE_ID=3028, po_header_id=92, po_line_id=373,po_distribution_id=80

                ACCOUNT PAYABLES TABLES

SELECT * FROM  AP_INVOICE_DISTRIBUTIONS_ALL
WHERE PO_DISTRIBUTION_ID =3823   --REQ_DISTRIBUTION_ID=  ,ACCOUNTING_EVENT_ID=926551,926552  ,INVOICE_ID=65057

SELECT * FROM  AP_INVOICE_LINES_ALL
WHERE INVOICE_ID=65057

SELECT * FROM  AP_INVOICES_ALL
WHERE INVOICE_ID=65057

                XLA TABLES 

SELECT * FROM  XLA.XLA_TRANSACTION_ENTITIES
WHERE SOURCE_ID_INT_1='65057'    --ENTITY_ID=1000248

SELECT * FROM  XLA.XLA_AE_HEADERS
WHERE ENTITY_ID=1000248  -- ae_header_id=1091228

SELECT * FROM  XLA.XLA_AE_LINES
WHERE AE_HEADER_ID=1091228    --gl_sl_link_id in(2046124,2046123)

                    GL TABLES

SELECT * FROM  GL_IMPORT_REFERENCES
WHERE GL_SL_LINK_ID IN(2046124,2046123)   --JE_HEADER_ID=1393995 , JE_BATCH_ID=1126487

SELECT * FROM  GL_JE_HEADERS
WHERE JE_HEADER_ID=1393995   --je_header_id=1393995

SELECT * FROM  GL_JE_LINES
WHERE JE_HEADER_ID=1393995   --GL_SL_LINK_ID  in(2046123,2046124)

Sunday, September 30, 2018

API Supplier Site Creation

API For supplier/vendor site creation in oracle r12 

DECLARE

l_vendor_site_rec ap_vendor_pub_pkg.r_vendor_site_rec_type;
l_return_status     VARCHAR2(10);
l_msg_count     NUMBER;
l_msg_data     VARCHAR2(1000);
l_vendor_site_id     NUMBER;
l_party_site_id     NUMBER;
l_location_id     NUMBER;

CURSOR C1 IS

--select * from XXPCL_SUPPLIER_LIB_PRE_ACT_V
--where 1=1
--and org_id = 141
----and  VENDOR_TYPE = '3RD PARTY'
----and  VENDOR_TYPE = 'CONSULTANT'
----and  VENDOR_TYPE  = 'VENDOR'
----and  VENDOR_TYPE  = 'EMPLOYEE'
--and  VENDOR_TYPE = 'TAX AUTHORITY'


/* 3RD PARTY   and  VENDOR  */
select '451075' VENDOR_ID,'PFCCL' SITE_CODE ,
'.'SITE_ADDRESS_LINE_1,
NULL SITE_ADDRESS_LINE_2,
NULL SITE_ADDRESS_LINE_3,
NULL SITE_CITY_TOWN,
NULL SITE_STATE,
NULL  SITE_PIN,
'141' OPERATING_UNIT,
'385665' LIABILITY_ACCOUNT,
'385633' PREPAYMENT_ACCOUNT
from dual;

/* EMPLOYEE */
--select '3763' VENDOR_ID,'OFFICE' SITE_CODE ,
--'.'SITE_ADDRESS_LINE_1,
--NULL SITE_ADDRESS_LINE_2,
--NULL SITE_ADDRESS_LINE_3,
--NULL SITE_CITY_TOWN,
--NULL SITE_STATE,
--NULL  SITE_PIN,
--'141' OPERATING_UNIT,
--'385660' LIABILITY_ACCOUNT,
--'385889' PREPAYMENT_ACCOUNT
--from dual;

/* CONSULTANT */
--select '401998' VENDOR_ID,'PFCCL' SITE_CODE ,
--'.'SITE_ADDRESS_LINE_1,
--NULL SITE_ADDRESS_LINE_2,
--NULL SITE_ADDRESS_LINE_3,
--NULL SITE_CITY_TOWN,
--NULL SITE_STATE,
--NULL  SITE_PIN,
--'141' OPERATING_UNIT,
--'385071' LIABILITY_ACCOUNT,
--'385633' PREPAYMENT_ACCOUNT
--from dual;

--select *
--from XXPCL_SUP_STAGING_TBL A
--where  1=1
----AND A.SUPPLIER_NAME= 'BSES Rajdhani Power Limited.'
--and exists ( select * from ap_suppliers Z where  Z.VENDOR_ID =  A.VENDOR_ID)
--and not exists ( select * from ap_supplier_sites_all X where X.VENDOR_ID =  A.VENDOR_ID and X.VENDOR_SITE_ID = A.VENDOR_SITE_ID) ;


BEGIN

  fnd_global.apps_initialize(0, 51572, 200);

  FOR I IN C1 LOOP

--Required
l_vendor_site_rec.vendor_id :=I.VENDOR_ID;
l_vendor_site_rec.vendor_site_code := I.SITE_CODE;
l_vendor_site_rec.address_line1 :=I.SITE_ADDRESS_LINE_1;
l_vendor_site_rec.address_line2 := I.SITE_ADDRESS_LINE_2;
l_vendor_site_rec.address_line3 :=I.SITE_ADDRESS_LINE_3;
--l_vendor_site_rec.address_line4 :=I.SITE_ADDRESS_LINE_4;
--l_vendor_site_rec.ADDRESS_LINES_ALT :=I.SITE_ROOM;
l_vendor_site_rec.CITY := I.SITE_CITY_TOWN;
l_vendor_site_rec.STATE :=I.SITE_STATE;
l_vendor_site_rec.ZIP :=I.SITE_PIN;
l_vendor_site_rec.country := 'IN';
l_vendor_site_rec.org_id := I.OPERATING_UNIT;
l_vendor_site_rec.ATTRIBUTE_CATEGORY:='Vendor Site Ref';
l_vendor_site_rec.ATTRIBUTE10 := I.SITE_CODE;
l_vendor_site_rec.ACCTS_PAY_CODE_COMBINATION_ID:= I.LIABILITY_ACCOUNT; -- Libility--
l_vendor_site_rec.PREPAY_CODE_COMBINATION_ID :=I.PREPAYMENT_ACCOUNT; -- Prepayment--

--Optional

l_vendor_site_rec.purchasing_site_flag:='Y';
l_vendor_site_rec.pay_site_flag :='Y';
l_vendor_site_rec.rfq_only_site_flag :='N';
l_vendor_site_rec.MATCH_OPTION :='R';
--l_vendor_site_rec.phone := '9876543210';

pos_vendor_pub_pkg.create_vendor_site
(
p_vendor_site_rec => l_vendor_site_rec,
x_return_status => l_return_status,
x_msg_count => l_msg_count,
x_msg_data => l_msg_data,
x_vendor_site_id => l_vendor_site_id,
x_party_site_id => l_party_site_id,
x_location_id => l_location_id
);

COMMIT;

dbms_output.put_line('return_status: '||l_return_status);
dbms_output.put_line('msg_data: '||l_msg_data);
dbms_output.put_line('vendor_site_id: '||l_vendor_site_id);
dbms_output.put_line('party_site_id: '||l_party_site_id);
dbms_output.put_line('location_id: '||l_location_id);

--UPDATE XXPCL_SUP_STAGING_TBL
--set VENDOR_SITE_ID = l_vendor_site_id,
--PARTY_SITE_ID = l_party_site_id,
--LOCATION_ID = l_location_id
--where VENDOR_ID = I.VENDOR_ID
--and VENDOR_STAGING_ID = I.VENDOR_STAGING_ID;

COMMIT;

END LOOP;

END;


  --POS_VENDOR_PUB_PKG.Update_Vendor_Site
  --POS_VENDOR_PUB_PKG.Create_Vendor_Contact

API Supplier Creation

How to create API For supplier/vendor creation in r12

DECLARE

l_vendor_rec     ap_vendor_pub_pkg.r_vendor_rec_type;
l_return_status     VARCHAR2(10);
l_msg_count     NUMBER;
l_msg_data     VARCHAR2(1000);
l_vendor_id    NUMBER;
l_party_id     NUMBER;

CURSOR C1 IS

select VENDOR_NAME SUPPLIER_NAME, VENDOR_TYPE SUPPLIER_TYPE
from (
SELECT 'WIPRO' VENDOR_NAME, 'VENDOR' VENDOR_TYPE FROM DUAL
--SELECT 'HELLO' VENDOR_NAME, '3RD PARTY' VENDOR_TYPE FROM DUAL
--SELECT 'HELLO' VENDOR_NAME, 'CONSULTANT' VENDOR_TYPE FROM DUAL
--SELECT 'HELLO' VENDOR_NAME, 'EMPLOYEE' VENDOR_TYPE FROM DUAL
--SELECT 'Ashok L Pathak' VENDOR_NAME, 'EMPLOYEE' VENDOR_TYPE FROM DUAL
--SELECT 'OMM NAMAH SHIVAYA TOURS '||CHR(38)||' TRAVELS' VENDOR_NAME, 'VENDOR' VENDOR_TYPE FROM DUAL  /*  &  */
--SELECT 'OMM NAMAH SHIVAYA TOURS '||CHR(39)||' TRAVELS' VENDOR_NAME, 'VENDOR' VENDOR_TYPE FROM DUAL  /*  '   */
);

--select * from XXPCL_SUP_STAGING_TBL A
--where  1=1
----AND A.SUPPLIER_NAME= 'R Rahman'
--and not exists ( select 1 from ap_suppliers Z where  TRIM(UPPER(Z.VENDOR_NAME)) =  TRIM(UPPER(A.SUPPLIER_NAME)));

--update ap_suppliers
--set vendor_name = REPLACE(vendor_name, CHR(13), '')
--where upper(vendor_name) likE '%MONICA JASSI%'

--select * from ap_suppliers where VENDOR_TYPE_LOOKUP_CODE like 'EMPLOYEE%'
--
--select 'STD', VENDOR_NAME, length(TRIM(VENDOR_NAME))  from ap_suppliers
--where upper(vendor_name) likE '%BINOD%%'
--union
--select 'CST', SUPPLIER_NAME, length(TRIM(SUPPLIER_NAME))  from XXPCL_SUP_STAGING_TBL A
--where upper(SUPPLIER_NAME) likE '%BINOD KUMAR ROY%'

BEGIN

--select * from fnd_responsibility_tl where RESPONSIBILITY_NAME like 'WIPRO%Resource%'

  fnd_global.apps_initialize(0, 51572, 200);

FOR I IN C1 LOOP

--Required
--l_vendor_rec.segment1 := '00002359'; --ID
l_vendor_rec.vendor_name := I.SUPPLIER_NAME;

--Optional
l_vendor_rec.VENDOR_TYPE_LOOKUP_CODE:= I.SUPPLIER_TYPE;
l_vendor_rec.ATTRIBUTE_CATEGORY := 'Vendor Categories';
l_vendor_rec.ATTRIBUTE4 :='COMMMISION';
l_vendor_rec.TERMS_DATE_BASIS := 'Invoice';
l_vendor_rec.match_option:='R' ;

pos_vendor_pub_pkg.create_vendor
(
p_vendor_rec => l_vendor_rec,
x_return_status => l_return_status,
x_msg_count => l_msg_count,
x_msg_data => l_msg_data,
x_vendor_id => l_vendor_id,
x_party_id => l_party_id
);

COMMIT;

dbms_output.put_line('return_status: '||l_return_status||SQLERRM);
dbms_output.put_line('msg_data: '||l_msg_data);
dbms_output.put_line('vendor_id: '||l_vendor_id);
dbms_output.put_line('vendor_Name: '||I.SUPPLIER_NAME);
dbms_output.put_line('party_id: '||l_party_id);

--UPDATE XXPCL_SUP_STAGING_TBL
--SET VENDOR_ID = l_vendor_id
--WHERE VENDOR_STAGING_ID = I.VENDOR_STAGING_ID;

COMMIT;

END LOOP;

END;