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: 

Creating settlement rule aborts

Former Member
0 Kudos

Hi Experts,

I want to create a function module for creating a settlement rule. For that purpose I want to use the function moduls K_SRULE_CREATE, K_SETTLEMENT_RULE_FILL and K_SETTLEMENT_RULE_SAVE.

When I am executing my created FM it aborts always with a message, which is delivered to my postbox.

In SM21 (System log) are three entries: update terminated, transaction canceled, short dump created and run time error: "Raise exception" occured. For error analysis I have looked in SM13, where I get the following information: Module name(function): K_SRULE_SAVE_UTASK Update return code error. Status of update module: Update was terminated; Report LKOBRU03 Row 22. That seems to be the point where the update of the databases should be done. But I don`t know and understand why that error occures. I hope someone can help me.

For better understanding I have written the source code of my FM below.

Best regards

Phillip

*"----


""Local Interface:

*" IMPORTING

*" VALUE(IP_BELNR) TYPE J_OBJNR

*" EXPORTING

*" VALUE(EP_SUBRC) TYPE SY-SUBRC

*"----


data: lv_subrc type sy-subrc,

lv_objnr type cobrb-objnr,

ls_cobra like cobra,

lt_cobra type table of cobra,

ls_cobrb type cobrb,

lt_cobrb type table of cobrb.

lv_subrc = 0.

call function 'K_SRULE_CREATE'

exporting

i_objnr = ip_belnr

  • I_CHECK_ONLY_LOCAL = ' '

importing

e_cobra = ls_cobra

exceptions

rule_already_exists = 1

others = 2

.

if sy-subrc = 0.

append ls_cobra to lt_cobra.

ls_cobrb-objnr = ip_belnr.

ls_cobrb-bureg = '000'.

ls_cobrb-lfdnr = '001'.

ls_cobrb-perbz = 'FUL'.

ls_cobrb-prozs = '100'.

ls_cobrb-konty = 'FXA'.

append ls_cobrb to lt_cobrb.

call function 'K_SETTLEMENT_RULE_FILL'

tables

i_cobra = lt_cobra

i_cobrb = lt_cobrb.

call function 'K_SETTLEMENT_RULE_SAVE'

exporting

objnr = ip_belnr

dialog = ' '

exceptions

no_rule_for_objnr = 1.

if sy-subrc = 0.

commit work.

else.

ev_subrc = '20'.

endif.

else.

ev_subrc = '10'.

endif.

endfunction.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

But if you have only to use K_SRULE_SAVE_UTASK, the code I have given must work. Because you create first a COBRA set and the corresponding COBRB set, which are imported to FM K_SRULE_SAVE_UTASK using FM K_SETTLEMENT_RULE_SAVE. But exactly there occures the error. I have written a short code to check FM K_SRULE_SAVE_UTASK (see below) and in that case I get a Raise Exception too.

data: itab_a type standard table of cobra.

data: itab_b type standard table of cobrb.

data: s_itab_a type cobra.

data: s_itab_b type cobrb.

move 'OR999999999999' to s_itab_a-objnr.

*move 'OR000000100020' to s_itab_a-objnr.

*move 'OR999999999999' to s_itab_b-objnr.

*move '000' to s_itab_b-bureg.

*move '001' to s_itab_b-lfdnr.

*move 'FUL' to s_itab_b-perbz.

*move '100' to s_itab_b-prozs.

*move 'FXA' to s_itab_b-konty.

append s_itab_a to itab_a.

*append s_itab_b to itab_b.

call function 'K_SRULE_SAVE_UTASK' tables t_cobra_update = itab_a t_cobrb_update = itab_b.

9 REPLIES 9

Sandra_Rossi
Active Contributor
0 Kudos

There are some sap notes about it, you don't mention whether you looked at them or not

Former Member
0 Kudos

hello

for creating a settlement rule you need to use this function module K_SRULE_SAVE_UTASK only ,

for that you need to create an internal table of the similar structure as of COBRA table and fill all the desired fields in that and paas this table to cobra insert parameter.

hope it helps.

Regards

geeta Gupta

Former Member
0 Kudos

But if you have only to use K_SRULE_SAVE_UTASK, the code I have given must work. Because you create first a COBRA set and the corresponding COBRB set, which are imported to FM K_SRULE_SAVE_UTASK using FM K_SETTLEMENT_RULE_SAVE. But exactly there occures the error. I have written a short code to check FM K_SRULE_SAVE_UTASK (see below) and in that case I get a Raise Exception too.

data: itab_a type standard table of cobra.

data: itab_b type standard table of cobrb.

data: s_itab_a type cobra.

data: s_itab_b type cobrb.

move 'OR999999999999' to s_itab_a-objnr.

*move 'OR000000100020' to s_itab_a-objnr.

*move 'OR999999999999' to s_itab_b-objnr.

*move '000' to s_itab_b-bureg.

*move '001' to s_itab_b-lfdnr.

*move 'FUL' to s_itab_b-perbz.

*move '100' to s_itab_b-prozs.

*move 'FXA' to s_itab_b-konty.

append s_itab_a to itab_a.

*append s_itab_b to itab_b.

call function 'K_SRULE_SAVE_UTASK' tables t_cobra_update = itab_a t_cobrb_update = itab_b.

0 Kudos

Check sap notes as I told you, there is a recent correction, maybe it's your issue

0 Kudos

I have checked the notes, but I haven`t found a recent correction. There are only corrections up to release 4.7, but I have ECC 6.0.

0 Kudos

Note 1236222 - VA02 update termination in funct module K_SRULE_SAVE_UTASK

0 Kudos

Hello.

Thank you for your answer. But are you sure? Because I get a runtime error RAISE EXCEPTION and not SAPSQL_ARRAY_INSERT_DUPREC?!

Furthermore, in the note is explained:

The problem occurs if an item that is not relevant for production but has a status object is changed to production-relevant.

I don`t know how to understand that and if this happens in my given source code at the top.

Best regards,

Phillip

0 Kudos

Noone can be sure, and you're right, it's not the same exception, so probably it doesn't correspond to your issue (I indicated this note as it was something close to your issue, it is recent and related to ECC 6, and you were not mentioning it in your previous message).

Something I don't understand is that you can't get the short dump, how is it possible?

0 Kudos

In your example code for K_SRULE_SAVE_UTASK you are adding a settlement rule using t_cobra_update, you must use t_cobra_insert instead.

When adding rules to COBRB please remember that the key includes a sequence number, lfdnr. COBRB-lfdnr should be incremented from the highest existing value that corresponds to a particular object number. You may want to increment COBRB-extnr as well.

One more thing, K_SRULE_SAVE_UTASK seems to work reliably when performing a single task. Therefore inserts and updates to COBRA and COBRB must each be in separate calls to K_SRULE_SAVE_UTASK. If you are adding another settlement rule to an existing set of settlement rules for any COBRB-objnr then you do not need to touch COBRA, only COBRB.