Skip to Content
Author's profile photo Former Member

Creating Settlement Rule for WBS Element

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!

Assigned Tags

      8 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Wallace Ferreira e Silva
      Wallace Ferreira e Silva

      Good job man,

      Now we can create fixed assets by ps projects.

      Author's profile photo Wallace Ferreira e Silva
      Wallace Ferreira e Silva

      This code will be used very hard here in Brasilia/DF

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      Alon is using this code. It worked!

      Author's profile photo Former Member
      Former Member

      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 ?

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      Hi Selva.

      I think this is not possible because of the limited size of the field LFDNR.

      Author's profile photo Former Member
      Former Member

      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.

      Author's profile photo Former Member
      Former Member

      How do you populate BUREG in COBRB ?

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      I didn't fill this field. Sorry but you have a technical issue. Search for SAP Notes.