‎2021 Nov 30 10:34 AM
Hi Experts,
I am facing issue in one requirement.
My requirement is when user create the PO , the PO should get automatically released .
If somebody has idea please share your thoughts.
Regards,
Shubham
P.S. - I have tried to create but getting exception 2 as PO must have not been generated.
CODE:
DATA ls_header TYPE mepoheader.
DATA lv_rel_code TYPE bapimmpara-po_rel_cod.
CALL METHOD im_header->get_data
RECEIVING
re_data = ls_header.
IF sy-tcode = 'ME21N' OR sy-tcode = 'ME22N'.
IF ls_header-konnr IS NOT INITIAL. " Outline Agreement
SELECT SINGLE FRGC1 FROM T16FS INTO lv_rel_code
WHERE FRGGR = 'NP'
AND FRGSX = '00'.
IF lv_rel_code IS NOT INITIAL.
CALL FUNCTION 'BAPI_PO_RELEASE'
EXPORTING
PURCHASEORDER = im_ebeln
PO_REL_CODE = lv_rel_code
USE_EXCEPTIONS = 'X'
NO_COMMIT = ' '
* IMPORTING
* REL_STATUS_NEW =
* REL_INDICATOR_NEW =
* RET_CODE =
* TABLES
* RETURN =
EXCEPTIONS
AUTHORITY_CHECK_FAIL = 1
DOCUMENT_NOT_FOUND = 2
ENQUEUE_FAIL = 3
PREREQUISITE_FAIL = 4
RELEASE_ALREADY_POSTED = 5
RESPONSIBILITY_FAIL = 6
OTHERS = 7.
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.
ENDIF.
ENDIF.
ENDIF.
‎2021 Nov 30 2:49 PM
Please edit your question, select your code and press the button [CODE], which makes the code appear colored/indented, it will be easier for people to look at it. Thank you!
‎2021 Nov 30 2:49 PM
Isn't PO auto-release a standard feature done by customizing?
‎2021 Dec 01 10:01 AM
this auto PO release is required only in case, if PO has outline agreement number
‎2021 Dec 01 10:12 AM
Hello Shubham,
If you are sure with your analysis that this requirement cannot be realised using any of the Standard SPRO settings in place, then I would suggest you to use the 'Special Function' Medium type which we have available in Output Management setup(NACE).

Using this setup you can arrange a call to a Custom Program in such a way that it would be called once the PO is saved to Database and the call to this Custom Program would be done based on the Output Setup in place using NACE settings with Special function feature. Please analyse on this direction.
Thanks,
Sijin
‎2021 Dec 01 12:24 PM
if there is no specific requirement, do not put release strategy. or create saprate document
‎2021 Dec 02 4:49 AM
Hi All,
Thank you all for your suggestion.
my issue resolved I was trying to use POST method instead of CLOSE.