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: 

call func 'BAPI_GOODSMVT_CREATE' problem

Former Member
0 Kudos
789

hi

ı have a trouble with 'BAPI_GOODSMVT_CREATE'

in this code its giving error like this "Error in function

Update control of movement type is incorrect (entry 301 X X _ Q)"

ı give manually in migo it says ok



FORM bapi.
if sy-subrc <> 0.
  message id sy-msgid type sy-msgty number sy-msgno
          with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  exit.
endif.


gmhead-pr_uname = sy-uname.
gmcode-gm_code = '04'.   "01 - MB01 - Goods Receipts for Purchase Order



loop at gt_out.
  itab-move_type  = '301'.
  itab-mvt_ind    = 'Q'.
  itab-plant      = gt_out-werks.
  itab-material   = gt_out-maktx .
  itab-entry_qnt  = gt_out-erfmg.
  itab-move_stloc = gt_out-tlgort.
  itab-stge_loc   = gt_out-flgort.
  itab-BATCH      = gt_out-charg.
  itab-WBS_ELEM   = gt_out-wbs.
  itab-VAL_TYPE   = gt_out-charg.
  gmhead-pstng_date = gt_out-postd.
gmhead-doc_date = gt_out-doc_d.
*  itab-po_number  = pcitab-pur_doc.
*  itab-po_item    = pcitab-po_item.
*  concatenate pcitab-del_no pcitab-del_item into itab-item_text.
*  itab-move_reas  = pcitab-scrap_reason.

  append itab.
endloop.


call function 'BAPI_GOODSMVT_CREATE'
  exporting
    goodsmvt_header             = gmhead
    goodsmvt_code               = gmcode
*   TESTRUN                     = ' '
 IMPORTING
    goodsmvt_headret            = mthead
*   MATERIALDOCUMENT            =
*   MATDOCUMENTYEAR             =
  tables
    goodsmvt_item               = itab
*   GOODSMVT_SERIALNUMBER       =
    return                      = errmsg
          .
clear errflag.
loop at errmsg.
  if errmsg-type eq 'E'.
    write:/'Error in function', errmsg-message.
    errflag = 'X'.
  else.
    write:/ errmsg-message.
  endif.
endloop.

if errflag is initial.
  commit work and wait.
  if sy-subrc ne 0.
    write:/ 'Error in updating'.
    exit.
  else.
    write:/ mthead-mat_doc, mthead-doc_year.
*    perform upd_sta.
  endif.
endif.

ENDFORM.

4 REPLIES 4

Former Member
0 Kudos
127

Hi,

Once go through the function module documentation, it will help you a lot.

pass movement indicator as 'B' and check once again

loop at gt_out.

itab-move_type = '301'.

itab-mvt_ind = 'Q'. <----


'B'

0 Kudos
127

hi

@Parupelly

when ı set 'Q' to 'B' it will want me a PO number but this items dont have any po number

now ı dont set any 'itab-mvt_ind ' and error occurs to this "WBS is neither a billing element nor an account assignment element"

0 Kudos
127

problem resolved

change wbs element with code is below

all problems resolved


itab-val_wbs_elem   = '00009001'.
*numan p_wbs düzeltme
   itab-wbs_elem       = '00009001'.
   itab-spec_mvmt      = 'R'.
*numanitab-val_wbs_elem -->itab-wbs_elem.

*  itab-po_number  = pcitab-pur_doc.
*  itab-po_item    = pcitab-po_item.
*  concatenate pcitab-del_no pcitab-del_item into itab-item_text.
*  itab-move_reas  = pcitab-scrap_reason.
perform conversion_exit_abpsp_output
                   changing  :
                               itab-val_wbs_elem.
    perform conversion_exit_abpsp_output
                   changing  :
                              itab-wbs_elem.


form conversion_exit_abpsp_output      using p_value.
  call function 'CONVERSION_EXIT_ABPSP_OUTPUT'
    exporting
      input  = p_value
    importing
      output = p_value.

endform.                    " CONVERSION_EXIT

eduardo_hinojosa
Active Contributor
0 Kudos
127

Hi

See also SAP Note 520813 - FAQ: BAPIs for goods movements

Regards

Eduardo