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: 

Cost center group

Former Member
0 Kudos

what is the easiest way to get the cost centers from cost center group(setname in SETLEAF) from table SETLEAF.

As i need to check if a PO (ekkn-kostl) is in the COST CENTER GROUP for a report.

appreciate any help. thanks in advance.

5 REPLIES 5

Former Member
0 Kudos

I've used FM K_HIERARCHY_TABLES_READ

Rob

Former Member
0 Kudos

data wa_setname like setleaf-setname.

data wa_subclass like setleaf-subclass.

data wa_valfrom like setleaf-valfrom.

MOVE EKKO-BUKRS TO WA_SUBCLASS.

MOVE EKKN-KOSTL TO WA_VALFROM.

select single setname into wa_setname

from setleaf

where setcalss = '0106'

and subclass = wa_subclass

and valfrom = wa_valfrom.

0 Kudos

BAPI_COSTCENTERGROUP_GETDETAIL

Regards

Raja

0 Kudos

Hi Sanjay,

i'd change your coding a very littke.

MOVE EKKO-<b>KOKRS</b> TO WA_SUBCLASS.

MOVE EKKN-KOSTL TO WA_VALFROM.

select setname into table stab

from setleaf

where setcalss = '010<b>1</b>'

and subclass = wa_subclass

and valfrom = wa_valfrom.

regards Andreas

Former Member
0 Kudos

Hi ..

Each cost center group is a separate set. if p_short is the cost center group name. Then this logic is useful for u.

DATA : OLD_SET LIKE RGSBS-SETNR.

CALL FUNCTION 'G_SET_GET_ID_FROM_NAME'

EXPORTING

SHORTNAME = P_SHORT

OLD_SETID = OLD_SET

IMPORTING

NEW_SETID = OLD_SET.

CALL FUNCTION 'G_SET_GET_INFO'

EXPORTING

SETNAME = OLD_SET

IMPORTING

INFO = ITAB1

EXCEPTIONS

SET_NOT_FOUND = 1

ILLEGAL_FIELD_REPLACEMENT = 2

OTHERS = 3.

IF SY-SUBRC = 0.

CALL FUNCTION 'G_SET_TREE_IMPORT'

EXPORTING

CLIENT = SY-MANDT

LANGU = SY-LANGU

SETID = OLD_SET

MAX_HIER_LEVEL = 99

TABLES

SET_VALUES = ITAB2

EXCEPTIONS

SET_NOT_FOUND = 1

ILLEGAL_FIELD_REPLACEMENT = 2

ILLEGAL_TABLE_REPLACEMENT = 3

OTHERS = 4.

IF SY-SUBRC = 0.

LOOP AT ITAB2.

P_KOSTL-SIGN = C_I.

P_KOSTL-OPTION = C_EQ.

P_KOSTL-LOW = ITAB2-FROM.

APPEND P_KOSTL.

ENDLOOP.

ENDIF.