Search This Blog

Sunday, May 20, 2018

Userhook on SIT Update oracle Apps R12






Requirement: To add Element, once the SIT is updated.


CREATE OR REPLACE PACKAGE APPS.XXFUJ_UPDATE_SIT_A_UHPKG IS

--USER HOOK PACKAGE FOR HR_SIT_BK1.CREATE_SIT_A

PROCEDURE XXFUJ_UPDATE_SIT_LEV_VAL

--THIS WILL VALIDATE THE SIT WITH REFERENCE TO THE LEAVE EXISTS.

/*

Example: If a emp is on Annual leave from 01-jan-2017 to 30-jan-2017

now we are entering in SIT (Training) 10-jan-2017 to 15-jan-2017

As training days falls between the annual leave days, then the user entering the SIT will be notified by warning message.

*/
(P_PERSON_ANALYSIS_ID in NUMBER
,P_PEA_OBJECT_VERSION_NUMBER in NUMBER
,P_COMMENTS in VARCHAR2
,P_DATE_FROM in DATE
,P_DATE_TO in DATE
,P_REQUEST_ID in NUMBER
,P_PROGRAM_APPLICATION_ID in NUMBER
,P_PROGRAM_ID in NUMBER
,P_PROGRAM_UPDATE_DATE in DATE
,P_ATTRIBUTE_CATEGORY in VARCHAR2
,P_ATTRIBUTE1 in VARCHAR2
,P_ATTRIBUTE2 in VARCHAR2
,P_ATTRIBUTE3 in VARCHAR2
,P_ATTRIBUTE4 in VARCHAR2
,P_ATTRIBUTE5 in VARCHAR2
,P_ATTRIBUTE6 in VARCHAR2
,P_ATTRIBUTE7 in VARCHAR2
,P_ATTRIBUTE8 in VARCHAR2
,P_ATTRIBUTE9 in VARCHAR2
,P_ATTRIBUTE10 in VARCHAR2
,P_ATTRIBUTE11 in VARCHAR2
,P_ATTRIBUTE12 in VARCHAR2
,P_ATTRIBUTE13 in VARCHAR2
,P_ATTRIBUTE14 in VARCHAR2
,P_ATTRIBUTE15 in VARCHAR2
,P_ATTRIBUTE16 in VARCHAR2
,P_ATTRIBUTE17 in VARCHAR2
,P_ATTRIBUTE18 in VARCHAR2
,P_ATTRIBUTE19 in VARCHAR2
,P_ATTRIBUTE20 in VARCHAR2
,P_SEGMENT1 in VARCHAR2
,P_SEGMENT2 in VARCHAR2
,P_SEGMENT3 in VARCHAR2
,P_SEGMENT4 in VARCHAR2
,P_SEGMENT5 in VARCHAR2
,P_SEGMENT6 in VARCHAR2
,P_SEGMENT7 in VARCHAR2
,P_SEGMENT8 in VARCHAR2
,P_SEGMENT9 in VARCHAR2
,P_SEGMENT10 in VARCHAR2
,P_SEGMENT11 in VARCHAR2
,P_SEGMENT12 in VARCHAR2
,P_SEGMENT13 in VARCHAR2
,P_SEGMENT14 in VARCHAR2
,P_SEGMENT15 in VARCHAR2
,P_SEGMENT16 in VARCHAR2
,P_SEGMENT17 in VARCHAR2
,P_SEGMENT18 in VARCHAR2
,P_SEGMENT19 in VARCHAR2
,P_SEGMENT20 in VARCHAR2
,P_SEGMENT21 in VARCHAR2
,P_SEGMENT22 in VARCHAR2
,P_SEGMENT23 in VARCHAR2
,P_SEGMENT24 in VARCHAR2
,P_SEGMENT25 in VARCHAR2
,P_SEGMENT26 in VARCHAR2
,P_SEGMENT27 in VARCHAR2
,P_SEGMENT28 in VARCHAR2
,P_SEGMENT29 in VARCHAR2
,P_SEGMENT30 in VARCHAR2
,P_CONCAT_SEGMENTS in VARCHAR2
,P_ANALYSIS_CRITERIA_ID in NUMBER);

END;

/

CREATE OR REPLACE PACKAGE BODY XXFUJ_UPDATE_SIT_A_UHPKG IS

--USER HOOK PACKAGE FOR HR_SIT_BK1.CREATE_SIT_A

PROCEDURE XXFUJ_UPDATE_SIT_LEV_VAL

--THIS WILL VALIDATE THE SIT WITH REFERENCE TO THE LEAVE EXISTS.

/*

Example: If a emp is on Annual leave from 01-jan-2017 to 30-jan-2017

now we are entering in SIT (Training) 10-jan-2017 to 15-jan-2017

As training days falls between the annual leave days, then the user entering the SIT will be notified by warning message.

*/

(P_PERSON_ANALYSIS_ID in NUMBER
,P_PEA_OBJECT_VERSION_NUMBER in NUMBER
,P_COMMENTS in VARCHAR2
,P_DATE_FROM in DATE
,P_DATE_TO in DATE
,P_REQUEST_ID in NUMBER
,P_PROGRAM_APPLICATION_ID in NUMBER
,P_PROGRAM_ID in NUMBER
,P_PROGRAM_UPDATE_DATE in DATE
,P_ATTRIBUTE_CATEGORY in VARCHAR2
,P_ATTRIBUTE1 in VARCHAR2
,P_ATTRIBUTE2 in VARCHAR2
,P_ATTRIBUTE3 in VARCHAR2
,P_ATTRIBUTE4 in VARCHAR2
,P_ATTRIBUTE5 in VARCHAR2
,P_ATTRIBUTE6 in VARCHAR2
,P_ATTRIBUTE7 in VARCHAR2
,P_ATTRIBUTE8 in VARCHAR2
,P_ATTRIBUTE9 in VARCHAR2
,P_ATTRIBUTE10 in VARCHAR2
,P_ATTRIBUTE11 in VARCHAR2
,P_ATTRIBUTE12 in VARCHAR2
,P_ATTRIBUTE13 in VARCHAR2
,P_ATTRIBUTE14 in VARCHAR2
,P_ATTRIBUTE15 in VARCHAR2
,P_ATTRIBUTE16 in VARCHAR2
,P_ATTRIBUTE17 in VARCHAR2
,P_ATTRIBUTE18 in VARCHAR2
,P_ATTRIBUTE19 in VARCHAR2
,P_ATTRIBUTE20 in VARCHAR2
,P_SEGMENT1 in VARCHAR2
,P_SEGMENT2 in VARCHAR2
,P_SEGMENT3 in VARCHAR2
,P_SEGMENT4 in VARCHAR2
,P_SEGMENT5 in VARCHAR2
,P_SEGMENT6 in VARCHAR2
,P_SEGMENT7 in VARCHAR2
,P_SEGMENT8 in VARCHAR2
,P_SEGMENT9 in VARCHAR2
,P_SEGMENT10 in VARCHAR2
,P_SEGMENT11 in VARCHAR2
,P_SEGMENT12 in VARCHAR2
,P_SEGMENT13 in VARCHAR2
,P_SEGMENT14 in VARCHAR2
,P_SEGMENT15 in VARCHAR2
,P_SEGMENT16 in VARCHAR2
,P_SEGMENT17 in VARCHAR2
,P_SEGMENT18 in VARCHAR2
,P_SEGMENT19 in VARCHAR2
,P_SEGMENT20 in VARCHAR2
,P_SEGMENT21 in VARCHAR2
,P_SEGMENT22 in VARCHAR2
,P_SEGMENT23 in VARCHAR2
,P_SEGMENT24 in VARCHAR2
,P_SEGMENT25 in VARCHAR2
,P_SEGMENT26 in VARCHAR2
,P_SEGMENT27 in VARCHAR2
,P_SEGMENT28 in VARCHAR2
,P_SEGMENT29 in VARCHAR2
,P_SEGMENT30 in VARCHAR2
,P_CONCAT_SEGMENTS in VARCHAR2
,P_ANALYSIS_CRITERIA_ID in NUMBER)

IS

