<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: problem with alv in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-alv/m-p/2868307#M672931</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Build a structure with the fields of each structure, fill the internal table to display by moving only the required fields into the table when adding a record leaving the other ones initial.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1 a b c d _ _ _ _ _ _ _ _ &lt;/P&gt;&lt;P&gt;2 _ _ _ _ e f g h i j _ _ _ &lt;/P&gt;&lt;P&gt;3 _ _ _ _ _ _ _ _ _ k l m &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;CLEAR record
CASE field1.
  WHEN '1'.
    MOVE-CORRESPONDING structure1 to record.
  WHEN '2'.
    MOVE-CORRESPONDING structure2 to record.
ENDCASE.
APPEND record TO itab.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 28 Sep 2007 14:24:27 GMT</pubDate>
    <dc:creator>RaymondGiuseppi</dc:creator>
    <dc:date>2007-09-28T14:24:27Z</dc:date>
    <item>
      <title>problem with alv</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-alv/m-p/2868305#M672929</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;i want to disply 4 different srtures in alv....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;like if one field value equal to 1 we need to disply first structure if it equal to 2 2nd structure and so on...(with colonm headings)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; example &lt;/P&gt;&lt;P&gt;1 a b c d&lt;/P&gt;&lt;P&gt;2 e f g h i j&lt;/P&gt;&lt;P&gt;3 k l m&lt;/P&gt;&lt;P&gt;4 m n o&lt;/P&gt;&lt;P&gt;1 a b c d&lt;/P&gt;&lt;P&gt;2 e f g h i j&lt;/P&gt;&lt;P&gt;3 k l m&lt;/P&gt;&lt;P&gt;4 m n o&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; if the field value eual to 1 struture cantaining field a, b,c,d should be displayed.&lt;/P&gt;&lt;P&gt;and soon....&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Sep 2007 14:16:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-alv/m-p/2868305#M672929</guid>
      <dc:creator>former_member799868</dc:creator>
      <dc:date>2007-09-28T14:16:07Z</dc:date>
    </item>
    <item>
      <title>Re: problem with alv</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-alv/m-p/2868306#M672930</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;consolidate the entire data that you want to display in the ALV into one ITAB...&lt;/P&gt;&lt;P&gt;based on the conditions that you want to select the structure..&lt;/P&gt;&lt;P&gt;eg.  if one field value equal to 1 then append that record in ITAB&lt;/P&gt;&lt;P&gt;same way for all the structures give the conditions..&lt;/P&gt;&lt;P&gt;Pass this consolidated ITAB to ALV....&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Sep 2007 14:19:23 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-alv/m-p/2868306#M672930</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-09-28T14:19:23Z</dc:date>
    </item>
    <item>
      <title>Re: problem with alv</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-alv/m-p/2868307#M672931</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Build a structure with the fields of each structure, fill the internal table to display by moving only the required fields into the table when adding a record leaving the other ones initial.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1 a b c d _ _ _ _ _ _ _ _ &lt;/P&gt;&lt;P&gt;2 _ _ _ _ e f g h i j _ _ _ &lt;/P&gt;&lt;P&gt;3 _ _ _ _ _ _ _ _ _ k l m &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;CLEAR record
CASE field1.
  WHEN '1'.
    MOVE-CORRESPONDING structure1 to record.
  WHEN '2'.
    MOVE-CORRESPONDING structure2 to record.
ENDCASE.
APPEND record TO itab.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Sep 2007 14:24:27 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-alv/m-p/2868307#M672931</guid>
      <dc:creator>RaymondGiuseppi</dc:creator>
      <dc:date>2007-09-28T14:24:27Z</dc:date>
    </item>
    <item>
      <title>Re: problem with alv</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-alv/m-p/2868308#M672932</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Have a look at the example programs BCALV_TREE_*.  They show how to set up a heirarchical tree using an ALV grid.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Sep 2007 14:57:37 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-alv/m-p/2868308#M672932</guid>
      <dc:creator>msshortza</dc:creator>
      <dc:date>2007-09-28T14:57:37Z</dc:date>
    </item>
    <item>
      <title>Re: problem with alv</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-alv/m-p/2868309#M672933</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Small but nice example -:)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp; Report  ZDUMMY_ATG_2
