Alv output in tree structure

Hii..
   I want to output alv list which seggregates the data into folders and subfolders according to conditions. How can I assign data to these folders. What function module is good for this purpose, and I also want coloured list output depending on these conditions

Hi Cynthia,
                Use FM "RS_TREE_LIST_DISPLAY"
Refer this code. :
TYPE-POOLS : STREE.
TABLES : VBAK, VBAP.
DATA : WA_NODE TYPE SNODETEXT.
DATA : NODE_TABLE LIKE WA_NODE OCCURS 0 WITH HEADER LINE.
TYPES : BEGIN OF D_VBAK,
        VBELN TYPE VBELN_VA,
        ERDAT TYPE ERDAT,
        KUNNR TYPE KUNAG,
        END OF D_VBAK.
TYPES : BEGIN OF D_VBAP,
        VBELN TYPE VBELN_VA,
        POSNR TYPE POSNR_VA,
        MATNR TYPE MATNR,
        VRKME TYPE VRKME,
        KWMENG TYPE KWMENG,
        ARKTX TYPE ARKTX,
        END OF D_VBAP.
TYPES : BEGIN OF D_LIKP,
        VBELV TYPE VBELN_VON,
        VBELN TYPE VBELN_NACH,
        END OF D_LIKP.
TYPES : BEGIN OF D_VBRK,
        VBELV TYPE VBELN_VON,
        VBELN TYPE VBELN_NACH,
        END OF D_VBRK.
DATA : I_VBAK TYPE STANDARD TABLE OF D_VBAK WITH HEADER LINE,
       I_VBAP TYPE STANDARD TABLE OF D_VBAP WITH HEADER LINE,
       I_LIKP TYPE STANDARD TABLE OF D_LIKP WITH HEADER LINE,
       I_VBRK TYPE STANDARD TABLE OF D_VBRK WITH HEADER LINE.
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME.
SELECT-OPTIONS : S_VBELN FOR VBAK-VBELN.
SELECTION-SCREEN END OF BLOCK B1.
START-OF-SELECTION.
PERFORM FETCH_DATA.
PERFORM FILL_NODES.
PERFORM TREE_DISPLAY.
FORM USER_COMMAND TABLES  NODE STRUCTURE SEUCOMM
                  USING COMMAND
                  CHANGING EXIT
                           LIST_REFRESH .
  DATA : D_VBELN TYPE VBELN_VA.
  DATA : D_PARENT TYPE n length 6.
  READ TABLE NODE_TABLE WITH KEY ID = NODE-PARENT.
  IF NODE_TABLE-NAME = 'INVOICE'.
  SET PARAMETER ID 'VF' FIELD NODE-NAME.
  CALL TRANSACTION 'VF03' AND SKIP FIRST SCREEN.
  ELSEIF NODE_TABLE-NAME = 'DELIVERY'.
  SET PARAMETER ID 'VL' FIELD NODE-NAME.
  CALL TRANSACTION 'VL03N' AND SKIP FIRST SCREEN.
  ELSEIF NODE_TABLE-NAME = 'ITEM DATA'.
  D_PARENT = NODE-PARENT - 1.
  READ TABLE NODE_TABLE WITH KEY ID = D_PARENT.
  D_VBELN = NODE_TABLE-NAME.
  SET PARAMETER ID 'AUN' FIELD D_VBELN.
  CALL TRANSACTION 'VA03' AND SKIP FIRST SCREEN.
  ENDIF.
ENDFORM.
*&      Form  FIELD_VALIDATION
      text
-->  p1        text
<--  p2        text
form FIELD_VALIDATION .
SELECT VBELN INTO TABLE I_VBAK
             FROM VBAK
             WHERE VBELN IN S_VBELN.
IF SY-SUBRC <> 0.
MESSAGE E201.
ENDIF.
SELECT VBELN INTO TABLE I_VBAK
             FROM VBAK
             WHERE VBELN = S_VBELN-HIGH.
IF SY-SUBRC <> 0.
MESSAGE E201.
ENDIF.
endform.                    " FIELD_VALIDATION
*&      Form  FETCH_DATA
      text
-->  p1        text
<--  p2        text
form FETCH_DATA .
SELECT VBELN
       ERDAT
       KUNNR INTO TABLE I_VBAK
             FROM VBAK
             WHERE VBELN IN S_VBELN.
SELECT VBELN
       POSNR
       MATNR
       VRKME
       KWMENG
       ARKTX
       INTO  TABLE I_VBAP
             FROM VBAP
             FOR ALL ENTRIES IN I_VBAK
             WHERE VBELN = I_VBAK-VBELN.
SELECT VBELV
       VBELN
       INTO TABLE I_LIKP
       FROM VBFA
       FOR ALL ENTRIES IN I_VBAK
       WHERE VBELV    = I_VBAK-VBELN
       AND   VBTYP_N  = 'J'.
SELECT VBELV
       VBELN
       INTO TABLE I_VBRK
       FROM VBFA
       FOR ALL ENTRIES IN I_VBAK
       WHERE VBELV    = I_VBAK-VBELN
       AND   VBTYP_N  = 'M'.
endform.                    " FETCH_DATA
*&      Form  FILL_NODES
      text
-->  p1        text
<--  p2        text
form FILL_NODES .
NODE_TABLE-TYPE = 'T'.
NODE_TABLE-NAME = 'SALES ORDER'.
NODE_TABLE-TLEVEL = '01'.
NODE_TABLE-NLENGTH = '15'.
NODE_TABLE-COLOR = '4'.
NODE_TABLE-TEXT = ''.
NODE_TABLE-TLENGTH = '20'.
NODE_TABLE-TCOLOR  = '3'.
APPEND NODE_TABLE.
CLEAR NODE_TABLE.
LOOP AT I_VBAK.
AT NEW VBELN.
NODE_TABLE-TYPE = 'P'.
NODE_TABLE-NAME = I_VBAK-VBELN.
NODE_TABLE-TLEVEL = '02'.
NODE_TABLE-NLENGTH = '20'.
NODE_TABLE-COLOR = '4'.
NODE_TABLE-TEXT = ''.
NODE_TABLE-TLENGTH = '30'.
NODE_TABLE-TCOLOR  = '3'.
APPEND NODE_TABLE.
CLEAR NODE_TABLE.
ENDAT.
NODE_TABLE-TYPE = 'P'.
NODE_TABLE-NAME = 'ITEM DATA'.
NODE_TABLE-TLEVEL = '03'.
NODE_TABLE-NLENGTH = '20'.
NODE_TABLE-COLOR = '4'.
NODE_TABLE-TEXT = ''.
NODE_TABLE-TLENGTH = '30'.
NODE_TABLE-TCOLOR  = '3'.
APPEND NODE_TABLE.
CLEAR NODE_TABLE.
LOOP AT I_VBAP WHERE VBELN = I_VBAK-VBELN.
NODE_TABLE-TYPE = 'P'.
NODE_TABLE-NAME = I_VBAP-POSNR.
NODE_TABLE-TLEVEL = '04'.
NODE_TABLE-NLENGTH = '20'.
NODE_TABLE-COLOR = '4'.
NODE_TABLE-TEXT = ''.
NODE_TABLE-TLENGTH = '30'.
NODE_TABLE-TCOLOR  = '3'.
APPEND NODE_TABLE.
CLEAR NODE_TABLE.
NODE_TABLE-TYPE = 'P'.
NODE_TABLE-NAME = 'MATERIAL NO'.
NODE_TABLE-TLEVEL = '05'.
NODE_TABLE-NLENGTH = '20'.
NODE_TABLE-COLOR = '4'.
NODE_TABLE-TEXT = I_VBAP-MATNR.
NODE_TABLE-TLENGTH = '30'.
NODE_TABLE-TCOLOR  = '3'.
APPEND NODE_TABLE.
CLEAR NODE_TABLE.
NODE_TABLE-TYPE = 'P'.
NODE_TABLE-NAME = 'UNIT'.
NODE_TABLE-TLEVEL = '05'.
NODE_TABLE-NLENGTH = '20'.
NODE_TABLE-COLOR = '4'.
NODE_TABLE-TEXT = I_VBAP-VRKME.
NODE_TABLE-TLENGTH = '30'.
NODE_TABLE-TCOLOR  = '3'.
APPEND NODE_TABLE.
CLEAR NODE_TABLE.
NODE_TABLE-TYPE = 'P'.
NODE_TABLE-NAME = 'QUANTITY'.
NODE_TABLE-TLEVEL = '05'.
NODE_TABLE-NLENGTH = '20'.
NODE_TABLE-COLOR = '4'.
NODE_TABLE-TEXT = I_VBAP-KWMENG.
NODE_TABLE-TLENGTH = '40'.
NODE_TABLE-TCOLOR  = '3'.
APPEND NODE_TABLE.
CLEAR NODE_TABLE.
NODE_TABLE-TYPE = 'P'.
NODE_TABLE-NAME = 'DESCRIPTION'.
NODE_TABLE-TLEVEL = '05'.
NODE_TABLE-NLENGTH = '20'.
NODE_TABLE-COLOR = '4'.
NODE_TABLE-TEXT = I_VBAP-ARKTX.
NODE_TABLE-TLENGTH = '30'.
NODE_TABLE-TCOLOR  = '3'.
APPEND NODE_TABLE.
CLEAR NODE_TABLE.
ENDLOOP.
LOOP AT I_LIKP WHERE VBELV = I_VBAK-VBELN.
NODE_TABLE-TYPE = 'P'.
NODE_TABLE-NAME = 'DELIVERY'.
NODE_TABLE-TLEVEL = '03'.
NODE_TABLE-NLENGTH = '20'.
NODE_TABLE-COLOR = '4'.
NODE_TABLE-TEXT = ''.
NODE_TABLE-TLENGTH = '30'.
NODE_TABLE-TCOLOR  = '3'.
APPEND NODE_TABLE.
CLEAR NODE_TABLE.
NODE_TABLE-TYPE = 'P'.
NODE_TABLE-NAME = I_LIKP-VBELN.
NODE_TABLE-TLEVEL = '04'.
NODE_TABLE-NLENGTH = '20'.
NODE_TABLE-COLOR = '4'.
NODE_TABLE-TEXT = ''.
NODE_TABLE-TLENGTH = '30'.
NODE_TABLE-TCOLOR  = '3'.
APPEND NODE_TABLE.
CLEAR NODE_TABLE.
ENDLOOP.
LOOP AT I_VBRK WHERE VBELV = I_VBAK-VBELN.
NODE_TABLE-TYPE = 'P'.
NODE_TABLE-NAME = 'INVOICE'.
NODE_TABLE-TLEVEL = '03'.
NODE_TABLE-NLENGTH = '15'.
NODE_TABLE-COLOR = '4'.
NODE_TABLE-TEXT = ''.
NODE_TABLE-TLENGTH = '20'.
NODE_TABLE-TCOLOR  = '3'.
APPEND NODE_TABLE.
CLEAR NODE_TABLE.
NODE_TABLE-TYPE = 'P'.
NODE_TABLE-NAME = I_VBRK-VBELN.
NODE_TABLE-TLEVEL = '04'.
NODE_TABLE-NLENGTH = '20'.
NODE_TABLE-COLOR = '4'.
NODE_TABLE-TEXT = ''.
NODE_TABLE-TLENGTH = '30'.
NODE_TABLE-TCOLOR  = '3'.
APPEND NODE_TABLE.
CLEAR NODE_TABLE.
ENDLOOP.
ENDLOOP.
endform.                    " FILL_NODES
*&      Form  TREE_DISPLAY
      text
-->  p1        text
<--  p2        text
form TREE_DISPLAY .
CALL FUNCTION 'RS_TREE_CONSTRUCT'
EXPORTING
  INSERT_ID                = '000000'
  RELATIONSHIP             = ' '
  LOG                      =
  TABLES
    nodetab                  = node_table