L_ANL VARCHAR2(1);
L_ERROR VARCHAR2(200);
L_ID_FLEX_NUM VARCHAR2(200);
L_SEGMENT1 VARCHAR2(200);
L_SEGMENT2 VARCHAR2(200);
L_SEGMENT3 VARCHAR2(200);
LCAL_ST_DT DATE;
LCAL_END_DT DATE;
L_ST_DT DATE;
L_END_DT DATE;
L_JOIN_DT DATE;
L_DAYS NUMBER;
L_PERSON_ID NUMBER;

L_EFF_DATE DATE;
L_ASSIGNMENT_ID NUMBER;
LN_ELEMENT_LINK_ID NUMBER;
LD_EFFECTIVE_START_DATE DATE;
LD_EFFECTIVE_END_DATE DATE;
LN_ELEMENT_ENTRY_ID NUMBER;
LN_OBJECT_VERSION_NUMBER NUMBER;
LB_CREATE_WARNING BOOLEAN;

BEGIN

BEGIN

SELECT PAC.ID_FLEX_NUM, SEGMENT1, SEGMENT2, SEGMENT3, PERSON_ID
INTO L_ID_FLEX_NUM, L_SEGMENT1, L_SEGMENT2, L_SEGMENT3, L_PERSON_ID
FROM PER_ANALYSIS_CRITERIA PAC,
per_person_analyses ppa
WHERE PAC.ANALYSIS_CRITERIA_ID = P_ANALYSIS_CRITERIA_ID
--where pac.id_flex_num = 50318
--and pac.ANALYSIS_CRITERIA_ID = 5167442
and pac.ANALYSIS_CRITERIA_ID = ppa.ANALYSIS_CRITERIA_ID
;

IF L_ID_FLEX_NUM = 50318 THEN

select start_date, end_date
into lcal_st_dt, lcal_end_dt
from per_calendar_entries;

L_ST_DT := fnd_conc_date.string_to_date(L_SEGMENT1);
L_END_DT := fnd_conc_date.string_to_date(L_SEGMENT2);
L_JOIN_DT := fnd_conc_date.string_to_date(L_SEGMENT3);

        if l_st_dt between lcal_st_dt and lcal_end_dt then
        l_days := least(lcal_end_dt,l_end_dt) - l_st_dt + 1 ;
        elsif
        l_end_dt between lcal_st_dt and lcal_end_dt then
        l_days := lcal_end_dt - l_end_dt + 1 ;
        elsif lcal_end_dt between l_st_dt and l_end_dt then
        l_days := lcal_end_dt - lcal_st_dt + 1;
        end if;
       
        L_EFF_DATE := TRUNC(L_JOIN_DT,'MM');
        L_ASSIGNMENT_ID  := XXPY_UPDATE_EMP_ASSIGNMENT.GET_EMP_ASSIGNMENT_ID(L_PERSON_ID,fnd_conc_date.string_to_date(sysdate));
       
        IF L_DAYS >'0'
        AND XX_FUJ_ENTRIES_ALLOWANCES.F_ELEMENT_EXISTS_YN(L_ASSIGNMENT_ID,'Fuj_Annual_Leave_Public_holiday','Days',L_EFF_DATE) = 'N'
        THEN
        --INSERT INTO TESTA        VALUES (L_DAYS,'TEST'||TO_CHAR(SYSDATE,'HH:MI'));
       
          BEGIN
      
       
                  LN_ELEMENT_LINK_ID :=
                     HR_ENTRY_API.get_link (
                        P_ASSIGNMENT_ID     => L_ASSIGNMENT_ID,
                        P_ELEMENT_TYPE_ID   => 2012,
                        P_SESSION_DATE      => SYSDATE);

                
                  PAY_ELEMENT_ENTRY_API.CREATE_ELEMENT_ENTRY(               -- Input data elements
                     -- -----------------------------
                     P_EFFECTIVE_DATE          => L_EFF_DATE,--to_date('01-MAY-2018'),
                     P_BUSINESS_GROUP_ID       => FND_PROFILE.VALUE ('PER_BUSINESS_GROUP_ID'),
                     P_ASSIGNMENT_ID           => L_ASSIGNMENT_ID,
                     P_ELEMENT_LINK_ID         => LN_ELEMENT_LINK_ID,
                     P_ENTRY_TYPE              => 'E',
                     P_INPUT_VALUE_ID1         => XXPY_CONSALIDATIONS.GET_INPUT_VALUE_ID(
                                                    'Fuj_Annual_Leave_Public_holiday',
                                                    'Days'),
                     P_ENTRY_VALUE1            => L_DAYS,
                     P_INPUT_VALUE_ID2         => XXPY_CONSALIDATIONS.GET_INPUT_VALUE_ID(
                                                    'Fuj_Annual_Leave_Public_holiday',
                                                    'Date'),
                     P_ENTRY_VALUE2            => L_EFF_DATE,
                     -- Output data elements
                     -- --------------------------------
                     P_EFFECTIVE_START_DATE    => LD_EFFECTIVE_START_DATE,
                     P_EFFECTIVE_END_DATE      => LD_EFFECTIVE_END_DATE,
                     P_ELEMENT_ENTRY_ID        => LN_ELEMENT_ENTRY_ID,
                     P_OBJECT_VERSION_NUMBER   => LN_OBJECT_VERSION_NUMBER,
                     P_CREATE_WARNING          => LB_CREATE_WARNING);
       END;
       
        --ELSE INSERT INTO TESTA   VALUES (L_DAYS,'EXISTS ALREADY'||TO_CHAR(SYSDATE,'HH:MI'));
       END IF;

END IF;

EXCEPTION WHEN OTHERS THEN
L_ERROR := SQLERRM;
INSERT INTO TESTA
SELECT 101,L_ERROR  FROM DUAL;
--DBMS_OUTPUT.PUT_LINE(SQLERRM);

END;

EXCEPTION WHEN OTHERS THEN NULL;

DBMS_OUTPUT.PUT_LINE(SQLERRM);

END;

END;


SELECT ahk.api_hook_id,
ahk.api_module_id,
ahk.hook_package,
ahk.hook_procedure
FROM hr_api_hooks ahk, hr_api_modules ahm
WHERE ahm.module_name like '%UPDATE_SIT%'
AND ahm.api_module_type = 'BP'
AND ahk.api_hook_type = 'AP'
AND ahk.api_module_id = ahm.api_module_id

API_HOOK_ID = 2884-- 2879
API_MODULE_ID = 1281--1279

HR_SIT_BK2.UPDATE_SIT_A

2.

DECLARE
L_API_HOOK_ID NUMBER:= 2884;
L_API_HOOK_CALL_ID NUMBER;
L_OBJECT_VERSION_NUMBER NUMBER;
L_SEQUENCE NUMBER;
BEGIN
SELECT HR_API_HOOKS_S.NEXTVAL
INTO L_SEQUENCE
FROM DUAL;
R_API_HOOK_CALL_API.CREATE_API_HOOK_CALL
(P_VALIDATE => FALSE,
P_EFFECTIVE_DATE => TO_DATE('01-JAN-1952','DD-MON-YYYY'),
P_API_HOOK_ID =>L_API_HOOK_ID ,
P_API_HOOK_CALL_TYPE => 'PP',
P_SEQUENCE => L_SEQUENCE,
P_ENABLED_FLAG => 'Y',
P_CALL_PACKAGE => 'XXFUJ_UPDATE_SIT_A_UHPKG',
P_CALL_PROCEDURE => 'XXFUJ_UPDATE_SIT_LEV_VAL',
P_API_HOOK_CALL_ID => L_API_HOOK_CALL_ID,
P_OBJECT_VERSION_NUMBER => L_OBJECT_VERSION_NUMBER);
DBMS_OUTPUT.PUT_LINE('L_API_HOOK_CALL_ID '|| L_API_HOOK_CALL_ID);
END ;

COMMIT

SELECT API_HOOK_CALL_ID,API_HOOK_ID,
OBJECT_VERSION_NUMBER,
CALL_PACKAGE,
CALL_PROCEDURE,
ENABLED_FLAG,
STATUS, CREATION_DATE
--SELECT *
FROM HR_API_HOOK_CALLS
--WHERE api_hook_id = 2878
--WHERE API_HOOK_CALL_ID = 1263
WHERE CALL_PACKAGE LIKE '%FUJ%'

