Wednesday, November 24, 2010

FINALLY CLOSE -- A PO /PO Line


Following API Can be used to "FINALLY CLOSE" a Standard/Blanket PO at header/line level.

  • Given example is at Line level for blanket PO.
  • For header level PO close, P_lineid will be passed as null.
  • For standard PO , instead of PA use PO.
  • If blanket PO line is referred on any OPEN standard PO, then BPA line cannot be changed to FINALLY CLOSE status.
**************************************************

DECLARE
x_action CONSTANT VARCHAR2 (20) := 'FINALLY CLOSE';
-- Change this parameter as per requirement
x_calling_mode CONSTANT VARCHAR2 (2) := 'PO';
x_conc_flag CONSTANT VARCHAR2 (1) := 'N';
x_return_code_h VARCHAR2 (100);
x_auto_close CONSTANT VARCHAR2 (1) := 'N';
x_origin_doc_id NUMBER;
x_returned BOOLEAN;
CURSOR c_po_details
IS
SELECT pha.po_header_id, pha.org_id, pha.segment1, pha.agent_id
,pha.closed_code, pha.closed_date
FROM apps.po_headers_all pha
WHERE authorization_status = 'APPROVED'
AND pha.closed_code <> 'FINALLY CLOSED'
AND segment1 = '15000002252';
-- Enter the PO Number if one PO needs to be finally closed/Closed
BEGIN
fnd_global.apps_initialize (user_id => 1468
,resp_id => 20707
,resp_appl_id => 201
);
FOR po_head IN c_po_details
LOOP
mo_global.init ('PA');
mo_global.set_policy_context ('S', po_head.org_id);
DBMS_OUTPUT.put_line
( 'Calling PO_Actions.close_po for Closing/Finally Closing PO =>'
|| po_head.segment1
);
x_returned :=
po_actions.close_po (p_docid => po_head.po_header_id
,p_doctyp => 'PA' -- "PO" for standard PO
,p_docsubtyp => 'BLANKET' --'STANDARD' for standard PO
,p_lineid => 7885858 -- null if you want to FINALLY CLOSE at header level
,p_shipid => NULL
,p_action => x_action
,p_reason => NULL
,p_calling_mode => x_calling_mode
,p_conc_flag => x_conc_flag
,p_return_code => x_return_code_h
,p_auto_close => x_auto_close
,p_action_date => SYSDATE
,p_origin_doc_id => NULL
);
IF x_returned = TRUE
THEN
DBMS_OUTPUT.put_line
( 'Purchase Order which just got Closed/Finally Closed is '
|| po_head.segment1
);
COMMIT;
ELSE
DBMS_OUTPUT.put_line
('API Failed to Close/Finally Close the Purchase Order');
END IF;
END LOOP;
EXCEPTION
WHEN OTHERS THEN
DBMS_OUTPUT.put_line
('Program failed with unexpected error');
END;

7 comments:

  1. Thanks for this useful information. I know about Finally Close but my concept was not clear. After reading your post I understand what exactly Finally Close mean and its working. The above clear my doubt. Great work.

    ReplyDelete
  2. Hi Uday,

    i am working on CLOSE po line ... but not able to close a line with this API . can you please let us know how to work on this.

    Code :declare
    l_result BOOLEAN;
    l_out_code varchar2(500);
    begin
    fnd_global.apps_initialize (159372, 68832, 201);
    l_result:= po_actions.close_po(
    p_docid => 7980436,
    p_doctyp =>'PO',
    p_docsubtyp => 'STANDARD',
    p_lineid => NULL,
    p_shipid => NULL,
    -- p_action => 'CLOSE',
    p_reason => 'ONT CLOSE Request : ',
    p_calling_mode => 'PO',
    p_conc_flag => 'N',
    p_return_code => l_out_code,
    p_auto_close => 'N ',
    p_action_date => SYSDATE,
    p_origin_doc_id => NULL);

    COMMIT;
    if (l_result)
    Then
    dbms_output.put_line('l_result: ');
    ELSE
    dbms_output.put_line('l_result: ERROR');
    end if;

    exception when others
    then
    dbms_output.put_line('Exception :'||SQLERRM);
    end;

    ReplyDelete
    Replies
    1. did u get any solution for this?

      Delete
  3. Hi, Thanks for the post. It was really helpful.

    Currently we are using the PO_ACTIONS.CLOSE_PO to close blanket releases.

    l_close_status :=
    PO_ACTIONS.CLOSE_PO (p_docid => po_rec.po_header_id,
    p_doctyp => 'PA',
    p_docsubtyp => 'BLANKET',
    p_lineid => NULL,
    p_shipid => NULL,
    p_action => 'FINALLY CLOSE',
    p_return_code => l_return_code,
    p_auto_close => 'N',
    p_action_date => SYSDATE);

    The above program final closes the Blanket PO (‘Finally Closed’) at the header level and all the releases are in ‘Closed’ status. Is it possible to have the release status to ‘Finally Closed’ instead of ‘Closed’ status?

    ReplyDelete
  4. Can you help to provide the solution first for the queries here.?
    Every where I can see your post begging for the training, Why can't you prove your knowledge by providing the solution first then you no need to beg like so.. by that people will approach you for the training. Its annoying as a Spam everywhere your similar post I am Sridevi Koduru,..... bla bla bla.. what the non-sense. !!!

    ReplyDelete
  5. totally agree, its a turn off, will never use her because of it

    ReplyDelete