EXCEPTIONS
  TREE_FAILURE             = 1
  ID_NOT_FOUND             = 2
  WRONG_RELATIONSHIP       = 3
  OTHERS                   = 4
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
        WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL FUNCTION 'RS_TREE_LIST_DISPLAY'
EXPORTING
  CALLBACK_PROGRAM                =
   CALLBACK_USER_COMMAND           = 'USER_COMMAND'
  CALLBACK_TEXT_DISPLAY           =
  CALLBACK_MOREINFO_DISPLAY       =
  CALLBACK_COLOR_DISPLAY          =
  CALLBACK_TOP_OF_PAGE            =
  CALLBACK_GUI_STATUS             =
  CALLBACK_CONTEXT_MENU           =
  STATUS                          = 'IMPLICIT'
  CHECK_DUPLICATE_NAME            = '1'
  COLOR_OF_NODE                   = '4'
  COLOR_OF_MARK                   = '3'
  COLOR_OF_LINK                   = '1'
  COLOR_OF_MATCH                  = '5'
  LOWER_CASE_SENSITIVE            = ' '
  MODIFICATION_LOG                = ' '
  NODE_LENGTH                     = 30
  TEXT_LENGTH                     = 75
  TEXT_LENGTH1                    = 0
  TEXT_LENGTH2                    = 0
  RETURN_MARKED_SUBTREE           = ' '
  SCREEN_START_COLUMN             = 0
  SCREEN_START_LINE               = 0
  SCREEN_END_COLUMN               = 0
  SCREEN_END_LINE                 = 0
  SUPPRESS_NODE_OUTPUT            = ' '
  LAYOUT_MODE                     = ' '
   USE_CONTROL                     = 'F'
IMPORTING
  F15                             =
Reward points if helpful.
Regards,
Hemant

