Fonction SAP BAPI_HIERA_CHANGESUBSTRUCTURE - Class Hierarchy BAPI: Change 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 Parameters
SUBSTRUCLISTNEW BAPI1003_TREE 116 Class List

Functionality
This BAPI changes a class hierarchy whose root is the instance. Theclasses involved must all exist. You cannot assign values to theassignments, because this would lead to quantities of data that are toolarge.
Any assignment that does not exist yet is created. Any assignment thatalready exists is changed. Any assignment that exists, but is not inthe table, is deleted.
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 to be changed is transferred in table 'SubtreeList'. Thismust contain correct entries for the fields 'ClassName' (class),'ChildName' (subordinate class), 'Level' (hierarchy level), 'Link'(multiple classification indicator), and 'Status'. The fields'RightName' and 'LeftName' are not relevant here, and the 'Description'field is ignored.
'ClassName' contains the class to which you want the class in'ChildName' assigned. The classification status is specified in'Status'. The hierarchy levels ('Level') can be anything you want, butwe recommend that you assign level 1 to the instance, level 2 to itssubordinate classes, and so on. The level of each class must be higherthan the level of its superior classes. If multiple classificationoccurs, the 'Link' field must be set. When you assign the class toanother superior class, this field contains the entry 'X'. The entriesin the table can be in any sequence.
First, a consistency check is run on the structure. If errors arefound, no changes are made, and the BAPI returns an error log. Thecheck uses the following rules:
The instance is the only class without a superior class.
Each class used exists and is valid.
Each assignment occurs only once (there is no other entry that has thesame classes for 'ClassName' and 'ChildName').
Each class in field 'ChildName' also occurs in field 'ClassName'. (Theclasses that have no subordinate classes have an entry with the'ChildName' left blank.)
Each class only occurs on one hierarchy level ('Level').
The hierarchy level of each class is higher than the level of itssuperior class (the superior class without the 'Link' indicator).
The hierarchy is not recursive. In other words, no class is assigned toitself (indirectly). This applies both to the structure to be changedand to all superior 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 table contains either onlythe error messages from the consistency check, or error/successmessages for creating/changing/deleting the individual assignments. Inthe former case, each entry contains the information that is requiredto identify the error. In the latter case, each assignment has themessage "The assignment of class X to class Y was (not)created/changed/deleted" with the message type 'E' or 'S'. Before thismessage are detailed messages on causes of error, but the actualassignment is not identified.

Example
The instance is Class1.
This class is to contain subordinate classes Class2 and Class3. Class2has subordinate class Class4, which has subordinate class Class5.Class5 is also assigned to Class3. The contents of the table are shownbelow (not all fields are shown):
ClassName ChildName Level Link
------------------------------------------------------------
Class1 Class2 1
Class1 Class3 1
Class2 Class4 2
Class3 Class5 2 X
Class4 Class5 3

Notes
It is necessary to evaluate table 'Return' accurately, because thisBAPI does not tend to return a 'true' or 'false' result. If you want toknow what actually happened, you can also display the new hierarchy byusing BAPI Class.GetSubstructure.
Large hierarchies slow down system performance a lot. If you only wantto change a few assignments, use BAPI Class.ChangeSubclassAllocation orClass.DeleteSubclassAllocation for the individual assignments.
Caution
Each assignment that exists, but is not in the table, is deleted. Ifyou do want this, you must transfer the entire substructure, includingassignments that are not to be changed.
This BAPI does not change the database. To do this, BAPIBapiService.TransactionCommit must be called afterward.

Description
Change number

Description
Class

Description
Class type

Description
Valid-from date

Default
System date

Description
Return parameters

Description
Class list