Skip to Content

Hi All,

Here is my code to generate ALV tree with 5 hierarchy dynamically (or less according with your needs and with no change in the code)  and changing just a perform parameters to generate it. I don’t know if it have a easier and better way to do but this one is working 🙂

If you know another way please share 😉

So follow the code:

Declarations:

  • My output table and work area are called, respectively: it_output and wa_output.
  • My fieldcat declaration fieldcat  TYPE lvc_t_fcat,

DATA: tree1              TYPE REF TO cl_gui_alv_tree.

DATA: v_icon1            TYPE lvc_s_layi,
     v_icon2           
TYPE lvc_s_layi,
     v_icon3           
TYPE lvc_s_layi,
     v_icon4           
TYPE lvc_s_layi,
     v_icon5           
TYPE lvc_s_layi.

FIELD-SYMBOLS: <field1>    TYPE any,
              <field2>   
TYPE any,
              <field3>   
TYPE any,
              <field4>   
TYPE any,
              <field5>   
TYPE any,
              <reffield1>
TYPE any,
              <reffield2>
TYPE any,
              <reffield3>
TYPE any,
              <reffield4>
TYPE any,
              <reffield5>
TYPE any.

Logic:

  • Hierarchic Field parameter must be called EXACTLY as the field name declarated in your output table. 
  • Ref tab and Ref Field will be used to bring the field information (data element). <reffieldX> will be used to compare the last information and the actual one and create a new node or keep the informationa agrrouped. It’s really important to have it done correctly! You can’t compare bananas to apples, right?!
  • If you want just 3 levels, clean the #4 and #5 in field_symbol. (Keep the ” though) Simply like that.

*                                                           Hierarchic Field / Ref Tab /  Ref Field
PERFORM f_field_symbol USING: ‘TYPED’    ‘T6B1T’      ‘VTEXT’ “1
                             
‘DESC’      ‘TB038B’    ‘TEXT’  “2
                             
‘KNUMA’    ‘KONA’       ‘KNUMA’ “3
                             
‘KSCHL’     ‘VAKEVB’  ‘KSCHL’ “4
                             
‘KOTABNR’ ‘VAKEVB’  ‘KOTABNR’. “5

*&———————————————————————*
*&      Form  F_FIELD_SYMBOL
*&———————————————————————*
*       text
*———————————————————————-*
*      –>P_0299   text
*      –>P_0300   text
*      –>P_0301   text
*———————————————————————-*
FORM f_field_symbol  USING field1 table1 param1
                            field2 table2 param2
                            field3 table3 param3
                            field4 table4 param4
                            field5 table5 param5
.

DATA r_elemdescr  TYPE REF TO cl_abap_elemdescr.
DATA r_field      TYPE REF TO data.
DATA: data_element TYPE dd04drollname.

IF field1 IS NOT INITIAL.

ASSIGN COMPONENT field1 OF STRUCTURE wa_output TO <field1>.
CHECK sysubrc = 0.

PERFORM f_fieldinfo USING table1 param1
CHANGING data_element.

r_elemdescr ?= cl_abap_elemdescr=>describe_by_name( data_element ).
CREATE DATA r_field TYPE HANDLE r_elemdescr.
ASSIGN r_field->* TO <reffield1>.
ENDIF.

IF field2 IS NOT INITIAL.

ASSIGN COMPONENT field2 OF STRUCTURE wa_output TO <field2>.
CHECK sysubrc = 0.

PERFORM f_fieldinfo USING table2 param2
CHANGING data_element.

r_elemdescr ?= cl_abap_elemdescr=>describe_by_name( data_element ).
CREATE DATA r_field TYPE HANDLE r_elemdescr.
ASSIGN r_field->* TO <reffield2>.
ENDIF.

IF field3 IS NOT INITIAL.

ASSIGN COMPONENT field3 OF STRUCTURE wa_output TO <field3>.
CHECK sysubrc = 0.