*&amp;amp;
*&amp;amp;---------------------------------------------------------------------*
REPORT zdummy_atg_2.

TYPES: BEGIN OF ty_header,
       carrid TYPE spfli-carrid,
       END OF ty_header.

TYPES: BEGIN OF ty_scarr,
       carrid TYPE scarr-carrid,
       carrname TYPE scarr-carrname,
       END OF ty_scarr.

TYPES: BEGIN OF ty_tree,
       carrid TYPE spfli-carrid,
       connid TYPE spfli-connid,
       countryfr TYPE spfli-countryfr,
       cityfrom TYPE spfli-cityfrom,
       airpfrom TYPE spfli-airpfrom,
       countryto TYPE spfli-countryto,
       cityto TYPE spfli-cityto,
       END OF ty_tree.

DATA: t_spfli TYPE STANDARD TABLE OF spfli,
      w_spfli LIKE LINE OF t_spfli,
      lt_f4 TYPE lvc_t_f4 WITH HEADER LINE,
      return_tab TYPE STANDARD TABLE OF ddshretval WITH HEADER LINE,
      t_stable TYPE STANDARD TABLE OF lvc_s_stbl WITH HEADER LINE,
      t_header TYPE STANDARD TABLE OF ty_header,
      t_scarr TYPE STANDARD TABLE OF ty_scarr,
      t_tree TYPE STANDARD TABLE OF ty_tree WITH HEADER LINE.

DATA: g_alv_tree TYPE REF TO cl_gui_alv_tree,
      g_custom_container TYPE REF TO cl_gui_custom_container,
      gs_fieldcat TYPE lvc_s_fcat,
      gt_fieldcat_tree TYPE lvc_t_fcat,
      l_hierarchy_header TYPE treev_hhdr,
      it_node_key TYPE lvc_t_nkey,
      w_index TYPE sy-tabix.

DATA: ok_code LIKE sy-ucomm,
      gt_fieldcat TYPE lvc_t_fcat.

FIELD-SYMBOLS: &amp;lt;fs_spfli&amp;gt; LIKE LINE OF t_spfli,
               &amp;lt;fs_header&amp;gt; LIKE LINE OF t_header,
               &amp;lt;fs_scarr&amp;gt; LIKE LINE OF t_scarr.

*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      START-OF-SELECTION                                             *
*&amp;amp;---------------------------------------------------------------------*
START-OF-SELECTION.
  PERFORM cargar_datos.
  PERFORM init_tree.

  CALL SCREEN 0100.

*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  CARGAR_DATOS                                             *
*&amp;amp;---------------------------------------------------------------------*
FORM cargar_datos.

  SELECT mandt carrid connid countryfr cityfrom
         airpfrom countryto cityto airpto
         fltime deptime arrtime distance
         distid fltype period
  INTO TABLE t_spfli
  FROM spfli.

  SELECT carrid carrname
  INTO TABLE t_scarr
  FROM scarr
  FOR ALL ENTRIES IN t_spfli
  WHERE carrid EQ t_spfli-carrid.

  DELETE ADJACENT DUPLICATES FROM t_scarr
  COMPARING carrid.

  LOOP AT t_scarr ASSIGNING &amp;lt;fs_scarr&amp;gt;.
    APPEND INITIAL LINE TO t_header
    ASSIGNING &amp;lt;fs_header&amp;gt;.
    MOVE &amp;lt;fs_scarr&amp;gt; TO &amp;lt;fs_header&amp;gt;.
  ENDLOOP.

ENDFORM.                    " CARGAR_DATOS

*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Module  STATUS_0100  OUTPUT                                    *
*&amp;amp;---------------------------------------------------------------------*
MODULE status_0100 OUTPUT.
  SET PF-STATUS 'MAIN_STATUS'.
*  SET TITLEBAR 'xxx'.

ENDMODULE.                 " STATUS_0100  OUTPUT

*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Module  USER_COMMAND_0100  INPUT                               *
*&amp;amp;---------------------------------------------------------------------*
MODULE user_command_0100 INPUT.

  ok_code = sy-ucomm.

  CASE ok_code.
    WHEN 'BACK' OR 'STOP' OR 'CANCEL'.
      SET SCREEN 0.
      LEAVE SCREEN.
  ENDCASE.

