Skip to Content

PRoblem when posting more than one document

Hi all,

I'm using BAPI BAPI_GOODSMOVEMENT_CREATE to post the documents for PO_GR.when i post one document through text file it is done succesfuully. when i'm posting more than one document it is giving error "posting not possible".

My code is as follows:

loop at i_data.

concatenate '0' i_data-stor_loc into i_data-stor_loc.

concatenate '00' i_data-plant into i_data-plant.

i_item-po_number = i_data-po_no.

i_item-po_item = i_data-po_item.

i_item-move_type = i_data-mvt_type.

i_head-doc_date = doc_date.

i_head-pstng_date = post_date.

i_head-ref_doc_no = i_data-del_note.

i_item-entry_qnt = i_data-entry_qty.

i_item-stge_loc = i_data-stor_loc.

i_item-plant = i_data-plant.

i_item-stck_type = i_data-stk_type.

i_item-batch = i_data-batch.

  • I_ITEM-move_val_type = i_data-move_batch.

APPEND: i_item,i_head.

CLEAR:i_item.

ENDLOOP.

CALL FUNCTION 'BAPI_GOODSMVT_CREATE'

EXPORTING

goodsmvt_header = i_head

goodsmvt_code = i_code

  • TESTRUN = ' '

IMPORTING

  • GOODSMVT_HEADRET =

MATERIALDOCUMENT = matdoc

  • MATDOCUMENTYEAR =

tables

goodsmvt_item = i_item

  • GOODSMVT_SERIALNUMBER =

return = return

.

IF return IS INITIAL.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.

ENDIF.

LOOP AT return.

WRITE: return-message.

ENDLOOP.

WRITE: matdoc.

PLease specify where i'm going wrong.

Regards,

SImha.

Add a comment
10|10000 characters needed characters exceeded

Related questions

3 Answers

  • Posted on Apr 11, 2006 at 09:06 AM

    HI Narasimha,

    I assume that i_data is the internal table that has all the records that are uploaded.

    so, you need to refresh the i_item, i_head etc for each set (for which you want to create a Goods movement doc).

    Are you refreshing the i_item ,i_hed???

    And the condition you are checking for commiting the transaction is not reliable.

    the return structure may have success messages some times.

    Regards,

    Ravi

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Apr 11, 2006 at 09:10 AM

    Hi,

    Using the BAPI you can post one document at a time. So, if you have got more data in the field, upload that into table. loop at the table and call the BAPI inside the loop.

    Also, i_head doesn't seem to a TABLE parameter in the BAPI, then why have declared it as TABLE.

    Can you give the structures of i_head and i_item.

    Regards,

    Ravi

    Note : Please mark the helpful answers.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Apr 11, 2006 at 09:13 AM

    Hi,

    I had used the same FM to post multiple documents, but never faced this error.

    *- Header

    MOVE: sy-datum TO bapigm_head-pstng_date,

    sy-datum TO bapigm_head-doc_date,

    sy-uname TO bapigm_head-pr_uname,

    v_mblnr TO bapigm_head-ref_doc_no,

    con_bfwms_bestand TO bapigm_head-ext_wms.

    *- Item

    *- Populate item data

    LOOP AT i_items_trans.

    CLEAR ibapigm_item.

    *- Convert the matnr backto 18 char form (External)

    CALL FUNCTION 'CONVERSION_EXIT_MATN2_INPUT'

    EXPORTING

    input = i_items_trans-matnr

    IMPORTING

    output = i_items_trans-matnr

    EXCEPTIONS

    number_not_found = 1

    length_error = 2

    OTHERS = 3.

    IF sy-subrc <> 0.

    • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

    • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

    ENDIF.

    ibapigm_item-material = i_items_trans-matnr.

    ibapigm_item-plant = i_items_trans-werks.

    ibapigm_item-stge_loc = i_items_trans-lgort.

    ibapigm_item-move_type = '101'. "Goods Receipt

    ibapigm_item-mvt_ind = 'B'. "Goods Movement for PO

    ibapigm_item-po_number = i_items_trans-ebeln.

    ibapigm_item-po_item = i_items_trans-ebelp.

    ibapigm_item-entry_qnt = i_items_trans-ktmng.

    ibapigm_item-entry_uom = i_items_trans-meins.

    APPEND ibapigm_item.

    ENDLOOP.

    *-Call FM

    CALL FUNCTION 'BAPI_GOODSMVT_CREATE'

    EXPORTING

    goodsmvt_header = bapigm_head

    goodsmvt_code = bapigm_code

    IMPORTING

    goodsmvt_headret = bapigm_headret

    TABLES

    goodsmvt_item = ibapigm_item

    return = ibapigm_ret.

    *- Commit on Success

    IF NOT bapigm_headret-mat_doc IS INITIAL.

    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.

    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.