PERFORM f_fieldinfo USING table3 param3
CHANGING data_element.

r_elemdescr ?= cl_abap_elemdescr=>describe_by_name( data_element ).
CREATE DATA r_field TYPE HANDLE r_elemdescr.
ASSIGN r_field->* TO <reffield3>.

ENDIF.

IF field4 IS NOT INITIAL.

ASSIGN COMPONENT field4 OF STRUCTURE wa_output TO <field4>.
CHECK sysubrc = 0.

PERFORM f_fieldinfo USING table4 param4
CHANGING data_element.

r_elemdescr ?= cl_abap_elemdescr=>describe_by_name( data_element ).
CREATE DATA r_field TYPE HANDLE r_elemdescr.
ASSIGN r_field->* TO <reffield4>.
ENDIF.

IF param5 IS NOT INITIAL.
ASSIGN COMPONENT field5 OF STRUCTURE wa_output TO <field5>.
CHECK sysubrc = 0.

PERFORM f_fieldinfo USING table5 param5
CHANGING data_element.

r_elemdescr ?= cl_abap_elemdescr=>describe_by_name( data_element ).
CREATE DATA r_field TYPE HANDLE r_elemdescr.
ASSIGN r_field->* TO <reffield5>.
ENDIF.

PERFORM build_sort_table USING field1 field2 field3 field4 field5.

ENDFORM.                    ” F_FIELD_SYMBOL

*&———————————————————————*
*&      Form  F_FIELDINFO
*&———————————————————————*
*       text
*———————————————————————-*
*      –>P_TABLE1  text
*      –>P_PARAM1  text
*      <–P_DATA_ELEMENT  text
*———————————————————————-*
FORM f_fieldinfo  USING    table
param
CHANGING data_element.

DATA: BEGIN OF dfies OCCURS 100.
INCLUDE STRUCTURE dfies.
DATA: END OF dfies.

DATA: tablenm  TYPE ddobjname,
fieldnm 
TYPE dfiesfieldname.

MOVE table TO tablenm.
MOVE param TO fieldnm.

***  Fname Description

IF NOT fieldnm IS INITIAL.
CALL FUNCTION ‘DDIF_FIELDINFO_GET’
EXPORTING
tabname       
= tablenm
fieldname     
= fieldnm
langu         
= sylangu
TABLES
dfies_tab     
= dfies
EXCEPTIONS
not_found     
= 1
internal_error
= 2
OTHERS         = 3.
IF sysubrc = 0.
READ TABLE dfies INDEX 1.
data_element
= dfiesrollname.
ENDIF.
ENDIF.

ENDFORM.                    ” F_FIELDINFO


Creating hierarchies

  • Basically it will change according to what you used as parameter in perform f_field_symbol.
  • Each node have your own perform because if you want to fill the 2nd node with something different to the standard counts (sum, avg, max, min, … – flagging H_FTYPE on fieldcat and using call method tree1->update_calculations.)  you need to use the same work are type used in your detailed line and organize it to show up what you want to.

*&———————————————————————*
*&      Form  CREATE_HIERARCHY
*&———————————————————————*
*       text
*———————————————————————-*
*  –>  p1        text
*  <–  p2        text
*———————————————————————-*
FORM create_hierarchy .

* add data to tree
DATA: l_last_key  TYPE lvc_nkey,
l_kotabnr  
TYPE vakevbkotabnr,
l_knuma    
TYPE vakevbknuma,
l_desc
(100) TYPE c,
l_kschl    
TYPE vakevbkschl,
l_add      
TYPE c.

DATA: l_param_key  TYPE lvc_nkey,
l_param2_key
TYPE lvc_nkey,
l_param3_key
TYPE lvc_nkey,
l_param4_key
TYPE lvc_nkey,
l_param5_key
TYPE lvc_nkey.

LOOP AT it_output INTO wa_output.

