Search This Blog

Monday, June 12, 2017

Create PO requisition in R12 from backend and apps initialization for OU's.

1. Package to insert data into PO_REQUISITIONS_INTERFACE_ALL


CREATE OR REPLACE PACKAGE FUJ_EMP_TICKET_INTEG
IS
PROCEDURE POREQ_CREATION(P_EMPLOYEE_NUMBER VARCHAR2) ;
END;

CREATE OR REPLACE PACKAGE BODY FUJ_EMP_TICKET_INTEG
IS
PROCEDURE POREQ_CREATION( P_EMPLOYEE_NUMBER VARCHAR2)
IS
CURSOR C1 IS

SELECT EMPLOYEE_NUMBER,
DECODE(INFO1,1,QUOT_AMOUNT1,
DECODE(INFO2,2,QUOT_AMOUNT2,
DECODE(INFO3,3,QUOT_AMOUNT3
)))AMOUNT
 FROM XXFUJ_TICKET_DETAILS
WHERE EMPLOYEE_NUMBER = P_EMPLOYEE_NUMBER

;

        BEGIN

FOR I IN C1 LOOP

INSERT INTO PO_REQUISITIONS_INTERFACE_ALL (INTERFACE_SOURCE_CODE,
                                           ORG_ID,
                                           DESTINATION_TYPE_CODE,
                                           AUTHORIZATION_STATUS,
                                           PREPARER_ID,
                                           --PREPARER_NAME,
                                           CHARGE_ACCOUNT_ID,
                                           SOURCE_TYPE_CODE,
                                           UNIT_OF_MEASURE,
                                           LINE_TYPE_ID,
                                           CATEGORY_ID,
                                           UNIT_PRICE,
                                           QUANTITY,
                                           DESTINATION_ORGANIZATION_ID,
                                           DELIVER_TO_LOCATION_ID,
                                           DELIVER_TO_REQUESTOR_ID,
                                           HEADER_DESCRIPTION,
                                           ITEM_DESCRIPTION,
                                           SUGGESTED_VENDOR_ID,
                                           SUGGESTED_VENDOR_SITE_ID,
                                           --ACCRUAL_ACCOUNT_ID ,
                                           --VARIANCE_ACCOUNT_ID,
                                           --BUDGET_ACCOUNT_ID,
                                           HEADER_ATTRIBUTE1,
                                           HEADER_ATTRIBUTE2,
                                           HEADER_ATTRIBUTE3,
                                           HEADER_ATTRIBUTE4,
                                           GL_DATE,
                                           REQUISITION_HEADER_ID                                         
                                           )
     VALUES ('IMPORT_EXP',                                  --Interface Source
             102,                                             --Operating Unit
             'EXPENSE',                                     --Destination Type
            'APPROVED',--'INCOMPLETE',       -- 'APPROVED',--                                     --Status
             26876,--6439,                      --This comes from per_people_f.person_id
            -- '???? ??? ????? ????? ?????????',
             106847,                                      --Code Combination ID
             'VENDOR',                                           --Source Type
             'Quantity',                                                     --UOM ok??yes
             1,                                           --Line Type of Goods
             1123,                                           --MISC.MISC Category
             I.AMOUNT,                                                       --Price
             1,                                                    --quantity
             108,--102                      --Represents Vision Operations Inv Org.
             142,--162,                                --Represents V1-New York City
             26876,--6439 ,                            --This is the Deliver to Requestor
             I.EMPLOYEE_NUMBER,                        --One Time Header Description
             I.EMPLOYEE_NUMBER,                        --One Time Item Description
             222,
             261,
             --17979,--Accrual
             --106847,--Varianlce
             --106847, --Budget
             'Y',--Header. ATT1
             'India',--Header 2
            'New Delhi',--Header 3
             I.EMPLOYEE_NUMBER,--Header 4
             TO_DATE('01-JAN-2017'),
              PO_REQUISITION_HEADERS_S.NEXTVAL
                           );
                           COMMIT;
/*
UPDATE  XXFUJ_TICKET_DETAILS
SET INFO4 = 'PR Created Success'
WHERE EMPLOYEE_NUMBER = I.EMPLOYEE_NUMBER;
COMMIT;
*/                         
END LOOP;


EXCEPTION WHEN OTHERS THEN NULL;

        END;
END;                                                        

2.to run concurrent program 'Requisition Import' from backend:

DECLARE
V_OUTPUT NUMBER;
BEGIN
         mo_global.init ('PO');
 MO_GLOBAL.set_policy_context('S',102);
fnd_global.apps_initialize (2605,50597,201,0,0);
 FND_REQUEST.SET_ORG_ID(102); --this is passed as operating unit
V_OUTPUT := fnd_request.submit_request
                        (
                         application      => 'PO',
                         program          => 'REQIMPORT',
                         description      => '',
                         start_time       => TO_CHAR(SYSDATE,'DD-MON-YY HH24:MI:SS'),
                         sub_request      => FALSE,
                         argument1        => 'IMPORT_EXP',--Interface Source code,
                         argument2        => '',  ----APPS.SONA_BATCH_ID_S.CURRVAL,--Batch ID,
                         argument3        => 'BUYER',--Group By,
                         argument4        => '',--Last Req Number,
                         argument5        => 'N',--Multi Distributions,
                         argument6        => 'Y'
                          ) ;
DBMS_OUTPUT.PUT_LINE(   V_OUTPUT);
commit;
EXCEPTION WHEN OTHERS THEN
                      DBMS_OUTPUT.PUT_LINE( SQLERRM);
END;     

3. To view exceptions after the above concurrent program.

Run the concurrent program 'Requisition Import Exceptions Report '.

1 comment: