Sunday, 14 July 2019

Sample code for RMA Receipt

procedure xxvem_rmaline_receive(p_order_number  IN  number,
                                p_item          IN  VARCHAR2,
                                p_serial_number IN  VARCHAR2,
                                p_return_status OUT varchar2
                                )
is                                                 
    l_req_id number;
    l_phase varchar2 (240);
    l_status varchar2 (240);
    l_dev_phase varchar2 (240);
    l_dev_status varchar2 (240);
    l_message varchar2 (4000);
    l_conc_status boolean;
    l_error_message varchar2(4000);
    l_error_exists boolean;
    l_org             VARCHAR2 (20)          := fnd_profile.VALUE ('ORG_ID');

    l_user_id                      NUMBER   ;
    l_resp_id                      NUMBER   ;
    l_resp_appl_id                 NUMBER   ;
    LN_EMPLOYEE_ID                 NUMBER   ;
    lv_waybill_num                 VARCHAR2(20);
 
CURSOR so_details is (select ooha.order_number
,      ooha.sold_from_org_id
,      ooha.org_id
,      ooha.payment_term_id
,      oola.ship_from_org_id
,      ooha.salesrep_id
,      oola.header_id
,      oola.line_id
,      olsn.from_serial_number
,      olsn.TO_SERIAL_NUMBER
,      oola.inventory_item_id
,      1 ordered_quantity --oola.ordered_quantity
,      hcsua.location customer_location
,      ott.NAME  order_type
,      msib.segment1 item
,      hcasa.cust_acct_site_id customer_site_id
,      hca.cust_account_id customer_id
 from oe_order_headers_all    ooha
 ,    oe_order_lines_all      oola
 ,    oe_lot_serial_numbers   olsn
 ,    oe_transaction_types_tl ott
 ,    mtl_system_items_b      msib
 ,    hz_cust_site_uses_all   hcsua
 ,    hz_cust_acct_sites_all  hcasa
 ,    hz_cust_accounts        hca
 where 1 = 1
 and ooha.header_id  = oola.header_id
 AND ooha.order_type_id = ott.transaction_type_id
 AND oola.flow_status_code NOT IN ('CLOSED','CANCELLED')
 AND ooha.flow_status_code NOT IN ('CLOSED','CANCELLED')
 AND oola.flow_status_code = 'AWAITING_RETURN'
 AND ott.NAME IN ('XXVEM Return Order', 'XXVEM Return Order')
 AND ott.LANGUAGE = USERENV ('LANG')   -- 'US'
 and oola.line_id              =   olsn.line_id(+)
 and ooha.org_id = fnd_profile.VALUE ('ORG_ID')
 and msib.organization_id = oola.ship_from_org_id
 and msib.inventory_item_id = oola.inventory_item_id
 AND ooha.ship_to_org_id = hcsua.site_use_id
 AND ooha.org_id = hcsua.org_id
 AND hcsua.site_use_code = 'SHIP_TO'
 AND hcsua.status = 'A'
 AND hcsua.cust_acct_site_id = hcasa.cust_acct_site_id
 AND hca.cust_account_id = hcasa.cust_account_id
 AND hca.status = 'A'
 AND olsn.FROM_SERIAL_NUMBER(+)  = p_serial_number
 AND ooha.order_number  =  p_order_number 
);
   
BEGIN
mo_global.set_policy_context ('S', l_org);
mo_global.init ('PO');

  l_user_id := fnd_global.user_id;
  l_resp_id := fnd_global.resp_id;
  l_resp_appl_id := fnd_global.resp_appl_id;

  fnd_global.apps_initialize  (user_id => l_user_id,
                               resp_id => l_resp_id,
                               resp_appl_id => l_resp_appl_id);
 

  BEGIN
     SELECT EMPLOYEE_ID
  INTO  LN_EMPLOYEE_ID
  FROM  FND_USER
  WHERE USER_ID = l_user_id;
 
  EXCEPTION
  WHEN OTHERS THEN
  DBMS_OUTPUT.PUT_LINE('ERROR WHILE GETTING EMPLOYEE ID OF THE USER : '||SQLERRM);
  END; 
 
  lv_waybill_num := NULL;

