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: 

PRoblem when posting more than one document

Simha_
Employee
Employee
0 Kudos

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.

18 REPLIES 18

former_member181962
Active Contributor
0 Kudos

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

Former Member
0 Kudos

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.

Former Member
0 Kudos

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

0 Kudos

Hi all,

but y i'm getting the error <b>" posting not possible for this material??"</b>. If i post the documents individually they r getting posted.

When i upload them in same file they r giving error..

any change has to be done in the code.

please resolve..

Thanks in Advance..

Simha.

0 Kudos

Hi,

In the data from the file, how are you differentiating the header from the item data. Unless that is known, we cannot separate the header and item data.

Can you put a sample data here?

Regards,

Ravi

0 Kudos

Hi Ravi,

This is tha sample data i am paasing.

when i post individually it gets posted. When i use both the PO's i'm getting the error.

Will i have to pass any serial number in tha data???

4500000762 10 101 07.03.2006 07.03.2006 ABC 1 10 10 2 XXX

4500000760 10 101 07.03.2006 07.03.2006 ABC 1 10 10 1 XXX

Please help me..

Regards,

SImha.

0 Kudos

Hi,

If your data has 2 records, should you get two mat docs in the end?

Is there any chance that these two recrds are two lines for the same mat docs?

Can you post your total code?

REgards,

Ravi

0 Kudos

So, I am assuming there is only one line item per PO that you want to create a GR for. Assuming i_data is the data from the file

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

CLEAR:i_item.

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.

Clear : REturn[], i_head, i_item[], i_code.

ENDLOOP.

Try this and let me know, if it still gives an error.

But if you get multiple line items for the same PO, then you will have to create one GR for all of them, in that case this code will not work.

Regards,

Ravi

Note : Please mark the helpful posts.

0 Kudos

If you have got mulitple PO line items use this code.

SORT I_DATA BY poNUMBER.

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

CLEAR:i_item.

At End of POnumber

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.

Clear : REturn[], i_head, i_item[], i_code.

endat.

ENDLOOP.

Regards,

Ravi

Don't forget to mark the helpful answers

0 Kudos

Hi ravi,

I have used ur code also.

It's giving the two errors now:

<b>Posting only possible in periods 2006/01 and 2005/12 in company code 0003

CODE is not supported by BAPI2017_GOODSMVT_CREATE</b>

Can u tell me where i'm going wrong.

I will award u points.

Please help me.

Regards,

Simha.

0 Kudos

Simha,

This is a configuration issue. There is something called as a POSTING PERIOD, which the functional consultants will set up. Basically it will tell you to account for this in a specific month. These posting periods will have to closed and a new one has to be opened every month (according to the client's practice). So in you case, you are trying to post the document in the current period which 2006/04, where as that period is not open yet. So, you will have to close the previous periods and then open the current one. Only then you will be able to post the document.

For testing purposes, you can change the POSTING DATA parameter to some data in Dec / Jan and that should go through.

Try and let me know.

Regards,

Ravi

Note : Please mark the helpful answers

0 Kudos

Hi Ravi,

Thanks for the reply.

But when i posted the single document , why it's getting posted??

Then also it should have to give the error.

can u explain this.

I have used ur code for multiple items.

Its giving.

CODE is not supported by BAPI2017_GOODSMVT_CREATE

CODE is not supported by BAPI2017_GOODSMVT_CREATE

for both the documents.

Can u help me out.

Please it's very urgent for me..

Anyway ur points will be awarded.

Regards,

simha.

0 Kudos

Hi,

Looks like there is a problem with the value you are passing to i_code. what is the value there?

Regards,

Ravi

Note - You can mark each answer as helpful, if they have helped.

0 Kudos

Hi,

I just noticed, why can't you use

BAPI_GOODSMVMT_CREATE.

Regards,

Ravi

0 Kudos

Hi ravi,

there is no such BAPI as u have said

BAPI_GOODSMVMT_CREATE.

I'm using i_code as '01' which is for PO_GR.

IF i'm wrong correct me.

PLease help me.

Regards,

SImha.

Message was edited by: Narasimha Rao Bandla

0 Kudos

I meant, BAPI_GOODSMOVEMENT_CREATE.

In your other message, you have mentioned about BAPI2017 or something like that.

regards,

Ravi

0 Kudos

Hi, even that BAPI doesn't exist.

Now one problem is solved .

for one document i can able to post.

But the second document in the post gives

Code not supported BAPI2017_GOODSMVT_CREATE

Plesae help me.

Regards,

SImha.

0 Kudos

Hi

Use code 03 , but not 0003