Application Development and Automation 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: 
Read only

Goods receipt against an Work Order using BAPI_GOODSMVT_CREATE not reflecting in the Actual cost of the WORK Order

Former Member
0 Kudos
1,095

I am doing a PGR against Work Order using the BAPI_GOODSMVT_CREATE using Movement Type 262, GM Code : 5,Valuation Type :C3

Though the Material document is getting created successfully but it is not reflecting the actual Cost against the order.

Please find my code below:

  lwa_code-gm_code = lc_gm_code. "'05' ."Goods Receipt for Other orders
  "order->can be used for maintenance order too.

  l_aufnr      = v_aufnr.
  l_aufnr_itno  = v_posnr.
  l_plant      = v_to_plant.
  l_lgort      = v_from_sloc.
  l_lgort_to    = v_to_sloc.
  l_quantity    = v_erfmg.
  l_uom        = v_erfme.
*
**** Header
  lwa_header-pstng_date = v_budat .
  lwa_header-doc_date  = v_bldat .
  lwa_header-pr_uname  = sy-uname .
  lwa_header-header_txt = v_bktxt.

*** Item
  CLEAR lwa_item  .
  lwa_item-move_type  = lc_mov_262. "'262' ->fixed for PGR
  lwa_item-val_type  = lc_val_typ. "'C3'.

**** Order Details
  lwa_item-orderid      = l_aufnr.
  lwa_item-order_itno    = l_aufnr_itno.
  lwa_item-plant        = l_plant.
  lwa_item-stge_loc      = l_lgort_to.
  lwa_item-move_stloc    = l_lgort_to.
  lwa_item-entry_qnt    = l_quantity.
*  lwa_item-batch        = lc_val_typ.
  lwa_item-entry_uom_iso = l_uom.
  lwa_item-entry_uom    = l_uom.
  lwa_item-item_text    = v_sgtxt.
  CLEAR l_matnr.
  CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
    EXPORTING
      input        = v_matnr
    IMPORTING
      output      = l_matnr
    EXCEPTIONS
      length_error = 1.
  IF sy-subrc IS INITIAL.
    lwa_item-material  = l_matnr.
  ENDIF. " IF sy-subrc IS INITIAL
*
  APPEND lwa_item TO li_item_pgr .
  CLEAR  lwa_item.

    lwa_serno-matdoc_itm = '1'.
    lwa_serno-serialno  = lwa_serial-gr_gernr.
    APPEND lwa_serno TO fp_li_serial_pgr.


  CALL FUNCTION 'BAPI_GOODSMVT_CREATE'
    EXPORTING
      goodsmvt_header      = lwa_header
      goodsmvt_code        = lwa_code
    IMPORTING
      goodsmvt_headret      = lwa_hedret
    TABLES
      goodsmvt_item              = li_item_pgr[]
      goodsmvt_serialnumber = fp_li_serial_pgr[]
      return                = li_ret[].

2 REPLIES 2
Read only

0 Kudos
323

Hi,

  1. Material Document no getting generated?
  2. Use  BAPI_TRANSACTION_COMMIT

CALL FUNCTION 'BAPI_GOODSMVT_CREATE'

     EXPORTING

       goodsmvt_header  = LS_HEADER

       goodsmvt_code    = LS_GM_CODE

     IMPORTING

       materialdocument = lv_mat_doc

       matdocumentyear  = lv_mat_year

     TABLES

       goodsmvt_item    = lt_items

       return           = lt_return_goods.


IF LV_mat_doc IS not INITIAL.

     CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' .

   ENDIF.

Regards,

Sathsih kumar Elumalai

Read only

0 Kudos
323

Hi Sathish,

Yeah i have already commited the Bapi.

Material Document is getting generated successfully but the Order actual cost is not getting reflected.