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: 

Cancelling Goods Movement

Former Member
0 Kudos

Hi,

I am trying to use function module BAPI_GOODSMVT_CANCEL to reverse an existing docuemnt. For the movement type it is mandatory to give the reason for movement code. The function module doesnt have a provision to import the reason code ( Field MSEG-GRUND). This there a way out or any other function module is available for this purpose. I am in SAP R/3 4.6c. The movement type we are using is a custom movement type similar to 502.

Thanks in advance for any suggestions.

Regards,

Gokul

1 ACCEPTED SOLUTION

Former Member
0 Kudos

hi,

try BAPI_GOODSMVT_CREATE this and give the movement type for reversal ..... like for GR movement type is 101 and if you want to cancel the GR ie reversal then use 102 with this FM.

Regards,

Gaurav Singh

6 REPLIES 6

former_member188685
Active Contributor
0 Kudos

Hi you need to pass the Material Doc number.

 X_MATDOCITEM-MATDOC_ITEM = '0001'.
      APPEND X_MATDOCITEM TO IT_MATDOCITEM.
      V_DOCYEAR = SY-DATUM+0(4).

      CALL FUNCTION 'BAPI_GOODSMVT_CANCEL'
        EXPORTING
           MATERIALDOCUMENT          = X_DATA-MBLNR
           MATDOCUMENTYEAR           = V_DOCYEAR
*           GOODSMVT_PSTNG_DATE       = SY-DATUM
*           GOODSMVT_PR_UNAME         = SY-UNAME
       IMPORTING
         GOODSMVT_HEADRET          = X_MVTCANCELRET
       TABLES
         RETURN                    = IT_RETURN_CANCEL
         GOODSMVT_MATDOCITEM       = IT_MATDOCITEM .
      IF IT_RETURN_CANCEL[] IS INITIAL.
        CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
        X_MESSAGE-MSGV2 = 'Goods Movement Cancelled'(014).
      ENDIF.

Former Member
0 Kudos

Hi,

I did pass the material document number and year. The issue is that the movement type requires Reason for Movement code to be entered, but I dont have provision to enter this value in BAPI_GOODSMVT_CANCEL . Is there any other function module which has provision to enter this value to reverse a material document?

Regards,

Gokul

0 Kudos

Hi Gokul,

i think it will be linked to MBLNR.

you need not to enter.

Do you want to cancel the Material Doc or not..

regards

vijay

0 Kudos

Hi Mohan,

You can use the FM BAPI_GOODSMVT_CREATE with movement indicator also specified. For eg if the original posting is 201, use 202 and if it is 261, the use 262.

See FM documentation for more help.

Regards,

Ravi

Former Member
0 Kudos

Hi,

Yes I do want to cancel the material document. While doing it in manual mode using transacitn MBST, you can see that there is a field 'Reason for Mvmt', this is mandatory in the movement type involved. The BAPI returns the message saying that 'Reason for Mvmt' need to enntered for movement type xxx. That is why I am looking for a funciton module which will also take reason for movement as input.

Regards,

Gokul

Former Member
0 Kudos

hi,

try BAPI_GOODSMVT_CREATE this and give the movement type for reversal ..... like for GR movement type is 101 and if you want to cancel the GR ie reversal then use 102 with this FM.

Regards,

Gaurav Singh