Wednesday, 14 July 2021

FNDLOAD Script for Webadi

Integrator
FNDLOAD apps/apps 0 Y DOWNLOAD $BNE_TOP/patch/115/import/bneintegrator.lct XXXX_AP_INV_INT_XINTG.ldt BNE_INTEGRATORS INTEGRATOR_ASN=SQLAP INTEGRATOR_CODE=XXXX_AP_INV_INT_XINTG 

FNDLOAD apps/apps 0 Y UPLOAD $BNE_TOP/patch/115/import/bneintegrator.lct XXXX_AP_INV_INT_XINTG.ldt 

Layout
FNDLOAD apps/apps 0 Y DOWNLOAD $BNE_TOP/patch/115/import/bnelay.lct XXXX_AR_INV_INT_LAYOUT.ldt BNE_LAYOUTS LAYOUT_ASN=SQLAP LAYOUT_CODE=XXXXAPINVINTERFACEINTEGRATOR 

FNDLOAD apps/apps 0 Y UPLOAD $BNE_TOP/patch/115/import/bnelay.lct XXXX_AP_INV_INT_LAYOUT.ldt 

Mapping
FNDLOAD apps/apps 0 Y DOWNLOAD $BNE_TOP/admin/import/bnemap.lct XXXX_APINV_IFACE_MAP.ldt BNE_MAPPINGS MAPPING_ASN="SQLAP" MAPPING_CODE="XXXX_APINV_IFACE_MAP"

FNDLOAD apps/apps 0 Y UPLOAD $BNE_TOP/patch/115/import/bnemap.lct XXXX_APINV_IFACE_MAP.ldt 

Content
FNDLOAD apps/apps 0 Y DOWNLOAD $BNE_TOP/patch/115/import/bnecont.lct XXXX_AP_INV_INT_CNT2.ldt BNE_CONTENTS CONTENT_ASN=SQLAP CONTENT_CODE=XXXX_AP_INV_INT_CNT2 

FNDLOAD apps/apps 0 Y UPLOAD $BNE_TOP/patch/115/import/bnecont.lct XXXX_AP_INV_INT_CNT2.ldt 

Standard Concurrent program to import Service Contracts from Order Management?

Run “Service Contracts Order Processing” Program to import the service contract from order management. 

Service Contract tables?

OKC_K_HEADERS_ALL_B
OKS_K_HEADERS_ALL_B
OKC_K_LINES_B
OKC_K_ITEMS
OKC_K_REL_OBJS
OKS_BILL_TRANSACTIONS
OKS_BILL_TXN_LINES
OKS_BILL_CONT_LINES
OKS_BILL_SUB_LINES
OKS_BILL_CONT_LINES
OKS_LEVEL_ELEMENTS
CSI_ITEM_INSTANCES

Query to findout Workflow Listeners Status

          SELECT   DISTINCT fcq.concurrent_queue_id,
                           fcq.concurrent_queue_name,
                           fcq.user_concurrent_queue_name,
                           fsc.component_status
         FROM     apps.fnd_concurrent_queues_vl fcq,
                  fnd_svc_components fsc
         WHERE    fsc.concurrent_queue_id = fcq.concurrent_queue_id
         AND      fcq.concurrent_queue_name IN ('WFALSNRSVC',
                                                'WFMLRSVC',
                                                'WFWSSVC')
         ORDER BY fcq.concurrent_queue_id;

Script to Activate and Deactivate Oracle EBS Workflow Listeners

CREATE OR REPLACE PACKAGE apps.workflow_listener_pkg
AS
   PROCEDURE MAIN(p_errbuf    OUT VARCHAR2,
                  p_retcode   OUT VARCHAR2);
END workflow_listener_pkg;


CREATE OR REPLACE PACKAGE BODY apps.workflow_listener_pkg
AS
   PROCEDURE MAIN(p_errbuf    OUT VARCHAR2,
                  p_retcode   OUT VARCHAR2)
   IS
      ln_spid   NUMBER;
  ln_user_id             NUMBER := fnd_profile.VALUE('USER_ID');
      ln_responsibility_id   apps.fnd_responsibility.responsibility_id%TYPE := fnd_profile.VALUE('RESP_ID');
      ln_resp_appl_id        apps.fnd_responsibility.application_id%TYPE := fnd_profile.VALUE('RESP_APPL_ID');
  
      CURSOR cur_wfsrv
      IS
         SELECT   DISTINCT fcq.concurrent_queue_id,
                           fcq.concurrent_queue_name,
                           fcq.user_concurrent_queue_name
         FROM     apps.fnd_concurrent_queues_vl fcq,
                  fnd_svc_components fsc
         WHERE    fsc.concurrent_queue_id = fcq.concurrent_queue_id
         AND      fcq.concurrent_queue_name IN ('WFALSNRSVC',
                                                'WFMLRSVC')
         AND      fsc.component_status = 'STOPPED'
         AND      fsc.component_id NOT IN (10040,
                                           10042)
         ORDER BY fcq.concurrent_queue_id;
   BEGIN
      -- WFMLRSVC : Workflow Mailer Service
  -- WFALSNRSVC : Workflow Agent Listener Service
      -- WFWSSVC : Workflow Document Web Services Service
      fnd_file.put_line(fnd_file.LOG, 'Workflow Listeners Program start');
  
  fnd_file.put_line(fnd_file.LOG, 'ln_user_id:' || ln_user_id);
      fnd_file.put_line(fnd_file.LOG, 'ln_responsibility_id:' || ln_responsibility_id);
      fnd_file.put_line(fnd_file.LOG, 'ln_resp_appl_id:' || ln_resp_appl_id);
      fnd_global.apps_initialize(ln_user_id, ln_responsibility_id, ln_resp_appl_id);
  
      FOR rec_wfsrv IN cur_wfsrv
      LOOP
         fnd_file.put_line(fnd_file.LOG, 'loop start');
         fnd_file.put_line(fnd_file.LOG, 'user_concurrent_queue_name:' || rec_wfsrv.user_concurrent_queue_name);
         fnd_file.put_line(fnd_file.LOG, 'concurrent_queue_name:' || rec_wfsrv.concurrent_queue_name);
         ln_spid   := fnd_request.submit_svc_ctl_request(command => 'ACTIVATE', service => rec_wfsrv.concurrent_queue_name, service_app => 'FND');
         fnd_file.put_line(fnd_file.LOG, 'ln_spid:' || ln_spid);

         IF ln_spid = 0 THEN
            fnd_file.put_line(fnd_file.LOG, 'IF ln_spid = 0:' || fnd_message.get);
         END IF;

         fnd_file.put_line(fnd_file.LOG, 'loop end');
      END LOOP;
      fnd_file.put_line(fnd_file.LOG, 'Workflow Listeners Program end');
   EXCEPTION
      WHEN OTHERS THEN
         fnd_file.put_line(fnd_file.LOG, 'In Main Exception :' || SQLCODE || ' - ' || SQLERRM);
         p_retcode   := 2;
         p_errbuf    := SQLCODE || ' - ' || SQLERRM;
   END MAIN;
