Costelement groups
Tables:
SETCLST Set Class Descriptions
SETHEADER Set Header and Directory
SETHEADERT Short Description of Sets
T800S FI-SL Set Table (before Release 4.0)
Note: The SETCLASS for Costelement groups = 0102
1. Create SETID
The setid is a concatenation from SETCLASS + Chart of accounts + Setname
Setname is the name of the costelement group.
You can either make the concatenation yourself or use function module G_SET_ENCRYPT_SETID
G_SET_ENCRYPT_SETID
EXPORTING
SETCLASS = '0102'
SHORTNAME = 'CA705_MAT'
KOKRS = '1000'
KTOPL = 'INT'
Returns setid: 0102INT CA705_MAT
Note that SETID can be decrypted again using functionmodule DECRYPT_SETID
2. Read accounst
CALL FUNCTION 'G_SET_TREE_IMPORT'
EXPORTING
CLIENT = '800'
SETID = '0102INT CA705_MAT'
NO_VARIABLE_REPLACEMENT = 'X'
NO_TABLE_BUFFERING = 'X'
Example
REPORT z_test.
data:
li_SET_VALUES like setvalues occurs 0,
l_SET_VALUES like setvalues.
DATA:
l_setid LIKE sethier-setid.
PARAMETERS:
p_ktopl LIKE sethier-ktopl DEFAULT 'INT', "Chart of accounts
p_kokrs LIKE sethier-kokrs DEFAULT '1000', "Controlling area
p_setcls LIKE sethier-setclass DEFAULT '0102', "Set class
p_setnam LIKE setheader-setname DEFAULT 'CA705_MAT'. "Setname – Costelement group
START-OF-SELECTION.
* Create SETID
CALL FUNCTION 'G_SET_ENCRYPT_SETID'
EXPORTING
setclass = p_setcls
shortname = p_setnam
kokrs = p_kokrs
ktopl = p_ktopl
IMPORTING
setid = l_setid.
.
* Read accounts
CALL FUNCTION 'G_SET_TREE_IMPORT'
EXPORTING
SETID = l_setid
TABNAME = ' '
NO_VARIABLE_REPLACEMENT = 'X'
MAX_HIER_LEVEL = 99
TABLES
SET_VALUES = li_SET_VALUES.
END-OF-SELECTION.
loop at li_SET_VALUES into l_SET_VALUES.
write: /
l_SET_VALUES-from,
l_SET_VALUES-to.
endloop.
September 24, 2010
·
admin ·
No Comments
Posted in: SAP General

Leave a Reply