**** LEVEL 1
IF <field1> IS ASSIGNED.
IF <field2> IS ASSIGNED. “Level 2 is empty
IF <field1> IS NOT INITIAL.
IF <reffield1> NE <field1>.
PERFORM level1 USING
v_icon1
fieldname
CHANGING l_param_key.

IF <field2> IS ASSIGNED.
CLEAR: <reffield2>.
ENDIF.

IF <field3> IS ASSIGNED.
CLEAR: <reffield3>.
ENDIF.

IF <field4> IS ASSIGNED.
CLEAR: <reffield4>.
ENDIF.

APPEND l_param_key TO it_expand_nodes.

ENDIF.
ENDIF.
ELSE.
“If next level is empty so finish the hierarchy
PERFORM add_complete_line USING 2
CHANGING l_last_key.
l_add
= ‘X’.
ENDIF.
ENDIF.

**** LEVEL 2
IF <field2> IS ASSIGNED.
IF <field3> IS ASSIGNED. “Level 3 is empty
IF <field2> IS NOT INITIAL.
IF <reffield2> NE <field2>.
PERFORM level2 USING l_param_key
2
v_icon2
fieldname
CHANGING l_param2_key.

IF <field3> IS ASSIGNED.
CLEAR: <reffield3>.
ENDIF.

IF <field4> IS ASSIGNED.
CLEAR: <reffield4>.
ENDIF.

APPEND l_param2_key TO it_expand_nodes.

ENDIF.
ENDIF.
ELSE.
“If next level is empty so finish the hierarchy
PERFORM add_complete_line USING L_PARAM_KEY 3
CHANGING l_last_key.
l_add
= ‘X’.
ENDIF.
ENDIF.

*** LEVEL 3
IF <field3> IS ASSIGNED.
IF <field4> IS ASSIGNED. “Level 4 is empty
IF <field3> IS NOT INITIAL.
IF <reffield3> NE <field3>.
PERFORM level3 USING l_param2_key
3
v_icon3
fieldname
CHANGING l_param3_key .

IF <field4> IS ASSIGNED.
CLEAR: <reffield4>.
ENDIF.

APPEND  l_param3_key TO it_expand_nodes.

ENDIF.
ENDIF.
ELSE.
“If next level is empty so finish the hierarchy
PERFORM add_complete_line USING l_param2_key 4
CHANGING l_last_key.
l_add
= ‘X’.
ENDIF.
ENDIF.

*** LEVEL 4
IF <field4> IS ASSIGNED.
IF <field5> IS ASSIGNED. “Level 4 is empty
IF <field4> IS NOT INITIAL.
IF <reffield4> NE <field4>.
PERFORM level4 USING l_param3_key
3
v_icon3
fieldname
CHANGING l_param4_key .

IF <field5> IS ASSIGNED.
CLEAR: <reffield5>.
ENDIF.

APPEND  l_param4_key TO it_expand_nodes.

ENDIF.
ENDIF.
ELSE.
“If next level is empty so finish the hierarchy
PERFORM add_complete_line USING l_param3_key 4
CHANGING l_last_key.
l_add
= ‘X’.
ENDIF.
ENDIF.

*** LEVEL 5
IF <field5> IS ASSIGNED.
IF <field5> IS NOT INITIAL.
IF <reffield5> NE <field5>.
PERFORM level5 USING l_param4_key
4
v_icon5
fieldname
CHANGING l_param5_key .

APPEND  l_param4_key TO it_expand_nodes.

PERFORM add_complete_line USING l_param5_key 6
CHANGING l_last_key.
l_add
= ‘X’.

ENDIF.
ENDIF.
ENDIF.

IF l_add IS INITIAL.
PERFORM add_complete_line USING l_param5_key 5
CHANGING l_last_key.
ENDIF.

IF <field1> IS ASSIGNED.
<reffield1>
= <field1>.
ENDIF.

IF <field2> IS ASSIGNED.
<reffield2>
= <field2>.
ENDIF.

IF <field3> IS ASSIGNED.
<reffield3>
= <field3>.
ENDIF.

IF <field4> IS ASSIGNED.
<reffield4>
= <field4>.
ENDIF.

IF <field5> IS ASSIGNED.
<reffield5>
= <field5>.
ENDIF.

CLEAR: l_add.

ENDLOOP.

*&———————————————————————*
*&      Form  LEVEL1
*&———————————————————————*
*       text
*———————————————————————-*
*      –>P_WA_DATA  text
*      –>P_L_PARAM2_KEY  text
*      –>P_3      text
*      –>P_1748   text
*      <–P_L_PARAM3_KEY  text
*———————————————————————-*
FORM level1 USING  p_relat_key TYPE lvc_nkey
p_icon
CHANGING p_node_key.

DATA: l_node_text TYPE lvc_value,
relat      
TYPE int4,
wa_refe    
TYPE tab_type,
wa_level  
TYPE ty_output.

* set item-layout
DATA: lt_item_layout TYPE lvc_t_layi,
ls_item_layout
TYPE lvc_s_layi.

DATA: ls_node TYPE lvc_s_layn.
ls_node
n_image   = space.
ls_node
exp_image = space.

ls_item_layoutt_image = p_icon.
ls_item_layout
style   = cl_gui_column_tree=>style_intensified.
ls_item_layout
fieldname = tree1->c_hierarchy_column_name.
APPEND ls_item_layout TO lt_item_layout.

* add node
l_node_text
= <field1>.
wa_level
level   = 1.

ls_nodeisfolder = ‘X’.

CALL METHOD tree1->add_node
EXPORTING
i_relat_node_key    
= p_relat_key
i_relationship      
= cl_gui_column_tree=>relat_last_child
i_node_text         
= l_node_text
is_outtab_line      
= wa_level
is_node_layout      
= ls_node
it_item_layout      
= lt_item_layout
IMPORTING
e_new_node_key      
= p_node_key
EXCEPTIONS
relat_node_not_found
= 1
node_not_found      
= 2
OTHERS               = 3.

ENDFORM.                    ” LEVEL1


*&———————————————————————*
*&      Form  LEVEL2
*&———————————————————————*
*       text
*———————————————————————-*
*      –>P_L_PARAM1_KEY  text
*      –>P_2      text
*      –>P_1721   text
*      <–P_L_PARAM2_KEY  text
*———————————————————————-*
FORM level2  USING p_relat_key TYPE lvc_nkey
hierarchy
icon
CHANGING p_node_key TYPE lvc_nkey.

* set item-layout
DATA: lt_item_layout TYPE lvc_t_layi,
l_node_text   
TYPE lvc_value,
ls_item_layout
TYPE lvc_s_layi,
relat         
TYPE int4,
wa_level     
TYPE ty_output.

ls_item_layoutt_image = icon.
ls_item_layout
style   cl_gui_column_tree=>style_intensified.
ls_item_layout
fieldname = tree1->c_hierarchy_column_name.
APPEND ls_item_layout TO lt_item_layout.

* add node
l_node_text
= <field2>.
wa_level
level = hierarchy.

relat = cl_gui_column_tree=>relat_last_child.
CALL METHOD tree1->add_node
EXPORTING
i_relat_node_key
= p_relat_key
i_relationship  
= relat
i_node_text     
= l_node_text
is_outtab_line  
= wa_level
it_item_layout  
= lt_item_layout
IMPORTING
e_new_node_key  
= p_node_key.

ENDFORM.                    “LEVEL2

*&———————————————————————*
*&      Form  LEVEL3
*&———————————————————————*
*       text
*———————————————————————-*
*      –>P_L_PARAM1_KEY  text
*      –>P_2      text
*      –>P_1721   text
*      <–P_L_PARAM2_KEY  text
*———————————————————————-*
FORM level3  USING p_relat_key TYPE lvc_nkey
hierarchy
icon
CHANGING p_node_key TYPE lvc_nkey.

