Display output fields in Hierarchy format in ALV report

Hi,
I have a requirement to display the output fileds in ALV report, the output format is like this . The output field should be in ALV format, under each purchase order its corresponding line item should appear.
Pruchase Order  4700000581  
company code        item
        9001                     10
        9001                     20.
        9001                     30.
Pruchase Order  4700000174  
        9001                     10
        9001                     20.
Can any one please help me how to do this in ALV report.

Hi
This can be achieved using the Heirarchial ALV list
see the sample and do it
REPORT ZALV5_OBJECTS.
TABLES : EKKO.
TYPE-POOLS : SLIS.
TYPES : BEGIN OF TY_EKKO,
EBELN TYPE EKPO-EBELN,
EBELP TYPE EKPO-EBELP,
STATU TYPE EKPO-STATU,
AEDAT TYPE EKPO-AEDAT,
MATNR TYPE EKPO-MATNR,
MENGE TYPE EKPO-MENGE,
MEINS TYPE EKPO-MEINS,
NETPR TYPE EKPO-NETPR,
PEINH TYPE EKPO-PEINH,
END OF TY_EKKO.
DATA: IT_EKKO TYPE STANDARD TABLE OF TY_EKKO INITIAL SIZE 0,
IT_EKPO TYPE STANDARD TABLE OF TY_EKKO INITIAL SIZE 0,
IT_EMPTYTAB TYPE STANDARD TABLE OF TY_EKKO INITIAL SIZE 0,
WA_EKKO TYPE TY_EKKO,
WA_EKPO TYPE TY_EKKO.
DATA: OK_CODE LIKE SY-UCOMM, "OK-Code
SAVE_OK LIKE SY-UCOMM.
*ALV data declarations
DATA: FIELDCATALOG TYPE LVC_T_FCAT WITH HEADER LINE.
DATA: GD_FIELDCAT TYPE LVC_T_FCAT,
GD_TAB_GROUP TYPE SLIS_T_SP_GROUP_ALV,
GD_LAYOUT TYPE SLIS_LAYOUT_ALV.
*ALVtree data declarations
CLASS CL_GUI_COLUMN_TREE DEFINITION LOAD.
CLASS CL_GUI_CFW DEFINITION LOAD.
DATA: GD_TREE TYPE REF TO CL_GUI_ALV_TREE,
GD_HIERARCHY_HEADER TYPE TREEV_HHDR,
GD_REPORT_TITLE TYPE SLIS_T_LISTHEADER,
GD_LOGO TYPE SDYDO_VALUE,
GD_VARIANT TYPE DISVARIANT.
*Create container for alv-tree
DATA: GD_TREE_CONTAINER_NAME(30) TYPE C,
GD_CUSTOM_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER.
*Includes
*INCLUDE ZDEMO_ALVTREEO01. "Screen PBO Modules
*INCLUDE ZDEMO_ALVTREEI01. "Screen PAI Modules
*INCLUDE ZDEMO_ALVTREEF01. "ABAP Subroutines(FORMS)
*Start-of-selection.
START-OF-SELECTION.
ALVtree setup data
PERFORM DATA_RETRIEVAL.
PERFORM BUILD_FIELDCATALOG.
PERFORM BUILD_LAYOUT.
PERFORM BUILD_HIERARCHY_HEADER CHANGING GD_HIERARCHY_HEADER.
PERFORM BUILD_REPORT_TITLE USING GD_REPORT_TITLE GD_LOGO.
PERFORM BUILD_VARIANT.
Display ALVtree report
CALL SCREEN 100.
*& Form data_retrieval
text
--> p1 text
<-- p2 text
FORM DATA_RETRIEVAL .
SELECT EBELN
UP TO 10 ROWS
FROM EKKO
INTO CORRESPONDING FIELDS OF TABLE IT_EKKO.
LOOP AT IT_EKKO INTO WA_EKKO.
SELECT EBELN EBELP STATU AEDAT MATNR MENGE MEINS NETPR PEINH
FROM EKPO
APPENDING TABLE IT_EKPO
WHERE EBELN EQ WA_EKKO-EBELN.
ENDLOOP.
ENDFORM. " data_retrieval
*& Form build_fieldcatalog
text
--> p1 text
<-- p2 text
FORM BUILD_FIELDCATALOG .
Please not there are a number of differences between the structure of
ALVtree fieldcatalogs and ALVgrid fieldcatalogs.
For example the field seltext_m is replace by scrtext_m in ALVtree.
FIELDCATALOG-FIELDNAME = 'EBELN'. "Field name in itab
FIELDCATALOG-SCRTEXT_M = 'Purchase Order'. "Column text
FIELDCATALOG-COL_POS = 0. "Column position
FIELDCATALOG-OUTPUTLEN = 15. "Column width
FIELDCATALOG-EMPHASIZE = 'X'. "Emphasize (X or SPACE)
FIELDCATALOG-KEY = 'X'. "Key Field? (X or SPACE)
fieldcatalog-do_sum = 'X'. "Sum Column?
fieldcatalog-no_zero = 'X'. "Don't display if zero
APPEND FIELDCATALOG TO GD_FIELDCAT.
CLEAR FIELDCATALOG.
FIELDCATALOG-FIELDNAME = 'EBELP'.
FIELDCATALOG-SCRTEXT_M = 'PO Iten'.
FIELDCATALOG-OUTPUTLEN = 15.
FIELDCATALOG-COL_POS = 1.
APPEND FIELDCATALOG TO GD_FIELDCAT..
CLEAR FIELDCATALOG.
FIELDCATALOG-FIELDNAME = 'STATU'.
FIELDCATALOG-SCRTEXT_M = 'Status'.
FIELDCATALOG-OUTPUTLEN = 15.
FIELDCATALOG-COL_POS = 2.
APPEND FIELDCATALOG TO GD_FIELDCAT..
CLEAR FIELDCATALOG.
FIELDCATALOG-FIELDNAME = 'AEDAT'.
FIELDCATALOG-SCRTEXT_M = 'Item change date'.
FIELDCATALOG-OUTPUTLEN = 15.
FIELDCATALOG-COL_POS = 3.
APPEND FIELDCATALOG TO GD_FIELDCAT..
CLEAR FIELDCATALOG.
FIELDCATALOG-FIELDNAME = 'MATNR'.
FIELDCATALOG-SCRTEXT_M = 'Material Number'.
FIELDCATALOG-OUTPUTLEN = 15.
FIELDCATALOG-COL_POS = 4.
APPEND FIELDCATALOG TO GD_FIELDCAT..
CLEAR FIELDCATALOG.
FIELDCATALOG-FIELDNAME = 'MENGE'.
FIELDCATALOG-SCRTEXT_M = 'PO quantity'.
FIELDCATALOG-OUTPUTLEN = 15.
FIELDCATALOG-COL_POS = 5.
APPEND FIELDCATALOG TO GD_FIELDCAT..
CLEAR FIELDCATALOG.
FIELDCATALOG-FIELDNAME = 'MEINS'.
FIELDCATALOG-SCRTEXT_M = 'Order Unit'.
FIELDCATALOG-OUTPUTLEN = 15.
FIELDCATALOG-COL_POS = 6.
APPEND FIELDCATALOG TO GD_FIELDCAT..
CLEAR FIELDCATALOG.
FIELDCATALOG-FIELDNAME = 'NETPR'.
FIELDCATALOG-SCRTEXT_M = 'Net Price'.
FIELDCATALOG-OUTPUTLEN = 15.
FIELDCATALOG-COL_POS = 7.
FIELDCATALOG-DATATYPE = 'CURR'.
APPEND FIELDCATALOG TO GD_FIELDCAT..
CLEAR FIELDCATALOG.
FIELDCATALOG-FIELDNAME = 'PEINH'.
FIELDCATALOG-SCRTEXT_M = 'Price Unit'.
FIELDCATALOG-OUTPUTLEN = 15.
FIELDCATALOG-COL_POS = 8.
APPEND FIELDCATALOG TO GD_FIELDCAT..
CLEAR FIELDCATALOG.
ENDFORM. " build_fieldcatalog
*& Form build_layout
text
--> p1 text
<-- p2 text
FORM BUILD_LAYOUT .
GD_LAYOUT-NO_INPUT = 'X'.
GD_LAYOUT-COLWIDTH_OPTIMIZE = 'X'.
GD_LAYOUT-TOTALS_TEXT = 'Totals'(201).
gd_layout-totals_only = 'X'.
gd_layout-f2code = 'DISP'. "Sets fcode for when double
"click(press f2)
gd_layout-zebra = 'X'.
gd_layout-group_change_edit = 'X'.
gd_layout-header_text = 'helllllo'
ENDFORM. " build_layout
*& Form build_hierarchy_header
text
<--P_GD_HIERARCHY_HEADER text
FORM BUILD_HIERARCHY_HEADER CHANGING
P_HIERARCHY_HEADER TYPE TREEV_HHDR.
P_HIERARCHY_HEADER-HEADING = 'Hierarchy Header'(013).
P_HIERARCHY_HEADER-TOOLTIP = 'This is the Hierarchy Header !'(014).
P_HIERARCHY_HEADER-WIDTH = 30.
P_HIERARCHY_HEADER-WIDTH_PIX = ''.
ENDFORM. " build_hierarchy_header
*& Form build_report_title
text
-->P_GD_REPORT_TITLE text
-->P_GD_LOGO text
FORM BUILD_REPORT_TITLE USING PT_REPORT_TITLE TYPE SLIS_T_LISTHEADER
P_GD_LOGO TYPE SDYDO_VALUE.
DATA: LS_LINE TYPE SLIS_LISTHEADER,
LD_DATE(10) TYPE C.
List Heading Line(TYPE H)
CLEAR LS_LINE.
LS_LINE-TYP = 'H'.
ls_line-key "Not Used For This Type(H)
LS_LINE-INFO = 'PO ALVTree Display'.
APPEND LS_LINE TO PT_REPORT_TITLE.
Status Line(TYPE S)
LD_DATE(2) = SY-DATUM+6(2).
LD_DATE+2(1) = '/'.
LD_DATE3(2) = SY-DATUM4(2).
LD_DATE+5(1) = '/'.
LD_DATE+6(4) = SY-DATUM(4).
LS_LINE-TYP = 'S'.
LS_LINE-KEY = 'Date'.
LS_LINE-INFO = LD_DATE.
APPEND LS_LINE TO PT_REPORT_TITLE.
Action Line(TYPE A)
CLEAR LS_LINE.
LS_LINE-TYP = 'A'.
CONCATENATE 'Report: ' SY-REPID INTO LS_LINE-INFO SEPARATED BY SPACE.
APPEND LS_LINE TO PT_REPORT_TITLE.
ENDFORM. " build_report_title
*& Form build_variant
text
--> p1 text
<-- p2 text
FORM BUILD_VARIANT .
Set repid for storing variants
GD_VARIANT-REPORT = SY-REPID.
ENDFORM. " build_variant
Reward points for useful Answers
Regards
Anji

