Wednesday, 24 October 2018

API To Close Purchase Order

DECLARE
x_return_code VARCHAR2(100);
l_progress VARCHAR2(100);
l_result BOOLEAN;
l_User_Id      Number;
 l_Resp_Id      Number;
 l_Resp_Appl_Id Number;
BEGIN
apps.fnd_client_info.set_org_context('102');
SELECT distinct fnd.user_id ,
  fresp.responsibility_id,
  fresp.application_id
  into
  l_user_id,
  l_resp_id,
  l_resp_appl_id
  FROM fnd_user fnd ,
  FND_RESPONSIBILITY_TL FRESP
where FND.USER_NAME = 'SYSADMIN'
and UPPER(FRESP.RESPONSIBILITY_NAME) like ('PURCHASING SUPER USER');
 Apps.Fnd_Global.Apps_Initialize(User_Id      => l_User_Id,
                                 Resp_Id      => l_Resp_Id,
                                 Resp_Appl_Id => l_Resp_Appl_Id);
l_result := PO_ACTIONS.CLOSE_PO(
                                P_DOCID => 1170,
                                P_DOCTYP => 'PO',
                                P_DOCSUBTYP => 'STANDARD',
                                P_LINEID => 0,--23152,
                                P_SHIPID => 0,--22990,
                                P_ACTION => 'CLOSE',
                                P_REASON => 'Testing',
                                P_CALLING_MODE => 'PO',
                                P_CONC_FLAG => 'N',
                                P_RETURN_CODE => x_return_code,
                                P_AUTO_CLOSE => 'Y',
                                P_ACTION_DATE => SYSDATE,
                                P_ORIGIN_DOC_ID => NULL
                                );
IF l_result then
dbms_output.put_line('The Closure was successful');
ELSE
dbms_output.put_line('The Closure was unsuccessful');
END IF;
END;

No comments:

Post a Comment