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: 

BAPI_GOODSMVT_CREATE

Former Member
0 Kudos

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.



1 ACCEPTED SOLUTION

yogendra_bhaskar
Contributor
0 Kudos

Hi Payal ,

Internal table : i_goodsmvt_item is not containing any data.


use append statement after the below code


""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.


             append k_goodsmvt_item to i_goodsmvt_item.

Regards,

Yogendra Bhaskar

4 REPLIES 4

yogendra_bhaskar
Contributor
0 Kudos

Hi Payal ,

Internal table : i_goodsmvt_item is not containing any data.


use append statement after the below code


""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.


             append k_goodsmvt_item to i_goodsmvt_item.

Regards,

Yogendra Bhaskar

0 Kudos

I passed all the values . even them am getting error saying.  'Subsequent adjustment subcontracting: No components were transferred' . Do u have any idea what it means?

0 Kudos

Hi Payal ,

Can't say much about the error ,subsequent adjustment is to correct the component consumption .

Whereas as for Bapi , please consider below scenario :

You have to use always 2 FM.

BAPI_GOODSMVT_CREATE

BAPI_TRANSACTION_COMMIT.


Remember about authorisation for material movements.


structures

GOODSMVT_HEADER

PSTNG_DATEDOC_DATEPR_UNAME

HEADER_TXT

19.05.201619.05.2016UNAMEText of mat doc.

GOODSMVT_CODE - depands on transaction

Go to OMJJ first and check allowed tcode for material movement then choose proper one.

GM
01MB01
02MB31
03MB1A
04MB1B
05MB1C
06MB11
07MB04

GOODSMVT_ITEM

MATERIALPLANSTGEBATCHMOVENTRY_QNT
123218XXXXYYYY1234510233

Hope this will help you out.

Regards,

Yogendra Bhaskar

Former Member
0 Kudos

Thank you so much..