Similar Messages

  • How to get this output format in ALV report

    Hi.
    Can any one pls let me know how to get the following output format in ALV report.Following are the outputfields
    companycode   location     position     approver
    300    800       01    watson
    null   null        03     candy
    null   null        04     smith
    null   null        05     michael
    one empty line after this again
    300     800     01     ryant
    null      null    02     gyan
    null      null    03     fermi
    null      null    04     ogata
    *Note: Null     indicates  empty space .( i.e I need to get empty space in  output where ever null is there.)
            Thanks in advance.
    Kind Regards,
    samiulla.

    hi,
    u can use 'REUSE_ALV_LIST_DISPLAY'
                           or
    'REUSE_ALV_GRID_DISPLAY'  function modules.
    SAMPLE CODE :
    *& Report  Y101982CHD
    *                         TABLES
    TABLES: vbak.    " standard table
    *                           Type Pools                                 *
    TYPE-POOLS: slis.
    *                     Global Structure Definitions                     *
    *-- Structure to hold data from table CE1MCK2
    TYPES: BEGIN OF tp_itab1,
           vbeln LIKE vbap-vbeln,
           posnr LIKE vbap-posnr,
           werks LIKE vbap-werks,
           lgort LIKE vbap-lgort,
           END OF tp_itab1.
    *-- Data Declaration
    DATA: t_itab1 TYPE TABLE OF tp_itab1.
    DATA : i_fieldcat TYPE slis_t_fieldcat_alv.
    *                    Selection  Screen                                 *
    *--Sales document-block
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-t01.
    SELECT-OPTIONS: s_vbeln FOR vbak-vbeln.
    SELECTION-SCREEN END OF  BLOCK b1.
    *--Display option - block
    SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-t02.
    PARAMETERS: alv_list RADIOBUTTON GROUP g1,
                alv_grid RADIOBUTTON GROUP g1.
    SELECTION-SCREEN END OF  BLOCK b2.
    *file download - block
    SELECTION-SCREEN BEGIN OF BLOCK b3 WITH FRAME TITLE text-t03.
    PARAMETERS: topc AS CHECKBOX,
                p_file TYPE rlgrap-filename.
    SELECTION-SCREEN END OF  BLOCK b3.
    *                      Initialization.                                *
    *                      At Selection Screen                            *
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
      CALL FUNCTION 'F4_DXFILENAME_4_DYNP'
        EXPORTING
          dynpfield_filename = 'P_FILE'
          dyname             = sy-cprog
          dynumb             = sy-dynnr
          filetype           = 'P'      "P-->Physical
          location           = 'P'     "P Presentation Srever
          server             = space.
    AT SELECTION-SCREEN ON s_vbeln.
      PERFORM vbeln_validate.
    *                           Start Of Selection                         *
    START-OF-SELECTION.
    *-- Fetching all the required data into the internal table
      PERFORM select_data.
    *                           End Of Selection                           *
    END-OF-SELECTION.
      IF t_itab1[] IS NOT INITIAL.
        IF topc IS NOT INITIAL.
          PERFORM download.
          MESSAGE 'Data Download Completed' TYPE 'S'.
        ENDIF.
        PERFORM display.
      ELSE.
        MESSAGE 'No Records Found' TYPE 'I'.
      ENDIF.
    *                           Top Of Page Event                          *
    TOP-OF-PAGE.
    *& Form           :      select_data
    * Description     : Fetching all the data into the internal tables
    *  parameters    :  none
    FORM select_data .
      SELECT vbeln
         posnr
         werks
         lgort
         INTO CORRESPONDING  FIELDS OF TABLE t_itab1
         FROM vbap
         WHERE  vbeln IN s_vbeln.
      IF sy-subrc <> 0.
        MESSAGE 'Enter The Valid Sales Document Number'(t04) TYPE 'I'.
        EXIT.
      ENDIF.
    ENDFORM.                    " select_data
    *& Form        : display
    *  decription  : to display data in given format
    * parameters   :  none
    FORM display .
      IF alv_list = 'X'.
        PERFORM build_fieldcat TABLES i_fieldcat[]
                               USING :
    *-Output-field Table      Len  Ref fld Ref tab Heading    Col_pos
       'VBELN'       'T_ITAB1'     10   'VBAP'  'VBELN'    ''            1,
       'POSNR'       'T_ITAB1'     6    'VBAP'  'POSNR'    ''            2,
       'WERKS'       'T_ITAB1'     4    'VBAP'  'WERKS'    ''            3,
       'LGORT'       'T_ITAB1'     4    'VBAP'  'LGORT'    ''            4.
        *CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'*
          *EXPORTING*
            *i_callback_program       = sy-repid*
    **        i_callback_pf_status_set = c_pf_status*
            *i_callback_user_command  = 'USER_COMMAND '*
    **        it_events                = t_alv_events[]*
            *it_fieldcat              = i_fieldcat[]*
          *TABLES*
            *t_outtab                 = t_itab1[]*
          *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.
      IF alv_grid = 'X'.
        PERFORM build_fieldcat TABLES i_fieldcat[]
                                 USING :
    *-Output-field Table      Len  Ref fld Ref tab Heading    Col_pos
         'VBELN'       'T_ITAB1'     10   'VBAP'  'VBELN'    ''            1,
         'POSNR'       'T_ITAB1'     6    'VBAP'  'POSNR'    ''            2,
         'WERKS'       'T_ITAB1'     4    'VBAP'  'WERKS'    ''            3,
         'LGORT'       'T_ITAB1'     4    'VBAP'  'LGORT'    ''            4.
        *CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'*
          *EXPORTING*
            *i_callback_program       = sy-repid*
    **        i_callback_pf_status_set = c_pf_status*
            *i_callback_user_command  = 'USER_COMMAND '*
            *it_fieldcat              = i_fieldcat*
          *TABLES*
            *t_outtab                 = t_itab1[]*
        *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.                    " display
    *& Form        : vbeln_validate
    *  description : to validate sales document number
    * parameters   :  none
    FORM vbeln_validate .
      DATA: l_vbeln TYPE vbak-vbeln.
      SELECT SINGLE vbeln
        FROM vbak
        INTO l_vbeln
        WHERE vbeln IN s_vbeln.
      IF sy-subrc NE 0.
        MESSAGE 'ENTER THE VALID SALES DOCUMENT NO:' TYPE 'I'.
        EXIT.
      ENDIF.
    ENDFORM.                    " vbeln_validate
    *& Form       :build_fieldcat
    * Description : This routine fills field-catalogue
    *  Prameters  : none
    FORM build_fieldcat TABLES  fpt_fieldcat TYPE slis_t_fieldcat_alv
                        USING   fp_field     TYPE slis_fieldname
                                fp_table     TYPE slis_tabname
                                fp_length    TYPE dd03p-outputlen
                                fp_ref_tab   TYPE dd03p-tabname
                                fp_ref_fld   TYPE dd03p-fieldname
                                fp_seltext   TYPE dd03p-scrtext_l
                                fp_col_pos   TYPE sy-cucol.
    *-- Local data declaration
      DATA:   wl_fieldcat TYPE slis_fieldcat_alv.
    *-- Clear WorkArea
      wl_fieldcat-fieldname       = fp_field.
      wl_fieldcat-tabname         = fp_table.
      wl_fieldcat-outputlen       = fp_length.
      wl_fieldcat-ref_tabname     = fp_ref_tab.
      wl_fieldcat-ref_fieldname   = fp_ref_fld.
      wl_fieldcat-seltext_l       = fp_seltext.
      wl_fieldcat-col_pos         = fp_col_pos.
    *-- Update Field Catalog Table
      APPEND wl_fieldcat  TO  fpt_fieldcat.
    ENDFORM.                    "build_fieldcat
    *& Form        : download
    *  description : To Download The Data
    *  Parameters  :  none
    FORM download .
      DATA: l_file TYPE string.
      l_file = p_file.
      CALL FUNCTION 'GUI_DOWNLOAD'
        EXPORTING
          filename                = l_file
          filetype                = 'ASC'
        TABLES
          data_tab                = t_itab1
        EXCEPTIONS
          file_write_error        = 1
          no_batch                = 2
          gui_refuse_filetransfer = 3
          invalid_type            = 4
          no_authority            = 5
          unknown_error           = 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.                    " download
    HOPE IT WILL HELP YOU
    REGARDS
    RAHUL SHARMA

  • Formatting in ALV report

    Hi All,
    I wanted to do the formatting in ALV report output. How I can do that?
    Formatting means colour the field, & all.
    If possible send me any sample code..
    Regards,
    Poonam

    hi
    Coloring a row is a bit (really a bit) more complicated. To enable row coloring, you should add an additional field to your list data table. It should be of character type and length at least 4. This field will contain the color code for the row. So, let’s modify declaration of our list data table “gt_list”.
    Code Part 13 – Adding the field that will contain row color data
    As you guess, you should fill the color code to this field. Its format will be the same as explained before at section C.6.3. But how will ALV Grid know that you have loaded the color data for the row to this field. So, you make it know this by 1/0: intensifiedon/off - - 1/0: inverseon/off
    Color numbers
    Internal table holding list data
    DATA BEGIN OF gt_list OCCURS 0 .
    INCLUDE STRUCTURE SFLIGHT .
    DATA rowcolor(4) TYPE c .
    DATA END OF gt_list .
    Passing the name of the field containing color codes to the field “INFO_FNAME” of the layout structure.
    e.g. ps_layout-info_fname = <field_name_containing_color_codes>. “e.g. ‘ROWCOLOR’
    You can fill that field anytime during execution. But, of course, due to the flow logic of screens, it will be reflected to your list display as soon as an ALV refresh occurs. You can color an entire row as described in the next section. However, this method is less time consuming.
    Here is a sample program.
    report zrich_0002 .
    Use of colours in ALV grid (cell, line and column)            *
    Table
    tables : mara.
    Type
    types : begin of ty_mara,
              matnr         like mara-matnr,
              matkl         like mara-matkl,
              counter(4)    type n,
              free_text(15) type c,
              color_line(4) type c,           " Line color
              color_cell    type lvc_t_scol,  " Cell color
    end of ty_mara.
    Structures
    data  : wa_mara     type ty_mara,
            wa_fieldcat type lvc_s_fcat,
            is_layout   type lvc_s_layo,
            wa_color    type lvc_s_scol.
    Internal table
    data : it_mara     type standard table of ty_mara,
           it_fieldcat type standard table of lvc_s_fcat,
           it_color    type table          of lvc_s_scol.
    Variables
    data : okcode like sy-ucomm,
           w_alv_grid          type ref to cl_gui_alv_grid,
           w_docking_container type ref to cl_gui_docking_container.
    parameters : p_column as checkbox,
                 p_line   as checkbox,
                 p_cell   as checkbox.
    at selection-screen output.
      perform get_data.
      perform fill_catalog.
      if w_docking_container is initial.
        perform create_objects.
      endif.
    *&      Form  create_objects
    form create_objects.
      create object w_docking_container
        exporting
          ratio                       = 60
        exceptions
          cntl_error                  = 1
          cntl_system_error           = 2
          create_error                = 3
          lifetime_error              = 4
          lifetime_dynpro_dynpro_link = 5
          others                      = 6.
      create object w_alv_grid
        exporting
          i_parent          = w_docking_container.
    Field that identify color line in internal table
      move 'COLOR_LINE' to is_layout-info_fname.
    Field that identify cell color in inetrnal table
      move 'COLOR_CELL' to is_layout-ctab_fname.
      call method w_alv_grid->set_table_for_first_display
        exporting
          is_layout                     = is_layout
        changing
          it_outtab                     = it_mara
          it_fieldcatalog               = it_fieldcat
        exceptions
          invalid_parameter_combination = 1
          program_error                 = 2
          too_many_lines                = 3
          others                        = 4.
    endform.
    *&      Form  get_data
    form get_data.
      select * from mara up to 5 rows.
        clear : wa_mara-color_line, wa_mara-color_cell.
        move-corresponding mara to wa_mara.
        add 1                   to wa_mara-counter.
        move 'Blabla'           to wa_mara-free_text.
        if wa_mara-counter = '0002'
        and p_line = 'X'.
    Color line
          move 'C410' to wa_mara-color_line.
        elseif wa_mara-counter = '0004'
        and p_cell = 'X'.
    Color cell
          move 'FREE_TEXT' to wa_color-fname.
          move '6'         to wa_color-color-col.
          move '1'         to wa_color-color-int.
          move '1'         to wa_color-color-inv.
          append wa_color to it_color.
          wa_mara-color_cell[] = it_color[].
        endif.
        append wa_mara to it_mara.
      endselect.
    endform.
    *&      Form  fill_catalog
    form fill_catalog.
    Colour code :                                                 *
    Colour is a 4-char field where :                              *
                 - 1st char = C (color property)                  *
                 - 2nd char = color code (from 0 to 7)            *
                                     0 = background color         *
                                     1 = blue                     *
                                     2 = gray                     *
                                     3 = yellow                   *
                                     4 = blue/gray                *
                                     5 = green                    *
                                     6 = red                      *
                                     7 = orange                   *
                 - 3rd char = intensified (0=off, 1=on)           *
                 - 4th char = inverse display (0=off, 1=on)       *
    Colour overwriting priority :                                 *
      1. Line                                                     *
      2. Cell                                                     *
      3. Column                                                   *
      data : w_position type i value '1'.
      clear wa_fieldcat.
      move w_position to wa_fieldcat-col_pos.
      move 'MATNR'    to wa_fieldcat-fieldname.
      move 'MARA'     to wa_fieldcat-ref_table.
      move 'MATNR'    to wa_fieldcat-ref_field.
      append wa_fieldcat to it_fieldcat.
      add 1 to w_position.
      clear wa_fieldcat.
      move w_position to wa_fieldcat-col_pos.
      move 'MATKL'    to wa_fieldcat-fieldname.
      move 'MARA'     to wa_fieldcat-ref_table.
      move 'MATKL'    to wa_fieldcat-ref_field.
    Color column
      if p_column = 'X'.
        move 'C610'     to wa_fieldcat-emphasize.
      endif.
      append wa_fieldcat to it_fieldcat.
      add 1 to w_position.
      clear wa_fieldcat.
      move w_position to wa_fieldcat-col_pos.
      move 'COUNTER'  to wa_fieldcat-fieldname.
      move 'N'        to wa_fieldcat-inttype.
      move '4'        to wa_fieldcat-intlen.
      move 'Counter'  to wa_fieldcat-coltext.
      append wa_fieldcat to it_fieldcat.
      add 1 to w_position.
      clear wa_fieldcat.
      move w_position  to wa_fieldcat-col_pos.
      move 'FREE_TEXT' to wa_fieldcat-fieldname.
      move 'C'         to wa_fieldcat-inttype.
      move '20'        to wa_fieldcat-intlen.
      move 'Text'      to wa_fieldcat-coltext.
      append wa_fieldcat to it_fieldcat.
    endform.
    Copy and paste this program, click a checkbox from the right and click execute. The program will color the line, column, or cell.
    chk this 4 more info...
    Re: add color in alv need help
    regards
    Satish

  • Re: Display format in ALV report

    Hi Expert,
    I have develop an alv report with some like lifnr,name1,dmbtr,budat,zterm, But my requiremnt is output should come in
    the below format like
    vendor number   vendor name   payment tern     jan          feb                mar            april       ...................... upto december.
                                                                               no  value   no  value     no value    no value ..................
    Abouce is my report format below jan i have two fields  no and value for  i have written code output is comming in alv but it
    is not commig in the above format
    My code is
    TYPE-POOLS: SLIS.
    TABLES: LFA1,BSAK,BSIK.
    TYPES: BEGIN OF TY_LFA1,
           LIFNR TYPE LFA1-LIFNR,   "VENDOR NUMBER
           NAME1 TYPE LFA1-NAME1,   "VENDOR NAME
           END OF TY_LFA1.
    TYPES: BEGIN OF TY_BSIK,
           LIFNR TYPE BSIK-LIFNR,    "VENDOR NUMBER
           DMBTR TYPE BSIK-DMBTR,    "AMOUNT IN  LOCAL CURRENCY
          WMWST TYPE BSIK-WMWST,    "TAX AMOUNT IN DOCUMENT CURRENCY
           BUDAT TYPE BSIK-BUDAT,    "POSTING DATE
           ZTERM TYPE BSIK-ZTERM,    "TERM OF PAYMENT
           END OF TY_BSIK.
    TYPES: BEGIN OF TY_OUTPUT,
            LIFNR TYPE LFA1-LIFNR,
            NAME1 TYPE LFA1-NAME1,
            DMBTR TYPE BSIK-DMBTR,
            BUDAT TYPE BSIK-BUDAT,
            ZTERM TYPE BSIK-ZTERM,
            NEW TYPE SY-DATUM,
            END OF TY_OUTPUT.
    SELECT T1~LIFNR
           T1~NAME1
           T2~DMBTR
           T2~BUDAT
           T2~ZTERM
              INTO TABLE GT_OUTPUT FROM LFA1 AS T1 INNER JOIN BSIK AS T2
               ON T1LIFNR = T2LIFNR
               WHERE T1~LIFNR IN S_LIFNR
               AND T2~BUDAT IN S_BUDAT
               AND ZTERM NE ' '.
    and then i have use alv function module REUSE_ALV_GRID_DISPLAY..........................
    How to display the report in the above format
    can any one throw some light in this..............
    Regards,
    Addu

    Dear Koolspy,
    You are correct i have check in the table BSIK their is one field called SHKZG for credit and debt please can you let me know how to wrtie this in my code my main logic is below.
    SELECT T1~LIFNR
           T1~NAME1
           T2~DMBTR
           T2~BUDAT
           T2~ZTERM
            INTO TABLE GT_OUTPUT FROM LFA1 AS T1 INNER JOIN BSIK AS T2
               ON T1LIFNR = T2LIFNR
               WHERE T1~LIFNR IN S_LIFNR
               AND T2~BUDAT IN S_BUDAT
               AND ZTERM NE ' '.
       LOOP AT GT_OUTPUT INTO WT_OUTPUT.
       WT_FINAL-LIFNR = WT_OUTPUT-LIFNR.
       WT_FINAL-NAME1 = WT_OUTPUT-NAME1.
       WT_FINAL-DMBTR = WT_OUTPUT-DMBTR.           "Amount
       WT_FINAL-NEW   = WT_OUTPUT-BUDAT+4(2).      "posting date
       WT_FINAL-ZTERM = WT_OUTPUT-ZTERM.
        APPEND WT_FINAL TO IT_FINAL.
        CLEAR WT_FINAL.
        ENDLOOP.
    LOOP AT IT_FINAL INTO WT_FINAL.
    COLLECT WT_FINAL INTO GT_OUTPUT5.
    ENDLOOP.
    LOOP AT GT_OUTPUT5 INTO WT_OUTPUT5.
      WT_OUTPUT2-LIFNR = WT_OUTPUT5-LIFNR.
      WT_OUTPUT2-NAME1 = WT_OUTPUT5-NAME1.
    WT_OUTPUT2-DMBTR = WT_OUTPUT5-DMBTR.
    WT_OUTPUT2-NEW   = WT_OUTPUT5-NEW.
      WT_OUTPUT2-ZTERM = WT_OUTPUT5-ZTERM.
      IF WT_OUTPUT5-NEW = '01'.                                "2
      MOVE WT_OUTPUT5-DMBTR TO WT_OUTPUT2-JAN.
                     "2
      ELSEIF WT_OUTPUT5-NEW = '02'.
        MOVE WT_OUTPUT5-DMBTR TO WT_OUTPUT2-FEB.
        ELSEIF WT_OUTPUT5-NEW = '03'.
         MOVE WT_OUTPUT5-DMBTR TO WT_OUTPUT2-MAR.
          ELSEIF WT_OUTPUT5-NEW = '04'.
            MOVE WT_OUTPUT5-DMBTR TO WT_OUTPUT2-APR.
          ELSEIF WT_OUTPUT5-NEW = '05'.
             MOVE WT_OUTPUT5-DMBTR TO WT_OUTPUT2-MAY.
          ELSEIF WT_OUTPUT5-NEW = '06'.
             MOVE WT_OUTPUT5-DMBTR TO WT_OUTPUT2-JUN.
          ELSEIF WT_OUTPUT5-NEW = '07'.
             MOVE WT_OUTPUT5-DMBTR TO WT_OUTPUT2-JUL.
           ELSEIF WT_OUTPUT5-NEW = '08'.
             MOVE WT_OUTPUT5-DMBTR TO WT_OUTPUT2-AUG.                  "5
             ELSEIF WT_OUTPUT5-NEW = '09'.                             "
               MOVE WT_OUTPUT5-DMBTR TO WT_OUTPUT2-SEP.
                ELSEIF WT_OUTPUT5-NEW = '10'.
                  MOVE WT_OUTPUT5-DMBTR TO WT_OUTPUT2-OCT.
                ELSEIF WT_OUTPUT5-NEW = '11'.
                  MOVE WT_OUTPUT5-DMBTR TO WT_OUTPUT2-NOV.
                  ELSEIF WT_OUTPUT5-NEW = '12'.
                    MOVE WT_OUTPUT5-DMBTR TO WT_OUTPUT2-DEC.
                 MODIFY GT_OUTPUT2 FROM  WT_OUTPUT2.
        ENDIF.
    APPEND WT_OUTPUT2 TO GT_OUTPUT2.
    collect WT_OUTPUT2 inTO GT_OUTPUT2.
    COLLECT WT_FINAL INTO GT_OUTPUT5.
    clear : wt_output2.
      ENDLOOP.
    Please let me know where to insert that SHKZG field.
    Regards,
    Am

  • Display concatenad fields under one column in alv.

    How can I concatenate three or four fields(Taken from different tables) and can display under one column in ALV report?
    I want to display:
    final_column = production orderStatusmaterial type+maintenance status (concatenation of four fields).
    production order: caufvd-aufnr
    status: tj02t-txt04
    material type: mara-mtart
    maintenance status:mara-pstat
    I want to display only final_column in my alv output screen.
    Kindly guide.
    Thanks and regards.
    Thanks and regards.
    Message was edited by:
            cinthia nazneen

    Please  go through the below   code and  do the same   for appearing  the   four fields  of different table into  One Field catalog at   Display  by Concatenating .
    DATA  :v_tmp  type  string .
    Loop at  itab1.
    Read table  itab2  key field1 = itab1-field1 .
    Read table  itab3  key field1 = itab1-field1 .
    Read table  itab4  key field1 = itab1-field1 .
    Concatenate  itab1-field1 itab2-field1 itab3-field1 itab4-field1 into v_tmp.
      fieldcatalog-fieldname   = 'V_TMP'.
      fieldcatalog-seltext_m   = 'Item change date'.
      fieldcatalog-col_pos     = 1.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
    endloop.
    Reward points if it is usefull .....
    Girish

  • Reg displaying a Field as Drop Down in ALV Grid Display

    Hi All,
    I have developed an ALV report program with one editable field using FM "REUSE_ALV_GRID_DISPLAY_LVC". My requirement is to make that editable field as dropdown box so that user can choose from the options. If i press SAVE all those will gets saved in a Ztable. Everything is working fine. But no values are getting populated in dropdown box.
    Kindly do the needful.
    Thanks in advance.

    Hi,
    Check out follwing subroutines in below programs.
    perform build_fieldcat changing pt_fieldcat.
    perform set_drdn_table.
    BCALV_EDIT_06
    BCALV_EDIT_07

  • Date format in ALV report

    Hi all,
    I want to change date format in ALV list that is displayed in wrong format.
    I use this piece of code:
    CALL METHOD r_alv_grid->set_table_for_first_display
        EXPORTING
          i_structure_name = 'ZSTANJEKOMISIONARA'
          is_layout        = gs_layout
        CHANGING
          it_outtab        = it_stanja
        EXCEPTIONS
          OTHERS           = 4.
    Problematic field of structure ZSTANJEKOMISIONARA is defined like this:
    VRIJEDI_DO     ZEVO_VRIJEDI_DO     DATS     8
    Now, date is displayed like this: 09.20.3009 insted it should be like this: 30.09.2009.
    How can I change this? Thanks.

    The data is internally stored in an external format. Go back to the program that filled this field, there is something missing there.
    Look at FM like
    - CONVERT_DATE_TO_INTERN_FORMAT
    - CONVERSION_EXIT_PDATE_INPUT
    You only keep date in external format when filling a BDC, for most other input mode (BAPI and the like) data must be converted to internal format.
    Regards,
    Raymond

  • Display two heading in single column using ALV report

    Hi Experts,
    I got a requirement for displaying 2 rows heading in a single column report. Is it possible that I can perform this task using ALV. How to get this 2 rows in ALV.
    This is a criteria that need to be output in ALV REPORT.
    MATERIAL CODE--MATERIAL NUMBERSTORAGE LOC----SLOC1     SLOC2
    --DATE--DATE1      DATE2
    123445--TEST MATERIAL22--
    3
    As mentioned above storage loc and date will be changing with respect to data dynamically and under this double heading qty will be displayed.
    Just want to know how to get double heading. It is clear that how to display dynamically but unaware of double heading using fieldcatalog.
    Regards,
    Yahya

    Hi Yahya,
    Please pass row position in fieldcatalogue for the respective columns.
    E.g  MOVE '2' to w_fieldcat-row_pos.  " This will display the field in 2nd row.
    Thanks,
    Rupali

  • Hyperlink Field in column of 2D ALV Report

    Hi,
    I have to display a ALV Report in which one of column reprsent a field which have hyperlink.
    How to acheive this?Can anybody tell me approach?
    -Rick

    Hi Ricky,
    Kindly go through the link below:
    http://help.sap.com/saphelp_erp2004/helpdata/EN/85/ce25c2d7ae11d3b56d006094192fe3/content.htm
    Hope it helps you
    Regrds
    Mansi

  • Regarding Conversion of the Charecter field Into Lowercase in an ALV REPORT

    HI ALL,
    I have created an editable alv Report. In which i have a coloumn with charecter field where i can enter 64 charecters. when ever i have enter and moved to another Tab its converting into Capital Letters. I need to stop it conversion. Can any one suggest me Regarding It. I am Using the Docking Container and method set_table_for_first_display for displaying the Grid.
    Please give some suggestion in order to control conversion of charecters.
    Thanks in Advance.
    Naresh

    What Kind of Dataelement/Domain you are using? CHAR60? Then try TEXT60 f.e.
    Maybe you check this out
    http://help.sap.com/saphelp_erp2005/helpdata/DE/bf/3bd1369f2d280ee10000009b38f889/frameset.htm
    and there the FC option lowercase..
    Edited by: Mathias Maerker on Apr 23, 2009 2:14 PM

  • How to change date format in alv report

    hi ,
    i wanna change date format which is in yyyy.mm.dd to mm/dd/yyyy in alv report.
    plz advise.
    thanks
    sudheer

    Hi sudheer,
    There is no direst Fm fro that.
    But u can follw the below way. it worked for me. kindly chk it.
    [code]DATA: V_DATE_IN(10) TYPE C,
    V_DATE_SAP TYPE SY-DATUM.
    V_DATE_IN = '01.01.2005.'.
    CONCATENATE V_DATE_IN+6(4) "<--for Year
    V_DATE_IN+3(2) "<--for month
    V_DATE_IN+0(2) "<--for Day
    INTO V_DATE_SAP.
    now V_DATE_SAP will have value like 20060101.
    now use.
    CONVERSION_EXIT_PDATE_OUTPUT Conversion Exit for Domain GBDAT: YYYYMMDD -> DD/MM/YYYY[/code]
    regards
    anver
    <b><i>if hlped pls mark points</i></b>

  • Output field length issue in OO ALV

    Hello Experts,
    I have an requirement to download ALV grid output into Excel but some of columns having more than 128 characters, as per standard SAP will not support so I have included one more button and I have written the below code.
      field-symbols: <fs_table> type standard table,
                     <fs_wa>.
    * Get the current fields of the layout
      CALL METHOD ALV_GRID->GET_FRONTEND_FIELDCATALOG
        IMPORTING
          ET_FIELDCATALOG = it_fcat.
    * Generate dynamic internal table
      CALL METHOD CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE
        EXPORTING
          IT_FIELDCATALOG           = it_fcatn
        IMPORTING
          EP_TABLE                  = dyn_table
      assign dyn_table->* to <fs_table>.
      create data dyn_line like line of <fs_table>.
      assign dyn_line->* to <fs_wa>.
    loop at lt_final into ls_final.
        if ls_final-EBELP is not INITIAL.
          CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
            EXPORTING
              INPUT  = ls_final-EBELP
            IMPORTING
              OUTPUT = ls_final-EBELP.
        endif.
        MOVE-CORRESPONDING ls_final to <fs_wa>.
        append <fs_wa> to <fs_table>.
      endloop.
      CALL FUNCTION 'GUI_DOWNLOAD'
        EXPORTING
          FILENAME                = FULLPATH
          FILETYPE                = 'DAT'
          WRITE_FIELD_SEPARATOR   = 'X'
          CONFIRM_OVERWRITE       = 'X'
        TABLES
          DATA_TAB                = <fs_table>
          FIELDNAMES              = LT_HEADING
    Now my problem is some of field output value getting truncated(in excel) but it displayed in Grid output.
    eg.
    lt_final having one text field(Doc. Type description) and the length is 20, actually printing 17 characters but we are not defining the output length.
    Can you please anyone faced the problem earlier? Basically the SAP version is R/3 4.7.
    Regards,
    Vadamalai A

    Hello All,
    Before calling CALL METHOD CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE
    we can define the length
      WHEN 'BATXT'.       wa_fcatn-OUTPUTLEN =
    20.
    Regards,
    Vadamalai A.
    We can close this thread.

  • ALV: How to display amount respective to currency format in ALV?

    Hi All,
    Normally in ALV, to display the amount respective to its currency, we just simply pass the currency field(coming from the t_outtab  of FM REUSE_ALV_GRID_DISPLAY) to CFIELDNAMEof ALV field catalog.
    For ordinary currencies with 2 decimal places, like USD, etc, it will work fine.
    But for currencies like KWD and IDR, their decimal place is always 3 via SAP standard definition in transaction OY04.
    Given this, ALV field catalog CFIELDNAME cannot handle as such automatic formatting.
    Is there any other way without using the code below?
    WRITE <amount_field_name> CURRENCY <currency_field_name>.
    Thanks.

    Answer:
    'WAERK' to w_alv_fcat-cfieldname,

  • Regarding Date format in ALV Report

    Dear All,
                  In ALV Reoport I have inserted Field BSTDK table VBKD by comparing vbeln my Date is getting displayed, but Problem is that  i want my date in this format for ex: 29.10.2008 but it is diaplaying as 20081029. this is an ex. same is repeating for all the dates against respective vbeln. 
    code as follows.
    LOOP AT GT_OUT1.
       SELECT SINGLE BSTDK INTO GT_OUT1-BSTDK
             FROM VBKD WHERE VBELN = GT_OUT1-AUBEL.
         MODIFY GT_OUT1.
    ENDLOOP.

    Moderator message - Please see How to post code in SCN, and some things NOT to do... before posting (date question) - post locked
    Rob

  • How to display values in top of page in ALV report

    Hai,
      This is my billing report program, i developed that object by using ALV but i could not able to use Top-of-page. please any one correct my code,
    *& Report  ZE0232_ALV_BILLING                                          *
    report  ze0232_alv_billing.
    type-pools: slis.
    data: repid like sy-repid.
    data: fieldcatalog type slis_t_fieldcat_alv,
          wa_fieldcatalog type slis_fieldcat_alv.
    data : ievent type slis_t_event,
    wevent type slis_alv_event.
    data: sal_text like tvkot-vtext,
          DIS_TEXT LIKE TVTWT-VTEXT,
          DIV_TEXT LIKE TSPAT-VTEXT.
    tables: vbrk.
    data: begin of i_vbrk occurs 0,
          vbeln like vbrk-vbeln,
          fkdat like vbrk-fkdat,
          erdat like vbrk-erdat,
          kunrg like vbrk-kunrg,
          name1 like kna1-name1,
          netwr like vbrk-netwr,
          stext like tvkot-vtext,
          dtext like tvtwt-vtext,
          divtext like tspat-vtext,
          end of i_vbrk.
    selection-screen begin of block billing with frame.
    parameters: salesorg like vbrk-vkorg.
    select-options: dischanl for vbrk-vtweg,
                    division for vbrk-spart,
                    bildat for vbrk-fkdat.
    selection-screen end of block billing.
    select vbeln fkdat erdat kunrg netwr from vbrk into corresponding fields of table i_vbrk where vkorg = salesorg
                                                                                    and vtweg in dischanl
                                                                                    and spart in division
                                                                                    and fkdat in bildat.
    select vtext from tvkot into sal_text where vkorg = salesorg and spras = 'EN'.
    endselect.
    select vtext from TVTWT into DIS_text where VTWEG IN dischanl and spras = 'EN'.
    endselect.
    select vtext from TSPAT into DIV_text where SPART IN DIVISION and spras = 'EN'.
    endselect.
    loop at i_vbrk.
      move: sal_text to i_vbrk-stext,
            DIS_TEXT TO I_VBRK-DTEXT,
            DIV_TEXT TO I_VBRK-DIVTEXT.
      modify i_vbrk.
    endloop.
    perform get_fieldcatalog.
    call function 'REUSE_ALV_GRID_DISPLAY'
    exporting
        i_callback_program                = repid
      I_GRID_TITLE                      =
        i_callback_top_of_page            = 'TOPS'
        it_fieldcat                       = fieldcatalog
      tables
        t_outtab                          = i_vbrk
    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  GET_FIELDCATALOG
          text
    <b>form tops.
      write :/ 'Hai Welcome'.
    endform.                    "tops</b>&----
    *&      Form  get_fieldcatalog
          text
    form get_fieldcatalog.
      wa_fieldcatalog-col_pos = '1'.
      wa_fieldcatalog-fieldname = 'VBELN'.
      wa_fieldcatalog-tabname   = 'I_VBAK'.
      wa_fieldcatalog-seltext_m = 'SALES DOCUMENT'.
    WA_fieldcatalog-rollname  = 'VBELN'.
      wa_fieldcatalog-hotspot   = 'X'.
      append wa_fieldcatalog to fieldcatalog.
      clear wa_fieldcatalog.
      wa_fieldcatalog-col_pos = '2'.
      wa_fieldcatalog-fieldname = 'FKDAT'.
      wa_fieldcatalog-tabname   = 'I_VBAK'.
      wa_fieldcatalog-seltext_m = 'BILL DATE'.
    WA_fieldcatalog-rollname  = 'VBELN'.
    WA_fieldcatalog-hotspot   = 'X'.
      append wa_fieldcatalog to fieldcatalog.
      clear wa_fieldcatalog.
      wa_fieldcatalog-col_pos = '3'.
      wa_fieldcatalog-fieldname = 'ERDAT'.
      wa_fieldcatalog-tabname   = 'I_VBAK'.
      wa_fieldcatalog-seltext_m = 'CREATED DATE'.
      append wa_fieldcatalog to fieldcatalog.
      clear wa_fieldcatalog.
      wa_fieldcatalog-col_pos = '4'.
      wa_fieldcatalog-fieldname = 'KUNRG'.
      wa_fieldcatalog-tabname   = 'I_VBAK'.
      wa_fieldcatalog-seltext_m = 'CUSTOMER NO'.
      append wa_fieldcatalog to fieldcatalog.
      clear wa_fieldcatalog.
      wa_fieldcatalog-col_pos = '5'.
      wa_fieldcatalog-fieldname = 'NAME1'.
      wa_fieldcatalog-tabname   = 'I_VBAK'.
      wa_fieldcatalog-seltext_m = 'CUSTOMER NAME'.
      append wa_fieldcatalog to fieldcatalog.
      clear wa_fieldcatalog.
      wa_fieldcatalog-col_pos = '6'.
      wa_fieldcatalog-fieldname = 'NETWR'.
      wa_fieldcatalog-tabname   = 'I_VBAK'.
      wa_fieldcatalog-seltext_m = 'NET VALUE'.
      append wa_fieldcatalog to fieldcatalog.
      clear wa_fieldcatalog.
      wa_fieldcatalog-col_pos = '7'.
      wa_fieldcatalog-fieldname = 'STEXT'.
      wa_fieldcatalog-tabname   = 'I_VBAK'.
      wa_fieldcatalog-seltext_m = 'SALES ORG'.
      append wa_fieldcatalog to fieldcatalog.
      clear wa_fieldcatalog.
      wa_fieldcatalog-col_pos = '8'.
      wa_fieldcatalog-fieldname = 'DTEXT'.
      wa_fieldcatalog-tabname   = 'I_VBAK'.
      wa_fieldcatalog-seltext_m = 'DIS.CHANNEL'.
      append wa_fieldcatalog to fieldcatalog.
      clear wa_fieldcatalog.
      wa_fieldcatalog-col_pos = '9'.
      wa_fieldcatalog-fieldname = 'DIVTEXT'.
      wa_fieldcatalog-tabname   = 'I_VBAK'.
      wa_fieldcatalog-seltext_m = 'DIVISION'.
      append wa_fieldcatalog to fieldcatalog.
      clear wa_fieldcatalog.
    endform.                    "GET_FIELDCATALOG

    HI see this report
    you can know how to write TOP-OF_PAGE code
    and insert LOGO also
    *& Report  ZTEST_ALV_LOGO
    REPORT  ztest_alv_logo.
    TYPE-POOLS : slis.
    *ALV Formatting tables /structures
    DATA: gt_fieldcat TYPE slis_t_fieldcat_alv.
    DATA: gt_events   TYPE slis_t_event.
    DATA: gs_layout   TYPE slis_layout_alv.
    DATA: gt_page     TYPE slis_t_listheader.
    DATA: gs_page     TYPE slis_listheader.
    DATA: v_repid     LIKE sy-repid.
    *ALV Formatting work area
    DATA: w_fieldcat TYPE slis_fieldcat_alv.
    DATA: w_events   TYPE slis_alv_event.
    DATA: gt_bsid TYPE TABLE OF bsid WITH HEADER LINE.
    INITIALIZATION.
      PERFORM build_events.
      PERFORM build_page_header.
    START-OF-SELECTION.
    *perform build_comment.     "top_of_page - in initialization at present
      SELECT * FROM bsid INTO TABLE gt_bsid UP TO 10 ROWS.
    *perform populate_for_fm using '1' '3' 'BUKRS' '8' 'GT_BSID' 'Whee'.
    *USING = Row, Column, Field name, display length, table name, heading
    *OR
      PERFORM build_fieldcat.
      gs_layout-zebra = 'X'.
    *top of page event does not work without I_callback_program
      v_repid = sy-repid.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          i_callback_program                = v_repid
          i_structure_name                  = 'BSID'
       i_background_id                   = 'ALV_BACKGROUND'
          i_grid_title                      = 'This is the grid title'
      I_GRID_SETTINGS                   =
          is_layout                         = gs_layout
          it_fieldcat                       = gt_fieldcat[]
          it_events                         = gt_events[]
        TABLES
          t_outtab                          = gt_bsid.
    Form..............:  populate_for_fm
    Description.......:  Populates fields for function module used in ALV
    FORM populate_for_fm USING p_row
                               p_col
                               p_fieldname
                               p_len
                               p_table
                               p_desc.
      w_fieldcat-row_pos      = p_row.          "Row Position
      w_fieldcat-col_pos      = p_col.          "Column Position
      w_fieldcat-fieldname    = p_fieldname.    "Field name
      w_fieldcat-outputlen    = p_len.          "Column Lenth
      w_fieldcat-tabname      = p_table.        "Table name
      w_fieldcat-reptext_ddic = p_desc.         "Field Description
      w_fieldcat-input        = '1'.
      APPEND w_fieldcat TO gt_fieldcat.
      CLEAR w_fieldcat.
    ENDFORM.                    " populate_for_fm
    *&      Form  build_events
    FORM build_events.
      DATA: ls_event TYPE slis_alv_event.
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
        EXPORTING
          i_list_type = 0
        IMPORTING
          et_events   = gt_events.
      READ TABLE gt_events
                 WITH KEY name =  slis_ev_user_command
                 INTO ls_event.
      IF sy-subrc = 0.
        MOVE slis_ev_user_command TO ls_event-form.
        APPEND ls_event TO gt_events.
      ENDIF.
      READ TABLE gt_events
                 WITH KEY name =  slis_ev_top_of_page
                 INTO ls_event.
      IF sy-subrc = 0.
        MOVE slis_ev_top_of_page TO ls_event-form.
        APPEND ls_event TO gt_events.
      ENDIF.
    ENDFORM.                    " build_events
    *&      Form  USER_COMMAND
    When user command is called it uses 2 parameters. The itab
    passed to the ALV is in whatever order it currently is on screen.
    Therefore, you can read table itab index rs_selfield-tabindex to get
    all data from the table. You can also check r_ucomm and code
    accordingly.
    FORM user_command USING  r_ucomm     LIKE sy-ucomm
                             rs_selfield TYPE slis_selfield.
      READ TABLE gt_bsid INDEX rs_selfield-tabindex.
    error checking etc.
      SET PARAMETER ID 'KUN' FIELD gt_bsid-kunnr.
      CALL TRANSACTION 'XD03' AND SKIP FIRST SCREEN.
    ENDFORM.                    "user_command
    *&      Form  top_of_page
    Your own company logo can go here if it has been saved (OAOR)
    If the logo is larger than the size of the headings in gt_page,
    the window will not show full logo and will have a scroll bar. Thus,
    it is a good idea to have a standard ALV header if you are going to
    use logos in your top of page.
    FORM top_of_page.
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
        EXPORTING
          it_list_commentary = gt_page
          i_logo             = 'ENJOYSAP_LOGO'.
    ENDFORM.                    "top_of_page
    *&      Form  build_fieldcat
    *Many and varied fields are available here. Have a look at documentation
    *for FM REUSE_ALV_LIST_DISPLAY and REUSE_ALV_FIELDCATALOG_MERGE
    FORM build_fieldcat.
      w_fieldcat-fieldname  = 'BUDAT'.
      w_fieldcat-seltext_m  = 'Dte pst'.
      w_fieldcat-ddictxt(1) = 'M'.
      w_fieldcat-edit = 'x'.
    Can change the position of fields if you do not want them in order
    of the DDIC or itab
    w_fieldcat-row_pos = '1'.
    w_fieldcat-col_pos = '10'.
      APPEND w_fieldcat TO gt_fieldcat.
      CLEAR w_fieldcat.
    ENDFORM.                    " build_fieldcat
    *&      Form  build_page_header
          gt_page is used in top of page (ALV subroutine - NOT event)
          *H = Header, S = Selection, A = Action
    FORM build_page_header.
    For Headers, Key is not printed and is irrelevant. Will not cause
    a syntax error, but is not used.
      gs_page-typ  = 'H'.
      gs_page-info = 'Header 1'.
      APPEND gs_page TO gt_page.
      gs_page-typ  = 'H'.
      gs_page-info = 'Header 2'.
      APPEND gs_page TO gt_page.
    For Selections, the Key is printed (bold). It can be anything up to 20
    bytes. It gets printed in order of code here, not by key value.
      gs_page-typ  = 'S'.
      gs_page-key  = 'And the winner is:'.
      gs_page-info = 'Selection 1'.
      APPEND gs_page TO gt_page.
      gs_page-typ  = 'S'.
      gs_page-key  = 'Runner up:'.
      gs_page-info = 'Selection 2'.
      APPEND gs_page TO gt_page.
    For Action, Key is also irrelevant.
      gs_page-typ  = 'A'.
      gs_page-info = 'Action goes here'.
      APPEND gs_page TO gt_page.
    ENDFORM.                    " build_page_header
    <b>Reward if useful</b>

Maybe you are looking for

  • Send Sale Quotation to customer by email

    Can i send out sale quotation to customer by email in B1. Can you help me! Thank you

  • Error in using GUI_DOWNLOAD

    Hi !! I am accessing my Module Pool program in web browser as a .dll file . I am using the function GUI_DOWNLOAD to save internal data in a text file. However  It is working fine in SAP , when i run the program in a web browser it gives me error . Ki

  • How to use many submit buttons in an one html form

    I'm doing a simple program to insert, edit, delete data from a web page to an database but the problem is that in an html form , you are allowed to put only 1 submit button. I heard that you can take the action of many buttons, for a one form using j

  • I can't open a zip file

    I just download the CD and am getting "unable to expand "xxxxxxx.zip" into "Music". (Error 2- No such file or directory). I then tried to open it in StuffIt Expander and it say the archive may be damaged. Could you direct me on how to make this work.

  • Real time scenarios...

    hello ther ....i am simi .. iam new to sdn...i have my interview in sem bps..in a couple of days time..iam through with the theoritical bit ...my concerns are related to the questions that may arise about project scenarios....would be much obliged if