How To Goods Movements with BAPI ==>> Calling the BAPI several times within one roll area
2010-08-25 08:54
1046 查看
http://wiki.sdn.sap.com/wiki/display/ERPSCM/How+To+Goods+Movements+with+BAPI
(see the documentation for the ABAP keyword CALL FUNCTION). Here you have to adhere to the following procedure: The call of the BAPI, for example, BAPI_GOODSMVT_CREATE and the subsequent call of BAPI BAPI_TRANSACTION_COMMIT or in case of an error of BAPI BAPI_TRANSACTION_ROLLBACK has to be included in a function module. This function module must be called with command CALL FUNCTION func DESTINATION 'NONE'. As a result, the system opens a new roll area. Then you must implement function module RFC_CONNECTION_CLOSE.This function module closes the roll area of the function module.As a result, a new roll area is opened when you call a function module with DESTINATIN 'NONE' for the next time, and thus, for example, no more internal buffer data is available.
Example 1: Test
Func1
Example 2:
ZBAPI_GDSMVT
Caution!
The commit work executed in func1 processes all function modules of DESTINATION 'NONE' that were called in 'update task'.If function modules in 'update task' are called in the calling program, these do not lead to a database update.In this case, you have to execute a further commit work in the calling program.
Calling the BAPI several times within one roll area
When you want to post depending Goods Movements in a series like GR and immediate transfer posting or GR and GI for the same material. The stock is only read from the database in the case of an actual goods issue. For a goods receipt, the data is read from the buffer and thereby at the time before the last posting in the same roll area. A goods receipt, for example with movement type 315, automatically posts an implicit goods issue in the stock in transfer. This situation is not taken into account in the current design. You may get an error message like M7 021 (Deficit of ... stock). To avoid this, you have to call the BAPI in a different way: Make sure that the program buffer is deleted by changing the roll area. You can accomplish this by logging off and then logging in again for the BAPI process. If the BAPI is called from an ABAP program, you can also use the command CALL FUNCTION func DESTINATION 'NONE'.(see the documentation for the ABAP keyword CALL FUNCTION). Here you have to adhere to the following procedure: The call of the BAPI, for example, BAPI_GOODSMVT_CREATE and the subsequent call of BAPI BAPI_TRANSACTION_COMMIT or in case of an error of BAPI BAPI_TRANSACTION_ROLLBACK has to be included in a function module. This function module must be called with command CALL FUNCTION func DESTINATION 'NONE'. As a result, the system opens a new roll area. Then you must implement function module RFC_CONNECTION_CLOSE.This function module closes the roll area of the function module.As a result, a new roll area is opened when you call a function module with DESTINATIN 'NONE' for the next time, and thus, for example, no more internal buffer data is available.
Example 1: Test
Program Test. ... LOOP. .... CALL FUNCTION func1 DESTINATION 'NONE'. CALL FUNCTION RFC_CONNECTION_CLOSE. .... ENDLOOP.
Func1
FUNCTION func1. .... CALL FUNCTION 'BAPI_GOODSMVT_CREATE'. ... IF 'no errors'. CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'. ELSE. CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'. ENDIF. ... ENDFUNCTION.
Example 2:
ZBAPI_GDSMVT
*&---------------------------------------------------------------------* *& Report ZBAPI_GDSMVT *& *&---------------------------------------------------------------------* *& *& *&---------------------------------------------------------------------* REPORT zbapi_gdsmvt. * DATA: ... * PARAMETERS: ... START-OF-SELECTION. * Prepare data for first Goods Movement * Call BAPI to create Goods Movement CALL FUNCTION 'BAPI_GOODSMVT_CREATE' DESTINATION 'NONE' * If no error, commit CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' DESTINATION 'NONE' EXPORTING wait = 'X'. * ELSE * Error handling CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK' DESTINATION 'NONE'. * Close RFC connection CALL FUNCTION 'RFC_CONNECTION_CLOSE' EXPORTING destination = 'NONE'. * Prepare data for next Goods Movement * Call BAPI to create Goods Movement CALL FUNCTION 'BAPI_GOODSMVT_CREATE' DESTINATION 'NONE' * If no error, commit CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' DESTINATION 'NONE' EXPORTING wait = 'X'. * ELSE * Error handling CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK' DESTINATION 'NONE'. * Close RFC connection CALL FUNCTION 'RFC_CONNECTION_CLOSE' EXPORTING destination = 'NONE'.
Caution!
The commit work executed in func1 processes all function modules of DESTINATION 'NONE' that were called in 'update task'.If function modules in 'update task' are called in the calling program, these do not lead to a database update.In this case, you have to execute a further commit work in the calling program.
相关文章推荐
- A collection with the function, print one then remove one. how to implement?
- How to replace the boot screen with one of your own
- How to Accelerate Your Test Automation Execution speed 3-4 times with only one setting
- coreData报错:The model used to open the store is incompatible with the one used to create the store
- CoreDataErrorThe model used to open the store is incompatible with the one used to create the store
- How To Use the PivotTable Office Web Component with VB (转载自微软)
- How to control the jobs with shell?
- error: memcached support requires ZLIB. Use --with-zlib-dir=<DIR> to specify the prefix where ZLIB
- Core Data异常: model used to open the store is incompatible with the one used to create the store
- how to exacting the initrd.img file with busybox
- How to integrate the latest lispbox with clisp.
- [cernRoot]how to deal with TPavetext->SetTextAngle()?
- How To Manipulate Icons in the System Tray with Visual Basic
- <Learning How to Learn>Week One: Focused versus Diffuse Thinking
- How to create fully custom Role, User, Event, Resource classes for use with the Security and Scheduler modules
- How to load the specified mscordacwks.dll for managed debugging when multiple .NET runtime are loaded in one process
- How To Use the Spreadsheet Web Component with Visual Basic
- How to craw the Info of BiliBIli with python
- How to automate PowerPoint by using Visual C++ 5.0 or Visual C++ 6.0 with The Microsoft Foundation Classes
- How to add one perference into the settings option