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: 

Is it possible to save in an internal table inside CJ20N without affecting SAP LUW?

Former Member
0 Kudos
195

Hi gurus,

I read you can't do commit work inside an exit.

But I've been assigned to capture newly created PR's. I'm going to use EXIT_SAPLCOZF_001 to capture all changes or creation of new PR but I need to store it in a customized table.

1. I've been reading and testing of passing it thru memory but my problem is the amount of records I'm passing making this solution impossible using memory.

2. I've read about buffer table but AFVC is not buffer enabled.

3. Last I've read about RFC Enable function call running in the background. I've been trying to google this but will this end SAP LUW?

Or there is another solution other than the three i mentioned? Thanks.

1 ACCEPTED SOLUTION

Former Member
0 Kudos
63

Hi John,

yes u can do.Please follow the below note.

Update task mode in function module

 

  

We can call a function module in Update task mode by using  "IN UPDATE TASK" statement. It allows you to call a function module but it will not be executed/called until an update task is initiated by the 'COMMIT WORK' statement in the report.

This means that the program logic after calling the FM will immediately continue with the next line of ABAP code and the function module will wait for the commit work statement and after that it will be executed/called.

Example:

CALL FUNCTION 'ZAU_FUNCTION' IN UPDATE TASK

  EXPORTING ur data

and save ur data under this FM.

 

commit work. "Commits all work to database and also starts all FM's running in update task

Why its used ?

Suppose you need to call / perform some actions only after database updation and not before that.

Thanks

Tarak

5 REPLIES 5

Former Member
0 Kudos
63

Hi John,

     Its correct that we can't use commit work inside an exit. As per the third point you mentioned, make use of a remote enabled Function Module call in which you can use commit work. Pass the internal table to the RFC so that you can update the custom table.

Hope this helps.

~Athreya

Former Member
0 Kudos
64

Hi John,

yes u can do.Please follow the below note.

Update task mode in function module

 

  

We can call a function module in Update task mode by using  "IN UPDATE TASK" statement. It allows you to call a function module but it will not be executed/called until an update task is initiated by the 'COMMIT WORK' statement in the report.

This means that the program logic after calling the FM will immediately continue with the next line of ABAP code and the function module will wait for the commit work statement and after that it will be executed/called.

Example:

CALL FUNCTION 'ZAU_FUNCTION' IN UPDATE TASK

  EXPORTING ur data

and save ur data under this FM.

 

commit work. "Commits all work to database and also starts all FM's running in update task

Why its used ?

Suppose you need to call / perform some actions only after database updation and not before that.

Thanks

Tarak

matt
Active Contributor
0 Kudos
63

Tarak is correct. Create and call a FM that does the db update in the update task. Then, when commit work is reached in the normal SAP code, the FM will run.

0 Kudos
63

Hi,

does update task store it in the database already?

This would be the scenario that will happen.

After sy-tcode = 'CJ20N' and sy-ucomm = 'SAVE' is satisfied. I need to store it in a custom table.

I need the data for further processing. Which means before cj20n ends and commit the data. I have to pull all records inside the custom table and compare it with AFVC. I'm going to check new entries in the custom table vs old entries in AFVC.

I haven't tried it yet since I'm still waiting for my functional. But mostly the logic would be insert data in the custom table then pull it out again. before the standard of cj20n commit work.

Also, I need to execute a delete statement of dbtab based in sy-uname.

P.S. Right now I'm checking se37 creation of FM and how to enable RFC.

raymond_giuseppi
Active Contributor
0 Kudos
63

Store in an internal table defined in the top include of the exit function group (Include ZXCOZTOP) the required data to execute your requirement (order and reservation number) and execute a PERFORM AT COMMIT which will be executed once at commit (the exit may be called at each modification of an operation that can change requisitions)

In the form (Include ZXCOZZZZ) call a FM to update data either in update task (if you don't need any code other than plain INSERT statements) or in background call (here you will be in a LUW after database update and can perform what you want, like commit-work and BAPI call)

Regards,

Raymond