About submitting requests in PL/SQL code

Source: Internet
Author: User

There are two scenarios for submitting requests in code:

1,
Submit a request in the PL/SQL Program

Call fnd_request.submit_request in PL/SQL,

/* Submit a request where no setup is required */

Declare

Req_id number;

Begin

Req_id: =
Fnd_request.submit_request ('fnd', -- Application name

'Fndmdgen ',
-- Request Name

'Message
File generator ', -- Description

'01-NOV-02 00: 00: 00', -- Start Time

False, -- whether it is a sub-request true/false

Arg1, -- parameter 1

Arg2, -- Parameter

Char (0); -- the parameter ends with Char (0)

If (req_id = 0) then

/* Handle submission Error */

......

Else

Commit; -- the request must be commit because a record is inserted into the fnd_concurrent_queues table, you can find the storage path of the output file and log file of the submitted request in this table.

End if;

End;

Fnd_request.submit_request () has more than one hundred parameters, but we do not need to fill in the PL/SQL program, we only need to add a char (0) when the parameter ends, if the returned req_id is 0, the request is not submitted successfully.

 

 

2,
Submit a request in Form

When submitting a request in form, we have to fill up more than one hundred parameters. If not written, an error will occur. You can write the null parameters for the submitted program as follows: ''or null, A total of one hundred instances are required, for example:

Declare

Rochelle request_id number;

Rochelle return_flag Boolean;

Rochelle bl_result Boolean;

X_phase
Varchar2 (100 );

X_status
Varchar2 (100 );

X_dev_phase
Varchar2 (100 );

X_dev_status varchar2 (100 );

X_message
Varchar2 (100 );

Begin

Rochelle request_id: =
Fnd_request.submit_request ('cux ', 'cuxexrenile ','',
'',
False, 'Hi man ', 'it''s work! ',
CHR (0), -- parameter end

/* Remaining parameters */

'','','','','','','',

'','','','','','','','','','',

'','','','','','','','','','',

'','','','','','','','','','',

'','','','','','','','','','',

'','','','','','','','','','',

'','','','','','','','','','',

'','','','','','','','','','',

'','','','','','','','','','',

'','','','','','','','','','');

Rochelle return_flag: = app_form.quietcommit; -- commit

/* If an error occurs */

If l_request_id is null or l_request_id
= 0 then

Fnd_message.retrieve;

Fnd_message.error;

End if;

/* Wait for the request to end */l_bl_result: = fnd_concurrent.wait_for_request (request_id => l_request_id,

Interval => 1,

Max_wait => 0,

Phase => x_phase,

Status => x_status,

Dev_phase => x_dev_phase,

Dev_status => x_dev_status,

Message
=> X_message );

/* After the request ends, open the request to find from and find the submitted request */

Fnd_function.execute (function_name => 'fnd _ fndrsrun ',

Open_flag => 'y ',

Session_flag => 'y ',

Other_params => 'concurrent _ program_name = "cuxexrenile"
Program_appl_short_name = "cux" dodt_req_id = "'| to_char (l_request_id) | '"');

End;

In addition to writing the parameters, In the from request, we should change the commit to the standard do_key ('commit _ form'). In the above example, app_from.quitecommit is used, it is also a standard writing method in from, which is quietly commit in the background. When the request fails to be submitted, we use fnd_message.retrieve to retrieve the error message from the message stack and use fnd_message.error to display the error message. You don't have to worry that it will pop up messages from other processes, because the message stack is process-specific.

When a request is submitted, we can wait for the end of the request. In the above example, fnd_concurrent.wait_for_request () is used to wait for the end of the request. interval indicates the time to check the execution of the request. max_wait indicates the maximum wait time, when it is set to 0, it will wait until there is a result. The following parameters include the request execution.

Fnd_function.execute () is used to execute a function. function_name is short for function. other_params can provide some parameters for this function. Of course, this function must support these parameters, in the above example, the function I executed is the request query function. In other_params, we passed the Request ID, so that after the execution is complete, we can directly jump to the request Query Form and find the request we submitted.

Let's talk about things related to fnd_request.submit_request (). When I submit a request, I usually print a report, which can be a report written in HTML in PL/SQL, it can also be a report made using XML publish. Let's talk about the report in XML publish format. xml publish can support reports in multiple formats, such as PDF, text, and excel, generally, the format is set when the report template is defined. You can control the output format in the Code as follows:

Before fnd_request_submit_request (), we write the following code:

L_temp: = fnd_request.add_layout (template_appl_name => 'cux ', -- Application abbreviation


Template_code => 'cuxappmbl ',

Template_language => 'zh ', -- language


Template_territory => 'cn', -- Region


Output_format =>
Rochelle output_format); -- format

Fnd_request.add_layout () is used to add a department to a report. We can set l_output_format to the desired format, such as 'pdf 'and 'rtf'

Of course, it is also possible to have two templates for a report. You only need to select the same data definition when defining the template. before calling the template, We need to select the template to be used, as shown in the following example:

--Set Template

If l_show_list = 'y' then

Rochelle temp: =
Fnd_request.add_layout (template_appl_name => 'cux ',


Template_code => 'cuxappmbl ',


Template_language => 'zh ',


Template_territory => 'cn ',-- Rec. default_territory


Output_format =>
Rochelle output_format );-- 'Pdf ');

Else

Rochelle temp: =
Fnd_request.add_layout (template_appl_name => 'cux ',


Template_code => 'cuxapp1_sum ',


Template_language => 'zh ',

Template_territory => 'cn ',-- Rec. default_territory


Output_format =>
Rochelle output_format );-- 'Pdf ');

End if;

There are two templates: cuxappmbl and cuxapp1_sum. Select the template as needed.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.