09-28-2005 12:04 AM
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.
09-28-2005 12:22 AM
09-28-2005 4:03 AM
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.
09-28-2005 6:53 AM
09-28-2005 8:23 AM
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
09-28-2005 7:14 AM
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.