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: 

How to pass custom movement type to BAPI - BAPI_GOODSMVT_CREATE

Former Member
0 Kudos

Hi Experts,

I would like to know how to pass the customized movement type "Z62" to the BAPI - BAPI_GOODSMVT_CREATE to create a material document. We want to pass this movement type ("Z62") in the table parameter GOODSMVT_ITEM.

This is the custom build movement type in SAP to reverse the goods which are consumed to the blocked status. Once we use this movement type for reversal, the consumed materials are moved to blocked status which we donu2019t want to use it again.

When we try to create the material document manually in SAP, we are able to create the material document successfully. If we pass the movement type as "Z62" and if I set the flag XSTOB to true, this BAPI is converting the movement type to "262" instead of the movement type "Z62" and creating the material document for the movement type as "262".

Please let us know how to pass the customized movement type to the BAPI - BAPI_GOODSMVT_CREATE to create the material document for the same movement type.

Please mention the fields in the structure GOODSMVT_ITEM that needs to be set for creating the material document with the same movement type which we are passing.

Thanks in Advance,

Mohan.

4 REPLIES 4

deepak_dhamat
Active Contributor
0 Kudos

Hi ,

This is we have done for Dispatch Movement ...

it_zhead-pstng_date = sy-datum.
      it_zhead-doc_date = sy-datum.
      APPEND it_zhead.

      gm = '04'.

      it_zitem-material = it_zdisp-zcompo.
      it_zitem-plant = it_zdisp-werks.
      it_zitem-stge_loc = it_zdisp-lgort.
      it_zitem-batch = it_zdisp-charg.
      it_zitem-move_type = '541'.
      it_zitem-vendor = it_zdisp-lifnr.
      it_zitem-entry_qnt = it_zdisp-zcompo_qty.
      it_zitem-po_number = it_zdisp-ebeln.
      it_zitem-item_text = it_zdisp-remark.
      APPEND it_zitem.

*** code for testing  ....
      CALL FUNCTION 'BAPI_GOODSMVT_CREATE'
        EXPORTING
          goodsmvt_header             = it_zhead
          goodsmvt_code               = gm
*          testrun                     = ' '
         IMPORTING
           goodsmvt_headret            = it_zheadret
           materialdocument            = matdoc
           matdocumentyear             = matyr
        TABLES
          goodsmvt_item               = it_zitem
*         goodsmvt_serialnumber       =
          return                      = it_zreturn.

      IF   it_zreturn[] IS INITIAL.

*        COMMIT WORK.
        CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
          EXPORTING
            wait   = ''
          IMPORTING
            return = return.



*      ENDIF.

regards

Deepak.

Edited by: Deepak Dhamat on Aug 29, 2011 12:26 PM

Former Member
0 Kudos

Hi,

Along with the custom Movement type you also have to pass corresponding Movement Code. Its documentation is available in BAPI Document. Please check documentation and take help of your functional consultant to determine correct GM_CODE.

Thanks,

Sai Ramesh.

0 Kudos

Hi Sai Ramesh,

Thanks for your reply.

Could you please clarify my doubt. While debugging the standard BAPI - BAPI_GOODSMVT_CREATE, I found that, the movement type is changed from "Z62"/"262" to "261" since it is trying to fetch the material details from RESB table based on the material number. The movement type for the material is maintained as "261" and hence it is over writing the existing movement type which we are sending while executing the BAPI.

The movement type "262" is working fine if we set the field XSTOB to true. If I remove this flag and changed the code GM_CODE to 04, I'm getting the error as "Goods Movement movement impossible with class 261".

Please let me know your views on this.

Thanks,

Mohan.

raymond_giuseppi
Active Contributor
0 Kudos

Don't forget to check the check customizing tables behind the BAPI - [Note 520813 - FAQ: BAPIs for goods movements|https://service.sap.com/sap/support/notes/520813]

- Look in table T158G to find gm_code relation to transaction (MB1A is '03' when MB1B is '04')

- Look in table T158B for transaction(s) allowed to movement '262' or 'Z62' (transaction OMJJ)

Regards,

Raymond