Application Development and Automation 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: 
Read only

Recursive function

Former Member
0 Likes
503

Hi,

This is my requirement.

the user will give a range of cost centre group on the selection screen as input.

take the first parent cost centre group and check whether it has any child cost centre groups and check if those child cost centre groups has any other subchilds. and find all the cost centres that exist for all the parent , child and subchilds.

for eg.

10000-->01

1000>10 1010>11 1011-->12

1001-->20

1020-->30.

20000-->40

2000-->50

2001-->60

2020-->70

here 10000 is the the parent cost centre group it has a child CCG has 1000,1010 and 1011 and 1000 has a child 1001 and 1001 has a child 1020.

All these CCG(Cost centre group) has cost centre like 01 for 10000 and 10 for 1000 and 11 for 1010 and 12 for 1011 and 20 for 1001 and 30 for 1020.

Like this hierarchy continues.

Now if the customer gives CCG 10000 alone as the input how can we find out all the child CCG for it and then their corresponding cost centres of them using a recursive function.

can anyone explain me the logic of this.

Regards,

Phyrose.

3 REPLIES 3
Read only

Former Member
0 Likes
432

Hi

use the fun module

G_SET_TREE_IMPORT

pass the setid which is the concatenation of class, subclass and the CC group together

see the tables setnode and setleaf also.

Regards

Anji

Read only

Former Member
0 Likes
432

HI,

Look at the function module <b>C13C_TREE_IMPORT</b> and look at the below link

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/0403a990-0201-0010-38b3-e1f...

Regards

Sudheer

Read only

RaymondGiuseppi
Active Contributor
0 Likes
432

Use the following function module

    CALL FUNCTION 'K_COSTELEM_SELECT'
         EXPORTING
              kokrs           = p-kokrs
              ce_group        = p-kagru
         TABLES
              it_result       = t_cskb_ex
         EXCEPTIONS
              no_record_found = 1
              group_not_found = 2
              OTHERS          = 3.

call the module for each group input by user and merge the internal tables.

Regards

PS: you could also use FM K_COSTELEM_SELECT_TAB