ENDMODULE.                 " USER_COMMAND_0100  INPUT

*---------------------------------------------------------------------*
*       FORM init_tree                                                *
*---------------------------------------------------------------------*
FORM init_tree.

  DATA: l_tree_container_name(30) TYPE c.

  l_tree_container_name = 'CUSTOM_ALV'.

  CREATE OBJECT g_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.

  CREATE OBJECT g_alv_tree
    EXPORTING
      parent                      = g_custom_container
      node_selection_mode         = cl_gui_column_tree=&amp;gt;node_sel_mode_single
      item_selection              = ''
      no_html_header              = 'X'
      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.

  PERFORM fill_catalog_tree.
  PERFORM build_hierarchy_header CHANGING l_hierarchy_header.

  CALL METHOD g_alv_tree-&amp;gt;set_table_for_first_display
    EXPORTING
      is_hierarchy_header = l_hierarchy_header
    CHANGING
      it_outtab           = t_tree[]
      it_fieldcatalog     = gt_fieldcat_tree.

  PERFORM create_hierarchy.

ENDFORM.                    "INIT_TREE

*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  FILL_CATALOG_TREE                                        *
*&amp;amp;---------------------------------------------------------------------*
FORM fill_catalog_tree.

  DATA: gs_fieldcat TYPE lvc_s_fcat.

  CLEAR gs_fieldcat.
  gs_fieldcat-col_pos   = 1.
  gs_fieldcat-fieldname = 'CARRID'.
  gs_fieldcat-scrtext_s = 'Compañía'.
  gs_fieldcat-tabname   = 'T_SPFLI'.
  gs_fieldcat-edit      = 'X'.
  gs_fieldcat-f4availabl = 'X'.
  gs_fieldcat-outputlen = '8'.
  APPEND gs_fieldcat TO gt_fieldcat_tree.

  CLEAR gs_fieldcat.
  gs_fieldcat-col_pos   = 2.
  gs_fieldcat-fieldname = 'CONNID'.
  gs_fieldcat-scrtext_s = 'Conexión'.
  gs_fieldcat-tabname   = 'T_SPFLI'.
  gs_fieldcat-edit      = 'X'.
  gs_fieldcat-outputlen = '8'.
  APPEND gs_fieldcat TO gt_fieldcat_tree.

  CLEAR gs_fieldcat.
  gs_fieldcat-col_pos   = 3.
  gs_fieldcat-fieldname = 'COUNTRYFR'.
  gs_fieldcat-scrtext_s = 'País'.
  gs_fieldcat-tabname   = 'T_SPFLI'.
  gs_fieldcat-edit      = 'X'.
  gs_fieldcat-outputlen = '4'.
  APPEND gs_fieldcat TO gt_fieldcat_tree.

  CLEAR gs_fieldcat.
  gs_fieldcat-col_pos   = 4.
  gs_fieldcat-fieldname = 'CITYFROM'.
  gs_fieldcat-scrtext_s = 'Ciudad Salida'.
  gs_fieldcat-tabname   = 'T_SPFLI'.
  gs_fieldcat-edit      = space.
  gs_fieldcat-outputlen = '20'.
  APPEND gs_fieldcat TO gt_fieldcat_tree.

  CLEAR gs_fieldcat.
  gs_fieldcat-col_pos   = 5.
  gs_fieldcat-fieldname = 'AIRPFROM'.
  gs_fieldcat-scrtext_s = 'Arp. Salida'.
  gs_fieldcat-tabname   = 'T_SPFLI'.
  gs_fieldcat-edit      = 'X'.
  gs_fieldcat-outputlen = '10'.
  APPEND gs_fieldcat TO gt_fieldcat_tree.

  CLEAR gs_fieldcat.
  gs_fieldcat-col_pos   = 6.
  gs_fieldcat-fieldname = 'COUNTRYTO'.
  gs_fieldcat-scrtext_s = 'País'.
  gs_fieldcat-tabname   = 'T_SPFLI'.
  gs_fieldcat-edit      = 'X'.
  gs_fieldcat-outputlen = '4'.
  APPEND gs_fieldcat TO gt_fieldcat_tree.

  CLEAR gs_fieldcat.
  gs_fieldcat-col_pos   = 7.
  gs_fieldcat-fieldname = 'CITYTO'.
  gs_fieldcat-scrtext_s = 'Ciudad Llegada'.
  gs_fieldcat-tabname   = 'T_SPFLI'.
  gs_fieldcat-edit      = space.
  gs_fieldcat-outputlen = '20'.
  APPEND gs_fieldcat TO gt_fieldcat_tree.

