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

Help with BAPI_GOODSMVT_CREATE

danny_loo
Participant
0 Likes
723

Hi all,

I'm trying to use the function BAPI_GOODSMVT_CREATE to do a batch iput for transfer posting when i was hit with this error.

Function module "BAPI_GOODSMVT_CREATE" was called with the parameter "GOODSMVT_HEADRET". This parametter is not defined.

I have define the parameter in my code so I'm not sure why it's not defined.

Below is my code for your reference.

REPORT  zbapi_goodsmovement.

parameters: p_file like rlgrap-filename default
                                 'd:\sapdata\TEST.xls'.
parameters: e_file like rlgrap-filename default
                                 'd:\sapdata\gdsmvterror.txt'.

parameters: xpost like sy-datum default sy-datum.

data: fname(40),
      w_line TYPE i VALUE 1,
      w_file TYPE rlgrap-filename.

data: t_tab LIKE
      TABLE OF ALSMEX_TABLINE
      WITH HEADER LINE.

data: fs_tab LIKE LINE OF t_tab.

data: begin of gmhead.
        include structure bapi2017_gm_head_01.
data: end of gmhead.

data: begin of gmcode.
        include structure bapi2017_gm_code.
data: end of gmcode.

data: begin of mthead.
        include structure bapi2017_gm_head_ret.
data: end of mthead.

data: begin of itab occurs 100.
        include structure bapi2017_gm_item_create.
data: end of itab.

data: begin of errmsg occurs 10.
        include structure bapiret2.
data: end of errmsg.

data: wmenge like iseg-menge,
      errflag.

data: begin of pcitab occurs 100,
        ext_doc(10),           "External Document Number
        mvt_type(3),           "Movement Type
        doc_date(8),           "Document Date
        post_date(8),          "Posting Date
        plant(4),              "Plant
        material(18),          "Material Number
        qty(13),               "Quantity
        recv_loc(4),           "Receiving Location
        issue_loc(4),          "Issuing Location
        pur_doc(10),           "Purchase Document No
        po_item(3),            "Purchase Document Item No
        del_no(10),            "Delivery Purchase Order Number
        del_item(3),           "Delivery Item
        prod_doc(10),          "Production Document No
        scrap_reason(10),      "Scrap Reason
        upd_sta(1),            "Update Status
      end of pcitab.

CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
  EXPORTING
    filename                      = p_file
    i_begin_col                   = 1
    i_begin_row                   = 1
    i_end_col                     = 10
    i_end_row                     = 1000
  tables
    intern                        = t_tab
 EXCEPTIONS
   INCONSISTENT_PARAMETERS       = 1
   UPLOAD_OLE                    = 2
   OTHERS                        = 3
          .
IF sy-subrc EQ 0.
message e010(zz) with text-001. "Problem uploading Excel Spreadsheet

ELSE.
  WRITE: 'UPLOAD SUCCESSFUL'.
ENDIF.

fname = '.\z_file.xls'.
OPEN DATASET fname FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
LOOP AT t_tab INTO fs_tab.
  TRANSFER fs_tab TO fname.
ENDLOOP.

IF sy-subrc EQ 0.
  WRITE: / 'FILE OPENED ON APPS SERVER'.
ELSE.
  WRITE: / 'FILE COULD NOT BE OPENED'.
ENDIF.

gmhead-pstng_date = sy-datum.
gmhead-doc_date = sy-datum.
gmhead-pr_uname = sy-uname.
gmcode-gm_code = '04'.               "04 - MB1B - Transfer Posting

loop at pcitab.
  itab-move_type  = pcitab-mvt_type.
  itab-mvt_ind    =                  "  - Goods movement w/o reference
  itab-plant      = pcitab-plant.
  itab-material   = pcitab-material.
  itab-entry_qnt  = pcitab-qty.
  itab-move_stloc = pcitab-recv_loc.
  itab-stge_loc   = pcitab-issue_loc.
  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.

loop at itab.
  write:/ itab-material, itab-plant, itab-stge_loc,
          itab-move_type, itab-entry_qnt, itab-entry_uom,
          itab-entry_uom_iso, itab-po_number, itab-po_item,
                                              pcitab-ext_doc.
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.
  endif.
endif.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
605

Hi

IMPORTING statement was commented in your code , it should be like this...



 IMPORTING                         " Uncomment by Prabhu
    goodsmvt_headret            = mthead


regards

Prabhu

2 REPLIES 2
Read only

Former Member
0 Likes
606

Hi

IMPORTING statement was commented in your code , it should be like this...



 IMPORTING                         " Uncomment by Prabhu
    goodsmvt_headret            = mthead


regards

Prabhu

Read only

0 Likes
604

Thanks Prabhu!