Similar Messages

  • Output like Tree structure

    Hi
    I am having Data in one internal table
    BEGIN OF ty_box,
           vbeln LIKE vbak-vbeln, "Sales Order Document Number
           exidv LIKE vekp-exidv, "External Handling Unit Identification
           vegr4 LIKE vekp-vegr4, "Integration required if the value is INTR
           matnr LIKE lips-matnr, "Delivery Item-Material Number
           arktx LIKE lips-arktx, "Delivery Item-Short text for Material
    END OF ty_box.
    I want to Display output like tree structure
    integration required?
    () Sales order                                              
    () HU  -
    checkbox                                                                               
    Mat A       Description of A
    Mat B       Description of B
    Please give sample program for this type.  '-' indicate sapce
    Message was edited by:
            sudhakara reddy
    Message was edited by:
            sudhakara reddy

    hi,
    use ALV TREE
    check these links.
    http://www.erpgenie.com/sap/abap/SalesOrderFlow.htm
    http://www.sapdevelopment.co.uk/reporting/alv/alvtree/alvtree_basic.htm
    Check these programs.
    BCALV_TREE_01 ALV tree control: build up the hierarchy tree
    BCALV_TREE_02 ALV tree control: event handling
    BCALV_TREE_03 ALV tree control: use an own context menu
    BCALV_TREE_04 ALV tree control: add a button to the toolbar
    BCALV_TREE_05 ALV tree control: add a menu to the toolbar
    BCALV_TREE_06 ALV tree control: Icon column and icon for nodes/items
    BCALV_TREE_DEMO Demo for ALV tree control
    BCALV_TREE_DND ALV tree control: Drag & Drop within a hierarchy tree
    BCALV_TREE_DND_MULTIPLE ALV tree control: Drag & Drop within a hierarchy tree
    RSDEMO_DRAG_DROP_TREE_MULTI
    BCALV_TREE_EVENT_RECEIVER Include BCALV_TREE_EVENT_RECEIVER
    BCALV_TREE_EVENT_RECEIVER01
    BCALV_TREE_ITEMLAYOUT ALV Tree: Change Item Layouts at Runtime
    BCALV_TREE_MOVE_NODE_TEST Demo for ALV tree control
    BCALV_TREE_SIMPLE_DEMO Program BCALV_TREE_SIMPLE_DEMO
    BCALV_TREE_VERIFY Verifier for ALV Tree and Simple ALV Tree
    Also please check the transaction DWDM This will give info also on trees.
    Check the links -
    drag drop required for alv column!
    drag and drop in a tree
    Drag&Drop within the Tree
    Drag&Drop within a tree
    Drag and drop in ALV tree

  • How to show alv report in tree structure

    hi all,
    how to show data or create a alv report in tree structure.
    thanks in advance.
    Harsha

    Hi Harsha,
    Its done using FM 'RS_TREE_CONSTRUCT'
    and FM for displaying the tree:  'RS_TREE_LIST_DISPLAY'
    Thanks
    Shrila

  • ALV Tree Structure

    Hi All,
           Is there any Function module to display the output in a ALV tree structure( like parent node --> child nodes)
    Thanx in advance,
    Regards,
    Ravi

    Hi kranthi,
    1. Its quite simple.
    2. Basically there are TWO FMs,
    which do the job.
    3. just copy paste in new program
    and u will know the whole logic.
    4.
    REPORT abc.
    DATA : tr LIKE TABLE OF snodetext WITH HEADER LINE.
    data
    tr-id = '1'.
    tr-tlevel = 1.
    tr-name = 'amit'.
    APPEND tr.
    tr-id = '2'.
    tr-tlevel = 2.
    tr-name = 'mittal'.
    APPEND tr.
    display
    CALL FUNCTION 'RS_TREE_CONSTRUCT'
    TABLES
    nodetab = tr
    EXCEPTIONS
    tree_failure = 1
    OTHERS = 4.
    CALL FUNCTION 'RS_TREE_LIST_DISPLAY'
    regards,
    amit m.

  • Multiple tree structured rows in output header

    Hi All,
    I have a requirement to create an output layout in which there are 3 dynamic rows in header and each row is having its own sub devision (like a tree structure). The number of columns will depend upon the data.
    I am able to create N number of dynamic columns according to data fetched at run time but dont know how to create multiple tree structures rows in header.
    Can any one please suggest how can I achieve this in SAP?
    Regards,
    Nilanjana

    Hi All,
    I have a requirement to create an output layout in which there are 3 dynamic rows in header and each row is having its own sub devision (like a tree structure). The number of columns will depend upon the data.
    I am able to create N number of dynamic columns according to data fetched at run time but dont know how to create multiple tree structures rows in header.
    Can any one please suggest how can I achieve this in SAP?
    Regards,
    Nilanjana

  • I am new to abap please give me  alv tree structures

    Hi,
       i am new to abap please give me demo  alv tree structures.
    Regards,
    venkat

    Hi,
    have a look at this links
    http://****************/Tutorials/ALV/ALVMainPage.htm
    http://www.sapdevelopment.co.uk/reporting/alv/alvtree/alvtree_mainsetup.htm
    http://sap.ittoolbox.com/groups/technical-functional/sap-dev/alv-inputenabled-985429
    Regards,
    Manoj.

  • Bookmarks of a Responsive HTML5 output as part of an overall tree structure

    With its Responsive HTML5 output, unstructured FrameMaker 12 can create a bookmark tree.
    Is it possible to tie trees (bookmarks) of multiple Responsive HTML5 outputs in an overall HTML tree structure?

    Hi Herbert
    Thanks for reporting the issue.
    For this problem, I will suggest two solutions
    1. Either create a master book containing all your books / fm documents and then publish, you will get integrated Responsive HTML5 output.
    2. Or use TCS and in RoboHelp use merge project Adobe RoboHelp 11 * Merging Help projects
    Please let us know if you find any issue in that.
    Thanks
    Amit Jha

  • Tree Structure Output

    Hello Everyone,
    I have only using ADOBE Interactive forms for a short time. I have a table that has
    seven fields. Region, Location, 4 diminsion fields, and one field that contains notes.
    The region and the locations are currently on every row of the table.
    However I would like the the output to be in a tree structure. Is there a
    way to out put the data in this format like below? Its a lot cleaners than
    duplicate regions and locations for every record.
    Like Below
    Region1
                Location1
                              Dimensions 1
                              Dimensions 2
                              Dimensions 3
                Location2
                              Dimensions 1
                              Dimensions 2
                              Dimensions 3
    Region2
                Location1
                              Dimensions 1
                              Dimensions 2
                              Dimensions 3
                Location2
                              Dimensions 1
                              Dimensions 2
                              Dimensions 3
    Thanks,
    Stephen

    I guess you can achieve that by nested tables. You can find lot of threads discussing it.
    Below given blog also discusses the same.
    /people/juergen.hauser2/blog/2009/12/01/using-tables-or-subforms-in-interactive-forms
    Thanks,
    Aravind

  • Regarding Tree structure display in Webdynpro ABAP

    Hi Experts,
    I am very new to webdynpro ABAP , I was asked to implement some functionalities of RWBE transaction in webdynpro , in RWBE transaction list can be displayed as Tree structure , in webdynpro how i can implement this ? using ALV UI element is it possible . Please help .
    Regards,
    Ratheesh BS

    Hi ,
    I need an output like the below
    <material number                 a1           a2        a3
              < plant                       b1          b2        b3
                 . org                        c1          c2        c3
    <material number                 A1          A2       A3
    is it possible to show the output as in this format using ALV ?.
    I have tried with the help provided by SDN , but not succeed .
    also i need to capture double click event and show the currosponding result in a seperate view.
    here material number is the parent node , plant and org were child nodes
    Regards,
    Ratheesh BS
    Edited by: Ratheesh Bhaskaran on Oct 7, 2008 4:22 PM
    Edited by: Ratheesh Bhaskaran on Oct 7, 2008 4:26 PM
    Edited by: Ratheesh Bhaskaran on Oct 7, 2008 4:29 PM

  • How to create tree structure in abap

    hi,
       I am mohan. Please send the how to create the tree structure. how to insert the child nodes in  root node. actually our requirement is we have list transaction codes. We are planning to put all transaction codes in tree level.
    please tell me how to do the program in tree structure.

    Hi Mohan,
    Check the following program on ALV tree.
    REPORT zalvtree.
    CLASS cl_gui_column_tree DEFINITION LOAD.
    CLASS cl_gui_cfw DEFINITION LOAD.
    DATA: go_grid TYPE REF TO cl_gui_alv_grid.
    DATA: ro_grid TYPE REF TO cl_gui_alv_grid.
    DATA tree1  TYPE REF TO cl_gui_alv_tree.
    DATA mr_toolbar TYPE REF TO cl_gui_toolbar.
    DATA : gt_checked TYPE lvc_t_chit,
           gs_checked LIKE LINE OF gt_checked,
           l_part_key TYPE lvc_nkey,
           gt_node TYPE lvc_s_chit-nodekey.
    INCLUDE <icon>.
    INCLUDE zamit_alv_tree_toolbar_event.
    INCLUDE zbcalv_tree_event_receiver.
    *DATA: toolbar_event_receiver TYPE REF TO lcl_toolbar_event_receiver.
    DATA: gt_sflight      TYPE sflight OCCURS 0,      "Output-Table
          gt_fieldcatalog TYPE lvc_t_fcat, "Fieldcatalog
          ok_code LIKE sy-ucomm.           "OK-Code
    START-OF-SELECTION.
    END-OF-SELECTION.
      CALL SCREEN 100.
    *&      Module  PBO  OUTPUT
          process before output
    MODULE pbo OUTPUT.
      SET PF-STATUS 'MAIN100'.
      IF tree1 IS INITIAL.
        PERFORM init_tree.
    else.
                  CALL METHOD me->refresh_table_display
                    EXCEPTIONS
                      PROGRAM_ERROR = 1
                      others        = 2
                  IF sy-subrc <> 0.
                   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
                  ENDIF.
      ENDIF.
      CALL METHOD cl_gui_cfw=>flush.
    ENDMODULE.                             " PBO  OUTPUT
    *&      Module  PAI  INPUT
          process after input
    MODULE pai INPUT.
      CASE ok_code.
        WHEN 'EXIT' OR 'BACK' OR 'CANC'.
          PERFORM exit_program.
    *mrk
        WHEN 'MOVE'.
          PERFORM check_selection.
        WHEN 'MBAK'.
          PERFORM another_selection.
        WHEN 'ALL'.
          PERFORM select_all.
        WHEN 'CLEAR'.
          PERFORM clear_all.
        WHEN 'DELETE'.
          PERFORM delete_all.
        WHEN 'EXPAND'.
          PERFORM expand_all.
        WHEN 'COLLAPSE'.
          PERFORM collapse_all.
        WHEN OTHERS.
          CALL METHOD cl_gui_cfw=>dispatch.
      ENDCASE.
      CLEAR ok_code.
      CALL METHOD cl_gui_cfw=>flush.
    ENDMODULE.                             " PAI  INPUT
    *&      Form  build_fieldcatalog
          build fieldcatalog for structure sflight
    FORM build_fieldcatalog.
    get fieldcatalog
      CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
        EXPORTING
          i_structure_name = 'SFLIGHT'
        CHANGING
          ct_fieldcat      = gt_fieldcatalog.
    change fieldcatalog
      DATA: ls_fieldcatalog TYPE lvc_s_fcat.
      LOOP AT gt_fieldcatalog INTO ls_fieldcatalog.
        CASE ls_fieldcatalog-fieldname.
          WHEN 'CARRID' OR 'CONNID' OR 'FLDATE'.
            ls_fieldcatalog-no_out = 'X'.
            ls_fieldcatalog-key    = ''.
          WHEN 'PRICE' OR 'SEATSOCC' OR 'SEATSMAX' OR 'PAYMENTSUM'.
            ls_fieldcatalog-do_sum = 'X'.
        ENDCASE.
        MODIFY gt_fieldcatalog FROM ls_fieldcatalog.
      ENDLOOP.
    ENDFORM.                               " build_fieldcatalog
    *&      Form  build_hierarchy_header
          build hierarchy-header-information
         -->P_L_HIERARCHY_HEADER  strucxture for hierarchy-header
    FORM build_hierarchy_header CHANGING
                                   p_hierarchy_header TYPE treev_hhdr.
      p_hierarchy_header-heading = 'Hierarchy Header'.          "#EC NOTEXT
      p_hierarchy_header-tooltip =
                             'This is the Hierarchy Header !'.  "#EC NOTEXT
      p_hierarchy_header-width = 30.
      p_hierarchy_header-width_pix = ''.
    ENDFORM.                               " build_hierarchy_header
    *&      Form  exit_program
          free object and leave program
    FORM exit_program.
      CALL METHOD tree1->free.
      LEAVE PROGRAM.
    ENDFORM.                               " exit_program
    *&      Form  check_selection
          text
    -->  p1        text
    <--  p2        text
    FORM check_selection .
    create container for alv-tree
      DATA: l_tree_container_name(30) TYPE c,
            l_custom_container2 TYPE REF TO cl_gui_custom_container.
      l_tree_container_name = 'TREE2'.
      IF sy-batch IS INITIAL.
        CREATE OBJECT l_custom_container2
          EXPORTING
                container_name = l_tree_container_name
          EXCEPTIONS
                cntl_error                  = 1
                cntl_system_error           = 2
                create_error                = 3
                lifetime_error              = 4
                lifetime_dynpro_dynpro_link = 5.
        IF sy-subrc <> 0.
          MESSAGE x208(00) WITH 'ERROR'.                        "#EC NOTEXT
        ENDIF.
      ENDIF.
      CREATE OBJECT go_grid
        EXPORTING
       I_SHELLSTYLE      = 0
       I_LIFETIME        =
          i_parent          = l_custom_container2
       I_APPL_EVENTS     = space
       I_PARENTDBG       =
       I_APPLOGPARENT    =
       I_GRAPHICSPARENT  =
       I_NAME            =
    EXCEPTIONS
       ERROR_CNTL_CREATE = 1
       ERROR_CNTL_INIT   = 2
       ERROR_CNTL_LINK   = 3
       ERROR_DP_CREATE   = 4
       others            = 5
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                   WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
      PERFORM load_data_into_grid.
    *data: lt_nodes type LVC_T_NKEY,
         ls_nodes like line of lt_nodes,
         ls_checked like line of gt_checked.
    *loop at gt_checked into ls_checked.
    ls_nodes = ls_checked-nodekey.
    append ls_nodes to lt_nodes.
    *endloop.
    *CALL METHOD tree1->unselect_nodes
    EXPORTING
       it_node_key                  = lt_nodes
    EXCEPTIONS
       CNTL_SYSTEM_ERROR            = 1
       DP_ERROR                     = 2
       MULTIPLE_NODE_SELECTION_ONLY = 3
       ERROR_IN_NODE_KEY_TABLE      = 4
       FAILED                       = 5
       others                       = 6
    *IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
               WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    *ENDIF.
    ENDFORM.                    " check_selection
    *&      Form  another_selection
          text
    -->  p1        text
    <--  p2        text
    FORM another_selection .
    create container for alv-tree
      DATA: l_tree_container_name(30) TYPE c,
            l_custom_container2 TYPE REF TO cl_gui_custom_container.
      l_tree_container_name = 'TREE2'.
      IF sy-batch IS INITIAL.
        CREATE OBJECT l_custom_container2
          EXPORTING
                container_name = l_tree_container_name
          EXCEPTIONS
                cntl_error                  = 1
                cntl_system_error           = 2
                create_error                = 3
                lifetime_error              = 4
                lifetime_dynpro_dynpro_link = 5.
        IF sy-subrc <> 0.
          MESSAGE x208(00) WITH 'ERROR'.                        "#EC NOTEXT
        ENDIF.
      ENDIF.
      CREATE OBJECT ro_grid
        EXPORTING
       I_SHELLSTYLE      = 0
       I_LIFETIME        =
          i_parent          = l_custom_container2
       I_APPL_EVENTS     = space
       I_PARENTDBG       =
       I_APPLOGPARENT    =
       I_GRAPHICSPARENT  =
       I_NAME            =
    EXCEPTIONS
       ERROR_CNTL_CREATE = 1
       ERROR_CNTL_INIT   = 2
       ERROR_CNTL_LINK   = 3
       ERROR_DP_CREATE   = 4
       others            = 5
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                   WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
      PERFORM load_data_into_grid1.
      DATA: lt_unsel TYPE lvc_t_nkey,
            ls_unsel LIKE LINE OF lt_unsel.
      LOOP AT gt_checked INTO gs_checked.
        ls_unsel = gs_checked-nodekey.
        APPEND ls_unsel TO lt_unsel.
      ENDLOOP.
      CALL METHOD tree1->unselect_nodes
        EXPORTING
          it_node_key                  = lt_unsel
        EXCEPTIONS
          cntl_system_error            = 1
          dp_error                     = 2
          multiple_node_selection_only = 3
          error_in_node_key_table      = 4
          failed                       = 5
          OTHERS                       = 6.
      IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
               WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    *CALL METHOD tree1->unselect_all
    EXCEPTIONS
       CNTL_SYSTEM_ERROR = 1
       FAILED            = 2
       others            = 3
    *IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
               WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    *ENDIF.
      DATA: text TYPE lvc_value,
       item TYPE lvc_t_layi,
       node TYPE lvc_s_layn,
       inode TYPE lvc_nkey.
      FIELD-SYMBOLS: <wa> TYPE ANY.
      DATA: l_dref_wa LIKE LINE OF gt_sflight.
      ASSIGN l_dref_wa TO <wa>.
      READ TABLE gt_checked INTO gs_checked WITH KEY nodekey = 3.
      inode = gs_checked-nodekey.
      CALL METHOD tree1->get_outtab_line
        EXPORTING
          i_node_key     = inode
        IMPORTING
          e_outtab_line  = <wa>
          e_node_text    = text
          et_item_layout = item
          es_node_layout = node
        EXCEPTIONS
          node_not_found = 1
          OTHERS         = 2.
      IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
               WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      DATA: lt_layout TYPE lvc_t_laci,
            layout LIKE LINE OF lt_layout.
      layout-chosen = 'X'.
      layout-fieldname = tree1->c_hierarchy_column_name.
    ls_item_layout-chosen = 'X'.           "To give default checkbox value checked
      layout-class   = cl_gui_column_tree=>item_class_checkbox.
      layout-editable = 'X'.
    LAYOUT-U_CHOSEN = 'X'.
      APPEND layout TO lt_layout.
      CALL METHOD tree1->change_node
        EXPORTING
          i_node_key     = inode
          i_outtab_line  = <wa>
       IS_NODE_LAYOUT =
          it_item_layout =  lt_layout
       I_NODE_TEXT    =
       I_U_NODE_TEXT  =
        EXCEPTIONS
          node_not_found = 1
          OTHERS         = 2
      IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
               WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    *CALL METHOD tree1->change_item
    EXPORTING
       i_node_key     = inode
       i_fieldname    = gs_checked-FIELDNAME
       i_data         = <wa>
       I_U_DATA       = ''
       IS_ITEM_LAYOUT = layout
    EXCEPTIONS
       NODE_NOT_FOUND = 1
       others         = 2
    *IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
               WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    *ENDIF.
    *loop at lt_unsel into ls_unsel.
    *CALL METHOD tree1->update_checked_items
    EXPORTING
       i_node_key    = ls_unsel
       i_fieldname   = ''
       i_checked     = ''
    EXCEPTIONS
       PROGRAM_ERROR = 1
       others        = 2
    *IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
               WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    *ENDIF.
    *endif.
    ENDFORM.                    " another_selection
    *&      Form  select_all
          text
    -->  p1        text
    <--  p2        text
    FORM select_all .
      CONSTANTS: c_x(1) TYPE c VALUE 'X'.
    *********Check box modifications.
      CALL METHOD tree1->delete_all_nodes
        EXCEPTIONS
          failed            = 1
          cntl_system_error = 2
          OTHERS            = 3.
      IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
               WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    clear l_part_key.
    create hierarchy
      PERFORM create_hierarchy USING c_x.
      CALL METHOD tree1->expand_node
        EXPORTING
          i_node_key          = gt_node
       I_LEVEL_COUNT       = 1
          i_expand_subtree    = 'X'
        EXCEPTIONS
          failed              = 1
          illegal_level_count = 2
          cntl_system_error   = 3
          node_not_found      = 4
          cannot_expand_leaf  = 5
          OTHERS              = 6
      IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
               WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    add own functioncodes to the toolbar
    perform change_toolbar.
    register events
    perform register_events.
    adjust column_width
    call method tree1->COLUMN_OPTIMIZE.
    ENDFORM.                    " select_all
    *&      Form  clear_all
          text
    -->  p1        text
    <--  p2        text
    FORM clear_all .
      CONSTANTS: c_x(1) TYPE c VALUE space.
    *********Check box modifications.
      CALL METHOD tree1->delete_all_nodes
        EXCEPTIONS
          failed            = 1
          cntl_system_error = 2
          OTHERS            = 3.
      IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
               WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    create hierarchy
      PERFORM create_hierarchy USING c_x.
      CALL METHOD tree1->expand_node
        EXPORTING
          i_node_key          = gt_node
       I_LEVEL_COUNT       = 1
          i_expand_subtree    = 'X'
        EXCEPTIONS
          failed              = 1
          illegal_level_count = 2
          cntl_system_error   = 3
          node_not_found      = 4
          cannot_expand_leaf  = 5
          OTHERS              = 6
      IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
               WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                    " clear_all
    *&      Form  delete_all
          text
    -->  p1        text
    <--  p2        text
    FORM delete_all .
    *********Check box modifications.
      CALL METHOD tree1->delete_all_nodes
        EXCEPTIONS
          failed            = 1
          cntl_system_error = 2
          OTHERS            = 3.
      IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
               WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                    " delete_all
    *&      Form  expand_all
          text
    -->  p1        text
    <--  p2        text
    FORM expand_all .
      CALL METHOD tree1->expand_node
        EXPORTING
          i_node_key          = gt_node
       I_LEVEL_COUNT       = 1
          i_expand_subtree    = 'X'
        EXCEPTIONS
          failed              = 1
          illegal_level_count = 2
          cntl_system_error   = 3
          node_not_found      = 4
          cannot_expand_leaf  = 5
          OTHERS              = 6
      IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
               WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                    " expand_all
    *&      Form  collapse_all
          text
    -->  p1        text
    <--  p2        text
    FORM collapse_all .
      CALL METHOD tree1->collapse_all_nodes
        EXCEPTIONS
          failed            = 1
          cntl_system_error = 2
          OTHERS            = 3.
      IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
               WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                    " collapse_all
    *&      Form  load_data_into_grid
          text
    -->  p1        text
    <--  p2        text
    FORM load_data_into_grid .
      DATA:
      For parameter IS_VARIANT
          l_layout TYPE disvariant,
      gs_layout TYPE lvc_s_layo.
      DATA gi_sflight TYPE TABLE OF zsflight.
    Load data into the grid and display them
      l_layout-report = sy-repid.
      gs_layout-grid_title = 'Amits Test Program'.
      gs_layout-sel_mode = 'A'.
      SELECT *
       FROM zsflight
       INTO TABLE gi_sflight.
      CALL METHOD go_grid->set_table_for_first_display
        EXPORTING
          i_structure_name = 'SFLIGHT'
          is_layout        = gs_layout
          is_variant       = l_layout
          i_save           = 'A'
        CHANGING
          it_outtab        = gi_sflight.
    ENDFORM.                    " load_data_into_grid
    *&      Form  load_data_into_grid
          text
    -->  p1        text
    <--  p2        text
    FORM load_data_into_grid1.
      DATA:
      For parameter IS_VARIANT
          l_layout TYPE disvariant,
      gs_layout TYPE lvc_s_layo.
      DATA gi_sflight TYPE TABLE OF zapempl.
    Load data into the grid and display them
      l_layout-report = sy-repid.
      gs_layout-grid_title = 'Rams Test Program'.
      gs_layout-sel_mode = 'A'.
      SELECT *
       FROM zapempl
       INTO TABLE gi_sflight.
      CALL METHOD ro_grid->set_table_for_first_display
        EXPORTING
          i_structure_name = 'ZAPEMPL'
          is_layout        = gs_layout
          is_variant       = l_layout
          i_save           = 'A'
        CHANGING
          it_outtab        = gi_sflight.
    ENDFORM.                    " load_data_into_grid1
    *&      Form  build_header
          build table for html_header
    -->  p1        text
    <--  p2        text
    FORM build_comment USING
          pt_list_commentary TYPE slis_t_listheader
          p_logo             TYPE sdydo_value.
      DATA: ls_line TYPE slis_listheader.
    LIST HEADING LINE: TYPE H
      CLEAR ls_line.
      ls_line-typ  = 'H'.
    LS_LINE-KEY:  NOT USED FOR THIS TYPE
      ls_line-info = 'ALV-tree-demo: flight-overview'.          "#EC NOTEXT
      APPEND ls_line TO pt_list_commentary.
    STATUS LINE: TYPE S
      CLEAR ls_line.
      ls_line-typ  = 'S'.
      ls_line-key  = 'valid until'.                             "#EC NOTEXT
      ls_line-info = 'January 29 1999'.                         "#EC NOTEXT
      APPEND ls_line TO pt_list_commentary.
      ls_line-key  = 'time'.
      ls_line-info = '2.00 pm'.                                 "#EC NOTEXT
      APPEND ls_line TO pt_list_commentary.
    ACTION LINE: TYPE A
      CLEAR ls_line.
      ls_line-typ  = 'A'.
    LS_LINE-KEY:  NOT USED FOR THIS TYPE
      ls_line-info = 'actual data'.                             "#EC NOTEXT
      APPEND ls_line TO pt_list_commentary.
      p_logo = 'ENJOYSAP_LOGO'.
    ENDFORM.                    "build_comment
    *&      Form  create_hierarchy
          text
    -->  p1        text
    <--  p2        text
    FORM create_hierarchy USING p_x.
      DATA: ls_sflight TYPE sflight,
            lt_sflight TYPE sflight OCCURS 0.
    get data
      SELECT * FROM sflight INTO TABLE lt_sflight
                            UP TO 200 ROWS .
      SORT lt_sflight BY carrid connid fldate.
    add data to tree
      DATA: l_carrid_key TYPE lvc_nkey,
            l_connid_key TYPE lvc_nkey,
            l_last_key TYPE lvc_nkey.
           l_part_key TYPE lvc_nkey
      PERFORM add_carrid_line USING    ls_sflight
                              CHANGING l_part_key.
      gt_node = l_part_key.
      LOOP AT lt_sflight INTO ls_sflight.
        ON CHANGE OF ls_sflight-carrid.
          PERFORM add_carrid_line USING    ls_sflight
                                           l_part_key
                                  CHANGING l_carrid_key.
          PERFORM add_connid_line USING    ls_sflight
                                           l_carrid_key
                                  CHANGING l_connid_key.
          PERFORM add_complete_line USING  ls_sflight
                                         l_connid_key
                                         p_x
                                CHANGING l_last_key.
          CONTINUE.
        ENDON.
        ON CHANGE OF ls_sflight-connid.
          PERFORM add_connid_line USING    ls_sflight
                                           l_carrid_key
                                  CHANGING l_connid_key.
          PERFORM add_complete_line USING  ls_sflight
                                         l_connid_key
                                         p_x
                                CHANGING l_last_key.
          CONTINUE.
        ENDON.
        PERFORM add_complete_line USING  ls_sflight
                                         l_connid_key
                                         p_x
                                CHANGING l_last_key.
      ENDLOOP.
    calculate totals
      CALL METHOD tree1->update_calculations.
    this method must be called to send the data to the frontend
      CALL METHOD tree1->frontend_update.
    ENDFORM.                               " create_hierarchy
    *&      Form  add_carrid_line
          add hierarchy-level 1 to tree
         -->P_LS_SFLIGHT  sflight
         -->P_RELEATKEY   relatkey
        <-->p_node_key    new node-key
    FORM add_carrid_line USING     ps_sflight TYPE sflight
                                   p_relat_key TYPE lvc_nkey
                         CHANGING  p_node_key TYPE lvc_nkey.
      DATA: l_node_text TYPE lvc_value,
            ls_sflight TYPE sflight.
    set item-layout
      DATA: lt_item_layout TYPE lvc_t_layi,
            ls_item_layout TYPE lvc_s_layi.
      ls_item_layout-t_image = '@3P@'.
      ls_item_layout-fieldname = tree1->c_hierarchy_column_name.
      ls_item_layout-style   =
                            cl_gui_column_tree=>style_intensifd_critical.
      APPEND ls_item_layout TO lt_item_layout.
    add node
      l_node_text =  ps_sflight-carrid.
      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   = ls_sflight
          it_item_layout   = lt_item_layout
        IMPORTING
          e_new_node_key   = p_node_key.
    ENDFORM.                               " add_carrid_line
    *&      Form  add_connid_line
          add hierarchy-level 2 to tree
         -->P_LS_SFLIGHT  sflight
         -->P_RELEATKEY   relatkey
        <-->p_node_key    new node-key
    FORM add_connid_line USING     ps_sflight TYPE sflight
                                   p_relat_key TYPE lvc_nkey
                         CHANGING  p_node_key TYPE lvc_nkey.
      DATA: l_node_text TYPE lvc_value,
            ls_sflight TYPE sflight.
    set item-layout
      DATA: lt_item_layout TYPE lvc_t_layi,
            ls_item_layout TYPE lvc_s_layi.
      ls_item_layout-t_image = '@3Y@'.
      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 =  ps_sflight-connid.
      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   = ls_sflight
          it_item_layout   = lt_item_layout
        IMPORTING
          e_new_node_key   = p_node_key.
    ENDFORM.                               " add_connid_line
    *&      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   ps_sflight TYPE sflight
                                   p_relat_key TYPE lvc_nkey
                                   p_x
                         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_layout-fieldname = tree1->c_hierarchy_column_name.
      ls_item_layout-chosen = p_x.           "To give default checkbox value checked
      ls_item_layout-class   = cl_gui_column_tree=>item_class_checkbox.
      ls_item_layout-editable = 'X'.
      APPEND ls_item_layout TO lt_item_layout.
      l_node_text =  ps_sflight-fldate.
      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   = ps_sflight
          i_node_text      = l_node_text
          it_item_layout   = lt_item_layout
        IMPORTING
          e_new_node_key   = p_node_key.
    ENDFORM.                               " add_complete_line
    *&      Form  register_events
          text
    -->  p1        text
    <--  p2        text
    FORM register_events.
    define the events which will be passed to the backend
      DATA: lt_events TYPE cntl_simple_events,
            l_event TYPE cntl_simple_event.
    define the events which will be passed to the backend
      l_event-eventid = cl_gui_column_tree=>eventid_expand_no_children.
      APPEND l_event TO lt_events.
      l_event-eventid = cl_gui_column_tree=>eventid_checkbox_change.
      APPEND l_event TO lt_events.
      l_event-eventid = cl_gui_column_tree=>eventid_header_context_men_req.
      APPEND l_event TO lt_events.
      l_event-eventid = cl_gui_column_tree=>eventid_node_context_menu_req.
      APPEND l_event TO lt_events.
      l_event-eventid = cl_gui_column_tree=>eventid_item_context_menu_req.
      APPEND l_event TO lt_events.
      l_event-eventid = cl_gui_column_tree=>eventid_header_click.
      APPEND l_event TO lt_events.
      l_event-eventid = cl_gui_column_tree=>eventid_item_keypress.
      APPEND l_event TO lt_events.
      CALL METHOD tree1->set_registered_events
        EXPORTING
          events                    = lt_events
        EXCEPTIONS
          cntl_error                = 1
          cntl_system_error         = 2
          illegal_event_combination = 3.
      IF sy-subrc <> 0.
        MESSAGE x208(00) WITH 'ERROR'.                          "#EC NOTEXT
      ENDIF.
    set Handler
      DATA: l_event_receiver TYPE REF TO lcl_tree_event_receiver.
      CREATE OBJECT l_event_receiver.
      SET HANDLER l_event_receiver->handle_node_ctmenu_request
                                                            FOR tree1.
      SET HANDLER l_event_receiver->handle_node_ctmenu_selected
                                                            FOR tree1.
      SET HANDLER l_event_receiver->handle_item_ctmenu_request
                                                            FOR tree1.
      SET HANDLER l_event_receiver->handle_item_ctmenu_selected
                                                            FOR tree1.
      SET HANDLER l_event_receiver->handle_checkbox_change FOR tree1.
    ENDFORM.                               " register_events
    *&      Form  change_toolbar
          text
    -->  p1        text
    <--  p2        text
    FORM change_toolbar.
    DATA: toolbar_event_receiver TYPE REF TO lcl_toolbar_event_receiver.
    get toolbar control
      CALL METHOD tree1->get_toolbar_object
        IMPORTING
          er_toolbar = mr_toolbar.
      CHECK NOT mr_toolbar IS INITIAL.
    add seperator to toolbar
      CALL METHOD mr_toolbar->add_button
        EXPORTING
          fcode     = ''
          icon      = ''
          butn_type = cntb_btype_sep
          text      = ''
          quickinfo = 'This is a Seperator'.                    "#EC NOTEXT
    add Standard Button to toolbar (for Delete Subtree)
      CALL METHOD mr_toolbar->add_button
        EXPORTING
          fcode     = 'DELETE'
          icon      = '@18@'
          butn_type = cntb_btype_button
          text      = ''
          quickinfo = 'Delete subtree'.                         "#EC NOTEXT
    add Dropdown Button to toolbar (for Insert Line)
      CALL METHOD mr_toolbar->add_button
        EXPORTING
          fcode     = 'INSERT_LC'
          icon      = '@17@'
          butn_type = cntb_btype_dropdown
          text      = ''
          quickinfo = 'Insert Line'.                            "#EC NOTEXT
    set event-handler for toolbar-control
      CREATE OBJECT toolbar_event_receiver.
      SET HANDLER toolbar_event_receiver->on_function_selected
                                                          FOR mr_toolbar.
      SET HANDLER toolbar_event_receiver->on_toolbar_dropdown
                                                          FOR mr_toolbar.
    ENDFORM.                               " change_toolbar
    *&      Form  init_tree
          text
    -->  p1        text
    <--  p2        text
    FORM init_tree.
    create fieldcatalog for structure sflight
      PERFORM build_fieldcatalog.
    create container for alv-tree
      DATA: l_tree_container_name(30) TYPE c,
            l_custom_container TYPE REF TO cl_gui_custom_container.
      l_tree_container_name = 'TREE1'.
      IF sy-batch IS INITIAL.
        CREATE OBJECT l_custom_container
          EXPORTING
                container_name = l_tree_container_name
          EXCEPTIONS
                cntl_error                  = 1
                cntl_system_error           = 2
                create_error                = 3
                lifetime_error              = 4
                lifetime_dynpro_dynpro_link = 5.
        IF sy-subrc <> 0.
          MESSAGE x208(00) WITH 'ERROR'.                        "#EC NOTEXT
        ENDIF.
      ENDIF.
    create tree control
      CREATE OBJECT tree1
        EXPORTING
            parent              = l_custom_container
            node_selection_mode = cl_gui_column_tree=>node_sel_mode_multiple "node_sel_mode_single
            item_selection      = 'X'
            no_html_header      = ''
            no_toolbar          = ''
        EXCEPTIONS
            cntl_error                   = 1
            cntl_system_error            = 2
            create_error                 = 3
            lifetime_error               = 4
            illegal_node_selection_mode  = 5
            failed                       = 6
            illegal_column_name          = 7.
      IF sy-subrc <> 0.
        MESSAGE x208(00) WITH 'ERROR'.                          "#EC NOTEXT
      ENDIF.
    create Hierarchy-header
      DATA l_hierarchy_header TYPE treev_hhdr.
      PERFORM build_hierarchy_header CHANGING l_hierarchy_header.
    create info-table for html-header
      DATA: lt_list_commentary TYPE slis_t_listheader,
            l_logo             TYPE sdydo_value.
      PERFORM build_comment USING
                     lt_list_commentary
                     l_logo.
    repid for saving variants
      DATA: ls_variant TYPE disvariant.
      ls_variant-report = sy-repid.
    create emty tree-control
      CALL METHOD tree1->set_table_for_first_display
        EXPORTING
          is_hierarchy_header = l_hierarchy_header
          it_list_commentary  = lt_list_commentary
          i_logo              = l_logo
          i_background_id     = 'ALV_BACKGROUND'
          i_save              = 'A'
          is_variant          = ls_variant
        CHANGING
          it_outtab           = gt_sflight "table must be emty !!
          it_fieldcatalog     = gt_fieldcatalog.
      CONSTANTS: c_s(1) TYPE c VALUE space.
    create hierarchy
      PERFORM create_hierarchy USING c_s.
    add own functioncodes to the toolbar
      PERFORM change_toolbar.
    register events
      PERFORM register_events.
    adjust column_width
    call method tree1->COLUMN_OPTIMIZE.
    ENDFORM.                    " init_tree
    Award points if found useful.
    Regards
    Indrajit

  • Tree structure in f4 help

    Hi experts,
    can any one give me sample code for providing tree structure in f4help.  like object part field have in iw21 transaction
    Regards
    reddy

    Hi Muttukundu,
    SAP has provided a lot of sample programs for developing tree structures. Just go to SE38, type BCALVTREE and hit F4. You'll get different sample programs with a range of operations on trees
    Go through the link,
    http://www.sapdevelopment.co.uk/reporting/alv/alvtree.htm
    Slowly check this code..you will get idea of how to develop tree structure.
    REPORT y_hierarchies_in_tables
    NO STANDARD PAGE HEADING.
    PARAMETER: g_group TYPE grpname. " DEFAULT 'Z_GLAB0000'.
    DATA:
    g_setid TYPE setid,
    g_class TYPE setclass.
    DATA: lt_hier TYPE STANDARD TABLE OF sethier,
    lt_val TYPE STANDARD TABLE OF setvalues.
    DATA: hier LIKE sethier OCCURS 0 WITH HEADER LINE,
    val LIKE setvalues OCCURS 0 WITH HEADER LINE,
    setinfo LIKE setinfo OCCURS 0 WITH HEADER LINE.
    DATA: zaccbas(20) TYPE c OCCURS 0 WITH HEADER LINE.
    DATA: miss_val LIKE setvalues-from OCCURS 0 WITH HEADER LINE.
    DATA: table_name TYPE tabname,
    field_name TYPE setfld.
    DATA: ambiguity_flag TYPE c.
    Ambiguity check
    PERFORM ambiguity_check.
    Display Records
    PERFORM display_records.
    *& Form AMBIGUITY_CHECK
    Ambiguity check
    FORM ambiguity_check .
    DATA: it_abaplist LIKE abaplist OCCURS 0 WITH HEADER LINE.
    DATA: BEGIN OF it_ascilist OCCURS 0,
    zeile(256) TYPE c,
    END OF it_ascilist.
    DATA: flag.
    SUBMIT rgsovl00 "VIA SELECTION-SCREEN
    WITH p_shrtn = g_group
    WITH path = 'X'
    EXPORTING LIST TO MEMORY
    AND RETURN.
    CALL FUNCTION 'LIST_FROM_MEMORY'
    TABLES
    listobject = it_abaplist
    EXCEPTIONS
    not_found = 1
    OTHERS = 2.
    CALL FUNCTION 'LIST_TO_ASCI'
    TABLES
    listasci = it_ascilist
    listobject = it_abaplist
    EXCEPTIONS
    empty_list = 1
    list_index_invalid = 2
    OTHERS = 3 .
    LOOP AT it_ascilist.
    IF it_ascilist-zeile = text-001.
    flag = 'X'.
    ENDIF.
    IF flag = 'X' AND
    it_ascilist-zeile = text-002.
    ambiguity_flag = 'X'.
    CLEAR flag.
    ENDIF.
    ENDLOOP.
    FREE MEMORY.
    ENDFORM. " AMBIGUITY_CHECK
    *& Form DISPLAY_RECORDS
    Display the Records
    FORM display_records .
    PERFORM get_records.
    PERFORM header_data.
    PERFORM item_data.
    ENDFORM. " DISPLAY_RECORDS
    *& Form GET_RECORDS
    Get all the Node values
    FORM get_records .
    Get the ID name for the Hierarchy
    CALL FUNCTION 'G_SET_GET_ID_FROM_NAME'
    EXPORTING
    shortname = g_group
    setclass = g_class
    old_setid = g_setid
    IMPORTING
    new_setid = g_setid.
    Get the Table and Field name for the Top Node
    CALL FUNCTION 'G_SET_GET_INFO'
    EXPORTING
    setname = g_setid
    no_set_title = 'X'
    use_table_buffer = 'X'
    IMPORTING
    info = setinfo.
    table_name = setinfo-tabname.
    field_name = setinfo-fld.
    Get all the Nodes for the Hierarchy
    CALL FUNCTION 'G_SET_TREE_IMPORT'
    EXPORTING
    no_descriptions = ' '
    no_rw_info = 'X'
    setid = g_setid
    TABLES
    set_hierarchy = lt_hier
    set_values = lt_val.
    hier[] = lt_hier.
    val[] = lt_val.
    SELECT (field_name) FROM (table_name) INTO TABLE zaccbas.
    LOOP AT zaccbas.
    READ TABLE val WITH KEY FROM = zaccbas.
    IF sy-subrc = 0.
    DELETE zaccbas.
    CLEAR zaccbas.
    DELETE val INDEX sy-tabix.
    CLEAR val.
    ENDIF.
    ENDLOOP.
    ENDFORM. " GET_RECORDS
    *& Form HEADER_DATA
    Header Data
    FORM header_data .
    DATA: desc TYPE settext.
    READ TABLE hier WITH KEY fieldname = field_name
    shortname = g_group.
    IF sy-subrc = 0.
    desc = hier-descript.
    ENDIF.
    SKIP.
    WRITE: 'Node :',g_group.
    WRITE:75 'User name :', sy-uname.
    WRITE:/ 'Description :', desc.
    WRITE:75 'Date:', sy-datum.
    WRITE:/ 'Table Name :' , table_name.
    WRITE:75 'Time:', sy-timlo.
    WRITE:/ 'Field Name :', field_name.
    write:75 'Client:', SY-MANDT.
    skip.
    IF ambiguity_flag = 'X'.
    WRITE:/ 'Ambiguity Check :'. WRITE: 'Success' COLOR 5.
    ELSE.
    WRITE:/ 'Ambiguity Check :'. WRITE: 'Failed' COLOR 6 .
    ENDIF.
    WRITE:/ sy-uline.
    WRITE:/37 'Validation for Hierarchy'.
    WRITE:/ sy-uline.
    ENDFORM. " HEADER_DATA
    *& Form ITEM_DATA
    Output Report for Nodes
    FORM item_data .
    IF NOT zaccbas[] IS INITIAL.
    WRITE:/ 'Missing Records from Hierarchy' COLOR 3.
    LOOP AT zaccbas.
    WRITE:/ zaccbas.
    ENDLOOP.
    ENDIF.
    IF NOT val[] IS INITIAL.
    SKIP 1.
    WRITE:/ 'Additional Records in Hierarchy' COLOR 3.
    LOOP AT val.
    WRITE:/ val-from. ", 28 val-DESCRIPT.
    ENDLOOP.
    ELSEIF ZACCBAS[] IS INITIAL.
    WRITE:/ 'No Missing Records Found' COLOR 3.
    ENDIF.
    ENDFORM. " ITEM_DATA
    Reward if found helpfull,
    Cheers,
    Chaitanya.

  • I am not getting the headings of the fields in ALV output.

    I am not getting ALV out put but  the headings of the fields in ALV output.
    Please see my below code .
    TYPES : BEGIN OF ty_zgxmit.
              INCLUDE STRUCTURE zgxmit.
    TYPES : END OF ty_zgxmit.
    DATA : gt_zgxmit TYPE TABLE OF ty_zgxmit.
    *&      Form  alv_display                                              *
    This subroutine is to display the out put in ALV.                    *
    FORM alv_display .
    Local data
      DATA: y_x          LIKE boole  VALUE 'X'.
    DATA: lt_fieldcat  TYPE slis_t_fieldcat_alv.
      DATA: lf_fieldcat  TYPE slis_fieldcat_alv.
      DATA: lh_index     LIKE lf_fieldcat-col_pos.
    For variant
    DATA: ws_repid LIKE sy-repid,
          g_save TYPE c VALUE 'A',
          g_exit TYPE c,
          g_variant LIKE disvariant,
          gx_variant LIKE disvariant.
      For 1st field.( RPT_LOC )
        CLEAR lf_fieldcat.
        lf_fieldcat-fieldname = 'RPT_LOC'.
        lf_fieldcat-tabname = 'GT_ZGXMIT'.
        lf_fieldcat-ref_tabname = 'RPT_LOC'.
        lf_fieldcat-ref_fieldname = 'ZGXMIT'.
        lh_index = lh_index + 1.
        lf_fieldcat-col_pos = lh_index.
        lf_fieldcat-key = y_x.
        lf_fieldcat-no_sum = y_x.
        APPEND lf_fieldcat TO lt_fieldcat.
    For 2nd field.( BAL_XMIT )
        CLEAR lf_fieldcat.
        lf_fieldcat-fieldname = 'BAL_XMIT'.
        lf_fieldcat-tabname = 'GT_ZGXMIT'.
        lf_fieldcat-ref_tabname = 'BAL_XMIT'.
        lf_fieldcat-ref_fieldname = 'ZGXMIT'.
        lh_index = lh_index + 1.
        lf_fieldcat-col_pos = lh_index.
        lf_fieldcat-key = y_x.
        lf_fieldcat-no_sum = y_x.
        APPEND lf_fieldcat TO lt_fieldcat.
    For 3rd field.( INC_XMIT )
        CLEAR lf_fieldcat.
        lf_fieldcat-fieldname = 'INC_XMIT'.
        lf_fieldcat-tabname = 'GT_ZGXMIT'.
        lf_fieldcat-ref_tabname = 'INC_XMIT'.
        lf_fieldcat-ref_fieldname = 'ZGXMIT'.
        lh_index = lh_index + 1.
        lf_fieldcat-col_pos = lh_index.
        lf_fieldcat-key = y_x.
        lf_fieldcat-no_sum = y_x.
        APPEND lf_fieldcat TO lt_fieldcat.
    For 4th field.( Z500_XMIT )
        CLEAR lf_fieldcat.
        lf_fieldcat-fieldname = 'Z500_XMIT'.
        lf_fieldcat-tabname = 'GT_ZGXMIT'.
        lf_fieldcat-ref_tabname = 'Z500_XMIT'.
        lf_fieldcat-ref_fieldname = 'ZGXMIT'.
        lh_index = lh_index + 1.
        lf_fieldcat-col_pos = lh_index.
        lf_fieldcat-key = y_x.
        lf_fieldcat-no_sum = y_x.
        APPEND lf_fieldcat TO lt_fieldcat.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
           EXPORTING
                i_callback_program       = 'ZJV_2245'
                it_fieldcat              = lt_fieldcat
           TABLES
                t_outtab                 = gt_zgxmit
           EXCEPTIONS
                program_error            = 1
                OTHERS                   = 2.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    ENDFORM.                    " alv_display

    You can force the headings like so.
    CLEAR lf_fieldcat.
    lf_fieldcat-fieldname = 'RPT_LOC'.
    lf_fieldcat-tabname = 'GT_ZGXMIT'.
    lf_fieldcat-ref_tabname = 'RPT_LOC'.
    lf_fieldcat-ref_fieldname = 'ZGXMIT'.
    lf_fieldcat-reptext_ddic  = 'Whatever Heading'.    "<-  Right here
    lh_index = lh_index + 1.
    lf_fieldcat-col_pos = lh_index.
    lf_fieldcat-key = y_x.
    lf_fieldcat-no_sum = y_x.
    APPEND lf_fieldcat TO lt_fieldcat.
    Regards,
    Rich Heilman

  • Co41 enhancement for add field in ALV output

    I must add a custom filed to ALV output of transaction CO41 and i trying to use all the 25 enhancements provided (that i find in other post CO41- Enhancement ), but i haven't found any way to get the desired results.
    Can any body help me?
    Thanks in advance.

    Hi,
    I had the same requirement to add a custom field to ALV output of transaction CO41.
    1. I first added the custom field to an new append-structure to the structure SFC_POCO.
    2. Then i added this field to the Dynpro-Screen 200 in the function-group COUP (by choosing the table control, pressing F6 and then adding the custom field of SFC_POCO).
    3. At last i added an Enhancement to the function CO_UP_PLANNED_ORDERS_SELECT and filled my custom field with data there.
    Please reward if useful.
    Regards,
    Henry

  • ALV output converted into PDF format and send that PDF to user through mail

    Hi Experts,
    I have report earlier its output was in alv grid.
    Now i want that ALV output converted into PDF format.And that PDF output send to user through mail.
    Can u please tell how to do?
    My code is here(output is displaying in ALV grid).
    INCLUDE <icon>.
    TYPE-POOLS: slis, kkblo.
    TABLES : zmsd_freight_hdr, zmsd_freight_det, zmsd_blinfo, zmsd_diheader.
    TABLES : lfa1.
    DATA : t_hdr   LIKE   zmsd_freight_hdr   OCCURS 0 WITH HEADER LINE,
           T_DET   LIKE   ZMSD_FREIGHT_DET   OCCURS 0 WITH HEADER LINE,
           t_bl    LIKE   zmsd_blinfo        OCCURS 0 WITH HEADER LINE,
           t_di    LIKE   zmsd_diheader      OCCURS 0 WITH HEADER LINE.
    DATA: BEGIN OF t_det OCCURS 0.
            INCLUDE STRUCTURE zmsd_freight_det.
    DATA    type(30).
    DATA: END OF t_det.
    DATA: v_target2(30),
          v_zsammg LIKE t_det-zsammg,
          v_gsttotal LIKE t_det-zamount.
    DATA : BEGIN OF t_data OCCURS 0,
             zsammg       LIKE  zmsd_freight_hdr-zsammg,
             zdidbl       LIKE  zmsd_freight_hdr-zdidbl,
             zvkorg       LIKE  zmsd_freight_hdr-zvkorg,
             zinvno       LIKE  zmsd_freight_hdr-zinvno,
             zttlamt      LIKE  zmsd_freight_hdr-zttlamt,
             zstatus      LIKE  zmsd_freight_hdr-zstatus,
             ztype        LIKE  zmsd_freight_hdr-ztype,
             zconfirm     LIKE  zmsd_freight_hdr-zconfirm,
             zconfirmdate LIKE  zmsd_freight_hdr-zconfirmdate,
             erdat        LIKE  zmsd_freight_hdr-erdat,
             ernam        LIKE  zmsd_freight_hdr-ernam,
             erzet        LIKE  zmsd_freight_hdr-erzet,
             aedat(10),
             aenam        LIKE  zmsd_freight_hdr-aenam,
             aezet        LIKE  zmsd_freight_hdr-aezet,
             zline        LIKE  zmsd_freight_det-zline,
             zfptype      LIKE  zmsd_freight_det-zfptype,
             zchrcode     LIKE  zmsd_freight_det-zchrcode,
             zcurcode     LIKE  zmsd_freight_det-zcurcode,
             zqty         LIKE  zmsd_freight_det-zqty,
             zuom         LIKE  zmsd_freight_det-zuom,
             zrate        LIKE  zmsd_freight_det-zrate,
             zamount      LIKE  zmsd_freight_det-zamount,
             zexrate      LIKE  zmsd_freight_det-zexrate,
           zccode       LIKE  zmsd_blinfo-zccode,      "MADK991565
             zccode       like  ZMSD_FREIGHT_HDR-zfcode, "MADK991565
             zbldate(10),
             zbl          LIKE  zmsd_blinfo-zbl,
             type(3),
             waerk        LIKE  zmsd_freight_det-zcurcode,
             zamountl     LIKE  zmsd_freight_det-zamount,
           END OF t_data.
    DATA : w_layout      TYPE   slis_layout_alv,
           w_catalog     TYPE   slis_fieldcat_alv,
           t_catalog     TYPE   slis_t_fieldcat_alv,
           w_sort        TYPE   slis_sortinfo_alv,
           t_sort        TYPE   slis_t_sortinfo_alv.
    DATA   V_ZINVNO    like   T_HDR-ZINVNO.                   "MADK991565
    DATA : v_count  TYPE  i.
    SELECTION-SCREEN BEGIN OF BLOCK a0 WITH FRAME TITLE text-001.
    PARAMETERS     :  p_zvkorg LIKE zmsd_freight_hdr-zvkorg  OBLIGATORY .
    SELECT-OPTIONS :  s_zdidbl FOR  zmsd_freight_hdr-zdidbl             ,
                      s_zccode FOR  lfa1-lifnr                          ,
                      s_status FOR  zmsd_freight_hdr-zstatus            ,
                      s_ztype  FOR  zmsd_freight_hdr-ztype              ,
                      s_erdat  FOR  zmsd_freight_hdr-erdat              ,
                      s_ernam  FOR  zmsd_freight_hdr-ernam              ,
                      s_zconfd FOR  zmsd_freight_hdr-zconfirmdate       .
    PARAMETERS     :  p_zconf  AS   CHECKBOX                            .
    SELECTION-SCREEN END OF BLOCK a0.
    SELECTION-SCREEN BEGIN OF BLOCK a1 WITH FRAME TITLE text-002.
    PARAMETERS     :  p_hdr    RADIOBUTTON GROUP rad DEFAULT 'X'        ,
                      p_det    RADIOBUTTON GROUP rad                    .
    SELECTION-SCREEN END OF BLOCK a1.
    INITIALIZATION.
    AT SELECTION-SCREEN.
    START-OF-SELECTION.
      PERFORM get_data.
      PERFORM process.
      PERFORM display.
    END-OF-SELECTION.
      PERFORM fm_get_num_pages.
    AT USER-COMMAND.
    AT LINE-SELECTION.
    TOP-OF-PAGE.
      PERFORM fm_top_of_page USING '7010' sy-title space.
    FORM get_data.
      SELECT   *
        FROM   zmsd_freight_hdr
        INTO   TABLE t_hdr
       WHERE   zvkorg        EQ  p_zvkorg
         AND   zdidbl        IN  s_zdidbl
         AND   zstatus       IN  s_status
         AND   ztype         IN  s_ztype
         AND   erdat         IN  s_erdat
         AND   ernam         IN  s_ernam
         AND   zconfirmdate  IN  s_zconfd
         AND   ZFCODE        IN  S_ZCCODE.                      "MADK991565
      IF p_zconf = 'X'.
        DELETE t_hdr WHERE zconfirm NE 'C'.
      ENDIF.
      CHECK NOT t_hdr[] IS INITIAL.
      SELECT   *
        FROM   zmsd_blinfo
        INTO   TABLE t_bl
         FOR   ALL ENTRIES IN t_hdr
       WHERE   zsammg = t_hdr-zsammg.
      SORT t_bl BY zsammg.
      SELECT   *
        FROM   zmsd_diheader
        INTO   TABLE t_di
         FOR   ALL ENTRIES IN t_hdr
       WHERE   zsammg = t_hdr-zsammg.
      SORT t_di BY zsammg.
    IF P_DET = 'X'. "MADK933361
      SELECT   *
        FROM   zmsd_freight_det
        INTO   TABLE t_det
         FOR   ALL ENTRIES IN t_hdr
       WHERE   zsammg  =  t_hdr-zsammg
       AND ZINVNO =  T_HDR-ZINVNO .                           "MADK991565
    SORT t_det BY zsammg zline.                            "MADK991565
       SORT T_DET BY ZSAMMG ZINVNO ZLINE.                     "MADK991565
    ENDIF. "MADK933361
    ENDFORM.
    FORM process.
      REFRESH t_data.
      CLEAR v_gsttotal.                                         "MADK933361
      LOOP AT t_hdr.
    Start of MADK933361
        CLEAR: v_target2.
        v_zsammg = t_hdr-zsammg.
        V_ZINVNO = T_HDR-ZINVNO.                                "MADK991565
       AT NEW zsammg.                                         "MADK991565
         AT NEW ZINVNO.                                         "MADK991565
          PERFORM get_gst_value.
        ENDAT.
    End of MADK933361
        PERFORM move_header.
        CHECK t_data-zccode IN s_zccode.
        IF p_det = 'X'.
    CSF Project Changes Starts   DEV34    MADK985782
        LOOP AT T_DET WHERE ZSAMMG = T_HDR-ZSAMMG..
          LOOP AT t_det WHERE zsammg = t_hdr-zsammg AND
                              zinvno = t_hdr-zinvno.
    CSF Project Changes Ends     DEV34    MADK985782
            PERFORM move_header.
            CHECK t_data-zccode IN s_zccode.
            MOVE-CORRESPONDING t_det TO t_data.
            t_data-zamountl = t_data-zamount * t_data-zexrate.
            APPEND t_data.
            CLEAR t_data.
          ENDLOOP.
        ELSE.
          APPEND t_data.
          CLEAR t_data.
        ENDIF.
        AT END OF zsammg.
          CLEAR v_gsttotal.
        ENDAT.
    *Start of changes for  IS090901289-PIA MADK991565
        AT END OF ZINVNO.
          CLEAR V_GSTTOTAL.
        ENDAT.
    *End of changes for  IS090901289-PIA MADK991565
      ENDLOOP.
    ENDFORM.
    FORM move_header.
      MOVE-CORRESPONDING t_hdr TO t_data.
      t_data-zttlamt = t_data-zttlamt + v_gsttotal.             "MADK933361
      t_data-waerk = 'SGD'.
      IF NOT t_hdr-aedat IS INITIAL.
        WRITE: t_hdr-aedat TO t_data-aedat.
      ELSE.
        CLEAR : t_data-aedat.
      ENDIF.
      READ TABLE t_bl WITH KEY zsammg = t_hdr-zsammg BINARY SEARCH.
      IF sy-subrc EQ 0.
      t_data-zccode  = t_bl-zccode.   "MADK991565
        T_DATA-ZCCODE = T_HDR-ZFCODE.   "MADK991565     
        IF NOT t_bl-zbldate IS INITIAL.
          WRITE: t_bl-zbldate TO t_data-zbldate.
        ENDIF.
        t_data-zbl     = t_bl-zbl.
        t_data-type    = 'DBL'.
      ELSE.
        READ TABLE t_di WITH KEY zsammg = t_hdr-zsammg BINARY SEARCH.
        IF sy-subrc EQ 0.
        t_data-zccode  = t_di-zdiforcode.     "MADK991565
          T_DATA-ZCCODE = T_HDR-ZFCODE.         "MADK991565
          t_data-type    = 'DI'.
        ENDIF.
      ENDIF.
    ENDFORM.
    FORM display.
      IF t_data[] IS INITIAL.
        MESSAGE s398(00) WITH 'No Data Selected'.
        EXIT.
      ENDIF.
      DATA : l_repid LIKE sy-repid.
      l_repid = sy-repid.
      REFRESH t_catalog.
      CLEAR   t_catalog.
      w_layout-cell_merge = 'X'.
      PERFORM map_fields.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
           EXPORTING
                i_callback_program      = l_repid
                i_callback_user_command = 'ALV_USER_COMMAND'
                is_layout               = w_layout
                it_fieldcat             = t_catalog[]
                i_grid_title            = sy-title
                i_save                  = 'A'
                it_sort                 = t_sort[]
           TABLES
                t_outtab                = t_data
           EXCEPTIONS
                program_error           = 1
                OTHERS                  = 2.
      IF sy-subrc <> 0.
      ENDIF.
    ENDFORM.
    FORM map_fields.
    Sort Order
      CLEAR v_count.
      PERFORM sf USING 'ZDIDBL'   'X'  'X'.
    Fields to be displayed
      CLEAR v_count.
      IF p_hdr = 'X'.
        PERFORM af USING :
       DESCRIPTION       FIELD        LEN   RTABLE             RFIELD
        'DI/DBL         ' 'ZDIDBL'     '14' '                ' '        ',
        'Type           ' 'TYPE'       '04' '                ' '        ',
        'Forwarder Code ' 'ZCCODE'     '14' '                ' '        ',
        'BL Number      ' 'ZBL'        '14' '                ' '        ',
        'BL Date        ' 'ZBLDATE'    '10' '                ' '        ',
        'Invoice Number ' 'ZINVNO'     '15' '                ' '        ',
        'Extraction     ' 'ZSTATUS'    '05' 'ZMSD_FREIGHT_HDR' 'ZSTATUS ',
        'Freight Type   ' 'ZTYPE'      '05' 'ZMSD_FREIGHT_HDR' 'ZTYPE   ',
        'Confirmation   ' 'ZCONFIRM'   '05' 'ZMSD_FREIGHT_HDR' 'ZCONFIRM',
        'Confirm Date   ' 'ZCONFIRMDATE' '10' 'ZMSD_FREIGHT_HDR'
    'ZCONFIRMDATE',
        'Total Amount   ' 'ZTTLAMT'    '18' '                ' '        ',
        'Created On     ' 'ERDAT'      '10' '                ' '        ',
        'Created By     ' 'ERNAM'      '10' '                ' '        ',
        'Changed On     ' 'AEDAT'      '10' '                ' '        ',
        'Changed By     ' 'AENAM'      '10' '                ' '        '.
      ELSE.
        PERFORM af USING :
       DESCRIPTION         FIELD     LEN   RTABLE             RFIELD
        'DI/DBL           ' 'ZDIDBL'   '14' '                ' '        ',
        'Type             ' 'TYPE'     '04' '                ' '        ',
        'Forwarder Code   ' 'ZCCODE'   '14' '                ' '        ',
        'BL Number        ' 'ZBL'      '14' '                ' '        ',
        'BL Date          ' 'ZBLDATE'  '10' '                ' '        ',
        'Invoice Number   ' 'ZINVNO'   '15' '                ' '        ',
        'Extraction       ' 'ZSTATUS'  '05' 'ZMSD_FREIGHT_HDR' 'ZSTATUS ',
        'Freight Type     ' 'ZTYPE'    '05' 'ZMSD_FREIGHT_HDR' 'ZTYPE   ',
        'Confirmation     ' 'ZCONFIRM' '05' 'ZMSD_FREIGHT_HDR' 'ZCONFIRM',
        'Confirm Date     ' 'ZCONFIRMDATE' '10' 'ZMSD_FREIGHT_HDR'
    'ZCONFIRMDATE',
        'Total Amount     ' 'ZTTLAMT'  '18' '                ' '        ',
        'Freight Payment  ' 'ZFPTYPE'  '14' '                ' '        ',
        'Charge Code      ' 'ZCHRCODE' '10' '                ' '        ',
        'Currency         ' 'ZCURCODE' '08' '                ' '        ',
        'Quantity         ' 'ZQTY'     '13' '                ' '        ',
        'UoM              ' 'ZUOM'     '04' '                ' '        ',
        'Rate             ' 'ZRATE'    '15' '                ' '        ',
        'Amt(Foreign Curr)' 'ZAMOUNT'  '16' '                ' '        ',
        'Exchange Rate    ' 'ZEXRATE'  '13' '                ' '        ',
        'Amt(Local Curr)  ' 'ZAMOUNTL' '16' '                ' '        ',
        'Created On       ' 'ERDAT'    '10' '                ' '        ',
        'Created By       ' 'ERNAM'    '10' '                ' '        ',
        'Changed On       ' 'AEDAT'    '10' '                ' '        ',
        'Changed By       ' 'AENAM'    '10' '                ' '        '.
      ENDIF.
    ENDFORM.
    FORM af USING text
                  field
                  len
                  table
                  reffield.
      v_count = v_count + 1.
      w_catalog-col_pos       = v_count.
      w_catalog-fieldname     = field.
      w_catalog-ref_tabname   = table.
      w_catalog-ref_fieldname = reffield.
      w_catalog-seltext_s     = text.
      w_catalog-seltext_m     = text.
      w_catalog-seltext_l     = text.
      w_catalog-outputlen     = len.
      IF field = 'ZTTLAMT' OR field = 'ZAMOUNTL'.
        w_catalog-no_zero     = 'X'.
        w_catalog-cfieldname  = 'WAERK'.
        w_catalog-datatype    = 'CURR'.
      ENDIF.
    IF FIELD = 'ZRATE' OR FIELD = 'ZAMOUNT'.
      IF field = 'ZAMOUNT'.
        w_catalog-no_zero     = 'X'.
        w_catalog-cfieldname  = 'ZCURCODE'.
        w_catalog-datatype    = 'CURR'.
      ENDIF.
      IF field = 'ZQTY' OR field = 'ZRATE'.
        w_catalog-no_zero     = 'X'.
        w_catalog-datatype  =  'DEC'.
      ENDIF.
      APPEND w_catalog TO t_catalog.
      CLEAR  w_catalog.
    ENDFORM.
    FORM sf    USING   fieldname  sortup  group.
      v_count = v_count + 1.
      CLEAR w_sort.
      w_sort-fieldname = fieldname.
      w_sort-spos      = v_count.
      w_sort-up        = sortup.
      w_sort-group     = group.
      APPEND w_sort TO t_sort.
    ENDFORM.
    FORM alv_user_command USING  in_ucomm    LIKE sy-ucomm
                                 in_selfield TYPE slis_selfield.
      DATA: lfs_data LIKE t_data.
      IF in_ucomm = '&IC1'.
        READ TABLE t_data INDEX in_selfield-tabindex INTO lfs_data.
        CHECK NOT lfs_data-zdidbl IS INITIAL.
        IF lfs_data-type = 'DBL'.
          DATA: l_zdbl LIKE zmsd_diheader-zdinum.
          l_zdbl = in_selfield-value.
          EXPORT l_zdbl TO MEMORY ID 'VBL'.
          CALL TRANSACTION 'ZMSD_BL01'.
        ENDIF.
        IF lfs_data-type = 'DI'.
          DATA: v_dinum LIKE zmsd_diheader-zdinum.
          v_dinum = in_selfield-value.
          EXPORT v_dinum TO MEMORY ID 'VDI'.
          CALL TRANSACTION 'ZMSD_DI01'.
        ENDIF.
      ENDIF.
    ENDFORM.
    FORM get_gst_value.
      LOOP AT t_det WHERE zsammg = v_zsammg
         AND ZINVNO = V_ZINVNO.                              "MADK991565
        CHECK t_data-zccode IN s_zccode.
        t_det-zamount  = t_det-zamount * t_det-zexrate.
        SELECT SINGLE  y0mmtarget2
                INTO   v_target2
                FROM   y0mmipstranslate
                WHERE  y0mmdatatype = '70' AND
                       y0mmsource = t_det-zchrcode.
        SELECT SINGLE y0mmtarget1
               INTO   t_det-type
               FROM   y0mmipstranslate
               WHERE  y0mmdatatype = '76' AND
                      y0mmsource = v_target2.
        IF t_det-type NE '3Z'.
          v_gsttotal    = v_gsttotal +
                               ( t_det-zamount * 5 / 100 ).
        ENDIF.
      ENDLOOP.
    Regards,
    Raj.

    Hello,
    Following is the procedure to convert alv output to spool and then it to PDF Format.
    After we display the ALV, we can check whether it is running in the background using system field u2018sy-batchu2018. Then,we call an function module named u2018GET_JOB_RUNTIME_INFOu2019 to get the current job information. Then go to spool request table tbtcp to get the spool id.
    Get current job details
      CALL FUNCTION u2018GET_JOB_RUNTIME_INFOu2019
           IMPORTING
                eventid                 = gd_eventid
                eventparm               = gd_eventparm
                external_program_active = gd_external_program_active
                jobcount                = gd_jobcount
                jobname                 = gd_jobname
                stepcount               = gd_stepcount
           EXCEPTIONS
                no_runtime_info         = 1
                OTHERS                  = 2.
    SELECT * FROM  tbtcp
                     INTO TABLE it_tbtcp
                     WHERE      jobname     = gd_jobname
                               AND jobcount = gd_jobcount
                               AND stepcount = gd_stepcount
                               AND listident <> u20180000000000u2032
                               ORDER BY   jobname
                                                   jobcount
                                                   stepcount.
      READ TABLE it_tbtcp INTO wa_tbtcp INDEX 1.
    Finally, we can call function module u2018CONVERT_ABAPSPOOLJOB_2_PDFu2018 to convert spool reqeust(which is stored in OTF format) to PDF format. Then we can call either function module u2018SO_DOCUMENT_SEND_API1u2032 or SAP BCS (Business Communication Service) to send the pdf as an email attachment.
    CALL FUNCTION u2018CONVERT_ABAPSPOOLJOB_2_PDFu2019
           EXPORTING
                src_spoolid              = gd_spool_nr
                no_dialog                = c_no
                dst_device               = c_device
           IMPORTING
                pdf_bytecount = gd_bytecount
           TABLES
                pdf = it_pdf_output
           EXCEPTIONS
                err_no_abap_spooljob     = 1
                err_no_spooljob          = 2
                err_no_permission        = 3
                err_conv_not_possible    = 4
                err_bad_destdevice       = 5
                user_cancelled           = 6
                err_spoolerror           = 7
                err_temseerror           = 8
                err_btcjob_open_failed   = 9
                err_btcjob_submit_failed = 10
                err_btcjob_close_failed  = 11
                OTHERS                   = 12.
    Regards,
    Sayali
    Edited by: Sayali Paradkar on Apr 20, 2010 12:51 PM

  • How to get Text for nodes in Tree Structure

    Hi Friends,
    How to get Text for nodes in Tree Structure
    REPORT  YFIIN_REP_TREE_STRUCTURE  no standard page heading.
                       I N I T I A L I Z A T I O N
    INITIALIZATION.
    AUTHORITY-CHECK OBJECT 'ZPRCHK_NEW' :
                      ID 'YFIINICD' FIELD SY-TCODE.
      IF SY-SUBRC NE 0.
        MESSAGE I000(yFI02) with SY-TCODE .
        LEAVE PROGRAM.
      ENDIF.
    class screen_init definition create private.
    Public section
      public section.
        class-methods init_screen.
        methods constructor.
    Private section
      private section.
        data: container1 type ref to cl_gui_custom_container,
              container2 type ref to cl_gui_custom_container,
              tree type ref to cl_gui_simple_tree.
        methods: fill_tree.
    endclass.
    Class for Handling Events
    class screen_handler definition.
    Public section
      public section.
        methods: constructor importing container
                   type ref to cl_gui_custom_container,
                 handle_node_double_click
                   for event node_double_click
                   of cl_gui_simple_tree
                   importing node_key .
    Private section
      private section.
    endclass.
    *&                        Classes implementation
    class screen_init implementation.
    *&                        Method INIT_SCREEN
      method init_screen.
        data screen type ref to screen_init.
        create object screen.
      endmethod.
    *&                        Method CONSTRUCTOR
      method constructor.
        data: events type cntl_simple_events,
              event like line of events,
              event_handler type ref to screen_handler.
        create object: container1 exporting container_name = 'CUSTOM_1',
                       tree exporting parent = container1
                         node_selection_mode =
                cl_gui_simple_tree=>node_sel_mode_multiple.
        create object: container2 exporting container_name = 'CUSTOM_2',
        event_handler exporting container = container2.
    event-eventid = cl_gui_simple_tree=>eventid_node_double_click.
        event-appl_event = ' '.   "system event, does not trigger PAI
        append event to events.
        call method tree->set_registered_events
             exporting events = events.
        set handler event_handler->handle_node_double_click for tree.
         call method: me->fill_tree.
      endmethod.
    *&                        Method FILL_TREE
      method fill_tree.
        data: node_table type table of abdemonode,
              node type abdemonode.
    types:    begin of tree_node,
              folder(50) type c,
              tcode(60) type c,
              tcode1(60) type c,
              tcode2(60) type c,
              text(60) type c,
              text1(60) type c,
              text2(60) type c,
              end of tree_node.
      data:  wa_tree_node type tree_node,
                t_tree_node type table of tree_node.
    wa_tree_node-folder = text-001.
    wa_tree_node-tcode  = text-002.
    wa_tree_node-text =  'Creditors ageing'.
    wa_tree_node-tcode1 = text-003.
    wa_tree_node-text1 =  'GR/IR aging'.
    wa_tree_node-tcode2 = text-004.
    wa_tree_node-text2 =  'Bank Balance'.
    append wa_tree_node to t_tree_node.
    clear wa_tree_node .
    wa_tree_node-folder = text-005.
    wa_tree_node-tcode  = text-006.
    wa_tree_node-text =  'Creditors ageing'.
    wa_tree_node-tcode1 = text-007.
    wa_tree_node-text1 =  'Creditors ageing'.
    wa_tree_node-tcode2 = text-008.
    wa_tree_node-text2 =  'Creditors ageing'.
    append wa_tree_node to t_tree_node.
    clear wa_tree_node .
    wa_tree_node-folder = text-009.
    wa_tree_node-tcode  = text-010.
    wa_tree_node-text =  'Creditors ageing'.
    wa_tree_node-tcode1 = text-011.
    wa_tree_node-text1 =  'Creditors ageing'.
    wa_tree_node-tcode2 = text-012.
    wa_tree_node-text2 =  'Creditors ageing'.
    append wa_tree_node to t_tree_node.
    clear wa_tree_node .
    node-hidden = ' '.                 " All nodes are visible,
        node-disabled = ' '.               " selectable,
        node-isfolder = 'X'.                                    " a folder,
        node-expander = ' '.               " have no '+' sign forexpansion.
        loop at t_tree_node into wa_tree_node.
          at new folder.
            node-isfolder = 'X'.                      " a folder,
            node-node_key = wa_tree_node-folder.
                   clear node-relatkey.
            clear node-relatship.
            node-text = wa_tree_node-folder.
            node-n_image =   ' '.
            node-exp_image = ' '.
            append node to node_table.
          endat.
         at new tcode .
            node-isfolder = ' '.                          " a folder,
            node-n_image =   '@CS@'.       "AV is the internal code
            node-exp_image = '@CS@'.       "for an airplane icon
            node-node_key = wa_tree_node-tcode.
             node-text = wa_tree_node-text .
                     node-relatkey = wa_tree_node-folder.
            node-relatship = cl_gui_simple_tree=>relat_last_child.
          endat.
          append node to node_table.
        at new tcode1 .
            node-isfolder = ' '.                          " a folder,
            node-n_image =   '@CS@'.       "AV is the internal code
            node-exp_image = '@CS@'.       "for an airplane icon
            node-node_key = wa_tree_node-tcode1.
                     node-relatkey = wa_tree_node-folder.
            node-relatship = cl_gui_simple_tree=>relat_last_child.
              node-text = wa_tree_node-text1.
         endat.
          append node to node_table.
           at new tcode2 .
            node-isfolder = ' '.                          " a folder,
            node-n_image =   '@CS@'.       "AV is the internal code
            node-exp_image = '@CS@'.       "for an airplane icon
            node-node_key = wa_tree_node-tcode2.
                     node-relatkey = wa_tree_node-folder.
            node-relatship = cl_gui_simple_tree=>relat_last_child.
            node-text = wa_tree_node-text2.
         endat.
          append node to node_table.
        endloop.
        call method tree->add_nodes
             exporting table_structure_name = 'ABDEMONODE'
                       node_table = node_table.
      endmethod.
    endclass.
    *&                        Class implementation
    class screen_handler implementation.
    *&                        Method CONSTRUCTOR
      method constructor.
       create object: HTML_VIEWER exporting PARENT = CONTAINER,
                      LIST_VIEWER exporting I_PARENT = CONTAINER.
      endmethod.
    *&                 Method HANDLE_NODE_DOUBLE_CLICK
      method handle_node_double_click.
      case node_key(12).
    when 'Creditors'.
    submit YFIIN_REP_CREADITORS_AGING  via selection-screen and return.
    when  'Vendor'.
    submit YFIIN_REP_VENDOR_OUTSTANDING  via selection-screen and return.
    when 'Customer'.
    submit YFIIN_REP_CUSTOMER_OUTSTANDING  via selection-screen and
    return.
    when 'GR/IR'.
    submit YFIIN_REP_GRIR_AGING  via selection-screen and return.
    when 'Acc_Doc_List'.
    submit YFIIN_REP_ACCOUNTINGDOCLIST  via selection-screen and return.
    when 'Bank Bal'.
    submit YFIIN_REP_BANKBALANCE  via selection-screen and return.
    when 'Ven_Cus_Dtl'.
    submit YFIIN_REP_VENDORCUST_DETAIL via selection-screen and return.
    when 'G/L_Open_Bal'.
    submit YFIIN_REP_OPENINGBALANCE via selection-screen and return.
    when 'Usr_Authn'.
    submit YFIIN_REP_USERAUTHRIZATION via selection-screen and return.
    endcase.
      endmethod.
    endclass.
    Program execution ************************************************
    load-of-program.
      call screen 9001.
    at selection-screen.
    Dialog Modules PBO
    *&      Module  STATUS_9001  OUTPUT
          text
    module status_9001 output.
      set pf-status 'SCREEN_9001'.
      set titlebar 'TIT_9001'.
      call method screen_init=>init_screen.
    endmodule.                 " STATUS_9001  OUTPUT
    Dialog Modules PAI
    *&      Module  USER_COMMAND_9001  INPUT
          text
    module user_command_9001 input.
    endmodule.                 " USER_COMMAND_9001  INPUT
    *&      Module  exit_9001  INPUT
          text
    module exit_9001 input.
    case sy-ucomm.
    when 'EXIT'.
      set screen 0.
    endcase.
    endmodule.
            exit_9001  INPUT

    you can read  the table node_table with nody key value which imports when docubble click the the tree node (Double clifk event).
    Regards,
    Gopi .
    Reward points if helpfull.

Maybe you are looking for

  • Smartforms

    hi experts, i want to display all items of customer means open and closed items. but on which condition we will display. reward points.

  • Multiple Ipods on the same computer

    I have an ipod mini, as does my roommate. We both have itunes and have had no issues downloading music and transferring to our ipods. Recently, an ipod shuffle was added to the computer successfully. Now, I cannot update my iopd mini, the songs will

  • SQL Loader and Insert Into Performance Difference

    Hello All, Im in a situation to measure performance difference between SQL Loader and Insert into. Say there 10000 records in a flat file and I want to load it into a staging table. I know that if I use PL/SQL UTL_FILE to do this job performance will

  • Is new logo a trade mark?

    Is it right that new logo is trade mark? In my humble opinion, it doesn't harmonize with open source ideology. If you are agreeable with me, can you remove (tm) from all pictures? Last edited by Ferhiord (2008-01-17 13:52:35)

  • Add more than one value in info attribute (Active Directory)

    Hello Guys, good evening! Please, maybe you can help us. We have a co-worker and she is visually impaired. So we think use the power shell, because the software "Jaws" can read the command line without problems. One of her responsabilities is disable