for so_rec in so_details
loop  
INSERT INTO RCV_HEADERS_INTERFACE(
                    HEADER_INTERFACE_ID     ,
                    GROUP_ID                ,
                    org_id                  ,
                    PROCESSING_STATUS_CODE  ,
                    RECEIPT_SOURCE_CODE     ,
                    TRANSACTION_TYPE        ,
                    LAST_UPDATE_DATE        ,
                    LAST_UPDATED_BY         ,
                    LAST_UPDATE_LOGIN       ,
                    CUSTOMER_ID             ,
                    EXPECTED_RECEIPT_DATE   ,
                    VALIDATION_FLAG         ,
                    WAYBILL_AIRBILL_NUM     ,
                    FREIGHT_CARRIER_CODE
                    )
                    SELECT
                    RCV_HEADERS_INTERFACE_S.NEXTVAL ,
                    RCV_INTERFACE_GROUPS_S.NEXTVAL  ,
                    l_org                           ,                  -- 550
                    'PENDING'                       ,
                    'CUSTOMER'                      ,
                    'NEW'                           ,
                    SYSDATE                         ,
                    l_user_id                       ,                  --USER_ID
                    0                               ,
                    so_rec.customer_id              ,                  --CUSTOMER_ID
                    SYSDATE                         ,
                    'Y'                             ,
                    lv_waybill_num                  ,
                    'TRANSFER'
                    FROM DUAL;
                   
  INSERT INTO RCV_TRANSACTIONS_INTERFACE
           (INTERFACE_TRANSACTION_ID,
           GROUP_ID,
           org_id,
           HEADER_INTERFACE_ID,
           LAST_UPDATE_DATE,
           LAST_UPDATED_BY,
           CREATION_DATE,
           CREATED_BY,
           TRANSACTION_TYPE,
           TRANSACTION_DATE,
           PROCESSING_STATUS_CODE,
           PROCESSING_MODE_CODE,
           TRANSACTION_STATUS_CODE,
           QUANTITY,
           UNIT_OF_MEASURE,
           INTERFACE_SOURCE_CODE,
           ITEM_ID,
           EMPLOYEE_ID,
           AUTO_TRANSACT_CODE,
           RECEIPT_SOURCE_CODE,
           TO_ORGANIZATION_ID,
           SOURCE_DOCUMENT_CODE,
           DESTINATION_TYPE_CODE,
           DELIVER_TO_LOCATION_ID,
           SUBINVENTORY,
       LOCATOR_ID,
           EXPECTED_RECEIPT_DATE,
           OE_ORDER_HEADER_ID,
           OE_ORDER_LINE_ID,
           CUSTOMER_ID,
           CUSTOMER_SITE_ID,
           VALIDATION_FLAG)
         Values
           (RCV_TRANSACTIONS_INTERFACE_S.NEXTVAL, --INTERFACE_TRANSACTION_ID
           RCV_INTERFACE_GROUPS_S.CURRVAL, --GROUP_ID
           l_org ,                         --550,
           RCV_HEADERS_INTERFACE_S.CURRVAL, --HEADER_INTERFACE_ID
           SYSDATE, --LAST_UPDATE_DATE
           l_user_id, --LAST_UPDATED_BY
           SYSDATE, --CREATION_DATE
           l_user_id, --CREATED_BY
           'RECEIVE', --TRANSACTION_TYPE
           SYSDATE, --TRANSACTION_DATE
           'PENDING', --PROCESSING_STATUS_CODE
           'BATCH',  --PROCESSING_MODE_CODE
           'PENDING', --TRANSACTION_MODE_CODE
           so_rec.ordered_quantity, --QUANTITY
           'Each', --UNIT_OF_MEASURE
           'RCV', --INTERFACE_SOURC E_CODE
           so_rec.inventory_item_id, --ITEM_ID
           LN_EMPLOYEE_ID, --EMPLOYEE_ID
           'DELIVER',--AUTO_TRANSACT_CODE
           'CUSTOMER', --RECEIPT_SOURCE_CODE
           so_rec.ship_from_org_id, --TO_ORGANIZATION_ID
           'RMA', --SOURCE_DOCUMENT_CODE
           'INVENTORY', --DESTINATION_TYPE_CODE
           so_rec.ship_from_org_id, --DELIVER_TO_LOCATION_ID
           'MAIN',    --SUBINVENTORY
           NULL, -- LOCATOT_ID -- PASS IF THE subinventory is locator controlled
           SYSDATE, --EXPECTED_RECEIPT_DATE
           so_rec.header_id, --OE_ORDER_HEADER_ID
           so_rec.LINE_ID, --OE_ORDER_LINE_ID
           so_rec.customer_id, --CUSTOMER_ID
           so_rec.customer_site_id,--CUSTOMER_SITE_ID
           'Y');
         
  IF so_rec.from_serial_number is not null and nvl(so_rec.to_serial_number,so_rec.from_serial_number) is not null THEN
         
  INSERT INTO mtl_serial_numbers_interface
                           (transaction_interface_id,
                            last_update_date,
                  last_updated_by,
                            creation_date,
                            created_by,
                            last_update_login,
              fm_serial_number,
                            to_serial_number,
              product_code,
                            product_transaction_id
                           )
                    VALUES (mtl_material_transactions_s.NEXTVAL,
                            sysdate,
                            l_user_id,                       
                            sysdate,       
                    l_user_id,
                            1,
                            so_rec.from_serial_number,
                            nvl(so_rec.to_serial_number,so_rec.from_serial_number),
                            'RCV',
                           rcv_transactions_interface_s.CURRVAL
                           );       
   END IF;
 