commit

3.

declare
l_api_module_id number := 1281; --Value 1731 is derived from Step 1 above using following query
begin
hr_api_user_hooks_utility.create_hooks_one_module (l_api_module_id);
dbms_output.put_line('Success');
exception when others then
dbms_output.put_line('Exception : '||SQLERRM);
end;

COMMIT


Oracle AR Receipt API apps r12

  
PROCEDURE POS_CREATE_RECEIPT
(
P_POS_ID VARCHAR2,
p_org_id number,
p_receipt_amount            NUMBER,
p_receipt_method_id number,
p_receipt_number varchar2,
p_activity number default 7256,
p_status out varchar2
,p_receipt_id out number
) AS
    --parameters
    l_receipt_amount            NUMBER := p_receipt_amount;--600;
    v_receipt_method_id number := p_receipt_method_id;--28083;
    v_receipt_number varchar2(200) := p_receipt_number;--'12313';
        l_org_id                    NUMBER := p_org_id;--1770;--FND_PROFILE.VALUE('ORG_ID') ;
    --local Variables
    g_loc                       NUMBER :=0;
    g_msg                       VARCHAR2(500);
    l_error_description         VARCHAR2 (2000) := NULL;
    g_sysdate                   DATE  := SYSDATE;
    l_ar_receipt_succ_count     NUMBER:= 0;
    l_ar_receipt_err_count      NUMBER:= 0;
    l_ar_receipt_tot_count      NUMBER:= 0;
    l_msg_index_num             NUMBER:= 1;
    l_msg_count                 NUMBER;
    l_data_txt                  VARCHAR2(1000);
    l_msg_data                  VARCHAR2(1000);
    l_apl_return_status         VARCHAR2 (1);
    l_apl_msg_count             NUMBER;
    l_apl_msg_data              VARCHAR2 (240);
    l_gl_date_count             NUMBER;
    l_functional_currency fnd_currencies.currency_code%TYPE;
    l_conv_type gl_daily_conversion_types.conversion_type%TYPE;
    l_conv_rate gl_daily_rates.conversion_rate%TYPE;
    l_cust_account_id hz_cust_accounts.cust_account_id%TYPE;
    l_receipt_id ar_cash_receipts_all.cash_receipt_id%TYPE;
    l_return_status             VARCHAR2(10);
    l_currency_code             fnd_currencies.currency_code%TYPE;
    l_cust_bank_acct_id         NUMBER;
    l_receipt_number            NUMBER ;
    l_rcpt_method_name          VARCHAR2(20);
    l_customer_trx_id           NUMBER ;
     p_attribute_rec                  AR_RECEIPT_API_PUB.attribute_rec_type;
    
