Skip to Content
author's profile photo Former Member
Former Member

Creating settlement rule aborts

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.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Aug 10, 2009 at 06:16 AM

    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.

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      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.

  • Posted on Aug 09, 2009 at 05:47 PM

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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Aug 10, 2009 at 03:49 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.