<?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: ALV help needed in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/alv-help-needed/m-p/3407527#M818347</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Have you tried setting the ALV to sub-total based on the p.org?  This should give you a heading line for each group.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 22 Feb 2008 22:45:43 GMT</pubDate>
    <dc:creator>former_member393151</dc:creator>
    <dc:date>2008-02-22T22:45:43Z</dc:date>
    <item>
      <title>ALV help needed</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/alv-help-needed/m-p/3407526#M818346</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi , &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am trying to develop a pricing report with the respective changes between a certain period .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My issue is ...there should be a seperate  heading everytime a new purchase org. is starting in the output and then the materials list.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I know how to make a simple report using one heading and then the list .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;REUSE_ALV_COMMENTARY_WRITE&lt;/P&gt;&lt;P&gt;REUSE_ALV_GRID_DISPLAY&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have used these several time for simple reports.But this time I have to make it with seperate headings ...when there are many purchase orgs in the output.&lt;/P&gt;&lt;P&gt;Anyone please help me with a sample program or appropriate function module name with structure of code....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: ramana peddu on Feb 22, 2008 11:16 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Feb 2008 22:16:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/alv-help-needed/m-p/3407526#M818346</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-02-22T22:16:06Z</dc:date>
    </item>
    <item>
      <title>Re: ALV help needed</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/alv-help-needed/m-p/3407527#M818347</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Have you tried setting the ALV to sub-total based on the p.org?  This should give you a heading line for each group.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Feb 2008 22:45:43 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/alv-help-needed/m-p/3407527#M818347</guid>
      <dc:creator>former_member393151</dc:creator>
      <dc:date>2008-02-22T22:45:43Z</dc:date>
    </item>
    <item>
      <title>Re: ALV help needed</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/alv-help-needed/m-p/3407528#M818348</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Why don't you use OO ALV Tree???&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It's better for that kind of reports...&lt;/P&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;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Feb 2008 22:48:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/alv-help-needed/m-p/3407528#M818348</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-02-22T22:48:47Z</dc:date>
    </item>
    <item>
      <title>Re: ALV help needed</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/alv-help-needed/m-p/3407529#M818349</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi ,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I don't know how to use both the methods can you send me the sample code for it ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Feb 2008 23:00:59 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/alv-help-needed/m-p/3407529#M818349</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-02-22T23:00:59Z</dc:date>
    </item>
    <item>
      <title>Re: ALV help needed</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/alv-help-needed/m-p/3407530#M818350</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&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, 22 Feb 2008 23:20:39 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/alv-help-needed/m-p/3407530#M818350</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-02-22T23:20:39Z</dc:date>
    </item>
    <item>
      <title>Re: ALV help needed</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/alv-help-needed/m-p/3407531#M818351</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you very much&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 23 Feb 2008 00:11:12 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/alv-help-needed/m-p/3407531#M818351</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-02-23T00:11:12Z</dc:date>
    </item>
  </channel>
</rss>

