Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Trigger BAPI while creating PO

shubham_pawar1
Explorer
0 Likes
3,061

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.
6 REPLIES 6
Read only

Sandra_Rossi
Active Contributor
2,905

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!

Read only

Sandra_Rossi
Active Contributor
2,905

Isn't PO auto-release a standard feature done by customizing?

Read only

shubham_pawar1
Explorer
0 Likes
2,905

this auto PO release is required only in case, if PO has outline agreement number

Read only

Sijin_Chandran
Active Contributor
0 Likes
2,905

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

Read only

MohdRKhan
Active Contributor
0 Likes
2,905

if there is no specific requirement, do not put release strategy. or create saprate document

Regards
Rashid Khan
Read only

shubham_pawar1
Explorer
0 Likes
2,905

Hi All,

Thank you all for your suggestion.

my issue resolved I was trying to use POST method instead of CLOSE.