l_req_id := apps.fnd_request.submit_request ('PO',
                                             'RVCTP',
                                              null,
                                              sysdate,
                                              null,
                                             'BATCH',
                                             RCV_INTERFACE_GROUPS_S.CURRVAL
                                              );
dbms_output.put_line('the request number is :'|| l_req_id);
commit;
if(l_req_id > 0) then
l_conc_status := apps.fnd_concurrent.wait_for_request (request_id => l_req_id,
                                                       interval => 2,
                                                       max_wait => 1200,
                                                       phase => l_phase,
                                                       status => l_status,
                                                       dev_phase => l_dev_phase,
                                                       dev_status => l_dev_status,
                                                       message => l_message);
 l_error_exists := false;
 dbms_output.put_line(' the request status id : ' ||l_dev_status);
 p_return_status := l_dev_status;
  if l_dev_status = 'NORMAL'
  then
   commit;
   for r1 in (select error_message
              from po_interface_errors
              where request_id = l_req_id)
    loop
    fnd_file.put_line(fnd_file.log,'RMA Receiving errors : ' || r1.error_message);
    l_error_exists := true;
   end loop;
  elsif l_dev_status in ('ERROR', 'CANCELLED', 'TERMINATED') then
  rollback;
   for r1 in (select pie.error_message
              from po_interface_errors pie
              where pie.request_id = l_req_id)
   loop
    fnd_file.put_line(fnd_file.log,'RMA Receiving errors : ' || r1.error_message);
    l_error_exists := true;
   end loop;
 end if;
end if;   
end loop;     
END;

Saturday, 20 January 2018

How to check loaded data via FBDI from front end in Oracle Cloud


Step1: Go to Application and select Navigator









Step2: Select More... Option



Step3: Select Reports and Analytics under Tools

























Step4: Select Browse Catalog Icon








Step5: Select New option and select Data Model under Published Reporting.

























Step6: Select SQL Query under Diagram Tab.














Enter Name, Data Source, Type of SQL and write a query in Query area and click OK.

















Step7: Select Data Tab and select View. you can see data in Tree and Table View.



Wednesday, 16 August 2017

Query to find AP Bank details at Suppliers and Supplier Sites

Query:

SELECT 'Bank Account At Supplier Site Level' Bank_Account_Level
     , sup.segment1
     , sup.vendor_name
     , epa.org_id
     , ss.vendor_site_code
     , NULL   Party_Site_Code
     , eba.bank_account_num
     , piu.order_of_preference priority
     , eba.ext_bank_account_id
  FROM ap_suppliers sup
     , ap_supplier_sites_all       ss
     , iby_external_payees_all epa
     , iby_pmt_instr_uses_all  piu
     , iby_ext_bank_accounts   eba
 WHERE sup.vendor_id     = ss.vendor_id
   AND ss.vendor_site_id = epa.supplier_site_id
   AND epa.ext_payee_id  = piu.ext_pmt_party_id    
   AND piu.instrument_id = eba.ext_bank_account_id
   AND sup.segment1      = '10824'
UNION
SELECT 'Bank Account at Supplier Level'
     , sup.segment1
     , sup.vendor_name
     , epa.org_id
     , NULL
     , NULL
     , eba.bank_account_num
     , piu.order_of_preference priority
     , eba.ext_bank_account_id
  FROM ap_suppliers sup
     , iby_external_payees_all epa
     , iby_pmt_instr_uses_all  piu
     , iby_ext_bank_accounts   eba
 WHERE sup.party_id        = epa.payee_party_id
   AND epa.ext_payee_id    = piu.ext_pmt_party_id    
   AND piu.instrument_id   = eba.ext_bank_account_id
   AND sup.segment1        = '10824'
   AND supplier_site_id    IS NULL
   AND party_site_id       IS NULL
   ;

SCript to Migrate OAF Personalizations To Other Instances

Download OAF form personalization java oracle.jrad.tools.xml.exporter.XMLExporter \/oracle/apps/ar/hz/components/account/site/webui/cust...