Skip to Content
author's profile photo Former Member
Former Member

alv tree

Do we have a common heading for header and item for alv tree ?

if we have the same heading how can we approach if we have different fields for header and item

please help.

Answers would definitely be rewarded

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Jan 31, 2008 at 08:35 AM

    Hi,

    Yes, we have common heading.

    To handle Header and Item, populate required fields when you add nodes.

    Eg:

    Considering Sales Details as an example, i would collect all details in an internal table.

    Internal table would be something like:

    types: begin <data>
      vbeln ..     " Header
      posnr ..     " Item
      auart ..     " Header
      vkorg ..     " Header
      ....
      matnr ..     " Item
      wekrs ..     " Item 
      menge ..     " Item
      ...
    end <data>.
    data: <itab> table ...
          <wa> ...
          <wa_node> ...
    
    ....
    ....
    
    " While appending nodes
    
    loop at <itab> into <wa>.
    
       at new vbeln.
          
          clear: <wa_node>.
          <wa_node>-vbeln = <wa>-vbeln.
          <wa_node>-auart = <wa>-auart.
          <wa_node>-vkorg = <wa>-vkorg.
          ....  " Similarly for the fields that are classified as parent
    
          perform append_node using <wa_node>.
          
       endat.
       
       clear: <wa_node>.
       <wa_node>-posnr = <wa>-posnr.
       <wa_node>-matnr = <wa>-matnr.
       <wa_node>-werks = <wa>-werks.
       ... " Similarly for the fields that are classified as child
       perform append_node using <wa_node>.
       
    endloop.
    

    Hope this gives you some idea.

    Regards

    Eswar

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 31, 2008 at 09:27 AM

    is it possible to save the alv tree output into a local file

    Add a comment
    10|10000 characters needed characters exceeded

    • Hi Veda

      you can downlaod to excel using this code.. with the header.. using this code..

       REPORT Excel.
      
      TABLES:
        sflight.
      
      * header data................................
      DATA :
        header1 LIKE gxxlt_p-text VALUE 'Suresh',
        header2 LIKE gxxlt_p-text VALUE 'Excel sheet'.
      
      * Internal table for holding the SFLIGHT data
      DATA BEGIN OF t_sflight OCCURS 0.
              INCLUDE STRUCTURE sflight.
      DATA END   OF t_sflight.
      
      * Internal table for holding the horizontal key.
      DATA BEGIN OF  t_hkey OCCURS 0.
              INCLUDE STRUCTURE gxxlt_h.
      DATA END   OF t_hkey .
      
      * Internal table for holding the vertical key.
      DATA BEGIN OF t_vkey OCCURS 0.
              INCLUDE STRUCTURE gxxlt_v.
      DATA END   OF t_vkey .
      
      * Internal table for holding the online text....
      DATA BEGIN OF t_online OCCURS 0.
              INCLUDE STRUCTURE gxxlt_o.
      DATA END   OF t_online.
      
      * Internal table to hold print text.............
      DATA BEGIN OF t_print OCCURS 0.
              INCLUDE STRUCTURE gxxlt_p.
      DATA END   OF t_print.
      
      * Internal table to hold SEMA data..............
      DATA BEGIN OF t_sema OCCURS 0.
              INCLUDE STRUCTURE gxxlt_s.
      DATA END   OF t_sema.
      
      * Retreiving data from sflight.
      SELECT * FROM sflight
               INTO TABLE t_sflight.
      
      * Text which will be displayed online is declared here....
      t_online-line_no    = '1'.
      t_online-info_name  = 'Created by'.
      t_online-info_value = 'SURESH KUMAR PARVATHANENI'.
      APPEND t_online.
      
      * Text which will be printed out..........................
      t_print-hf     = 'H'.
      t_print-lcr    = 'L'.
      t_print-line_no = '1'.
      t_print-text   = 'This is the header'.
      APPEND t_print.
      
      t_print-hf     = 'F'.
      t_print-lcr    = 'C'.
      t_print-line_no = '1'.
      t_print-text   = 'This is the footer'.
      APPEND t_print.
      
      * Defining the vertical key columns.......
      t_vkey-col_no   = '1'.
      t_vkey-col_name = 'MANDT'.
      APPEND t_vkey.
      
      t_vkey-col_no   = '2'.
      t_vkey-col_name = 'CARRID'.
      APPEND t_vkey.
      
      t_vkey-col_no   = '3'.
      t_vkey-col_name = 'CONNID'.
      APPEND t_vkey.
      
      t_vkey-col_no   = '4'.
      t_vkey-col_name = 'FLDATE'.
      APPEND t_vkey.
      
      * Header text for the data columns................
      
      t_hkey-row_no = '1'.
      t_hkey-col_no = 1.
      t_hkey-col_name = 'PRICE'.
      APPEND t_hkey.
      
      t_hkey-col_no = 2.
      t_hkey-col_name = 'CURRENCY'.
      APPEND t_hkey.
      
      t_hkey-col_no = 3.
      t_hkey-col_name = 'PLANETYPE'.
      APPEND t_hkey.
      
      t_hkey-col_no = 4.
      t_hkey-col_name = 'SEATSMAX'.
      APPEND t_hkey.
      
      t_hkey-col_no = 5.
      t_hkey-col_name = 'SEATSOCC'.
      APPEND t_hkey.
      
      t_hkey-col_no = 6.
      t_hkey-col_name = 'PAYMENTSUM'.
      APPEND t_hkey.
      
      * populating the SEMA data..........................
      t_sema-col_no  = 1.
      t_sema-col_typ = 'STR'.
      t_sema-col_ops = 'DFT'.
      APPEND t_sema.
      
      t_sema-col_no = 2.
      APPEND t_sema.
      
      t_sema-col_no = 3.
      APPEND t_sema.
      
      t_sema-col_no = 4.
      APPEND t_sema.
      
      t_sema-col_no = 5.
      APPEND t_sema.
      
      t_sema-col_no = 6.
      APPEND t_sema.
      
      t_sema-col_no = 7.
      APPEND t_sema.
      
      t_sema-col_no = 8.
      APPEND t_sema.
      
      t_sema-col_no = 9.
      APPEND t_sema.
      
      t_sema-col_no = 10.
      t_sema-col_typ = 'NUM'.
      t_sema-col_ops = 'ADD'.
      APPEND t_sema.
      
      CALL FUNCTION 'XXL_FULL_API'
        EXPORTING
      *   DATA_ENDING_AT          = 54
      *   DATA_STARTING_AT        = 5
         filename                = 'TESTFILE'
         header_1                = header1
         header_2                = header2
         no_dialog               = 'X'
         no_start                = ' '
          n_att_cols              = 6
          n_hrz_keys              = 1
          n_vrt_keys              = 4
         sema_type               = 'X'
      *   SO_TITLE                = ' '
        TABLES
          data                    = t_sflight
          hkey                    = t_hkey
          online_text             = t_online
          print_text              = t_print
          sema                    = t_sema
          vkey                    = t_vkey
       EXCEPTIONS
         cancelled_by_user       = 1
         data_too_big            = 2
         dim_mismatch_data       = 3
         dim_mismatch_sema       = 4
         dim_mismatch_vkey       = 5
         error_in_hkey           = 6
         error_in_sema           = 7
         file_open_error         = 8
         file_write_error        = 9
         inv_data_range          = 10
         inv_winsys              = 11
         inv_xxl                 = 12
         OTHERS                  = 13
                .
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.

  • author's profile photo Former Member
    Former Member
    Posted on Jan 31, 2008 at 12:26 PM

    Hi

    we can print the headings for list displays(hierarchical alv,blocked alv) by using events.Just have a look on the following code.

    It is hierarchical alv report.

    TYPE-POOLS: SLIS.

    DATA: BEGIN OF I_VBAK OCCURS 0,

    VBELN LIKE VBAK-VBELN,

    ERNAM LIKE VBAK-ERNAM,

    ERDAT LIKE VBAK-ERDAT,

    AUDAT LIKE VBAK-AUDAT,

    VAR1,

    END OF I_VBAK.

    DATA: BEGIN OF I_VBAP OCCURS 0,

    VBELN LIKE VBAP-VBELN,

    POSNR LIKE VBAP-POSNR,

    MATNR LIKE VBAP-MATNR,

    CHARG LIKE VBAP-CHARG,

    END OF I_VBAP.

    DATA: FLDCAT TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE,

    LAYOUT TYPE SLIS_LAYOUT_ALV,

    KEY TYPE SLIS_KEYINFO_ALV.

    DATA: it_header1 TYPE slis_t_listheader.

    DATA: wa_header1 TYPE slis_listheader.

    DATA: it_eve1 TYPE slis_t_event,

    wa_eve1 TYPE slis_alv_event.

    SELECT VBELN ERNAM ERDAT AUDAT FROM VBAK

    INTO CORRESPONDING FIELDS OF TABLE I_VBAK

    UP TO 20 ROWS.

    SELECT VBELN POSNR MATNR CHARG FROM VBAP

    INTO CORRESPONDING FIELDS OF TABLE I_VBAP

    UP TO 20 ROWS.

    FLDCAT-FIELDNAME = 'VBELN'.

    FLDCAT-TABNAME = 'I_VBAK'.

    FLDCAT-REF_FIELDNAME = 'VBELN'.

    FLDCAT-REF_TABNAME = 'VBAK'.

    FLDCAT-SELTEXT_M = 'SALES DOC.'.

    FLDCAT-COL_POS = 0.

    FLDCAT-KEY = 'X'.

    APPEND FLDCAT.

    CLEAR FLDCAT.

    FLDCAT-FIELDNAME = 'ERNAM'.

    FLDCAT-TABNAME = 'I_VBAK'.

    FLDCAT-REF_FIELDNAME = 'ERNAM'.

    FLDCAT-REF_TABNAME = 'VBAK'.

    FLDCAT-SELTEXT_M = 'NAME OF PERSON'.

    FLDCAT-COL_POS = 1.

    APPEND FLDCAT.

    CLEAR FLDCAT.

    FLDCAT-FIELDNAME = 'ERDAT'.

    FLDCAT-TABNAME = 'I_VBAK'.

    FLDCAT-REF_FIELDNAME = 'ERDAT'.

    FLDCAT-REF_TABNAME = 'VBAK'.

    FLDCAT-SELTEXT_M = 'RECORD DATE'.

    FLDCAT-COL_POS = 2.

    APPEND FLDCAT.

    CLEAR FLDCAT.

    FLDCAT-FIELDNAME = 'AUDAT'.

    FLDCAT-TABNAME = 'I_VBAK'.

    FLDCAT-REF_FIELDNAME = 'AUDAT'.

    FLDCAT-REF_TABNAME = 'VBAK'.

    FLDCAT-SELTEXT_M = 'DOCUMENT DATE'.

    FLDCAT-COL_POS = 3.

    APPEND FLDCAT.

    CLEAR FLDCAT.

    FLDCAT-FIELDNAME = 'POSNR'.

    FLDCAT-TABNAME = 'I_VBAP'.

    FLDCAT-REF_FIELDNAME = 'POSNR'.

    FLDCAT-REF_TABNAME = 'VBAP'.

    FLDCAT-SELTEXT_M = 'SALES DOC ITEM'.

    FLDCAT-COL_POS = 4.

    APPEND FLDCAT.

    CLEAR FLDCAT.

    FLDCAT-FIELDNAME = 'MATNR'.

    FLDCAT-TABNAME = 'I_VBAP'.

    FLDCAT-REF_FIELDNAME = 'MATNR'.

    FLDCAT-REF_TABNAME = 'VBAP'.

    FLDCAT-SELTEXT_M = 'MATERIAL NO'.

    FLDCAT-COL_POS = 5.

    APPEND FLDCAT.

    CLEAR FLDCAT.

    FLDCAT-FIELDNAME = 'CHARG'.

    FLDCAT-TABNAME = 'I_VBAP'.

    FLDCAT-REF_FIELDNAME = 'CHARG'.

    FLDCAT-REF_TABNAME = 'VBAP'.

    FLDCAT-SELTEXT_M = 'BATCH NUMBER'.

    FLDCAT-COL_POS = 6.

    APPEND FLDCAT.

    CLEAR FLDCAT.

    LAYOUT-EXPAND_FIELDNAME = 'VAR1'.

    KEY-HEADER01 = 'VBELN'.

    KEY-ITEM01 = 'VBELN'.

    CLEAR wa_eve1.

    wa_eve1-name = 'TOP_OF_PAGE'.

    wa_eve1-form = 'TOP-OF-PAGE1'.

    APPEND wa_eve1 TO it_eve1.

    CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'

    EXPORTING

    I_CALLBACK_PROGRAM = SY-REPID

    IS_LAYOUT = LAYOUT

    IT_FIELDCAT = FLDCAT[]

    IT_EVENTS = it_eve1[]

    I_TABNAME_HEADER = 'I_VBAK'

    I_TABNAME_ITEM = 'I_VBAP'

    IS_KEYINFO = KEY

    TABLES

    T_OUTTAB_HEADER = I_VBAK

    T_OUTTAB_ITEM = I_VBAP

    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.

    FORM top-of-page1. "#EC CALLED

    wa_header1-typ = 'H'.

    wa_header1-info = 'Test heading for hierarchical'.

    APPEND wa_header1 TO it_header1.

    CLEAR wa_header1.

    CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

    EXPORTING

    it_list_commentary = it_header1[].

    REFRESH it_header1.

    ENDFORM. "TOP-OF-PAGE1

    reward points,if it is useful.

    Thanks,

    chandu.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

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

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