BEGIN
 

    l_msg_count           := 0;
    l_data_txt            := NULL;
    l_msg_index_num       := NULL;
    l_gl_date_count       := 0;
    l_currency_code       := 'AED';
    l_functional_currency := NULL;
    l_conv_type           := NULL;
    l_conv_rate           := NULL;
    l_receipt_id          := NULL;
    l_return_status       := NULL;
    l_msg_data            := NULL;
    l_receipt_number      := NULL;
    p_attribute_rec.ATTRIBUTE5 := '1';   
   
    --FND_GLOBAL.APPS_INITIALIZE(2605, 52306, 222);
     FND_GLOBAL.APPS_INITIALIZE(FND_PROFILE.VALUE('USER_ID'),
     FND_PROFILE.VALUE('RESP_ID'),
     FND_PROFILE.VALUE('RESP_APPL_ID'));
     MO_GLOBAL.SET_POLICY_CONTEXT('S',l_org_id); --FND_PROFILE.VALUE('ORG_ID')
   
    dbms_output.put_line('before calling api ');

    -- Call Api to create receipt
    AR_RECEIPT_API_PUB.CREATE_MISC( p_api_version       => 1.0,
                                    p_init_msg_list     => fnd_api.g_true,
                                    p_commit            => fnd_api.g_false,
                                    p_validation_level  => FND_API.G_VALID_LEVEL_FULL,
                                    p_currency_code     => l_currency_code,
                                    p_amount            => l_receipt_amount,     -- receipt amount
                                    p_receipt_number    => v_receipt_number ,--'1234567',
                                    p_receivables_trx_id => p_activity, --Activity
                                    p_receipt_date      => SYSDATE,
                                    --p_maturity_date     => SYSDATE + 30,
                                    p_gl_date           => SYSDATE,
                                    p_receipt_method_id => v_receipt_method_id,
                                    p_org_id              => l_org_id,
                                    p_attribute_record       => p_attribute_rec,
                                    p_misc_receipt_id     => l_receipt_id,
                                    x_return_status       => l_return_status,
                                    x_msg_count           => l_msg_count,
                                    x_msg_data            => l_msg_data
                                    );
   
    dbms_output.put_line('called api ');
    p_receipt_id := l_receipt_id;
    p_status := l_return_status;
    IF (l_return_status = 'S') THEN
        dbms_output.put_line('Calling Api AR_RECEIPT_API_PUB.CREATE_CASH success -- >' ||l_return_status ||' Receipt Id > '||l_receipt_id);
        UPDATE XXFUJ_POS_H
        SET RECEIPT_ID = l_receipt_id
        WHERE POS_ID = P_POS_ID;
        COMMIT;
    ELSE
        dbms_output.put_line('Error in Calling Receipt API:');
       
        FOR i IN 1 .. l_msg_count
        LOOP
            FND_MSG_PUB.GET(p_msg_index => i, p_encoded => 'F', p_data => l_data_txt, p_msg_index_out => l_msg_index_num );        
            l_error_description := SUBSTR(l_error_description||l_data_txt,1,400);
            DBMS_OUTPUT.put_line( l_error_description);
        END LOOP;
       
       
    END IF;

COMMIT;
EXCEPTION
    WHEN OTHERS THEN NULL;
        dbms_output.put_line('Error in procedure '||SQLERRM);
END ;  

Inventory Move Order API oracle apps R12

 PROCEDURE pos_create_move_order