* set item-layout
DATA: lt_item_layout TYPE lvc_t_layi,
l_node_text   
TYPE lvc_value,
ls_item_layout
TYPE lvc_s_layi,
relat         
TYPE int4,
wa_level     
TYPE ty_output.

ls_item_layoutt_image = icon.
ls_item_layout
style   cl_gui_column_tree=>style_intensified.
ls_item_layout
fieldname = tree1->c_hierarchy_column_name.
APPEND ls_item_layout TO lt_item_layout.

* add node
l_node_text
= <field3>.

wa_levelknuma   = wa_outputknuma.

CONCATENATE wa_outputdatab+6(2)
wa_output
datab+4(2)
wa_output
datab(4)
INTO wa_levelzzbrandd
SEPARATED BY ‘.’.

CONCATENATE wa_outputdatbi+6(2)
wa_output
datbi+4(2)
wa_output
datbi(4)
INTO wa_levelkunnr
SEPARATED BY ‘.’.

wa_levelmatnr   = wa_outputwaers.
wa_level
kondm   = wa_outputagnotes.
wa_level
level   = hierarchy.

relat = cl_gui_column_tree=>relat_last_child.
CALL METHOD tree1->add_node
EXPORTING
i_relat_node_key
= p_relat_key
i_relationship  
= relat
i_node_text     
= l_node_text
is_outtab_line  
= wa_level
it_item_layout  
= lt_item_layout
IMPORTING
e_new_node_key  
= p_node_key.

ENDFORM.                    ” LEVEL3

*&———————————————————————*
*&      Form  LEVEL4
*&———————————————————————*
*       text
*———————————————————————-*
*      –>P_L_PARAM1_KEY  text
*      –>P_2      text
*      –>P_1721   text
*      <–P_L_PARAM2_KEY  text
*———————————————————————-*
FORM level4  USING p_relat_key TYPE lvc_nkey
hierarchy
icon
CHANGING p_node_key TYPE lvc_nkey.

* set item-layout
DATA: lt_item_layout TYPE lvc_t_layi,
l_node_text   
TYPE lvc_value,
ls_item_layout
TYPE lvc_s_layi,
relat         
TYPE int4,
wa_level     
TYPE ty_output.

ls_item_layoutt_image = icon.
ls_item_layout
style   cl_gui_column_tree=>style_intensified.
ls_item_layout
fieldname = tree1->c_hierarchy_column_name.
APPEND ls_item_layout TO lt_item_layout.

* add node

l_node_text = <field4>.

wa_levelzzbrandd = wa_outputcombin.
wa_level
level   = hierarchy.

wa_levelknuma = wa_outputknuma.

relat = cl_gui_column_tree=>relat_last_child.
CALL METHOD tree1->add_node
EXPORTING
i_relat_node_key
= p_relat_key
i_relationship  
= relat
i_node_text     
= l_node_text
is_outtab_line  
= wa_level
it_item_layout  
= lt_item_layout
IMPORTING
e_new_node_key  
= p_node_key.

ENDFORM.                    “LEVEL4

*&———————————————————————*
*&      Form  LEVEL5
*&———————————————————————*
*       text
*———————————————————————-*
*      –>P_L_PARAM1_KEY  text
*      –>P_2      text
*      –>P_1721   text
*      <–P_L_PARAM2_KEY  text
*———————————————————————-*
FORM level5  USING p_relat_key TYPE lvc_nkey
hierarchy
icon
CHANGING p_node_key TYPE lvc_nkey.

* set item-layout
DATA: lt_item_layout TYPE lvc_t_layi,
l_node_text   
TYPE lvc_value,
ls_item_layout
TYPE lvc_s_layi,
relat         
TYPE int4,
wa_level     
TYPE ty_output.