END workflow_listener_pkg;
/

Note:
For Activate
spid   := fnd_request.submit_svc_ctl_request(command => 'ACTIVATE', service => l_cqname, service_app => 'FND');

For Deactivate
spid   := fnd_request.submit_svc_ctl_request(command => 'DEACTIVATE', service => l_cqname, service_app => 'FND');

For Abort
spid   := fnd_request.submit_svc_ctl_request(command => 'ABORT', service => l_cqname, service_app => 'FND');

Tuesday, 1 June 2021

How to convert single column into row in PL SQL

CREATE TABLE sale_records
(
   sale_id       NUMBER PRIMARY KEY,
   fiscal_year    NUMBER,
   quantity1      NUMBER,
   quantity2      NUMBER,
   quantity3      NUMBER
); 

INSERT INTO sale_records(sale_id, fiscal_year, quantity1, quantity2, quantity3)
VALUES(1,2019, NULL, 100, 200);
 
INSERT INTO sale_records(sale_id, fiscal_year, quantity1, quantity2, quantity3)
VALUES(2,2020, 350, NULL, 450);
 
INSERT INTO sale_records(sale_id, fiscal_year, quantity1, quantity2, quantity3)
VALUES(3,2021,  580, 680, NULL);

SELECT * FROM sale_records

Query output:
---------------- 
SALE_ID        FISCAL_YEAR          QUANTITY1  QUANTITY2            QUANTITY3
1                      2019                                                      100                             200
2                      2020                             350                                                      450
3                      2021                             580                   680      

SELECT * FROM sale_records
UNPIVOT INCLUDE NULLS(
    quantity_value
    FOR quantity
    IN (
        quantity1 AS 'quantity1',
        quantity2 AS 'quantity2',
        quantity3 AS 'quantity3'
    )
);

Query output:
----------------
SALE_ID        FISCAL_YEAR         QUANTITY            QUANTITY_VALUE
1                      2019                            quantity1        
1                      2019                            quantity2                 100
1                      2019                            quantity3                 200
2                      2020                            quantity1                 350
2                      2020                            quantity2        
2                      2020                            quantity3                 450
3                      2021                            quantity1                 580
3                      2021                            quantity2                 680
3                      2021                            quantity3

Monday, 31 May 2021

How to convert multiple columns into row in PL SQL

 
CREATE TABLE sales_records
(
   sales_id       NUMBER PRIMARY KEY,
   fiscal_year    NUMBER,
   quantity1      NUMBER,
   quantity2      NUMBER,
   amount1        NUMBER,
   amount2        NUMBER
);

INSERT INTO sales_records(sales_id, fiscal_year, quantity1, quantity2, amount1, amount2)
VALUES(1, 2020, 100, 200, 1000, 2000);
 
INSERT INTO sales_records(sales_id, fiscal_year, quantity1, quantity2, amount1, amount2)
VALUES(2, 2021, 300, 400, 3000, 4000);

SELECT * FROM  sales_records


SALES_ID FISCAL_YEAR  QUANTITY1  QUANTITY2   AMOUNT1     AMOUNT2
1                 2020                     100                  200                    1000                2000
2                 2021                     300                  400                    3000                4000



SELECT sales_id, fiscal_year,rownumber,quantity, amount
FROM sales_records
UNPIVOT (
    (quantity, amount)
    FOR rownumber
    IN (
        (quantity1, amount1) AS '1',
        (quantity2, amount2) AS '2'       
    )
);

SALES_ID      FISCAL_YEAR         ROWNUMBER            QUANTITY    AMOUNT
1                      2020                            1                                      100                  1000
1                      2020                            2                                      200                  2000
2                      2021                            1                                      300                  3000
2                      2021                            2                                      400                  4000