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: 

Update termination error in FM - K_SRULE_SAVE_UTASK

vikas_mulay2
Participant
0 Kudos

Hello Experts,

I am making use of FM "K_SRULE_SAVE_UTASK" in BADI method IF_EX_WORKORDER_UPDATE~BEFORE_UPDATE.

The FM is also used in a User Exit EXIT_SAPLCOZR_001.

After execution i do not get any exception in the working as well as non working scenario.

But i have identified a scenario where it doesn't work correctly.(still no exception is raised from FM)

Scenario is as follow:

In Tcode CJ20N i open a project.The project/activity is in REL status(Released) and then for the activity i press CTRL + F3 to see the settlement rule and come back again to the main screen of CJ20N(where i can see the same project again) and then  click on SAVE(here BADI is called where the FM is used).

Now when the BADI is called i don't see any exception getting raised from FM K_SRULE_SAVE_UTASK and once the SAVE is done i get the "Update termination error".

Now going to SM13 tcode i found that the error is due to FM K_SRULE_SAVE_UTASK...If i see the log in more detail then i see that the error is due to Duplicate records getting inserted in COBRA table.But if i see the the Internal for COBRA passed to FM K_SRULE_SAVE_UTASK in the bADI then there is no duplicate record.

Now...In SM13 log i found that the record that is seen as duplicate entry is the one for which i have pressed CTRL + F3 to see the settlement rule.

I also have verified that all the Workarea and Internal table are cleared properly in BADI.

I am not understanding where code is trying to insert the Duplicate record and where in buffer is the activity stored when i pressed CTRL + F3.

I already have read all the post related to this Fm but nothing came handy...

Is calling of FM two times been done in same LUW which is a problem??

Do i need to do some thing different in calling the FM since it is of type 'Update Module'?

Regards,

Vikas

1 ACCEPTED SOLUTION

vikas_mulay2
Participant
0 Kudos

Hi Klaus,

I am calling the FM K_SRULE_SAVE_UTASK in UPDATE TASK inj the BADI but will not COMMIT it(let my FM data be committed by SAP COMMIT stmt which is called at the end).

Note-SAP already have started the Update Task for FM K_SRULE_SAVE_UTASK in standard program before my BADI call...

For the duplicate record that i see in SAP Buffer table - > I will use/pass Internal table T_COBRA_UPDATE to  to FM K_SRULE_SAVE_UTASK....

And for rest other unique record - I will use Internal table T_COBRA_INSERT for the FM.

This solution worked for me...

@Klaus - Thanks for your suggestion...It helped me to get the solution...

Thanks

Regards,

Vikas

Message was edited by: Vikas Mulay

7 REPLIES 7

former_member195402
Active Contributor
0 Kudos

Hi Vikas,

make sure that you call this function with option IN UPDATE TASK.

Also check, that it isn't called twice (by your BADI and automatically in CJ20N) in SM13.

Regards,

Klaus

0 Kudos

Hello Klaus,

Thanks for your suggestion.

Its not allowing me to use the FM IN UPDATE TASK...

Its Giving me a Short Dump after COMMIT WORK stmt.

Regards,

Vikas

0 Kudos

Hi Vikas,

which type of Short Dump do you get? Maybe you're already in update task and can't process a COMMIT there ...

Please show us a full list of the SM13 update modules.

Regards,

Klaus

0 Kudos

Hello Klaus,

Yes,you are correct...The FM K_SRULE_SAVE_UTASK is called by SAP in Update task before my FM call(In BADI)  and hence i am not able to use commit work.

Below is the log from SM13.

Moreover during debugging i found the reason of Duplicate entry...

In SAP Include program LKOBSF5E-> regeln_sichern(form name) SAP fill Internal table  lt_cobra_insert and then update it using FM K_SRULE_SAVE_UTASK IN UPDATE TASK.

..But since COMMIT work is not called the entry is not update in COBRA table...

Now using the BADI i update the same entry using FM  K_SRULE_SAVE_UTASK(It allows me since the entry is not present in DB)....

And then after the call of BADI  SAP calls COMMIT WORK where it tries to insert the same record that is already inserted in table using FM in BADI...hence when SAP inserts the record we are getting the dump of duplicate record.

PS: Internal table lt_cobra_insert is getting updated from Buffer table GT_COBRA_BUF.


I am still looking if i can avoid updating the entry from SAP Buffer table using BADI...


Is there any table that SAP has where LUW is maintained.??


Regards,

Vikas

0 Kudos

Hi,

what will happen if you fill table T_COBRA_UPDATE instead of table T_COBRA_INSERt in your BADI in the interface of  fm K_SRULE_SAVE_UTASK?

Regards,

Klaus

0 Kudos

Hi Klaus,

Using T_COBRA_UPDATE  will also not work because for Update we need to ensure that the record is already present in DB which is not the case up here.


Also i cannot skip the updation of duplicate record in COBRA/COBRB  table during update in BADI if it present in SAP Buffer table since it would not then create settlement rule for me.


Some where i am wondering if i can prevent SAP buffer table to be updated(for the record for which i am pressing CTRL + F3)...But again i think that is not a recommend solution.

Regards,

Vikas

Message was edited by: Vikas Mulay

vikas_mulay2
Participant
0 Kudos

Hi Klaus,

I am calling the FM K_SRULE_SAVE_UTASK in UPDATE TASK inj the BADI but will not COMMIT it(let my FM data be committed by SAP COMMIT stmt which is called at the end).

Note-SAP already have started the Update Task for FM K_SRULE_SAVE_UTASK in standard program before my BADI call...

For the duplicate record that i see in SAP Buffer table - > I will use/pass Internal table T_COBRA_UPDATE to  to FM K_SRULE_SAVE_UTASK....

And for rest other unique record - I will use Internal table T_COBRA_INSERT for the FM.

This solution worked for me...

@Klaus - Thanks for your suggestion...It helped me to get the solution...

Thanks

Regards,

Vikas

Message was edited by: Vikas Mulay