ls_item_layoutt_image = icon.
ls_item_layout
style   cl_gui_column_tree=>style_intensified.
ls_item_layout
fieldname = tree1->c_hierarchy_column_name.
APPEND ls_item_layout TO lt_item_layout.

* add node

l_node_text = <field5>.

wa_levelzzbrandd = wa_outputcombin.
wa_level
level   = hierarchy.

wa_levelknuma = wa_outputknuma.

relat = cl_gui_column_tree=>relat_last_child.
CALL METHOD tree1->add_node
EXPORTING
i_relat_node_key
= p_relat_key
i_relationship  
= relat
i_node_text     
= l_node_text
is_outtab_line  
= wa_level
it_item_layout  
= lt_item_layout
IMPORTING
e_new_node_key  
= p_node_key.

ENDFORM.                    “LEVEL5

*&———————————————————————*
*&      Form  add_cmplete_line
*&———————————————————————*
*       add hierarchy-level 3 to tree
*———————————————————————-*
*      –>P_LS_SFLIGHT  sflight
*      –>P_RELEATKEY   relatkey
*     <–>p_node_key    new node-key
*———————————————————————-*
FORM add_complete_line USING  p_relat_key TYPE lvc_nkey
hierarchy
CHANGING  p_node_key TYPE lvc_nkey.

DATA: l_node_text TYPE lvc_value.

* set item-layout
DATA: lt_item_layout TYPE lvc_t_layi,
ls_item_layout
TYPE lvc_s_layi.

ls_item_layoutfieldname = tree1->c_hierarchy_column_name.
APPEND ls_item_layout TO lt_item_layout.

l_node_text = wa_outputbonem.

IF l_node_text IS INITIAL.
MESSAGE s021(zgeral) DISPLAY LIKE ‘E’.
LEAVE LIST-PROCESSING.
ENDIF.

DATA: ls_node TYPE lvc_s_layn.
ls_node
n_image   = space.
ls_node
exp_image = space.

wa_outputlevel = hierarchy.

CALL METHOD tree1->add_node
EXPORTING
i_relat_node_key
= p_relat_key
i_relationship  
= cl_gui_column_tree=>relat_last_child
is_outtab_line  
= wa_output
i_node_text     
= l_node_text
is_node_layout  
= ls_node
it_item_layout  
= lt_item_layout
IMPORTING
e_new_node_key  
= p_node_key.
ENDFORM.                               ” add_complete_line

I think that is everything here. Let me know if I missed something or someone need help to understand it.

Hope it helps.

Regards,

Andréa

To report this post you need to login first.

8 Comments

