Skip to Content
author's profile photo Former Member
Former Member

Can any one say What are the mandatory parameters in BAPI_GOODSMVT_CREATE

Hi,

Can any one say What are the mandatory parameters in

BAPI_GOODSMVT_CREATE.

Helpful answer will be rewarded.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

5 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on May 20, 2008 at 09:57 AM

    Hi,

    Here is some sample code from one of my programs, which does a 551 movement type. This should get you started. Just check the RETURN table for messages, they should tell you what you are missing.

    code

    Structures for BAPI

    data: gm_header type bapi2017_gm_head_01.

    data: gm_code type bapi2017_gm_code.

    data: gm_headret type bapi2017_gm_head_ret.

    data: gm_item type table of

    bapi2017_gm_item_create with header line.

    data: gm_return type bapiret2 occurs 0.

    data: gm_retmtd type bapi2017_gm_head_ret-mat_doc.

    clear: gm_return, gm_retmtd. refresh gm_return.

    Setup BAPI header data.

    gm_header-pstng_date = sy-datum.

    gm_header-doc_date = sy-datum.

    gm_code-gm_code = '06'. " MB11

    Write 551 movement to table

    clear gm_item.

    move '551' to gm_item-move_type .

    move '000000000040001234' to gm_item-material.

    move '1' to gm_item-entry_qnt.

    move 'EA' to gm_item-entry_uom.

    move '0004' to gm_item-plant.

    move '4000' to gm_item-stge_loc.

    move '201' to gm_item-move_reas.

    Determine cost center per plant

    case xresb-werks.

    when '0004'.

    move '0000041430' to gm_item-costcenter.

    when '0006'.

    move '0000041630' to gm_item-costcenter.

    when '0007'.

    move '0000041731' to gm_item-costcenter.

    when '0008'.

    move '0000041830' to gm_item-costcenter.

    endcase.

    append gm_item.

    Call goods movement BAPI

    call function 'BAPI_GOODSMVT_CREATE'

    exporting

    goodsmvt_header = gm_header

    goodsmvt_code = gm_code

    importing

    goodsmvt_headret = gm_headret

    materialdocument = gm_retmtd

    tables

    goodsmvt_item = gm_item

    return = gm_return.

    call function 'BAPI_TRANSACTION_COMMIT'

    exporting

    wait = 'X'.

    Refer further:

    Please take a look at this links for sample coding of BAPI_GOODSMVT_CREATE.

    http://www.sap-img.com/abap/bapi-goodsmvt-create-to-post-goods-movement.htm

    http://www.4ap.de/abap/bapi_goodsmvt_create.php

    Hope this will help.

    Regards,

    Shiva Kumar

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 20, 2008 at 09:53 AM

    hi,

    CALL FUNCTION 'BAPI_GOODSMVT_CREATE'
        EXPORTING
          goodsmvt_header  = lwa_goodsmvt_header
          goodsmvt_code    = lwa_goodsmvt_code
        IMPORTING
          materialdocument = g_material_doc
          matdocumentyear  = g_matdoc_year
        TABLES
          goodsmvt_item    = li_goodsmvt_item
          return           = i_return.

    These are the mandatory segments.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on May 20, 2008 at 09:57 AM

    Hi,

    CALL FUNCTION 'BAPI_GOODSMVT_CREATE'

    EXPORTING

    goodsmvt_header = it_header

    goodsmvt_code = '05'

    testrun = ' '

    IMPORTING

    goodsmvt_headret = st_headret

    materialdocument = st_doc

    matdocumentyear = st_year

    TABLES

    goodsmvt_item = it_item

    return = i_return.

    Regards,

    Bharat

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 20, 2008 at 09:58 AM

    Hi,

    Please take a look at this links for sample coding of BAPI_GOODSMVT_CREATE.

    http://www.sap-img.com/abap/bapi-goodsmvt-create-to-post-goods-movement.htm

    http://www.4ap.de/abap/bapi_goodsmvt_create.php

    Regards

    Kiran Sure

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 20, 2008 at 10:08 AM

    Hi,

    The following is an abap program making used of the BAPI function BAPI_GOODSMVT_CREATE to do Goods Receipts for Purchase Order after importing the data from an external system.

    *

    • BAPI TO Upload Inventory Data

    *

    • GMCODE Table T158G - 01 - MB01 - Goods Receipts for Purchase Order

    • 02 - MB31 - Goods Receipts for Prod Order

    • 03 - MB1A - Goods Issue

    • 04 - MB1B - Transfer Posting

    • 05 - MB1C - Enter Other Goods Receipt

    • 06 - MB11

    *

    • Domain: KZBEW - Movement Indicator

    • Goods movement w/o reference

    • B - Goods movement for purchase order

    • F - Goods movement for production order

    • L - Goods movement for delivery note

    • K - Goods movement for kanban requirement (WM - internal only)

    • O - Subsequent adjustment of "material-provided" consumption

    • W - Subsequent adjustment of proportion/product unit material

    *

    report zbapi_goodsmovement.

    parameters: p-file like rlgrap-filename default

    'c:\sapdata\TEST.txt'.

    parameters: e-file like rlgrap-filename default

    'c:\sapdata\gdsmvterror.txt'.

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

    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 'WS_UPLOAD'

    exporting

    filename = p-file

    filetype = 'DAT'

    • IMPORTING

    • FILELENGTH =

    tables

    data_tab = pcitab

    • EXCEPTIONS

    • FILE_OPEN_ERROR = 1

    • FILE_READ_ERROR = 2

    • NO_BATCH = 3

    • GUI_REFUSE_FILETRANSFER = 4

    • INVALID_TYPE = 5

    • OTHERS = 6

    .

    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-pstng_date = sy-datum.

    gmhead-doc_date = sy-datum.

    gmhead-pr_uname = sy-uname.

    gmcode-gm_code = '01'. "01 - MB01 - Goods Receipts for Purchase Order

    loop at pcitab.

    itab-move_type = pcitab-mvt_type.

    itab-mvt_ind = 'B'.

    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.

    perform upd_sta.

    endif.

    endif.

    ----


    • FORM UPD_STA *

    ----


    • ........ *

    ----


    form upd_sta.

    loop at pcitab.

    pcitab-upd_sta = 'X'.

    modify pcitab.

    endloop.

    call function 'WS_DOWNLOAD'

    exporting

    filename = p-file

    filetype = 'DAT'

    • IMPORTING

    • FILELENGTH =

    tables

    data_tab = pcitab

    • EXCEPTIONS

    • FILE_OPEN_ERROR = 1

    • FILE_READ_ERROR = 2

    • NO_BATCH = 3

    • GUI_REFUSE_FILETRANSFER = 4

    • INVALID_TYPE = 5

    • OTHERS = 6

    .

    endform.

    *--- End of Program

    Reward for useful answers.

    Regards,

    Raj.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.