Application Development 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: 

ME_REQ_POSTED

Former Member
0 Kudos

Is there a way within the BAdI implementation for the POSTED

method to determine whether the Purchase Requisition is being

created or changed?

1 ACCEPTED SOLUTION

former_member156446
Active Contributor
0 Kudos

Use this code:

lt_eban = im_eban.

* Get the BANF number
    READ TABLE lt_eban INDEX 1 INTO lv_my_banf.

    IF lv_my_banf IS NOT INITIAL.
*   Check on database, if the BANF number already exists
      SELECT SINGLE banfn FROM eban INTO lv_banfn WHERE banfn = lv_my_banf-banfn.
      lv_subrc = sy-subrc.
      IF lv_subrc NE 0.
        lv_mode = 1. " thn its a change
      ELSE.
        lv_mode = 0. " its a creation
      ENDIF.
    ENDIF.

2 REPLIES 2

former_member194669
Active Contributor
0 Kudos

One way is using SY-TCODE = 'ME51N'

PS : (But there is an issue on this if PR creation is thru BAPI then what will be sy-tcode ?)

former_member156446
Active Contributor
0 Kudos

Use this code:

lt_eban = im_eban.

* Get the BANF number
    READ TABLE lt_eban INDEX 1 INTO lv_my_banf.

    IF lv_my_banf IS NOT INITIAL.
*   Check on database, if the BANF number already exists
      SELECT SINGLE banfn FROM eban INTO lv_banfn WHERE banfn = lv_my_banf-banfn.
      lv_subrc = sy-subrc.
      IF lv_subrc NE 0.
        lv_mode = 1. " thn its a change
      ELSE.
        lv_mode = 0. " its a creation
      ENDIF.
    ENDIF.