ENDFORM.                    " FILL_CATALOG_TREE

*---------------------------------------------------------------------*
*       FORM build_hierarchy_header                                   *
*---------------------------------------------------------------------*
FORM build_hierarchy_header CHANGING
                               p_hierarchy_header TYPE treev_hhdr.

  CLEAR p_hierarchy_header.
  p_hierarchy_header-heading = 'Código'(300).
  p_hierarchy_header-width = 60.
  p_hierarchy_header-width_pix = ' '.

ENDFORM.                    "BUILD_HIERARCHY_HEADER

*---------------------------------------------------------------------*
*       FORM create_hierarchy                                         *
*---------------------------------------------------------------------*
FORM create_hierarchy.

  DATA: l_root_key TYPE lvc_nkey,
        l_next_key TYPE lvc_nkey,
        l_last_key TYPE lvc_nkey,
        header TYPE string,
        w_menge_text(13) TYPE c.

  CLEAR l_root_key.

  LOOP AT t_header ASSIGNING &amp;lt;fs_header&amp;gt;.
    READ TABLE t_scarr WITH KEY carrid = &amp;lt;fs_header&amp;gt;-carrid
    ASSIGNING &amp;lt;fs_scarr&amp;gt;.
    IF sy-subrc EQ 0.
      header = &amp;lt;fs_scarr&amp;gt;-carrname.
    ENDIF.
    CLEAR l_root_key.
    CLEAR l_next_key.
    PERFORM add_node USING header l_root_key
                     CHANGING l_next_key.
    LOOP AT t_spfli ASSIGNING &amp;lt;fs_spfli&amp;gt;
    WHERE carrid EQ &amp;lt;fs_header&amp;gt;-carrid.

      MOVE-CORRESPONDING &amp;lt;fs_spfli&amp;gt; TO t_tree.

      PERFORM add_leaf USING t_tree l_next_key
                       CHANGING l_last_key.
    ENDLOOP.
  ENDLOOP.

  CALL METHOD g_alv_tree-&amp;gt;frontend_update.

ENDFORM.                    "CREATE_HIERARCHY

*---------------------------------------------------------------------*
*       FORM ADD_NODE                                                 *
*---------------------------------------------------------------------*
FORM add_node USING l_name l_root_key
              CHANGING l_next_key.

  DATA: l_node_text TYPE lvc_value,
        ls_tree TYPE ty_tree.

  l_node_text =  l_name.
  CALL METHOD g_alv_tree-&amp;gt;add_node
    EXPORTING
      i_relat_node_key = l_root_key
      i_relationship   = cl_gui_column_tree=&amp;gt;relat_last_child
      i_node_text      = l_node_text
      is_outtab_line   = ls_tree
    IMPORTING
      e_new_node_key   = l_next_key.

ENDFORM.                    "ADD_NODE

*---------------------------------------------------------------------*
*       FORM ADD_LEAF                                                 *
*---------------------------------------------------------------------*
FORM add_leaf USING l_tree TYPE ty_tree
                    l_next_key
              CHANGING l_last_key.

  CALL METHOD g_alv_tree-&amp;gt;add_node
    EXPORTING
      i_relat_node_key = l_next_key
      i_relationship   = cl_gui_column_tree=&amp;gt;relat_last_child
      is_outtab_line   = t_tree
    IMPORTING
      e_new_node_key   = l_last_key.

ENDFORM.                    "ADD_LEAF
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Greetings,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Blag.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Sep 2007 17:23:28 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/problem-with-alv/m-p/2868309#M672933</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-09-28T17:23:28Z</dc:date>
    </item>
  </channel>
</rss>