You must be Logged on to comment or reply to a post.

  1. sikken s

    hi,

    I read your blog it’s very interest, i tried to implement the code and i have a lot of missing variable and form……

    thanks,

    sikken s.

    (0) 
    1. Andrea Molina Post author

      Hi sikken s

      I thought that a few will be missed. I just copied and pasted from a code that was working and it’s quite big.

      Can you please send it to me and them we can make it easier for other people.  You can send a private message and I can edit it here. It’s up to you.

      Thanks for your compliment.

      Andréa

      (0) 
      1. Artur Izdebski

        Hello,

        Missing FORM “build_sort_table”,

        missing definition of :
            –     it_output

          –     wa_output


        Missing PERFORM for “create_hierarchy”


        Best regards

        Artur

        (0) 
        1. Andrea Molina Post author

          This is not a guide to create the ALV tree but a guide to make it dynamically.

          Anyway, in PBO:

          *&———————————————————————*

          *&      Module  PBO_100  OUTPUT

          *&———————————————————————*

          *       text

          *———————————————————————-*

          MODULE pbo_100 OUTPUT.

             SET PF-STATUS ‘MAIN’.

             IF tree1 IS INITIAL.

               ” The Tree Control has not been created yet.

               ” Create a Tree Control and insert nodes into it.

               PERFORM create_and_init_tree.

             ENDIF.

          ENDMODULE.                 ” PBO_100  OUTPUT

          *&———————————————————————*

          *&      Form  CREATE_AND_INIT_TREE

          *&———————————————————————*

          *       text

          *———————————————————————-*

          *  –>  p1        text

          *  <–  p2        text

          *———————————————————————-*

          FORM create_and_init_tree.

             DATA: node_table TYPE node_table_type,

                   events     TYPE cntl_simple_events,

                   event      TYPE cntl_simple_event.

          * create container for alv-tree

             PERFORM setup_container USING ‘TREE_CONTAINER’.

          * repid for saving variants

             DATA: ls_variant TYPE disvariant.

             ls_variantreport = syrepid.

          * create hierarchy

             CALL METHOD tree1->set_table_for_first_display

               EXPORTING

                 is_hierarchy_header = v_hierarchy_header

                 it_list_commentary  = lt_list_commentary

                 i_logo              = l_logo

                 i_background_id     = ‘Z_BICYCLE_BG’

                 i_save              = ‘A’

                 is_variant          = ls_variant

               CHANGING

                 it_outtab           = it_output_empty

                 it_fieldcatalog     = fieldcat.

          * create hierarchy

             PERFORM create_hierarchy.

             PERFORM events.

          **** optimize column-width

          *  CALL METHOD tree1->column_optimize

          *    EXPORTING

          *      i_start_column = tree1->c_hierarchy_column_name

          *      i_end_column   = tree1->c_hierarchy_column_name.

          ENDFORM.                    ” CREATE_AND_INIT_TREE

          For deeper reference to how to create an ALV tree please check SAP samples. (E.g.: SAPSIMPLE_TREE_CONTROL_DEMO)

          The it_ouput and wa_output depends of you want to show up in the ALV. It’s the t_outtab in the function ‘REUSE_ALV_GRID_DISPLAY’. Is it clear now?

          The FORM “build_sort_table” is in the general comment.

          Let me know if more help is needed

          Thanks,

          Andréa

          (0) 
  2. Andrea Molina Post author

    *&———————————————————————*

    *&      Form  BUILD_SORT_TABLE

    *&———————————————————————*

    *       text

    *———————————————————————-*

    FORM build_sort_table USING field1

                                 field2

                                 field3

                                 field4

                                 field5

                                 field6.

       DATA ls_sort_wa TYPE lvc_s_sort.

       ADD 1 TO ls_sort_waspos.

       ls_sort_wafieldname = field1.

       ls_sort_waup = ‘X’.

       ls_sort_wasubtot = .

       APPEND ls_sort_wa TO gt_sort.

       ADD 1 TO ls_sort_waspos.

       ls_sort_wafieldname = field2.

       ls_sort_waup = ‘X’.

       ls_sort_wasubtot = .

       APPEND ls_sort_wa TO gt_sort.

       ADD 1 TO ls_sort_waspos.

       ls_sort_wafieldname = field3.

       ls_sort_waup = ‘X’.

       ls_sort_wasubtot = .

       APPEND ls_sort_wa TO gt_sort.

       ADD 1 TO ls_sort_waspos.

       ls_sort_wafieldname = field3.

       ls_sort_waup = ‘X’.

       ls_sort_wasubtot = .

       APPEND ls_sort_wa TO gt_sort.

       ADD 1 TO ls_sort_waspos.

       ls_sort_wafieldname = field4.

       ls_sort_waup = ‘X’.

       ls_sort_wasubtot = .

       APPEND ls_sort_wa TO gt_sort.

       ADD 1 TO ls_sort_waspos.

       ls_sort_wafieldname = field5.

       ls_sort_waup = ‘X’.

       ls_sort_wasubtot = .

       APPEND ls_sort_wa TO gt_sort.

       ADD 1 TO ls_sort_waspos.

       ls_sort_wafieldname = field6.

       ls_sort_waup = ‘X’.

       ls_sort_wasubtot = .

       APPEND ls_sort_wa TO gt_sort.

    (0) 

Leave a Reply