(
P_POS_ID VARCHAR2,
P_organization_id NUMBER,
P_REQUEST_NUMBER VARCHAR2, --generate seq
P_transaction_type_id NUMBER DEFAULT 63,--move order issue
P_move_order_type NUMBER DEFAULT 1 --Requisition
,x_return_status out varchar2
,x_header_id out number
)
   IS
      l_hdr_rec         inv_move_order_pub.trohdr_rec_type              := inv_move_order_pub.g_miss_trohdr_rec;
      l_line_tbl        inv_move_order_pub.trolin_tbl_type              := inv_move_order_pub.g_miss_trolin_tbl;
      --x_return_status   VARCHAR2 (1);
      x_msg_count       NUMBER;
      x_msg_data        VARCHAR2 (4000);
      x_hdr_rec         inv_move_order_pub.trohdr_rec_type              := inv_move_order_pub.g_miss_trohdr_rec;
      x_hdr_val_rec     inv_move_order_pub.trohdr_val_rec_type;
      x_line_tbl        inv_move_order_pub.trolin_tbl_type;
      x_line_val_tbl    inv_move_order_pub.trolin_val_tbl_type;
      v_msg_index_out   NUMBER;
      l_rsr_type        inv_reservation_global.mtl_reservation_tbl_type;
      v_line number := 1;
      v_line_count number :=0;
     
     CURSOR C1 IS
      SELECT inventory_item_id,COST_OF_SALES_ACCOUNT,xxfuj.quantity quantity, xxfuj.uom uom
      from mtl_system_items_b mtl,
      xxfuj_pos_d xxfuj
      where xxfuj.item_id =inventory_item_id
      and organization_id = P_organization_id
      and xxfuj.pos_id =  P_POS_ID
      --and rownum =1
      ;
     
   BEGIN

      l_line_tbl.DELETE;
      x_line_tbl.DELETE;
      l_hdr_rec.date_required := SYSDATE;
      l_hdr_rec.REQUEST_NUMBER := P_REQUEST_NUMBER;--'1232';
      l_hdr_rec.header_status := inv_globals.g_to_status_preapproved;
      l_hdr_rec.organization_id := P_organization_id;--1770 ; ---- fill in the values for ORganization_ID
      l_hdr_rec.status_date := SYSDATE;
      l_hdr_rec.transaction_type_id := P_transaction_type_id;--63;--inv_globals.g_type_transfer_order_issue;
      l_hdr_rec.move_order_type := P_move_order_type;--1;--inv_globals.g_move_order_requisition;
      l_hdr_rec.db_flag := fnd_api.g_true;
      l_hdr_rec.operation := inv_globals.g_opr_create;
     
         for i in c1 loop
   v_line_count := v_line_count + v_line;
   dbms_output.put_line(v_line_count);
      l_line_tbl (v_line_count).date_required := SYSDATE;
      l_line_tbl (v_line_count).inventory_item_id := I.inventory_item_id;--95081;
      l_line_tbl (v_line_count).line_id := fnd_api.g_miss_num;
      l_line_tbl (v_line_count).line_number := v_line_count; --line number
      l_line_tbl (v_line_count).line_status := inv_globals.g_to_status_preapproved;
      l_line_tbl (v_line_count).transaction_type_id := inv_globals.g_type_transfer_order_issue;
      l_line_tbl (v_line_count).organization_id := P_organization_id ;
      l_line_tbl (v_line_count).quantity := i.quantity;  --quantity
      l_line_tbl (v_line_count).status_date := SYSDATE;
      l_line_tbl (v_line_count).uom_code := upper(I.UOM);  -- UOM code
      l_line_tbl (v_line_count).db_flag := fnd_api.g_true;
      l_line_tbl (v_line_count).operation := inv_globals.g_opr_create;
      l_line_tbl (v_line_count).to_account_id := i.COST_OF_SALES_ACCOUNT;--3348167; --ask moamen
           end loop; 
      inv_move_order_pub.process_move_order (p_api_version_number      => 1.0
                                           , p_init_msg_list           => fnd_api.g_false
                                           , p_return_values           => fnd_api.g_false
                                           , p_commit                  => fnd_api.g_false
                                           , x_return_status           => x_return_status
                                           , x_msg_count               => x_msg_count
                                           , x_msg_data                => x_msg_data
                                           , p_trohdr_rec              => l_hdr_rec
                                           , p_trolin_tbl              => l_line_tbl
                                           , x_trohdr_rec              => x_hdr_rec
                                           , x_trohdr_val_rec          => x_hdr_val_rec
                                           , x_trolin_tbl              => x_line_tbl
                                           , x_trolin_val_tbl          => x_line_val_tbl
                                            );
                                         
      DBMS_OUTPUT.put_line ('Return Status is :' || x_return_status);
      DBMS_OUTPUT.put_line ('Message Count is :' || x_msg_count);
      DBMS_OUTPUT.put_line ('Move Order Number is :' || x_hdr_rec.request_number);
      DBMS_OUTPUT.put_line ('Move Order Number is :' || x_hdr_rec.header_id);
      DBMS_OUTPUT.put_line ('Number of Lines Created are :' || x_line_tbl.COUNT);
     
      x_header_id := x_hdr_rec.header_id;
     
      IF x_return_status = 'S'
      THEN
              UPDATE XXFUJ_POS_H
        SET MOVE_ORDER_ISSUE_ID = x_hdr_rec.header_id
        WHERE POS_ID = P_POS_ID;
        COMMIT;
         COMMIT;
      ELSE
         ROLLBACK;
      END IF;

      IF x_msg_count > 0
      THEN
         FOR v_index IN 1 .. x_msg_count
         LOOP
            fnd_msg_pub.get (p_msg_index => v_index, p_encoded => 'F', p_data => x_msg_data, p_msg_index_out => v_msg_index_out);
            x_msg_data := SUBSTR (x_msg_data, 1, 200);
            DBMS_OUTPUT.put_line (x_msg_data);
            DBMS_OUTPUT.put_line ('============================================================');
         END LOOP;
      END IF;
   END;