‎2008 Jan 09 1:28 PM
Hello,
Can someone let me know how to form the relation between the tables.
SETNODE
SETLEAF
SETHEADER.
Any help greatly appreciated.
Best Regards,
Siva.
‎2008 Jan 09 1:55 PM
‎2008 Jan 09 2:21 PM
hi,
SETHEADER This is information about the nodes in the hierarchy
SETNODE This is the relationship between the nodes
SETLEAF This is the attachment of the object (Profit Center, Cost
Center) to the bottom node of the hierarchy.
Reading these tables is rather difficult. To build a hierarchy you have
to read SETNODE for each level of the hierarchy
and build the tree.
For reading the Profit/Cost Center hierarchy these functions can be
used:
call function G_SET_GET_HIGHER_LEVEL
exporting index = indexl set number levels = level1 number of levels upwards importing header = head1 exceptions invalid_index = 01.
call function G_SET_GET
exporting index = indx1 control_block = cb1 level = setlevel replace_variables = space importing subrc = result header = head index = indx2.
and
call function G_OBJECT_GET
exporting index = index control_block = cb2 replace_variables = space importing subrc = result entry = entry.
As our validations are using sets , and i need to do some checks for my programs for these sets, am using table SETLEAF to access the data.
But this table has only 4 key fields and the valfrom and valto are the major ones which are not key fields. .
SETHEADER table where SETCLASS = '0102'
SETNODE table where SETCLASS = SETHEADER-SETCLASS
and SUBCLASS = SETHEADER-SUBCLASS
subclass is the Cost Element Group
SETLEAF table where SETCLASS = SETHEADER-SETCLASS
and SUBCLASS = SETHEADER-SUBCLASS
and SETNAME = SETNODE-SETNAME
REPORT ZPGM_HIERARCHY_IMPRTD_TO_PCNTR
LINE-SIZE 80.
TABLES: SETHEADER, "Set Header and Directory
SETLEAF, " Values in Sets
SETLINET. " Short Description of Set Line
DATA: WA_DESCRIPT LIKE SETLINET-DESCRIPT.
DATA: BEGIN OF I_RESULT OCCURS 0,
MANDT LIKE SETHEADER-MANDT, " Client
SETCLASS LIKE SETHEADER-SETCLASS, " Set class
SUBCLASS LIKE SETHEADER-SUBCLASS, " Orgz Unit as Set Subclass
SETNAME LIKE SETHEADER-SETNAME, " Set ID
SETTYPE LIKE SETHEADER-SETTYPE, " Set type
TABNAME LIKE SETHEADER-TABNAME, " Table Name
FIELDNAME LIKE SETHEADER-FIELDNAME, " Field Name
LINEID LIKE SETLEAF-LINEID, " Set line counter
VALOPTION LIKE SETLEAF-VALOPTION, " OPTION field in structure of
" SELECT-OPTIONS tables
VALFROM LIKE SETLEAF-VALFROM, "From Value
VALTO LIKE SETLEAF-VALTO, "To value
DESCRIPT LIKE SETLINET-DESCRIPT, " Short text for a set line
END OF I_RESULT.
SELECT A~MANDT
A~SETCLASS
A~SUBCLASS
A~SETNAME
A~SETTYPE
A~TABNAME
A~FIELDNAME
B~LINEID
B~VALOPTION
B~VALFROM
B~VALTO
INTO TABLE I_RESULT
FROM SETHEADER AS A INNER JOIN
SETLEAF AS B
ON
AMANDT EQ BMANDT
AND
ASETCLASS EQ BSETCLASS
AND
ASUBCLASS EQ BSUBCLASS
AND
ASETNAME EQ BSETNAME
AND
B~LINEID NE ' '
AND
B~VALOPTION NE ' '
AND
B~VALFROM NE ' '
AND
B~VALTO NE ' '.
LOOP AT I_RESULT.
SELECT DESCRIPT
FROM SETLINET CLIENT SPECIFIED
INTO WA_DESCRIPT
WHERE
MANDT EQ I_RESULT-MANDT AND
SETCLASS EQ I_RESULT-SETCLASS AND
SUBCLASS EQ I_RESULT-SUBCLASS AND
SETNAME EQ I_RESULT-SETNAME AND
LINEID EQ I_RESULT-LINEID.
AND LANGU EQ 'E'. " UNCOMMENT TO READ ONLY ENGLISH ****
MOVE WA_DESCRIPT TO I_RESULT-DESCRIPT.
MODIFY I_RESULT.
ENDSELECT.
ENDLOOP.
COMMENT THE BELOW CODE TO INCLUDE ENTRIES WITH EMPTY DESCRIPTIONS.
*DELETE I_RESULT WHERE DESCRIPT EQ ' '.
LOOP AT I_RESULT.
ULINE (80).
WRITE:/2 '*****HIERARCHY No-->',SY-TABIX.
WRITE:/2 I_RESULT-SETNAME.
WRITE:/2 I_RESULT-DESCRIPT.
WRITE:/2 '**********ROOT'.
WRITE:/2 'CLASS',
20 I_RESULT-SETCLASS.
WRITE:/2 'TYPE',
20 I_RESULT-SETTYPE.
WRITE:/2 'TABLE',
20 I_RESULT-TABNAME.
WRITE:/2 'FIELD',
20 I_RESULT-FIELDNAME.
WRITE:/2 '**********LEAF'.
WRITE:/2 'FROM',
20 I_RESULT-VALFROM.
WRITE:/2 'TO',
20 I_RESULT-VALTO.
WRITE:/2 'LINEID',
20 I_RESULT-LINEID.
ENDLOOP.
pls reward points if helpful,
shylaja
Edited by: shylaja puchala on Jan 9, 2008 3:23 PM
‎2008 Jan 09 2:48 PM
Hi siva,
Look at FM K_HIERARCHY_TABLES_READ
Also,
Take a look at SAP program RGSEX001 - good example of several Set related functions. Also other RGSEX* programs.
pls reward if found helpful.
cheers,
Hema.
‎2014 Jan 07 8:12 AM