Skip to Content

Saving Variant in CL_GUI_ALV_TREE (ALV tree)

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

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Posted on Nov 12, 2015 at 08:28 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 12, 2015 at 09:31 AM

    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?

    Add a comment
    10|10000 characters needed characters exceeded

    • 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

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.