Skip to Content
0
Former Member
May 17, 2016 at 02:23 PM

BAPI_GOODSMVT_CREATE

345 Views

Hello Everyone.

I have a requirement to perform bapi_goodsmvt_create for Movement type 562.

But I'm getting an error in i_return table saying 'No items transferred'. Why is that? Can anyone help me out?

And this is my code:

READ TABLE i_item1 INTO k_item1 WITH KEY mark = 'X'.

IF k_item1-mark = 'X' AND k_item1-pstyv = 'YTAS'.

SELECT a~ebeln a~ebelp INTO TABLE i_ekknbatch FROM

EKKN AS a INNER JOIN VBAP AS b ON a~vbeln = b~vbeln WHERE

a~vbeln = k_headermp-vbeln AND a~vbelp = k_item1-posnr AND b~pstyv = 'YTAS'.

READ TABLE i_ekknbatch INTO k_ekknbatch INDEX 1.

IF sy-subrc = 0.

SELECT COUNT(*) FROM EKET WHERE

WEMNG = '0' AND EBELN = k_ekknbatch-ebeln AND ebelp = k_ekknbatch-ebelp.

IF sy-subrc <> 0.

MESSAGE s004(zflip) DISPLAY LIKE 'E'.

LEAVE TO SCREEN 0100.

ELSE.

SELECT MATNR CHARG LIFNR BDMNG FROM RESB into TABLE i_resbbatch WHERE

ebeln = k_ekknbatch-ebeln AND ebelp = k_ekknbatch-ebelp.

READ TABLE i_resbbatch INTO k_resbbatch INDEX 1.

IF sy-subrc = 0.

REFRESH: i_return.

CLEAR: k_return.

""Populate Header

MOVE: sy-datlo TO k_goodsmvt_header-pstng_date,

sy-datlo TO k_goodsmvt_header-doc_date,

sy-uname TO k_goodsmvt_header-pr_uname.

""Populate Code

MOVE: c_gmcode TO k_goodsmvt_code-gm_code. "c_gmcode is '01'

""Populate Items

MOVE: k_resbbatch-matnr TO k_goodsmvt_item-material,

k_resbbatch-charg TO k_goodsmvt_item-batch,

k_resbbatch-lifnr TO k_goodsmvt_item-vendor,

k_resbbatch-bdmng TO k_goodsmvt_item-entry_qnt,

c_bwart TO k_goodsmvt_item-move_type. "c_bwart 9s '562'

APPEND k_resbbatch TO i_resbbatch.

CALL FUNCTION 'BAPI_GOODSMVT_CREATE'

EXPORTING

GOODSMVT_HEADER = k_goodsmvt_header

GOODSMVT_CODE = k_goodsmvt_code

* TESTRUN = ' '

* GOODSMVT_REF_EWM

IMPORTING

GOODSMVT_HEADRET = k_goodsmvt_headret

MATERIALDOCUMENT = k_materialdocument

MATDOCUMENTYEAR = k_matdocumentyear

TABLES

GOODSMVT_ITEM = i_goodsmvt_item

* GOODSMVT_SERIALNUMBER =

RETURN = i_return.

* GOODSMVT_SERV_PART_DATA =

* EXTENSIONIN =

LOOP AT i_return INTO k_return WHERE type = 'E'.

g_error = 'X'.

CALL FUNCTION 'FORMAT_MESSAGE'

EXPORTING

id = k_return-id

lang = sy-langu

no = k_return-number

v1 = k_return-message_v1

v2 = k_return-message_v2

v3 = k_return-message_v3

v4 = k_return-message_v4

IMPORTING

msg = v_msg

EXCEPTIONS

not_found = 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.

CONCATENATE text-047 v_msg INTO v_msg .

MESSAGE v_msg TYPE 'E'.

ENDLOOP.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.

* EXPORTING

* WAIT =

* IMPORTING

* RETURN = .

ENDIF.

ENDIF.

ENDIF.

ENDIF.

ENDIF.