Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Saving Variant in CL_GUI_ALV_TREE (ALV tree)

Former Member
0 Kudos

Hi,

I' am using the class CL_GUI_ALV_TREE in my report for displaying a hierarchy, all the nodes have a check box attached.

When the user selects the nodes randomly, I would like to give them an option to save the variant.

Is this functionality possible in ALV ? If Yes, please help me finding the way.

Thanks in anticipation

--Amit

6 REPLIES 6

former_member182550
Active Contributor
0 Kudos

A variant does not save report data - rather it saves the report 'look and feel' - the displayed coplumns,  their order, the sort and filter criteria etc.  Your check boxes are basically data.

I would look at possibly inheriting the tree into a local class and redefining the load and save variant methods (if you can find them) to load and save your checkbox selections as well.  Don't forget to call the Super methods though.

Regards

Rich

Former Member
0 Kudos

Hi AKP,

    Could you please elaborate your requirement, because my doubt is that the nodes/hierarchy might be changed based on user input so how you save the output and re-use it?

0 Kudos

I have a ALV created using the component CL_GUI_ALV_TREE.

The tree has a feature to expand/collapse, and each node/subnode has a check box associated to it.

When the user selects the node/subnodes, he should be able to save this selection using variants (this happens correctly in selection screen)

I' am unable to replicate the same behavior in ALV tree.

0 Kudos

Hi AKP,

    According to me its not good idea to save the output because output might change based on the user input e.g., the no.of nodes/sub nodes might be different for different input criteria, so there won't be any use of saving variant in this case.

   

     As an alternative, you can create some custom button and add the logic to create a variant as per user selection so that user can use this variant as input for next time.

0 Kudos

Hi Surendra,

Basically that's what I' am trying to do, "create some custom button and add the logic to create a variant as per user selection so that user can use this variant as input for next time."

But in ALV tree I' am finding it difficult to implement this option, can you help me on how can i achieve this ??

--Thanks

Amit

0 Kudos

After your call to Set_Table_For_First_Display,  call method Add_Button of the toolbar object to add a custom button:

Form Set_ToolBar Changing eo_Alv_Tree Type Alv_Tree.

*

     Data lo_ToolBar Type ToolBar.

*

     Call Method eo_Alv_tree->Get_Toolbar_Object

       Importing

          er_toolbar = lo_toolbar.

*

*    Add seperator to toolbar

*

     Call Method lo_Toolbar->Add_Button

       Exporting

         Fcode     = ''

         Icon      = ''

         Butn_Type = cntb_Btype_Sep

         Text      = ''.

*

*    Add Standard Button to toolbar for mass processing

*

     Call Method lo_Toolbar->Add_Button

       Exporting

         Fcode     = c_ui_Update_Purchase_Orders

         Icon      = ICON_MASS_CHANGE

         Butn_Type = cntb_Btype_Button

         Text      = ''

         Quickinfo = 'Update Purchase Orders'(017).

EndForm.

Then create an avent handler for your tree and register various events including user-command:

Form Set_Handlers Using i_Root_Node Type Tree_Node

                        io_Alv_Tree Type Alv_Tree

               Changing eo_Handler  Type Event_Handler.

*

     Field-Symbols: <f_Event> Type Control_Event.

*

     Data: lt_Events          Type Control_Events,

           lo_Root_Node      Type Ref To Data.

*

     Get Reference Of: i_Root_Node Into lo_Root_Node.

*

*    Register Any events.

*

     Call Method Io_Alv_Tree->Get_Registered_Events

        Importing

          Events     = lt_Events

        Exceptions

          Cntl_Error = 0

          Others     = 0.

     Add_Event: EventId_Checkbox_Change,

                EventId_Item_Double_Click,

                EventId_Node_Double_Click.

*

     Call Method io_Alv_Tree->Set_Registered_Events

       Exporting

          Events                    = lt_Events

       Exceptions

          Cntl_Error                = 0

          Cntl_System_Error         = 0

          Illegal_Event_Combination = 0.

*

     Create Object eo_Handler

        Exporting

            io_Tree      = io_Alv_Tree

            io_Root_Node = lo_Root_Node.

     Set Handler: eo_Handler->Handle_Cb_Changed   For io_Alv_Tree,

                  eo_Handler->Handle_User_Command For io_Alv_Tree,

                  eo_Handler->Handle_Item_DClick  For io_Alv_Tree,

                  eo_Handler->Handle_Node_DClick  For io_Alv_Tree.

     Free lo_Root_Node.

EndForm.

And then in your local event handler define a handler for user command or whatever.

Regards

Rich