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

BAPI_GOODSMVT_CREATE, and automatic batch numbers

john_pawski
Participant
0 Likes
1,421

Hello,

I am using BAPI_GOODSMVT_CREATE and doing good receipt vs., a Purchase Order, GM 01. The material is auto batch managed and I see the batches are generated when I go into MSEG for the good receipt line items. However, batch numbers are not returned in the bapi return information.

Is there a way to get the batch numbers to return in the BAPI_GOODSMVT_CREATE bapi? If so, please let me know. If not, please also let me know and I will do a subsequent look-up to get that info.

Thanks

2 REPLIES 2
Read only

pole_li
Active Participant
0 Likes
913

Hi,

As far as I know, BAPI_GOODSMVT_CREATE will not return the batch number, You need to do a subsequent look-up.

Read only

Former Member
0 Likes
913

BAPI_GOODSMVT_CREATE will return the material document number posted. Use that to get the batch number from table MSEG.


CALL FUNCTION 'BAPI_GOODSMVT_CREATE'
  EXPORTING
    GOODSMVT_HEADER  = LS_GOODSMVT_HEADER
    GOODSMVT_CODE    = LS_GOODSMVT_CODE
  IMPORTING
    GOODSMVT_HEADRET = LS_GOODSMVT_HEADRET
  TABLES
    GOODSMVT_ITEM    = LT_GOODSMVT_ITEM
    RETURN           = LT_RETURN.

IF LS_GOODSMVT_HEADRET-MAT_DOC IS NOT INITIAL.
  CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
    EXPORTING
      WAIT   = GC_TRUE
    IMPORTING
      RETURN = LS_RETURN.
  SELECT SINGLE CHARG FROM MSEG INTO LV_CHARG
          WHERE MBLNR EQ LS_GOODSMVT_HEADRET-MAT_DOC
            AND ZEILE EQ '0001'.
ENDIF.

*Assumes single item document posted