2013 Oct 24 10:59 AM
Hi Experts,
I am working on one Z report in that am using BDC for MB1B ( call Transaction method) for transferring unrestricted to block stock and Bapi (BAPI_GOODSMVT_CREATE) for (Batch to Batch stock transfer )
Both are working fine in debug mode but while executing the transaction directly it is not working.
Please help me its an urgent requirement.
Thanks and Regards.,
Uma
Hi Experts,
I am working on one Z report in that am using BDC for MB1B ( call Transaction method) for transferring unrestricted to block stock and Bapi (BAPI_GOODSMVT_CREATE) for (Batch to Batch stock transfer )
Both are working fine in debug mode but while executing the transaction directly it is not working.
Please help me its an urgent requirement.
Thanks and Regards.,
Uma
2013 Oct 24 11:03 AM
Hi Uma,
Have you used COMMIT WORK statement after BAPI?
If not use Commit work and also try WAIT UP TO 2 SECONDS (2 or 3 seconds) before COMMIT WORK.
Orelse you can also use Function module :: BAPI_TRANSACTION_COMMIT. (Also use Wait statement before calling this FM).
Hope this works,
Thanks & Regards,
- Vijay
2013 Oct 24 11:11 AM
Hi Vijaykrishna
Ya am using COMMIT WORK and BAPI_TRANSACTION_COMMIT statement ...
If that is the case it should not work in debug mode also right?
2013 Oct 24 11:15 AM
Hi Uma,
I have experienced the same issue, that time myself realized that system need some time (maximum 1 or 2 seconds, some times fraction of seconds too) to update all the tables and commit its work. In the debugging obviously system gets time to update or commit by the time we press keys like F5 or F6 etc. So I used WAIT statement, then my issue solved .
You can also use SET UPDATE TASK LOCAL instead of BAPI_TRANSACTION_COMMIT after BAPI.
-Vijay
2013 Oct 24 11:05 AM
Hi-
Both are working fine in debug mode means are you able to post material document? if so have you checked that material document in DB table MSEG?
After BAPI call just call this BAPI 'BAPI_TRANSACTION_COMMIT'.
Hope this helps!
-Venkat
2013 Oct 24 11:12 AM
Yes i can able to see the document which is generated in debug mode
2013 Oct 24 11:16 AM
Are you using BAPI commit?
Can you place your sample code written for BAPI?
2013 Oct 24 11:21 AM
Hi-
Try like this...
CALL FUNCTION 'BAPI_GOODSMVT_CREATE'
EXPORTING
goodsmvt_header = lwa_goodsmvt_header
goodsmvt_code = lwa_goodsmvt_code
IMPORTING
goodsmvt_headret = lwa_goodsmvt_headret
materialdocument = lwa_materialdocument
matdocumentyear = lwa_matdocumentyear
TABLES
goodsmvt_item = i_goodsmvt_item
return = i_return.
IF lwa_materialdocument IS NOT INITIAL.
*--BAPI commit
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'.
ENDIF.
-Venkat
2013 Oct 24 11:23 AM
Hi Venakat,
Here is my code for BAPI
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 = '04'. " MB1B
* Write 971 movement to table
clear gm_item.
gm_item-material = g_matnr.
gm_item-plant = w_ztppi-werks.
gm_item-stge_loc = 'WP20'.
gm_item-batch = w_ztppi-rcharg.
gm_item-move_type = '309'.
move w_ztppi-rkwmeng to lv_qty.
condense lv_qty.
move lv_qty to gm_item-entry_qnt .
gm_item-move_mat = g_matnr.
gm_item-move_plant = w_ztppi-werks.
gm_item-move_stloc = 'WP20'.
gm_item-move_batch = w_ztppi-scharg.
append gm_item to gm_item.
clear 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'.
commit work.
2013 Oct 24 11:28 AM
May I know the difference between my code ur code?
Bcz am always getting material document no.in debug mode
2013 Oct 24 11:39 AM
Are you getting any entries in BAPI return table? If so then there might be data missing problem.
Else just check for material document number returned from BAPI.
Say:
lwa_materialdocument is not initial
Then call BAPI commit
-Venkat
2013 Oct 24 11:43 AM
Can you please put a screen shot of debugger when document number is generated along with contents of LT_RETURN table
2013 Oct 24 12:14 PM
2013 Oct 24 12:24 PM
What does GM_RETURN table has..? When you execute it completely are you able to see the document in MB03..? Seconldy when you execute directly put a break piint after commit and check what does return have then
2013 Oct 24 12:28 PM
Hi-
If your BAPI posting was successful you would have got your return table without any entries, in your case return table is not initial hence there is some problem with the data you are passing. Check them.
In below screenshot I have successfully posted material document hence return table is initial.
Hope this helps!
-Venkat
2013 Oct 24 1:20 PM
Replace this Code with your existing code after BAPI Call .... ..
IF gm_retmtd IS INITIAL .
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
EXIT.
ELSE.
gm_return-TYPE = 'S'.
gm_return-MESSAGE = gm_retmtd.
APPEND gm_return .
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'.
ENDIF.
Replace above code with your below code....
also check below notes:
Note 369518 - Transfer stock not reached if posted with BAPI
Note 520813 - FAQ: BAPIs for goods movements
Note 457499 - No material document generated for BAPI BAPI_GOODSMVT_CREATE
Regard's
Smruti
2013 Oct 24 11:36 AM
Uma ,
WAIT UNTIL sy-subrc eq 0.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'
IMPORTING
RETURN = RETURN.
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |