Fonction SAP BAPI_HIERA_ADDSUBSTRUCTURE - Class Hierarchy BAPI: Create Hierarchy (Top Down)

Paramètre Reférence Type Long. Valeur par déf. Facultatif Description
CHANGENUMBER BAPI1003_KEY-CHANGENUMBER C 12 X Change number
CLASSNUM BAPI1003_KEY-CLASSNUM C 18 Class
CLASSTYPE BAPI1003_KEY-CLASSTYPE C 3 Class type
KEYDATE BAPI1003_KEY-KEYDATE D 8 SY-DATUM X Valid-From Date

Paramètre Reférence Long. Facultatif Description
RETURN BAPIRET2 548 Return parameter
SUBSTRUCLIST BAPI1003_TREE 116 Class List

Functionality
This BAPI creates a class hierarchy whose root is the instance. Theclasses involved must all exist. You cannot assign values to theassignments, because this would involve too much data.
The instance is defined by the class name ('ClassNum') and the classtype ('ClassType'). You can also specify a date ('KeyDate') and achange number ('ChangeNumber').
The structure you create is transferred in table 'SubtreeList'. In thistable, the fields 'ClassName' (class), 'ChildName' (subordinate class),'Level' (hierarchy level), 'Link' (multiple classification indicator),and 'Status' must be filled correctly. The fields 'RightName' and'LeftName' are irrelevant here, and the 'Description' field is ignored.
'ClassName' contains the class to which you want to assign the class in'ChildName'. The classification status is specified in 'Status'. Thehierarchy levels ('Level') can be anything you like, but we recommendassigning level 1 to the instance, level 2 to its immediate subordinateclasses, and so on. In any case, the level of a class must always behigher than the level of its subordinate class. If multipleclassification applies, the field 'Link' must be set. When a class isassigned to a second superior class, this field contains the entry 'X'.The sequence of entries in the table is irrelevant.
First, the structure is checked for consistency. If errors are found,nothing is created, and the BAPI just returns the error log. Thefollowing rules are checked:
The instance is the only class without a superior class.
Each class used exists and is valid.
Each assignment is unique (no other entry has the same classes for'ClassName' and 'ChildName').
Each class in field 'ChildName' also occurs in field 'ClassName'.(Classes without subordinate classes have an entry with an empty'ChildName' field.)
A class is always on the same hierarchy level ('Level').
The hierarchy level of each class is higher than the level of itssuperior class (the one without the 'Link' indicator).
The hierarchy is not recursive - no class is (indirectly) assigned toitself. This rule applies to both the structure being created and allsuperior classes of the instance.
Each class in field 'ChildName' has exactly one entry without the'Link' indicator.
The results are logged in table RETURN. This contains either the errormessages from the consistency check only, or the error/success messagesfrom creating the individual assignments. In the former case, eachentry contains the information required to identify the error. In thelatter case, each assignment has the message "The assignment of class Xto class Y was (not) created", with the appropriate message type "E" or"S". Before this message, there are detailed messages on the causes oferrors, but without identifying which belongs to which assignment.

Example
The instance is Class1.
It is to contain subordinate classes Class2 and Class3. Class2 hassubordinate class Class4, which has subordinate class Class5. Class5 isalso assigned to Class3. The table then looks as follows (not allfields are shown):
ClassName,,ChildName,,Level,,Link
Class1,,Class2,,1
Class1,,Class3,,1
Class2,,Class4,,2
Class3,,Class5,,2,,X
Class4,,Class5,,3

Notes
Ensure that you evalute table RETURN accurately, because this BAPI doesnot deliver a result that is either "correct" or "incorrect". If youwant to know what has actually been created, you can use BAPIClass.GetSubstructure to display the hierarchy you have created.
Large hierarchies slow down system performance. If you only want tocreate one assignment, always use BAPI Class.CreateSubclassAllocation.
This BAPI does not change the database. To do this, call BAPIBapiService.TransactionCommit afterward.

Description
Change number

Description
Class

Description
Class type

Description
Valid-from date

Default
System date

Description
Return parameters

Description
Class list