Block in the button form:
declare
url varchar2(2000);
L_TXN_ID_D NUMBER;
begin
L_TXN_ID_D:= :FUJ_IMM_TXN_D.TXN_ID_D;
url:= xximm_submit_report.xx_hr_report_retrun(
p_template =>'XX_IMM_WK' /*XML report template code*/
,p_application => 'XXCUST'
,p_program => 'XX_IMM_WK ' --Concurrent Program Code
,p_arg1 => L_TXN_ID_D --Parameters
);
web.show_document(url);
exception when others then
message(sqlerrm);
end;
CREATE OR REPLACE PACKAGE APPS.xximm_submit_report
AS
PROCEDURE xx_get_mime_type (
ftype IN VARCHAR2,
mtype IN OUT VARCHAR2,
wopen IN OUT BOOLEAN
);
FUNCTION xx_browser_show_retrun (
fname VARCHAR2,
node VARCHAR2,
mtype VARCHAR2,
req_id NUMBER DEFAULT NULL
)
RETURN VARCHAR2;
FUNCTION xx_hr_report_retrun (
p_template IN VARCHAR2 DEFAULT NULL,
p_application IN VARCHAR2 DEFAULT NULL,
p_program IN VARCHAR2 DEFAULT NULL,
p_description IN VARCHAR2 DEFAULT NULL,
p_arg1 IN VARCHAR2 DEFAULT NULL,
p_arg2 IN VARCHAR2 DEFAULT NULL,
p_arg3 IN VARCHAR2 DEFAULT NULL,
p_arg4 IN VARCHAR2 DEFAULT NULL,
p_arg5 IN VARCHAR2 DEFAULT NULL,
p_arg6 IN VARCHAR2 DEFAULT NULL,
p_arg7 IN VARCHAR2 DEFAULT NULL
)
RETURN VARCHAR2;
END xximm_submit_report;
/
CREATE OR REPLACE PACKAGE BODY APPS.xximm_submit_reportASPROCEDURE xx_get_mime_type (ftype IN VARCHAR2,mtype IN OUT VARCHAR2,wopen IN OUT BOOLEAN)ISprofile_defined BOOLEAN := FALSE;errcode NUMBER;g_size NUMBER;initial_mtype VARCHAR2 (80); -- initial value for viewer poplistBEGINwopen := FALSE;-- check profile options for each file formatIF (ftype = 'TEXT')THENIF (fnd_profile.defined ('FS_MIME_TEXT'))THENfnd_profile.get ('FS_MIME_TEXT', mtype);profile_defined := TRUE;END IF;ELSIF (ftype = 'HTML')THENIF (fnd_profile.defined ('FS_MIME_HTML'))THENfnd_profile.get ('FS_MIME_HTML', mtype);profile_defined := TRUE;END IF;ELSIF (ftype = 'PDF')THENIF (fnd_profile.defined ('FS_MIME_PDF'))THENfnd_profile.get ('FS_MIME_PDF', mtype);profile_defined := TRUE;END IF;ELSIF (ftype = 'PS')THENIF (fnd_profile.defined ('FS_MIME_PS'))THENfnd_profile.get ('FS_MIME_PS', mtype);profile_defined := TRUE;END IF;ELSIF (ftype = 'PCL')THENIF (fnd_profile.defined ('FS_MIME_PCL'))THENfnd_profile.get ('FS_MIME_PCL', mtype);profile_defined := TRUE;END IF;ELSIF (ftype = 'XML')THENIF (fnd_profile.defined ('FS_MIME_XML'))THENfnd_profile.get ('FS_MIME_XML', mtype);profile_defined := TRUE;END IF;ELSEmtype := 'text/plain';profile_defined := TRUE;END IF;IF NOT wopenTHENDBMS_OUTPUT.put_line ('Wopen False');ELSEDBMS_OUTPUT.put_line ('Wopen true');END IF;-- if profile option does not exists then look for fnd_mime_types_vl-- view for mime type.IF (NOT profile_defined)THENFOR c IN (SELECT mime_typeFROM fnd_mime_types_vlWHERE file_format_code = ftype AND ROWNUM = 1)LOOPmtype := c.mime_type;EXIT;END LOOP;END IF; -- not profile_definedEND;FUNCTION xx_browser_show_retrun (fname VARCHAR2,node VARCHAR2,mtype VARCHAR2,req_id NUMBER DEFAULT NULL)RETURN VARCHAR2ISbase VARCHAR2 (255);url VARCHAR2 (255);ID VARCHAR2 (32);gwyuid VARCHAR2 (32);two_task VARCHAR2 (64);fs_enabled VARCHAR2 (2);pos NUMBER;svc VARCHAR2 (240);x_mode VARCHAR2 (30) := 'BINARY';oftype VARCHAR2 (4);published_req BOOLEAN := FALSE;pub_reqid VARCHAR2 (32);int_request_id NUMBER;base_type VARCHAR2 (50);PRAGMA AUTONOMOUS_TRANSACTION;BEGINint_request_id := req_id;DBMS_OUTPUT.put_line ('node ===>' || node);DBMS_OUTPUT.put_line ('mtype ===>' || mtype);DBMS_OUTPUT.put_line ('req_id ===>' || req_id);fnd_profile.get ('TWO_TASK', two_task);fnd_profile.get ('GWYUID', gwyuid);IF (fnd_profile.defined ('APPS_CGI_AGENT'))THENfnd_profile.get ('APPS_CGI_AGENT', base);END IF;IF (base IS NULL)THENfnd_profile.get ('APPS_WEB_AGENT', base);base_type := 'WEB';END IF;IF (fnd_profile.defined ('FS_SVC_PREFIX'))THENfnd_profile.get ('FS_SVC_PREFIX', svc);IF (svc IS NOT NULL)THENsvc := SUBSTR (svc || node, 1, 255);ELSEsvc := 'FNDFS_' || node;END IF;ELSEsvc := 'FNDFS_' || node;END IF;IF (req_id IS NOT NULL)THENBEGINSELECT file_typeINTO oftypeFROM fnd_conc_req_outputsWHERE concurrent_request_id = req_id AND ROWNUM = 1;IF (oftype IN ('PDF', 'PS', 'PCL', 'EXCEL'))THENx_mode := 'BINARY';END IF;EXCEPTIONWHEN NO_DATA_FOUNDTHENBEGINSELECT NVL (output_file_type, 'TEXT')INTO oftypeFROM fnd_concurrent_requestsWHERE request_id = req_id;IF (oftype IN ('PDF', 'PS', 'PCL','XML'))THENx_mode := 'BINARY';END IF;EXCEPTIONWHEN NO_DATA_FOUNDTHENx_mode := 'TEXT';END;END;END IF;DBMS_OUTPUT.put_line ('X_mode:' || x_mode);IF published_req = TRUETHENint_request_id := pub_reqid;DBMS_OUTPUT.put_line ('published_req ===>true');ELSEDBMS_OUTPUT.put_line ('published_req ===>false');END IF;ID :=fnd_webfile.create_id (fname,svc,10,mtype,NVL (int_request_id, req_id),x_mode,'Y');DBMS_OUTPUT.put_line ('fname ===>' || fname);DBMS_OUTPUT.put_line ('svc ==>' || svc);DBMS_OUTPUT.put_line ('mtype' || mtype);DBMS_OUTPUT.put_line ('ID ===>' || ID);DBMS_OUTPUT.put_line ('pub_reqid ==>' || pub_reqid);DBMS_OUTPUT.put_line ('ID after publish' || ID);base := LTRIM (RTRIM (base));IF (base_type = 'WEB')THEN-- Strip any file path from the base URL by truncating at the-- third '/'.-- This leaves us with something like 'http://ap363sun:8000'.pos := INSTR (base, '/', 1, 3);IF (pos > 0)THENbase := SUBSTR (base, 1, pos - 1);END IF;-- 2638328 - security violation - removing login information from URLurl := base || '/OA_CGI/FNDWRR.exe?' || 'temp_id=' || ID;ELSIF (base_type = 'CGI')THENIF (SUBSTR (base, LENGTH (base)) <> '/')THENbase := base || '/';END IF;url := base || 'FNDWRR.exe?' || 'temp_id=' || ID;END IF;DBMS_OUTPUT.put_line ('Before : ' || url);-- FND_WEBFILE.GET_URL(FND_WEBFILE.request_out,ID,gwyuid,two_task,100);url :=fnd_webfile.get_url (file_type => fnd_webfile.request_out,ID => req_id,gwyuid => gwyuid,two_task => two_task,expire_time => 100 -- minutes, security!.);DBMS_OUTPUT.put_line ('after : ' || url);/* pos := INSTR(base, '/', 1, 3);IF (pos > 0) THENbase := SUBSTR(base, 1, pos - 1);END IF;url := base || '/OA_CGI/FNDWRR.exe?' || 'temp_id=' || ID ;--|| '&' || 'login=' || gwyuid || '@' || two_task;*//*htp.htmlOpen;htp.headOpen;htp.title('Get request output');htp.headClose;htp.bodyOpen;htp.p('<A HREF='||url||'>Click to get request output</a>');htp.bodyclose;htp.htmlclose;*/DBMS_OUTPUT.put_line (url);RETURN url;END;FUNCTION xx_hr_report_retrun (p_template IN VARCHAR2 DEFAULT NULL,p_application IN VARCHAR2 DEFAULT NULL,p_program IN VARCHAR2 DEFAULT NULL,p_description IN VARCHAR2 DEFAULT NULL,p_arg1 IN VARCHAR2 DEFAULT NULL,p_arg2 IN VARCHAR2 DEFAULT NULL,p_arg3 IN VARCHAR2 DEFAULT NULL,p_arg4 IN VARCHAR2 DEFAULT NULL,p_arg5 IN VARCHAR2 DEFAULT NULL,p_arg6 IN VARCHAR2 DEFAULT NULL,p_arg7 IN VARCHAR2 DEFAULT NULL)RETURN VARCHAR2ISl_req_id NUMBER;l_user_id NUMBER := fnd_profile.VALUE ('USER');l_resp_id NUMBER := 52168;--53237;l_resp_appl_id NUMBER := 800;l_url VARCHAR2 (3000);ftype VARCHAR2 (30) := 'XML';mtype VARCHAR2 (80);wopen BOOLEAN := FALSE;filename fnd_concurrent_requests.outfile_name%TYPE;node fnd_concurrent_requests.outfile_node_name%TYPE;l_request_completed BOOLEAN := FALSE;l_req_phase VARCHAR2 (20);l_req_status VARCHAR2 (1000);l_req_dev_phase VARCHAR2 (1000);l_req_dev_status VARCHAR2 (1000);l_req_message VARCHAR2 (1000);b_success BOOLEAN;v_set_layout_option BOOLEAN;v_error_message VARCHAR (2000);v_count NUMBER;v_template_type VARCHAR2 (200);v_cycle_name VARCHAR2 (200);v_traning_v VARCHAR2 (200);v_comb VARCHAR2 (200);BEGIN-- v_template_type := 'FUJ_HR_HOTEL_WKPERMIT';fnd_global.apps_initialize(2605,52168, 800);v_set_layout_option :=fnd_request.add_layout (template_appl_name => p_application,template_code => p_template,--p_program,template_language => 'en',template_territory => '',output_format => 'PDF');IF (NOT v_set_layout_option)THENfnd_file.put_line (fnd_file.LOG,'Unable to apply template');fnd_file.put_line (fnd_file.LOG, v_error_message);ELSEl_req_id :=fnd_request.submit_request (application => p_application,program => p_program,description => null,--p_description,start_time => NULL,argument1 => p_arg1,argument2 => p_arg2,argument3 => p_arg3,argument4 => p_arg4,argument5 => p_arg5,argument6 => p_arg6,argument7 => p_arg7);DBMS_OUTPUT.put_line ('l_req_id ===> ' || l_req_id);COMMIT;END IF;l_request_completed :=fnd_concurrent.wait_for_request (request_id => l_req_id,INTERVAL => 1,phase => l_req_phase,status => l_req_status,dev_phase => l_req_dev_phase,dev_status => l_req_dev_status,MESSAGE => l_req_message);COMMIT;FOR c IN (SELECT NVL (output_file_type, 'PDF') ftype,outfile_name filename, outfile_node_name node,ofile_sizeFROM fnd_concurrent_requestsWHERE request_id = l_req_id)LOOPftype := c.ftype;filename := c.filename;node := c.node;EXIT;END LOOP;xx_get_mime_type (ftype => ftype, mtype => mtype, wopen => wopen);IF NOT wopenTHENl_url := xx_browser_show_retrun (filename, node, mtype, l_req_id);END IF;RETURN l_url;END;END xximm_submit_report;/
No comments:
Post a Comment