Hi Daniela,
Here is the code of the package :
CREATE OR REPLACE PACKAGE ALS_REPORT_PK AUTHID CURRENT_USER AS
-- ============================================================================+
-- $Id: ALS_REPORT_PK,v 1.0.0.0 2005/12/01 RGI Exp $
-- NOM PROGRAMME: ALS_REPORT_PK.sql
--
-- OBJET: All functions/procedures for reports ( printing for example )
--
--
-- HISTORY
--
-- 01-DEC-05- RGI - Creation
-- ============================================================================+
-- Stored procedure concurrent programs : could be used directly in PLSQL or directly in concurrent program
-- If you modify this procedure : take care of this :
-- Stored procedure concurrent programs accept input parameters only except error_message and return code
-- Use errbuf to return any error messages, and retcode
-- to return completion status. The parameter retcode returns 0 for
-- success, 1 for success with warnings, and 2 for error.
-- this proc is autonomous
PROCEDURE LAUNCH_REPORT(ERRBUF OUT VARCHAR2, -- any error message
RETCODE OUT NUMBER, -- return code
p_appli IN VARCHAR2, -- report application
p_prog IN VARCHAR2, -- program short_name
p_printer_1 IN VARCHAR2, -- first printer ---
p_copies_1 IN VARCHAR2, -- number of copies for printer 1 ---
p_printer_2 IN VARCHAR2 DEFAULT NULL, -- second printer ---
p_copies_2 IN VARCHAR2 DEFAULT NULL, -- number of copies for printer 2 ---
Parameter_used IN INTEGER, -- number of parameter used
Parameter1 IN VARCHAR2 DEFAULT NULL,
Parameter2 IN VARCHAR2 DEFAULT NULL,
Parameter3 IN VARCHAR2 DEFAULT NULL,
Parameter4 IN VARCHAR2 DEFAULT NULL,
Parameter5 IN VARCHAR2 DEFAULT NULL,
Parameter6 IN VARCHAR2 DEFAULT NULL,
Parameter7 IN VARCHAR2 DEFAULT NULL,
Parameter8 IN VARCHAR2 DEFAULT NULL,
Parameter9 IN VARCHAR2 DEFAULT NULL,
Parameter10 IN VARCHAR2 DEFAULT NULL,
Parameter11 IN VARCHAR2 DEFAULT NULL,
Parameter12 IN VARCHAR2 DEFAULT NULL,
Parameter13 IN VARCHAR2 DEFAULT NULL,
Parameter14 IN VARCHAR2 DEFAULT NULL,
Parameter15 IN VARCHAR2 DEFAULT NULL,
Parameter16 IN VARCHAR2 DEFAULT NULL,
Parameter17 IN VARCHAR2 DEFAULT NULL,
Parameter18 IN VARCHAR2 DEFAULT NULL,
Parameter19 IN VARCHAR2 DEFAULT NULL,
Parameter20 IN VARCHAR2 DEFAULT NULL
);
END ALS_REPORT_PK;
/
show errors
CREATE OR REPLACE PACKAGE BODY ALS_REPORT_PK AS
FUNCTION I_Submit_request (nom_appli IN VARCHAR2,
nom_prog IN VARCHAR2,
Parameter1 IN VARCHAR2 DEFAULT NULL,
Parameter2 IN VARCHAR2 DEFAULT NULL,
Parameter3 IN VARCHAR2 DEFAULT NULL,
Parameter4 IN VARCHAR2 DEFAULT NULL,
Parameter5 IN VARCHAR2 DEFAULT NULL,
Parameter6 IN VARCHAR2 DEFAULT NULL,
Parameter7 IN VARCHAR2 DEFAULT NULL,
Parameter8 IN VARCHAR2 DEFAULT NULL,
Parameter9 IN VARCHAR2 DEFAULT NULL,
Parameter10 IN VARCHAR2 DEFAULT NULL,
Parameter11 IN VARCHAR2 DEFAULT NULL,
Parameter12 IN VARCHAR2 DEFAULT NULL,
Parameter13 IN VARCHAR2 DEFAULT NULL,
Parameter14 IN VARCHAR2 DEFAULT NULL,
Parameter15 IN VARCHAR2 DEFAULT NULL,
Parameter16 IN VARCHAR2 DEFAULT NULL,
Parameter17 IN VARCHAR2 DEFAULT NULL,
Parameter18 IN VARCHAR2 DEFAULT NULL,
Parameter19 IN VARCHAR2 DEFAULT NULL,
Parameter20 IN VARCHAR2 DEFAULT NULL,
Parameter_used IN INTEGER) RETURN NUMBER IS
Conc_id NUMBER;
BEGIN
IF Parameter_used = 0 THEN
conc_id := FND_REQUEST.SUBMIT_REQUEST(nom_appli,nom_prog,NULL,NULL,FALSE,
CHR(0),
'',
'',
'',
'',
'',
'',
'',
'',
'',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','') ;
ELSIF Parameter_used = 1 THEN
conc_id := FND_REQUEST.SUBMIT_REQUEST(nom_appli,nom_prog,NULL,NULL,FALSE,
Parameter1,
CHR(0),
'',
'',
'',
'',
'',
'',
'',
'',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','') ;
ELSIF Parameter_used = 2 THEN
conc_id := FND_REQUEST.SUBMIT_REQUEST(nom_appli,nom_prog,NULL,NULL,FALSE,
Parameter1,
Parameter2,
CHR(0),
'',
'',
'',
'',
'',
'',
'',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','') ;
ELSIF Parameter_used = 3 THEN
conc_id := FND_REQUEST.SUBMIT_REQUEST(nom_appli,nom_prog,NULL,NULL,FALSE,
Parameter1,
Parameter2,
Parameter3,
CHR(0),
'',
'',
'',
'',
'',
'',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','') ;
ELSIF Parameter_used = 4 THEN
conc_id := FND_REQUEST.SUBMIT_REQUEST(nom_appli,nom_prog,NULL,NULL,FALSE,
Parameter1,
Parameter2,
Parameter3,
Parameter4,
CHR(0),
'',
'',
'',
'',
'',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','') ;
ELSIF Parameter_used = 5 THEN
conc_id := FND_REQUEST.SUBMIT_REQUEST(nom_appli,nom_prog,NULL,NULL,FALSE,
Parameter1,
Parameter2,
Parameter3,
Parameter4,
Parameter5,
CHR(0),
'',
'',
'',
'',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','') ;
ELSIF Parameter_used = 6 THEN
conc_id := FND_REQUEST.SUBMIT_REQUEST(nom_appli,nom_prog,NULL,NULL,FALSE,
Parameter1,
Parameter2,
Parameter3,
Parameter4,
Parameter5,
Parameter6,
CHR(0),
'',
'',
'',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','') ;
ELSIF Parameter_used = 7 THEN
conc_id := FND_REQUEST.SUBMIT_REQUEST(nom_appli,nom_prog,NULL,NULL,FALSE,
Parameter1,
Parameter2,
Parameter3,
Parameter4,
Parameter5,
Parameter6,
Parameter7,
CHR(0),
'',
'',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','') ;
ELSIF Parameter_used = 8 THEN
conc_id := FND_REQUEST.SUBMIT_REQUEST(nom_appli,nom_prog,NULL,NULL,FALSE,
Parameter1,
Parameter2,
Parameter3,
Parameter4,
Parameter5,
Parameter6,
Parameter7,
Parameter8,
CHR(0),
'',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','') ;
ELSIF Parameter_used = 9 THEN
conc_id := FND_REQUEST.SUBMIT_REQUEST(nom_appli,nom_prog,NULL,NULL,FALSE,
Parameter1,
Parameter2,
Parameter3,
Parameter4,
Parameter5,
Parameter6,
Parameter7,
Parameter8,
Parameter9,
CHR(0),
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','') ;
ELSIF Parameter_used = 10 THEN
conc_id := FND_REQUEST.SUBMIT_REQUEST(nom_appli,nom_prog,NULL,NULL,FALSE,
Parameter1,
Parameter2,
Parameter3,
Parameter4,
Parameter5,
Parameter6,
Parameter7,
Parameter8,
Parameter9,
Parameter10,
CHR(0),
'','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','') ;
ELSIF Parameter_used = 11 THEN
conc_id := FND_REQUEST.SUBMIT_REQUEST(nom_appli,nom_prog,NULL,NULL,FALSE,
Parameter1,
Parameter2,
Parameter3,
Parameter4,
Parameter5,
Parameter6,
Parameter7,
Parameter8,
Parameter9,
Parameter10,
Parameter11,
CHR(0),'','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','') ;
ELSIF Parameter_used = 12 THEN
conc_id := FND_REQUEST.SUBMIT_REQUEST(nom_appli,nom_prog,NULL,NULL,FALSE,
Parameter1,
Parameter2,
Parameter3,
Parameter4,
Parameter5,
Parameter6,
Parameter7,
Parameter8,
Parameter9,
Parameter10,
Parameter11,
Parameter12,CHR(0),'','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','') ;
ELSIF Parameter_used = 13 THEN
conc_id := FND_REQUEST.SUBMIT_REQUEST(nom_appli,nom_prog,NULL,NULL,FALSE,
Parameter1,
Parameter2,
Parameter3,
Parameter4,
Parameter5,
Parameter6,
Parameter7,
Parameter8,
Parameter9,
Parameter10,
Parameter11,
Parameter12,Parameter13,CHR(0),'','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','') ;
ELSIF Parameter_used = 14 THEN
conc_id := FND_REQUEST.SUBMIT_REQUEST(nom_appli,nom_prog,NULL,NULL,FALSE,
Parameter1,
Parameter2,
Parameter3,
Parameter4,
Parameter5,
Parameter6,
Parameter7,
Parameter8,
Parameter9,
Parameter10,
Parameter11,
Parameter12,Parameter13,Parameter14,CHR(0),'','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','') ;
ELSIF Parameter_used = 15 THEN
conc_id := FND_REQUEST.SUBMIT_REQUEST(nom_appli,nom_prog,NULL,NULL,FALSE,
Parameter1,
Parameter2,
Parameter3,
Parameter4,
Parameter5,
Parameter6,
Parameter7,
Parameter8,
Parameter9,
Parameter10,
Parameter11,
Parameter12,Parameter13,Parameter14,Parameter15,CHR(0),'','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','') ;
ELSIF Parameter_used = 16 THEN
conc_id := FND_REQUEST.SUBMIT_REQUEST(nom_appli,nom_prog,NULL,NULL,FALSE,
Parameter1,
Parameter2,
Parameter3,
Parameter4,
Parameter5,
Parameter6,
Parameter7,
Parameter8,
Parameter9,
Parameter10,
Parameter11,
Parameter12,Parameter13,Parameter14,Parameter15,Parameter16,CHR(0),'','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','') ;
ELSIF Parameter_used = 17 THEN
conc_id := FND_REQUEST.SUBMIT_REQUEST(nom_appli,nom_prog,NULL,NULL,FALSE,
Parameter1,
Parameter2,
Parameter3,
Parameter4,
Parameter5,
Parameter6,
Parameter7,
Parameter8,
Parameter9,
Parameter10,
Parameter11,
Parameter12,Parameter13,Parameter14,Parameter15,Parameter16,Parameter17,CHR(0),'','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','') ;
ELSIF Parameter_used = 18 THEN
conc_id := FND_REQUEST.SUBMIT_REQUEST(nom_appli,nom_prog,NULL,NULL,FALSE,
Parameter1,
Parameter2,
Parameter3,
Parameter4,
Parameter5,
Parameter6,
Parameter7,
Parameter8,
Parameter9,
Parameter10,
Parameter11,
Parameter12,Parameter13,Parameter14,Parameter15,Parameter16,Parameter17,Parameter18,CHR(0),'',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','') ;
ELSIF Parameter_used = 19 THEN
conc_id := FND_REQUEST.SUBMIT_REQUEST(nom_appli,nom_prog,NULL,NULL,FALSE,
Parameter1,
Parameter2,
Parameter3,
Parameter4,
Parameter5,
Parameter6,
Parameter7,
Parameter8,
Parameter9,
Parameter10,
Parameter11,
Parameter12,Parameter13,Parameter14,Parameter15,Parameter16,Parameter17,Parameter18,Parameter19,CHR(0),
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','') ;
ELSIF Parameter_used = 20 THEN
conc_id := FND_REQUEST.SUBMIT_REQUEST(nom_appli,nom_prog,NULL,NULL,FALSE,
Parameter1,
Parameter2,
Parameter3,
Parameter4,
Parameter5,
Parameter6,
Parameter7,
Parameter8,
Parameter9,
Parameter10,
Parameter11,
Parameter12,Parameter13,Parameter14,Parameter15,Parameter16,Parameter17,Parameter18,Parameter19,Parameter20,
CHR(0),'','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','',
'','','','','','','','','','') ;
ELSE conc_id := 0;
END IF;
return nvl (conc_id,0);
END I_Submit_Request;
--***********************************************************************************
PROCEDURE LAUNCH_REPORT(ERRBUF OUT VARCHAR2, -- any error message
RETCODE OUT NUMBER, -- return code
p_appli IN VARCHAR2, -- report application
p_prog IN VARCHAR2, -- program short_name
p_printer_1 IN VARCHAR2, -- first printer ---
p_copies_1 IN VARCHAR2, -- number of copies for printer 1 ---
p_printer_2 IN VARCHAR2 DEFAULT NULL, -- second printer ---
p_copies_2 IN VARCHAR2 DEFAULT NULL, -- number of copies for printer 2 ---
Parameter_used IN INTEGER, -- number of parameter used
Parameter1 IN VARCHAR2 DEFAULT NULL,
Parameter2 IN VARCHAR2 DEFAULT NULL,
Parameter3 IN VARCHAR2 DEFAULT NULL,
Parameter4 IN VARCHAR2 DEFAULT NULL,
Parameter5 IN VARCHAR2 DEFAULT NULL,
Parameter6 IN VARCHAR2 DEFAULT NULL,
Parameter7 IN VARCHAR2 DEFAULT NULL,
Parameter8 IN VARCHAR2 DEFAULT NULL,
Parameter9 IN VARCHAR2 DEFAULT NULL,
Parameter10 IN VARCHAR2 DEFAULT NULL,
Parameter11 IN VARCHAR2 DEFAULT NULL,
Parameter12 IN VARCHAR2 DEFAULT NULL,
Parameter13 IN VARCHAR2 DEFAULT NULL,
Parameter14 IN VARCHAR2 DEFAULT NULL,
Parameter15 IN VARCHAR2 DEFAULT NULL,
Parameter16 IN VARCHAR2 DEFAULT NULL,
Parameter17 IN VARCHAR2 DEFAULT NULL,
Parameter18 IN VARCHAR2 DEFAULT NULL,
Parameter19 IN VARCHAR2 DEFAULT NULL,
Parameter20 IN VARCHAR2 DEFAULT NULL
)
AS
PRAGMA AUTONOMOUS_TRANSACTION;
THE_PRINT_OPTION BOOLEAN;
ln_request_id1 NUMBER;
ln_request_id2 NUMBER;
msg_out VARCHAR2(2000);
-- variable for wait request
l_phase VARCHAR2(100);
l_status VARCHAR2(10);
l_dev_phase VARCHAR2(100);
l_dev_status VARCHAR2(100);
l_message VARCHAR2(100);
l_bool BOOLEAN;
l_print_style VARCHAR2(200);
BEGIN
ERRBUF:='OK';
RETCODE:=0;
ALS_CONCSUB.conc_init ('ALS',FND_PROFILE.VALUE('USER_ID') );
-- launch report for printer 1
THE_PRINT_OPTION:=fnd_request.set_print_options (p_printer_1, NULL, p_copies_1, TRUE, 'N');
ln_request_id1:=I_Submit_Request(p_appli,
p_prog,
parameter1,
parameter2,
parameter3,
parameter4,
parameter5,
parameter6,
parameter7,
parameter8,
parameter9,
parameter10,
parameter11,
parameter12,
parameter13,
parameter14,
parameter15,
parameter16,
parameter17,
parameter18,
parameter19,
parameter20,
parameter_used
);
COMMIT;
IF ln_request_id1=0 THEN
ERRBUF:=replace('ERROR', chr(0),' ');
RETCODE:=2;
ELSE
-- WAIT FOR THE CONCURRENT TO FINISH ( to have the output file )
l_bool:=FND_CONCURRENT.WAIT_FOR_REQUEST(ln_request_id1,
2, -- check every 2 seconds if the concurrent is finished
0,
l_phase,
l_status,
l_dev_phase,
l_dev_status,
l_message
);
END IF;
-- launch report for printer 2 if any ( try to reprint )
IF UPPER(l_dev_status) = 'NORMAL' AND l_bool THEN --1
IF p_printer_2 IS NOT NULL THEN -- 2
-- retrieve print style
BEGIN
SELECT output_print_style
INTO l_print_style
FROM
fnd_concurrent_programs
WHERE
concurrent_program_name=p_prog
;
EXCEPTION
WHEN NO_DATA_FOUND THEN
ERRBUF:='NO OUTPUT STYLE RETRIEVED';
RETCODE:=2;
WHEN OTHERS THEN
ERRBUF:='OUTPUTSTYLE OTHER ERROE';
RETCODE:=2;
END;
THE_PRINT_OPTION := fnd_request.set_print_options (p_printer_2, NULL, NVL(p_copies_1,1), TRUE, 'N');
ln_request_id2 := FND_REQUEST.SUBMIT_REQUEST('FND'
,'FNDREPRINT'
,''
,NULL
,FALSE
,ln_request_id1 -- request_id first print of report
,p_printer_2 -- printer
,NVL(p_copies_1,1) -- number of copies
,l_print_style -- Style of concurrent
,''
,'','','','','' -- 10--
,'','','','','','','','','','' -- 20--
,'','','','','','','','','','' -- 30--
,'','','','','','','','','','' -- 40--
,'','','','','','','','','','' -- 50--
,'','','','','','','','','','' -- 60--
,'','','','','','','','','','' -- 70--
,'','','','','','','','','','' -- 80--
,'','','','','','','','','','' -- 90--
,'','','','','','','','','','' -- 100--
);
COMMIT;
IF ln_request_id2=0 THEN
ERRBUF:='ERROR REPRINT';
RETCODE:=2;
END IF;
END IF; -- 2
END IF; -- 1
END LAUNCH_REPORT;
END ALS_REPORT_PK;
/
show errors
exit
BUT IT WON'T WORK IN A TRIGGER !!!!!!!!!!! BECAUSE OF THE WAITING PROCEDURE.
but you can create a concurrent program in ORACLE APPLICATION ased on the stored proc LAUNCH_REPORT above.
Bye Bye
Romeo
|