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

Passing Parameter

Former Member
0 Likes
826

Hi all,

Can you help me to work with <b>Perform on Commit</b>?

Thanks

Imtiaz

3 REPLIES 3
Read only

Former Member
0 Likes
539

Hi,

This is used to commit the changes to the database

when you write some code in the PERFORM ..ON COMMIT

subroutine, all the statements reagrding database update are committed only when you write explicit COMMIT WORK and for Roll back ROLLBACK has to be used.

Regards,

Padmam.

Read only

Former Member
0 Likes
539

check the below link..

http://www.sts.tu-harburg.de/teaching/sap_r3/ABAP4/commit.htm

PERFORM ON COMMIT routines are not executed in the dialog module.

You must ensure that any subroutines called using ON COMMIT can be delayed until the next COMMIT WORK in the calling program. Remember that the global data of the dialog module is destroyed along with the internal session when control returns to the calling program. Consequently, subroutines called using PERFORM ON COMMIT must not use this global data.

The statement PERFORM ON COMMIT calls a subroutine in the dialog work process. However, it is not executed until the system reaches the next COMMIT WORK statement. Here, as well, the ABAP statement COMMIT WORK defines the end of the SAP LUW, since all statements in a subroutine called with PERFORM ON COMMIT that make database changes are executed in the

database LUW of the corresponding dialog step.

The advantage of this bundling technique against CALL FUNCTION... IN UPDATE TASK is better performance, since the update data does not have to be written into an extra table. The disadvantage, however, is that you cannot pass parameters in a PERFORM... ON COMMIT statement. Data is passed using global variables and ABAP memory. There is a considerable danger of data inconsistency when you use this method to pass data.

You can also put the CALL FUNCTION IN UPDATE TASK into a subroutine and call the subroutine with:

PERFORM SUBROUT ON COMMIT.

If you choose this method, the subroutine is executed at the commit. Thus the request to run the function in the update task is also logged during commit processing. As a result, the parameter values logged with the request are those current at the time of the commit.

Ex.

a = 1.

PERFORM F ON COMMIT.

a = 2.

PERFORM F ON COMMIT.

a = 3.

COMMIT WORK.

FORM f.

CALL FUNCTION 'UPD_FM' IN UPDATE TASK EXPORTING PAR = A.

ENDFORM.

In this example, the function module UPD_FM is carried out with the value 3 in PAR. The update task executes the function module only once, despite the two PERFORM ON COMMIT statements. This is because a given function module, logged with the same parameter values, can never be executed more than once in the update task. The subroutine itself, containing the function module call, may not have parameters.

********************************************

perform update_zproc_files .

form update_zproc_files .

wa_zproc_files-mandt = sy-mandt.

wa_zproc_files-batch = v_batch.

wa_zproc_files-rcvdt = v_rcvdt.

wa_zproc_files-totdoc = v_totdoc.

wa_zproc_files-totamt = v_totamt.

wa_zproc_files-processdate = sy-datum.

wa_zproc_files-processtime = sy-uzeit.

append wa_zproc_files to i_zproc_files.

clear wa_zproc_files.

insert zproc_files from table i_zproc_files.

if sy-subrc eq 0.

commit work.

endif.

refresh i_zproc_files.

endform. " update_zproc_files

*********************************************

Regards

vasu

Read only

Former Member
0 Likes
539

<b>Perform on Commit</b>

This statement registers the subroutine directly specified using subroutine in the same program. The subroutine is not executed immediately, but a flag is set for execution when one of the statements COMMIT WORK or ROLLBACK WORK (since Release 6.10) is reached.

The registered subroutines are executed if the statement COMMIT WORK or ROLLBACK WORK is executed in their work process and before update function modules registered using CALL FUNCTION ... IN UPDATE TASK. Subroutines that are registered during execution of an update function module for COMMIT are executed at the end of the update in the update work process i.e

a = 1.

PERFORM F ON COMMIT.

a = 2.

PERFORM F ON COMMIT.

a = 3.

COMMIT WORK.

FORM f.

CALL FUNCTION 'UPD_FM' IN UPDATE TASK EXPORTING PAR = A.