Sunday 20 May 2012

How to submit a concurrent program from backend


How to submit a concurrent program from backend:

   Using FND_REQUEST.SUBMIT_REQUEST Funtion and by passing the required parameters to it we can submit a concurrent program from backend. 
But before doing so, We have to set the environment of the user submitting the Request.

We have to Initialize the following parameters using FND_GLOBAL.APPS_INITIALIZE Procedure
1). USER_ID  2).RESPONSIBILITY_ID  3). RESPONSIBILITY_APPLICATION_ID

syntax:
FND_GLOBAL.APPS_INITIALIZE:

PROCEDURE APPS_INITIALIZE( user_id in number,
                                         resp_id in number,
                                         resp_appl_id in number);


FND_REQUEST.SUBMIT_REQUEST:
REQ_ID :=FND_REQUEST.SUBMIT_REQUEST(Application=> 'ApplicationName',
                                                                               Program => 'Program Name',
                                                                               Description=>'null',
                                                                              start_time=>'null',
                                                                             sub_request=>false,
                                                                             argument1=>1,
                                                                             argument2=>2,
                                                                             .
                                                                             .
                                                                             .
                                                                             . argument n=>n);

Where ,Req_id is the concurrent request id upon successful completion.And concurrent request ID returns 0 for any submission problems.
Example:-
1st get the user_id and responsibility_id by which we have to submit the program:

SELECT USER_ID,
               RESPONSIBILITY_ID,
               RESPONSIBILITY_APPLICATION_ID,
                SECURITY_GROUP_ID
FROM FND_USER_RESP_GROUPS
WHERE USER_ID =(SELECT USER_ID
                                  FROM FND_USER
                                WHERE USER_NAME='&USER_NAME')
AND RESPONSIBILITY_ID=(SELECT RESPONSIBILITY_ID
                                                   FROM FND_RESPONSIBILITY_VL
                                                   WHERE RESPONSIBILITY_NAME='&RESP_NAME');
Now create this procedure

create or replace procedure apps.call_racust (p_return_code out number,
                                                              p_org_id number,
                                                              p_return_msg  out varchar2)
IS
V_REQUEST_ID VARCHAR2(100);
P_CREATE_RECIPROCAL_FLAG VARCHAR2(1) :='N';
BEGIN
FND_GLOBAL.APPS_INITIALIZE(10081,5559,220);
V_REQUEST_ID:=APPS.FND_REQUEST.SUBMIT_REQUEST('AR',
                                                                            'RACUST',
                                                                            '' ",
                                                                            FALSE,
                                                                           P_CREATE_RECIPROCAL_FLAG,
                                                                            P_ORG_ID,
                                                                             CHAR(0));
P_RETURN_MSG:='Request submitted.ID=' || V_REQUEST_ID;
P_RETURN_CODE:=0; COMMIT;
EXCEPTION
WHEN OTHERS THAN
P_RETURN_MSG:='REQUEST SET SUBMISSION FAILED -UNKNOWN ERROR:'||SQLERRM;
P_RETURN_CODE:=2;
END; 

1 comment:

  1. how to submit xml reports request set from backend

    ReplyDelete