CREATE OR REPLACE PROCEDURE OUTBOUND_INTERFACE(ERRBUF VARCHAR2, RETCODE VARCHAR2) IS
CURSOR C1 IS SELECT VENDOR_NAME,VENDOR_ID,VENDOR_TYPE_LOOKUP_CODE FROM PO_VENDORS;
V_OUTFILE UTL_FILE.FILE_TYPE;
V_OUTPATH VARCHAR2(100);
V_OUTFILENAME VARCHAR2(200);
V_HEADER VARCHAR2(400);
V_LINE VARCHAR2(4000);
BEGIN
FND_PROFILE.GET ('CMG_ABC_INCOMING_PATH', V_OUTPATH);
V_OUTFILENAME :='ENS_EXCEL_FEED' || '.csv';
V_OUTFILE := UTL_FILE.FOPEN (V_OUTPATH, V_OUTFILENAME, 'w');
V_HEADER :='VENDOR_NAME'||','||'VENDOR_ID'||','||'VENDOR_TYPE_LOOKUP_CODE';
UTL_FILE.PUT_LINE (V_OUTFILE, V_HEADER);
FOR UPC_REC IN C1 LOOP
V_LINE:=UPC_REC.VENDOR_NAME||','||UPC_REC.VENDOR_ID||','||UPC_REC.VENDOR_TYPE_LOOKUP_CODE;
UTL_FILE.PUT_LINE (V_OUTFILE, V_LINE);
END LOOP;
UTL_FILE.FCLOSE (V_OUTFILE);
EXCEPTION
WHEN UTL_FILE.INVALID_OPERATION THEN
FND_FILE.PUT_LINE(FND_FILE.LOG,'INVALID OPERATION');
WHEN UTL_FILE.INVALID_PATH THEN
FND_FILE.PUT_LINE(FND_FILE.LOG,'INVALID PATH');
WHEN UTL_FILE.INVALID_MODE THEN
FND_FILE.PUT_LINE(FND_FILE.LOG,'INVALID MODE');
WHEN UTL_FILE.INVALID_FILEHANDLE THEN
FND_FILE.PUT_LINE(FND_FILE.LOG,'INVALID FILE');
WHEN UTL_FILE.READ_ERROR THEN
FND_FILE.PUT_LINE(FND_FILE.LOG,'READ ERROR');
WHEN UTL_FILE.INTERNAL_ERROR THEN
FND_FILE.PUT_LINE(FND_FILE.LOG,'INTERNAL ERROR');
WHEN OTHERS THEN
FND_FILE.PUT_LINE(FND_FILE.LOG,'OTHER ERROR');
END;
/
/HDGSTG01/APPLR11I/COMMON/ABC/INCOMING
SELECT FND_PROFILE.VALUE('CMG_ABC_INCOMING_PATH') FROM DUAL
No comments:
Post a Comment