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 with move_type = 101 & mvt_ind = B not working

former_member226999
Contributor
0 Kudos

Hi Experts,

I have this program which is not working in our system. The problem is it dose not post any records and dose not return any error messages.

Can some one point out why this dose not post any records for a delivery or ASN?


*&---------------------------------------------------------------------*
*& Report  ZFY_TEST2
*&---------------------------------------------------------------------*
REPORT  zfy_test2 MESSAGE-ID zmm1.
DATA: gt_goodsmvt_header  LIKE bapi2017_gm_head_01,
      gt_goodsmvt_item    LIKE bapi2017_gm_item_create OCCURS 0 WITH HEADER LINE,
      gt_return           LIKE bapiret2 OCCURS 0 WITH HEADER LINE.
DATA: gt_goodsmvt_headret LIKE bapi2017_gm_head_ret,
      goodsmvt_code_tmp   TYPE bapi2017_gm_code,
      testrun             TYPE c VALUE 'X'.
TABLES lips.

PARAMETERS p_vbeln LIKE lips-vbeln. " Delivery number

START-OF-SELECTION.
  gt_goodsmvt_header-pstng_date = sy-datum.
  gt_goodsmvt_header-doc_date   = sy-datum.

  SELECT * FROM lips INTO lips
    WHERE vbeln = p_vbeln.
***<<<<<<<<<<<BAPI Communication Structure: Material Document Header Data>>>>>>>
    gt_goodsmvt_item-material             =  lips-matnr .
    gt_goodsmvt_item-plant                =  lips-werks.
    gt_goodsmvt_item-stge_loc             =  lips-lgort.
    gt_goodsmvt_item-deliv_numb_to_search = lips-vbeln.
    gt_goodsmvt_item-deliv_item_to_search = lips-posnr.
    gt_goodsmvt_item-move_type            = lips-bwart .    "'101'.
    gt_goodsmvt_item-entry_qnt            = lips-lfimg .    "'50'.
    gt_goodsmvt_item-entry_uom            = lips-vrkme.
    gt_goodsmvt_item-mvt_ind              = lips-kzbew.
    gt_goodsmvt_item-po_number            = lips-vgbel.
    gt_goodsmvt_item-po_item              = lips-vgpos.
    gt_goodsmvt_item-no_more_gr           = 'X'.
    APPEND  gt_goodsmvt_item.
  ENDSELECT.
  goodsmvt_code_tmp =          '01'. "Assign code to transaction for BAPI goods movement
****<<<<<<<Post goods movements with MB_CREATE_GOODS_MOVEMENT>>>>>>>>>>>>>>>>>>>
  CALL FUNCTION 'BAPI_GOODSMVT_CREATE'
    EXPORTING
      goodsmvt_header          = gt_goodsmvt_header
      goodsmvt_code            = goodsmvt_code_tmp
*      testrun                  = testrun
   IMPORTING
     goodsmvt_headret          =  gt_goodsmvt_headret
    TABLES
      goodsmvt_item            = gt_goodsmvt_item
*   GOODSMVT_SERIALNUMBER       =
      return                   = gt_return.

  IF gt_return[] IS INITIAL.
    COMMIT WORK AND WAIT.
    WRITE:/3  'ASN Number', gt_goodsmvt_item-deliv_numb_to_search,
          /3  'Item',gt_goodsmvt_item-deliv_item_to_search.
  ELSE.
    read table gt_return index 1.
    WRITE: '~ERROR~',
           / gt_return-message.
  ENDIF.

<REMOVED BY MODERATOR>

Thanks,

Franc

Edited by: Franc on Aug 7, 2008 4:55 PM

Edited by: Alvaro Tejada Galindo on Aug 8, 2008 6:05 PM

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Franc

U need to use the BAPI for COMMIT (BAPI_TRANSACTION_COMMIT) after calling the BAPI_GOODSMVT_CREATE, if any error is returned it means the BAPI can post the document.

Max

5 REPLIES 5

Former Member
0 Kudos

Hi Franc

U need to use the BAPI for COMMIT (BAPI_TRANSACTION_COMMIT) after calling the BAPI_GOODSMVT_CREATE, if any error is returned it means the BAPI can post the document.

Max

0 Kudos

Hi Max

I thought commit work dose the same thing.

Ok I tried with the BAPI_TRANSACTION_COMMIT but still no luck.

Any more ideas?

Franc

0 Kudos

hi,

for goods movement code '01' you need to pass movement indicator as 'B'. If your able to get return for BAPI in SE37 by passing movement indicator as 'B' with all other inputs, then i think you need to hardcode your movement indicator as 'B' in your current program.

0 Kudos

Hi harshavardhana,

Thanks for the response.This was a test program so I specifically select the delivery's which have goods movement code '01' and movement indicator as 'B'. In my actual program I have defined constants for these values.

Now it seems that the postings are there in MSEG but it dose not update the VBUP which I expect when I have marked gt_goodsmvt_item-no_more_gr = 'X'.

Do you guys have any idea?

former_member226999
Contributor
0 Kudos

Thank you all.

Now the posting is being done but the vbup-wbsta flag is not being updated.

This being another problem I am closing this topic and start a new one.

Franc