Skip to Content

To create Settlement Rules via ABAP  use the K_SRULE_SAVE_UTASK function module. View code:

     DATA: t_prps      TYPE TABLE OF prps,

           wa_prps     TYPE prps,
t_cobrb    
TYPE TABLE OF cobrb,
wa_cobrb   
TYPE cobrb
.

“Select WBS Elements
SELECT *
FROM prps
INTO TABLE t_prps
WHERE psphi EQ im_projectdefinition-pspnr.

LOOP AT t_prps INTO wa_prps.

wa_cobrb-objnr      = im_projectdefinition-objnr.
ADD 1 TO wa_cobrb-lfdnr.

***    USE THE CONVERSION EXITS !!!
CALL FUNCTION ‘CONVERSION_EXIT_PERBZ_INPUT’
EXPORTING
input  = ‘PER’
IMPORTING
output = wa_cobrb-perbz.

CALL FUNCTION ‘CONVERSION_EXIT_OBART_INPUT’
EXPORTING
input     = ‘PEP’
IMPORTING
output    = wa_cobrb-konty
EXCEPTIONS
not_found =
1
OTHERS    = 2.

IF sy-subrc NE 0.

ENDIF.

wa_cobrb-prozs      = ‘100.00’.
wa_cobrb-kokrs      = wa_prps-pkokr.
wa_cobrb-bukrs      = wa_prps-pbukr.
wa_cobrb-ps_psp_pnr = wa_prps-pspnr.
wa_cobrb-rec_objnr1 = wa_prps-objnr.

APPEND wa_cobrb TO t_cobrb.

ENDLOOP.

 

     “Create Settlement Rule
CALL FUNCTION ‘K_SRULE_SAVE_UTASK’
TABLES
t_cobrb_insert    = t_cobrb
EXCEPTIONS
srule_utask_error =
1
OTHERS            = 2.

IF sy-subrc NE 0.
“Implement suitable error handling here
ENDIF.

This code can be used in Z report program or in BADI PROJECTDEF_UPDATE.

 

Best Regards,

 

Rodrigo Abreu Costa

@digoabreu

Galo Doido!

To report this post you need to login first.

8 Comments

You must be Logged on to comment or reply to a post.

  1. Selva A

    With this approach we can generate only 999 settlement rules per WBS. If it exceeds , it will given a dump. How do u resolve this issue ?

    (0) 
      1. Selva A

        Yes Rodrigo. For one of my requirements, I need to achieve this functionality. They may create more than 999 settlement rules .I need to generate the respective number of profit segments. I am checking the possibilities to implement it. Please let me know if you have any thoughts on this.

        (0) 

Leave a Reply