Skip to Content
0
Former Member
Jan 29, 2009 at 04:48 AM

'BAPI_GOODSMVT_CREATE'

132 Views

hi,

how can i get the no. of goods successfully posted. and the no. of failed goods movement.

Even though there are numerous postings on the BAPI itself but I could not find something relevant to this issue.

here is my code.

data: rno type rkpf-rsnum,

itno type rkpf-kdpos.

&----


*& Module USER_COMMAND_0100 INPUT

&----


  • text

----


module USER_COMMAND_0100 input.

if sy-ucomm = 'F4'.

perform check_screen_0100.

elseif sy-ucomm = 'F2'.

clear rno.

clear itno.

elseif sy-ucomm = 'F3'.

exit.

endif.

endmodule. " USER_COMMAND_0100 INPUT

&----


*& Form check_screen_0100

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form check_screen_0100 .

select rsnum kdpos from rkpf into (rno,itno) where rsnum = rno and

kdpos = itno.

endselect.

if sy-subrc ne 0.

CALL FUNCTION 'CALL_MESSAGE_SCREEN'

EXPORTING

I_MSGID = 'ZDHRUV'

i_lang = 'E'

i_msgno = '001'

  • I_MSGV1 =

  • I_MSGV2 =

  • I_MSGV3 =

  • I_MSGV4 =

  • I_SEPERATE = ' '

  • I_CONDENSE = ' '

  • I_MESSAGE_SCREEN = '0999'

  • I_LINE_SIZE = 0

  • I_LINES = 0

I_NON_LMOB_ENVT = 'X'

  • I_MODPL =

  • IMPORTING

  • O_ANSWER =

  • TABLES

  • T_MSG_TEXT =

  • EXCEPTIONS

  • INVALID_MESSAGE1 = 1

  • OTHERS = 2

.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

else.

types: begin of mblb,

rsnum like rkpf-rsnum,

kdpos like rkpf-kdpos,

kdauf like rkpf-kdauf,

end of mblb.

data: it_mblb type standard table of mblb,

wa_mblb type mblb.

move rno to wa_mblb-rsnum.

move itno to wa_mblb-kdpos.

append wa_mblb to it_mblb.

data : goodsmvt_header type bapi2017_gm_head_01 .

data : goodsmvt_code type bapi2017_gm_code .

*data : it_headret type bapi2017_gm_head_ret.

*data : materialdocument type bapi2017_gm_head_ret-mat_doc .

*data : matdocumentyear type bapi2017_gm_head_ret-doc_year .

data : goodsmvt_item type table of bapi2017_gm_item_create .

data : gw_goodsmvt_item type bapi2017_gm_item_create .

data : return type table of bapiret2 .

data : gw_return type bapiret2 .

*Fill Header Data

goodsmvt_header-pstng_date = sy-datum .

goodsmvt_header-doc_date = sy-datum .

*Fill Movement Code This you have to fill as per you requirement

goodsmvt_code = '04' .

loop at it_mblb into wa_mblb.

if wa_mblb-kdauf is not initial.

*select rsnum kdpos from rkpf into table goodsmvt_item.

move wa_mblb-rsnum to gw_goodsmvt_item-reserv_no.

move wa_mblb-kdpos to gw_goodsmvt_item-s_ord_item.

  • CHECK SY-SUBRC EQ 0.

gw_goodsmvt_item-MOVE_TYPE = '311+E'.

gw_goodsmvt_item-mvt_ind = ' '.

append gw_goodsmvt_item to goodsmvt_item.

*endif.

else.

select rsnum kdpos from rkpf into table goodsmvt_item.

CHECK SY-SUBRC EQ 0.

gw_goodsmvt_item-MOVE_TYPE = '311'.

gw_goodsmvt_item-mvt_ind = ' '.

append gw_goodsmvt_item to goodsmvt_item.

endif.

endloop.

CALL FUNCTION 'BAPI_GOODSMVT_CREATE'

EXPORTING

GOODSMVT_HEADER = goodsmvt_header

GOODSMVT_CODE = goodsmvt_code

  • TESTRUN = ' '

  • GOODSMVT_REF_EWM =

  • IMPORTING

  • GOODSMVT_HEADRET = it_headret

  • MATERIALDOCUMENT = materialdocument

  • MATDOCUMENTYEAR = matdocumentyear

TABLES

GOODSMVT_ITEM = goodsmvt_item

  • GOODSMVT_SERIALNUMBER =

RETURN = return

  • GOODSMVT_SERV_PART_DATA =

  • EXTENSIONIN =

.

*if sy-subrc = 0.

*CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

  • EXPORTING

  • WAIT = 'X'

  • IMPORTING

  • RETURN =

  • .

*endif.

LOOP AT return into gw_return.

WRITE:/ gw_return-type, gw_return-id, gw_return-number,

gw_return-message.

ENDLOOP.

endif.

endform. " check_screen_0100