Skip to Content
0
Former Member
Mar 25, 2008 at 02:11 PM

call BAPI_GOODSMVT_CREATE to create a goods receipt for purchase order

3657 Views

Hi,

I'm calling the bapi BAPI_GOODSMVT_CREATE to create a goods receipt for purchase order, but the following code doesn't work. It doesn't give me any kind of error message but it does nothing as well...

Can anyone help me please?

Thank You

Hugo

Code

DATA: wa_goodsmvt_header LIKE bapi2017_gm_head_01,

wa_goodsmvt_code LIKE bapi2017_gm_code,

wa_bapi2017_gm_head TYPE bapi2017_gm_head_ret-mat_doc.

DATA: it_goodsmvt_item LIKE bapi2017_gm_item_create OCCURS 0 WITH HEADER LINE,

it_return LIKE bapiret2 OCCURS 0 WITH HEADER LINE.

wa_goodsmvt_header-pstng_date = SY-DATUM.

wa_goodsmvt_header-doc_date = SY-DATUM.

wa_goodsmvt_header-ref_doc_no = '4500000020'.

wa_goodsmvt_code-gm_code = '01'. "Goods receipt for purchase Order

it_goodsmvt_item-stge_loc = 'BPF2'.

it_goodsmvt_item-move_type = '101' .

it_goodsmvt_item-entry_qnt = 17.

it_goodsmvt_item-entry_uom = 'KG'.

it_goodsmvt_item-mvt_ind = 'B'.

it_goodsmvt_item-po_number = '4500000020'.

it_goodsmvt_item-po_item = '00010'.

it_goodsmvt_item-material = '50'.

APPEND it_goodsmvt_item.

CALL FUNCTION 'BAPI_GOODSMVT_CREATE'

EXPORTING

goodsmvt_header = wa_goodsmvt_header

goodsmvt_code = wa_goodsmvt_code

IMPORTING

materialdocument = wa_bapi2017_gm_head

TABLES

goodsmvt_item = it_goodsmvt_item

return = it_return.

data: begin of errmsg occurs 10.

include structure bapiret2.

data: end of errmsg.

data: wmenge like iseg-menge,

errflag.

clear errflag.

loop at errmsg.

if errmsg-type eq 'E'.

write:/'Error in function', errmsg-message.

errflag = 'X'.

else.

write:/ errmsg-message.

endif.

endloop.

if errflag is initial.

commit work and wait.

if sy-subrc ne 0.

write:/ 'Error in updating'.

exit.

else.

write:/ 'Ok'.

endif.

endif.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

wait = ' '.