Thursday, 17 March 2016

SQL LOADER USING THAT POPULATES THE REQUEST_ID

In SQL LOADER program the following things should be ready.
1. prepare a control file .
2. prepare .csv file .
3. move the files in to the custom directory of the bin folder.
4. register the concurrent program from the EBS 

control file

OPTIONS (SKIP = 1)
LOAD DATA
infile '$FILE'
badfile '$FILE'
truncate into table TEMP_INTERFACE_STG
FIELDS TERMINATED BY "," OPTIONALLY ENCLOSED BY '"' TRAILING NULLCOLS
(
STATUS_FLAG                   constant "N",
RECORD_NUM   "RG_FA_TAX_SEQ.NEXTVAL",
ASSET_NUMBER                 "NVL(:ASSET_NUMBER,Null)",  
BOOK_TYPE_CODE                     "NVL(:BOOK_TYPE_CODE,Null)",  
ADJUSTED_RATE                      "NVL(:ADJUSTED_RATE,Null)",
CREATED_BY                  FLOAT   EXTERNAL   "FND_GLOBAL.USER_ID",
CREATION_DATE        SYSDATE,
LAST_UPDATED_BY      FLOAT   EXTERNAL   "FND_GLOBAL.USER_ID",
LAST_UPDATE_DATE      SYSDATE ,
LAST_UPDATE_LOGIN    FLOAT   EXTERNAL   "FND_GLOBAL.LOGIN_ID",
)


validate the program based on the conditions and move the records from staging table to the interface table .
in this case the staging table is TEMP_INTERFACE_STG

develop a package and perform the validations and call the above registered SQL LOADER program in that package.


SQLloader doesn't populate the request id, File name or other input parameters directly through
control file.

so execute an update statement in the package and register that package in the EBS.

Call SQL*Loader program that load the data from csv file 


l_req_id := fnd_request.submit_request(application   => 'xxx',
  program       => 'xx_progam',
  description   => '',
  start_time    => SYSDATE,
  sub_request   => FALSE,
  argument1  => 'apps/apps_st/test/custom/bin/file.csv');

FND_FILE.PUT_LINE(FND_FILE.LOG,'Request Id for the sql loader'||l_req_id);

IF l_req_id != 0 
    THEN

        COMMIT;

        l_call_status :=  fnd_concurrent.wait_for_request 
                                ( l_req_id,
                                  3,        -- interval
                                  0,        -- max_wait
                                  l_phase,
                                  l_status,
                                  l_dev_phase,
                                  l_dev_status,
                                  l_message
                                 );

    END IF;

    --Check Program completion status
    IF  (l_dev_phase = 'COMPLETE' AND l_dev_status = 'NORMAL') 
THEN
        fnd_file.put_line( fnd_file.log,'Program Completed Successfully');
UPDATE TEMP_INTERFACE_STG 
           SET request_id= l_req_id
where creation_date=sysdate;

        COMMIT;
ELSE
        fnd_file.put_line( fnd_file.log, 'Program did not Completed Successfully: '||l_dev_status);        

    END IF;

Tuesday, 8 March 2016

link between AP, PO,INV to get the invoice price,po price,item price through QUERY

SELECT CITV.ITEM_NUMBER AS ITEM_NUMBER,
 aila.INVENTORY_ITEM_ID ,
  ROUND(CITV.ITEM_COST,5) AS INV_ITEM_UNIT_COST,
  PHA.SEGMENT1 PO_NUMBER,
  PLA.UNIT_PRICE AS PURCHASE_UNIT_PRICE,
  AIA.INVOICE_DATE,
  AIA.INVOICE_NUM,
  AILA.QUANTITY_INVOICED AS AP_INVOICED_QUANTITY,
  aida.unit_price ap_inv_unit_price,
  aida.amount ipv_amount
FROM PO.PO_HEADERS_ALL PHA,
  PO.PO_LINES_ALL PLA,
  PO.PO_LINE_LOCATIONS_ALL PLLA,
  PO.PO_DISTRIBUTIONS_ALL PDA,
  AP.AP_INVOICE_DISTRIBUTIONS_ALL AIDA,
  ap_invoice_lines_all AILA,
  AP.AP_INVOICES_ALL AIA,
  CST_ITEM_COST_TYPE_V CITV
WHERE PHA.PO_HEADER_ID              = PLA.PO_HEADER_ID
AND PLA.PO_LINE_ID                  =PLLA.PO_LINE_ID
AND PLLA.LINE_LOCATION_ID           =PDA.LINE_LOCATION_ID
AND PDA.PO_DISTRIBUTION_ID          =AIDA.PO_DISTRIBUTION_ID
AND AILA.LINE_NUMBER                =AIDA.DISTRIBUTION_LINE_NUMBER
AND AIDA.INVOICE_ID                 =AIA.INVOICE_ID
AND AIDA.inventory_transfer_status IS NOT NULL
AND AILA.INVOICE_ID                 = aida.INVOICE_ID
AND CITV.INVENTORY_ITEM_ID          =PLA.ITEM_ID
AND CITV.ORGANIZATION_ID            = PLLA.SHIP_TO_ORGANIZATION_ID
AND aida.LINE_TYPE_LOOKUP_CODE      = 'IPV'
  -- and aida.INVOICE_DISTRIBUTION_ID=566513
ORDER BY CITV.ITEM_NUMBER,
  AIA.INVOICE_DATE,
  PHA.SEGMENT1,
  PO_NUMBER,
  PLA.LINE_NUM,

  AILA.INVENTORY_ITEM_ID;

replace syntax to remove the extra spaces in the column for a table

update table_name set column_name=replace(replace(DEA, CHR(10),''), CHR(13),'');