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

calling multiple times BAPI_GOODSMVT_CREATE getting error

Former Member
0 Likes
1,044

Hi Friends,

I am calling multiple times BAPI_GOODSMVT_CREATE for same Purchase order to post goods receipt.

for the first 4 times it is creating the GR successfully, but then it returning the message 'No goods receipt possible for purchase order 4500001004 01350'.

Please help.

Thanks

Ravi

7 REPLIES 7
Read only

Former Member
0 Likes
851

calling multiple times ---> have u seen PO history in ME23N , is there any open QTY ? if there is no Open qty in PO for doing GR then u will get this kind of error.

po qty = 80kgs

gr1 qty = 20kgs

gr2 =20kgs

gr 3 = 20kgs

gr 4 - 20kgs ,

then next time it wont allow u to do GR on this PO.

if u want to do , then change qty of PO.

Regards

Prabhu

Read only

0 Likes
851

Hi prabhu,

Thanks for the reply.

I am also reversing the goods receipt mean time.

I think DB is not updating immediately, that might the reason.

then, how could we make sure the DB update before processing the next run of the GR posting...

Thanks

Ravi

Read only

0 Likes
851

I am also reversing the goods receipt mean time.---> with what REF ?

Reversal should be with ref of original Document.

like

101 -


100kgs (+ ) ---doc1 - no ref.

102----100kgs -


doc2-ref: doc1.

so better to split ur program

perform 101_add.

perform 102_minus.

<b>in reversal also it will check the same as i said in first post.</b>

Regards

prabhu

Read only

0 Likes
851

Hi Prabhu,

I am also passing correct reference document and year for reverse posting and I observed the GR reverse while debugging, it is working for the first 5 or 6 runs of GR posting for the same PO in the program, but not to all the runs. I think DB might be not updated.

How could I make sure the DB updation before the next Gr posting.

Each and every posting is dependent on DB updates.

Please help me out.

Thanks & Regards

Ravi

Message was edited by:

ravikumar s

Read only

0 Likes
851

After Transaction_commit

Use Wait up to statement for the next gr posting.

Read only

0 Likes
851

Thank you.

But we can not fix the time duration.

and program execution time limited to an hour only.

In production environment my user can have more number of postings, it may exceed more than an hour some times, if we use wait up to XX seconds, I expect.

please help me out.

Thanks & Regards

Ravi

Message was edited by:

ravikumar s

Read only

Former Member
0 Likes
851

Use Wait up to statement in loop.

Ex:

loop at it_filedir1.

REFRESH I_TAB.

CLEAR I_TAB.

  • REFRESH I_TAB2.

  • REFRESH ITAB1.

data: g_file(100) type c .

name = it_filedir1-name.

concatenate: gfile '\' name into g_file.

data : i_tab1(500).

OPEN DATASET g_file FOR INPUT IN TEXT MODE

ENCODING DEFAULT

IGNORING CONVERSION ERRORS.

IF SY-SUBRC EQ 0.

DO.

READ DATASET g_file INTO i_tab1.

if sy-subrc = 0.

split i_tab1 at ',' into I_TAB-SOL_DOCNO I_TAB-SOL_DOCDT

I_TAB-GI_TXN_TYPE I_TAB-WERKS I_TAB-LGOBE I_TAB-MATNR

I_TAB-ERFMG I_TAB-ERFME.

else.

exit.

endif.

APPEND I_TAB.

clear I_TAB.

ENDDO.

ENDIF.

CLOSE DATASET g_file.

concatenate: hfile '\' name into h_file.

REFRESH I_MAIN.

CLEAR I_MAIN.

I_MAIN[] = I_TAB[].

REFRESH I_OUT.

CLEAR I_TAB.

I_OUT[] = I_TAB[].

DELETE ADJACENT DUPLICATES FROM I_TAB COMPARING SOL_DOCNO.

SORT I_TAB BY SOL_DOCNO.

LOOP AT I_TAB.

count = sy-tabix.

SELECT SINGLE * FROM ZMM_GI_WIP

WHERE GI_NO = I_TAB-SOL_DOCNO AND

GI_DATE = I_TAB-SOL_DOCDT.

IF SY-SUBRC = 0.

I_TAB-FLAG = 'C'.

modify i_tab index count.

CONCATENATE 'ERROR GI : ' I_TAB-SOL_DOCNO

' WAS ALREADY UPLOADED' INTO I_MSG1.

APPEND I_MSG1.

CLEAR I_TAB-FLAG.

CONTINUE.

ELSE.

CONCATENATE I_TAB-SOL_DOCDT+4(2)

I_TAB-SOL_DOCDT+6(2)

I_TAB-SOL_DOCDT+2(2)

I_TAB-SOL_DOCDT+0(2)

INTO G_DATE.

gmhead-pstng_date = G_DATE.

gmhead-doc_date = sy-datum.

gmhead-pr_uname = sy-uname.

  • "01 - MB01 - Goods Receipts for Purchase Order

gmcode-gm_code = '03'.

refresh itab.

clear itab.

SORT I_MAIN BY SOL_DOCNO.

LOOP AT I_MAIN WHERE SOL_DOCNO = I_TAB-SOL_DOCNO.

IF I_MAIN-GI_TXN_TYPE = 'RMGI'.

itab-move_type = '291'.

ENDIF.

itab-mvt_ind = ' '.

itab-plant = I_MAIN-WERKS.

itab-material = I_MAIN-MATNR.

itab-entry_qnt = I_MAIN-ERFMG.

  • itab-stge_loc = 'OMR1'.

  • itab-move_stloc = pcitab-recv_loc.

itab-stge_loc = I_MAIN-LGOBE.

itab-ENTRY_UOM = I_MAIN-ERFME.

IF I_MAIN-WERKS = 'OMR'.

itab-TR_PART_BA = '11'.

ELSEIF I_MAIN-WERKS = 'OMR'.

itab-TR_PART_BA = '12'.

ENDIF.

append itab.

ENDLOOP.

if not itab[] is initial.

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.

move errmsg-message to i_msg1.

append i_msg1.

endloop.

if errflag is initial.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

  • EXPORTING

  • WAIT =

  • IMPORTING

  • RETURN =

.

  • commit work and wait.

if sy-subrc ne 0.

write:/ 'Error in updating'.

exit.

else.

write:/ mthead-mat_doc, mthead-doc_year.

ZMM_GI_WIP-GI_NO = I_TAB-SOL_DOCNO.

ZMM_GI_WIP-GI_DATE = I_TAB-SOL_DOCDT.

INSERT ZMM_GI_WIP.

COMMIT WORK.

I_TAB-FLAG = 'C'.

MODIFY I_TAB INDEX COUNT.

CONCATENATE mthead-mat_doc mthead-doc_year

into i_msg1.

append i_msg1.

  • perform upd_sta.

endif.

endif.

endif.

ENDIF.

wait up to 20 seconds.

ENDLOOP.