ALV Examples?????

Hi experts,
                 could anyone please tell me about any sap standard alv interactive report, if there are any?
Thanks and Regards,
Ramana

Hi,
i've listed some standard ALV Reports.this may help you
BALVEX02 ALV demo program: Output flights (simplest version)
BALVEXTR Extract management
BALVHD01 Demo program ALV: Hierarchical-sequential list flight model
BALVHD01_GROUP Demo program ALV: Hierarchical-sequential list flight model
BALVHT01 Test program ALV: hierarchical-sequential list flight model
BALVHTMAINTENANCE Report for manipulating HTML templates
BALVHTTRANSLHTMPL ALV: Report for automatic HTML template translation
BALVSD01 Demo program ALV: Simple list flight model
BALVSD02 ALV demo program: Output flights (simplest version)
BALVSD02_GRID Simple ALV grid control call in fullscreen mode
BALVSD02_SAVE Simple ALV call with storage option
BALVSD03 Simple list
BALVSD04 Simple list (merged)
BALVSD06 Demoprogram ALV: Output flights (simple version + save)
BALVSD11 Demo program ALV: Simple list with interactions and variants
BALVST01 Test program ALV: Simple list flight model
BALVST02 Test program ALV: Simple list flight model
BCALV_TEST_BLOCK_LIST Program BCALV_TEST_BLOCK_LIST
BCALV_TEST_COLUMN_TREE Program BCALV_TEST_COLUMN_TREE
BCALV_TEST_EXCEL_DATATYPES FILTER Test Report
BCALV_TEST_FB_CREATE Test Report for Dynamic Generation of Tables
BCALV_TREE_01 ALV tree control: build up the hierarchy tree
BCALV_TREE_02 ALV tree control: event handling

Similar Messages

  • ALV example

    Dear experts,
                        i have just started off with WEB dynpro's for ABAP. i wanted a very basic ALV example to start off with. thanks in advance .

    Hi Girish,
       Welcome to the interesting world of Web Dynpro ABAP !
    For Web dynpro ABAP you will require SAP ECC 6.0 onwards and WAS 7.0
    is a must. It has very good future propspects as this is best UI technology.
    In web dynpro ABAP we follow MVC(Model View Controller) architecture.
    In this object oriented ABAP is used to provide background functionality. Here, your ABAP skills can be utilized to the fullest. Programming in web dynpro ABAP is different than conventional ABAP programming. Here we strictly follow MVC architecture in terms of controller interface. Also there are many wizards available so that we can directly pick the code from wizards.
    e.g We can call BAPI through a service call in web dynpro application. Thus automatically backgroud code for BAPI execution will be generated.
    To start with Web dynpro ABAP you can try following tutorial:
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/a282c952-0801-0010-1eb5-87953e036712
    You can start with tutorials and all. There are around six tutorials in SDN library.
    Web Dynpro for ABAP
    http://help.sap.com/saphelp_erp2005/helpdata/en/a5/1a1e3e7181b60ae10000000a114084/frameset.htm
    best tutorials in wbdynpro for ABAP to start with :
    https://www.sdn.sap.com/irj/sdn/developerareas/webdynpro?rid=/webcontent/uuid/fed073e5-0901-0010-4eb4-c9882aac7b11 [original link is broken]
    Have a look at the following SDN WDA Wiki . There you can find all relevant information.
    https://wiki.sdn.sap.com/wiki/display/WDABAP/Main
    SAP has provided you with ample demo example of WD ABAP already bundled with SAP . Just Try out Components starting with WDR . I can tell you few like WDR_TEST_EVENTS ( It shows how every UI elments to use )
    See packages like SWDP_DEMO , SALV_WD_DEMO
    there are many more .
    /people/marilyn.pratt/blog/2005/12/20/web-dynpro-for-abap
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/a282c952-0801-0010-1eb5-87953e036712
    The specified item was not found.
    Also you can search weblogs on web dynpro ABAP.
    Hope this will help you.
    Cheers,
    Darshna.

  • ALV Example with multiple headers, tree, editable column combined...

    Hello Experts,
    Any examples would be highly appreciated.Thank you and take care!

    Hi,
    Check this thread for ALVs -
    Interactive ALV
    ashish

  • Sap alv examples

    hai
    blow the function modules can u send the some code examples
    Reuse_alv_list_display
    Reuse_alv_fieldcatalog_merge
    Reuse_alv_events_get
    Reuse_alv_commentary_write
    Reuse_alv_grid_display

    Hi
    <b>Reuse_alv_list_display</b>
    type-pools: slis.
    data: fieldcat type slis_t_fieldcat_alv,
    fieldcat_ln like line of fieldcat,
    fs_layout type slis_layout_alv,
    t_layoout like standard table
    of fs_layout.
    data: begin of fs_spfli,
    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,
    airpto type spfli-airpto,
    fltime type spfli-fltime,
    deptime type spfli-deptime,
    arrtime type spfli-arrtime,
    distance type spfli-distance,
    distid type spfli-distid,
    fltype type spfli-fltype,
    period type spfli-period,
    checkbox,
    color(3),
    end of fs_spfli.
    data:
    begin of fs_table,
    carrid type spfli-carrid,
    connid type spfli-connid,
    end of fs_table.
    data: begin of fs_sflight,
    check,
    color(3).
    include type sflight.
    data:end of fs_sflight.
    data:
    begin of fs_table1,
    carrid type sflight-carrid,
    connid type sflight-connid,
    fldate type sflight-fldate,
    end of fs_table1.
    data:
    t_spfli like standard table
    of fs_spfli.
    data:
    t_table like standard table
    of fs_table.
    data:
    t_table1 like standard table
    of fs_table1.
    data:
    t_sflight like standard table
    of fs_sflight.
    data:
    t_sbook like standard table
    of sbook.
    data t_layout type slis_layout_alv.
    select *
    into corresponding fields of table t_spfli
    from spfli.
    perform start_list_viewer.
    perform get_spfli_details.
    *& Form SUB1
    * text
    * -->RT_EXTAB text
    form sub1 using rt_extab type slis_t_extab.
    data: flight type slis_extab.
    flight-fcode = 'SFLIGHT'.
    append flight to rt_extab.
    set pf-status 'SFLIGHT'. " EXCLUDING RT_EXTAB.
    endform. "SUB1
    *& Form START_LIST_VIEWER
    * text
    * --> p1 text
    * <-- p2 text
    form start_list_viewer .
    data: pgm like sy-repid.
    pgm = sy-repid.
    fs_layout-box_fieldname = 'CHECKBOX'.
    fs_layout-info_fieldname = 'COLOR'.
    call function 'REUSE_ALV_LIST_DISPLAY'
    exporting
    i_callback_program = pgm
    i_callback_pf_status_set = 'SUB1'
    i_callback_user_command = 'USER_COMMAND'
    i_structure_name = 'SPFLI'
    is_layout = fs_layout
    tables
    t_outtab = t_spfli
    exceptions
    program_error = 1
    others = 2.
    if sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    * WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    endif.
    endform. " START_LIST_VIEWER
    ********Process Call Back Events (Begin)***************************
    form user_command using ucomm like sy-ucomm
    selfield type slis_selfield.
    case ucomm.
    when 'SFLIGHT'.
    selfield-refresh = 'X'.
    perform get_spfli_details.
    select *
    from sflight
    into corresponding fields of table t_sflight
    for all entries in t_table
    where carrid eq t_table-carrid
    and connid eq t_table-connid.
    perform display_sflight.
    when 'SBOOK'.
    selfield-refresh = 'X'.
    perform get_sflight_details.
    select *
    from sbook
    into corresponding fields of table t_sbook
    for all entries in t_table1
    where carrid eq t_table1-carrid
    and connid eq t_table1-connid
    and fldate eq t_table1-fldate.
    perform display_sbook.
    endcase.
    endform. "USER_COMMAND
    *& Form SUB2
    * text
    * -->RT_EXTAB text
    form sub2 using rt_extab type slis_t_extab.
    data: flight type slis_extab.
    flight-fcode = 'SBOOK'.
    append flight to rt_extab.
    set pf-status 'SBOOK'. " EXCLUDING RT_EXTAB.
    endform. "SUB2
    *& Form DISPLAY_SFLIGHT
    * text
    * --> p1 text
    * <-- p2 text
    form display_sflight .
    data: pgm like sy-repid.
    pgm = sy-repid.
    clear t_layout.
    fs_layout-box_fieldname = 'CHECK'.
    fs_layout-info_fieldname = 'COLOR'.
    call function 'REUSE_ALV_LIST_DISPLAY'
    exporting
    i_callback_program = pgm
    i_callback_pf_status_set = 'SUB2'
    i_callback_user_command = 'USER_COMMAND'
    i_structure_name = 'SFLIGHT'
    is_layout = fs_layout
    tables
    t_outtab = t_sflight
    exceptions
    program_error = 1
    others = 2.
    if sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    * WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    endif.
    endform. " DISPLAY_SFLIGHT
    *& Form GET_SPFLI_DETAILS
    * text
    * --> p1 text
    * <-- p2 text
    form get_spfli_details .
    loop at t_spfli into fs_spfli.
    if fs_spfli-checkbox = 'X'.
    fs_spfli-color = 'C51'.
    fs_spfli-checkbox = '1'.
    fs_table-carrid = fs_spfli-carrid.
    fs_table-connid = fs_spfli-connid.
    append fs_table to t_table.
    modify t_spfli from fs_spfli.
    endif.
    endloop.
    endform. " GET_SFLIGHT_DETAILS
    *& Form GET_SFLIGHT_DETAILS
    * text
    * --> p1 text
    * <-- p2 text
    form get_sflight_details .
    loop at t_sflight into fs_sflight.
    if fs_sflight-check = 'X'.
    fs_sflight-color = 'C71'.
    fs_sflight-check = '1'.
    fs_table1-carrid = fs_sflight-carrid.
    fs_table1-connid = fs_sflight-connid.
    fs_table1-fldate = fs_sflight-fldate.
    append fs_table1 to t_table1.
    modify t_sflight from fs_sflight.
    endif.
    endloop.
    endform. " GET_SFLIGHT_DETAILS
    *& Form DISPLAY_SBOOK
    * text
    * --> p1 text
    * <-- p2 text
    form display_sbook .
    data: pgm like sy-repid.
    pgm = sy-repid.
    call function 'REUSE_ALV_LIST_DISPLAY'
    exporting
    i_callback_program = pgm
    i_structure_name = 'SBOOK'
    tables
    t_outtab = t_sbook
    exceptions
    program_error = 1
    others = 2.
    if sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    * WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    endif.
    endform. " DISPLAY_SBOOK
    <b> Reuse_alv_fieldcatalog_merge</b>
    *data definition
    tables:
    marav. "Table MARA and table MAKT
    * Data to be displayed in ALV
    * Using the following syntax, REUSE_ALV_FIELDCATALOG_MERGE can auto-
    * matically determine the fieldstructure from this source program
    Data:
    begin of imat occurs 100,
    matnr like marav-matnr, "Material number
    maktx like marav-maktx, "Material short text
    matkl like marav-matkl, "Material group (so you can test to make
                            " intermediate sums)
    ntgew like marav-ntgew, "Net weight, numeric field (so you can test to
                            "make sums)
    gewei like marav-gewei, "weight unit (just to be complete)
    end of imat.
    * Other data needed
    * field to store report name
    data i_repid like sy-repid.
    * field to check table length
    data i_lines like sy-tabix.
    * Data for ALV display
    TYPE-POOLS: SLIS.
    data int_fcat type SLIS_T_FIELDCAT_ALV.
    select-options:
    s_matnr for marav-matnr matchcode object MAT1.
    start-of-selection.
    * read data into table imat
      select * from marav
      into corresponding fields of table imat
      where
      matnr in s_matnr.
    * Check if material was found
      clear i_lines.
      describe table imat lines i_lines.
      if i_lines lt 1.
    *   Using hardcoded write here for easy upload
        write: /
        'No materials found.'.
        exit.
      endif.
    end-of-selection.
    * Now, we start with ALV
    * To use ALV, we need a DDIC-structure or a thing called Fieldcatalogue.
    * The fieldcatalouge can be generated by FUNCTION
    * 'REUSE_ALV_FIELDCATALOG_MERGE' from an internal table from any
    * report source, including this report.
    * The only problem one might have is that the report and table names
    * need to be in capital letters. (I had it :-( )
    * Store report name
      i_repid = sy-repid.
    * Create Fieldcatalogue from internal table
      CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
           EXPORTING
                I_PROGRAM_NAME         = i_repid
                I_INTERNAL_TABNAME     = 'IMAT'  "capital letters!
                I_INCLNAME             = i_repid
           CHANGING
                CT_FIELDCAT            = int_fcat
           EXCEPTIONS
                INCONSISTENT_INTERFACE = 1
                PROGRAM_ERROR          = 2
                OTHERS                 = 3.
    *explanations:
    *    I_PROGRAM_NAME is the program which calls this function
    *    I_INTERNAL_TABNAME is the name of the internal table which you want
    *                       to display in ALV
    *    I_INCLNAME is the ABAP-source where the internal table is defined
    *               (DATA....)
    *      CT_FIELDCAT contains the Fieldcatalouge that we need later for
    *      ALV display
      IF SY-SUBRC <> 0.
        write: /
        'Returncode',
        sy-subrc,
        'from FUNCTION REUSE_ALV_FIELDCATALOG_MERGE'.
      ENDIF.
    *This was the fieldcatlogue
    * And now, we are ready to display our list
    * Call for ALV list display
      CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
           EXPORTING
    *            I_CALLBACK_PROGRAM = 'Z_ALV_SIMPLE_EXAMPLE_WITH_ITAB'
                I_CALLBACK_PROGRAM = i_repid
                IT_FIELDCAT        = int_fcat
                I_SAVE             = 'A'
           TABLES
                T_OUTTAB           = imat
           EXCEPTIONS
                PROGRAM_ERROR      = 1
                OTHERS             = 2.
    *explanations:
    *    I_CALLBACK_PROGRAM is the program which calls this function
    *    IT_FIELDCAT (just made by REUSE_ALV_FIELDCATALOG_MERGE) contains
    *                 now the data definition needed for display
    *    I_SAVE allows the user to save his own layouts
    *      T_OUTTAB contains the data to be displayed in ALV
      IF SY-SUBRC <> 0.
        write: /
        'Returncode',
        sy-subrc,
        'from FUNCTION REUSE_ALV_LIST_DISPLAY'.
      ENDIF.
    <b> Reuse_alv_events_get</b>
    By using this  function module called 'REUSE_ALV_EVENTS_GET' where u get all the events like PF_STATUS_SET, TOP_OF_LIST, END_OF_PAGE,END_OF_LIST etc populated into an internal table So u can read this internal table and call the appropriate form to print the content at the end of the list. Below is the sample code for ur reference.
    FORM build_events USING flag
    CHANGING pa_events TYPE slis_t_event.
    *Get all possible events
    CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
    EXPORTING
    i_list_type = 0
    IMPORTING
    et_events = pa_events
    EXCEPTIONS
    list_type_wrong = 1
    OTHERS = 2.
    IF sy-subrc <> 0.
    ENDIF.
    * Specify events used in selection screen
    READ TABLE pa_events WITH KEY name = slis_ev_top_of_page
    INTO ls_events.
    IF sy-subrc = 0.
    IF flag = 1.
    ls_events-form = 'TOP_OF_PAGE1'.
    ELSEIF flag = 2.
    ls_events-form = 'TOP_OF_PAGE2'.
    ELSE.
    ls_events-form = 'TOP_OF_PAGE3'.
    ENDIF.
    MODIFY pa_events FROM ls_events INDEX sy-tabix.
    CLEAR ls_events.
    ENDIF.
    ENDFORM. "build_events
    *& Form top_of_page1
    FORM top_of_page1.
    WRITE: 'Last Year'.
    ENDFORM. "TOP_OF_PAGE1
    *& Form top_of_page2
    FORM top_of_page2.
    WRITE: 'Budget'.
    ENDFORM. "TOP_OF_PAGE2
    *& Form top_of_page3
    FORM top_of_page3.
    WRITE: 'This year'.
    ENDFORM. "TOP_OF_PAGE3 
    <b>Reuse_alv_commentary_write </b>
    *& Report  ZALV                                                        *
    Report  ZALV  .
    TABLES:     ekko.
    type-pools: slis.                                 "ALV Declarations
    *Data Declaration
    TYPES: BEGIN OF t_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 t_ekko.
    DATA: it_ekko TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,
          wa_ekko TYPE t_ekko.
    *ALV data declarations
    data: fieldcatalog type slis_t_fieldcat_alv with header line,
          gd_tab_group type slis_t_sp_group_alv,
          gd_layout    type slis_layout_alv,
          gd_repid     like sy-repid,
          gt_events     type slis_t_event,
          gd_prntparams type slis_print_alv.
    *Start-of-selection.
    START-OF-SELECTION.
    perform data_retrieval.
    perform build_fieldcatalog.
    perform build_layout.
    perform build_events.
    perform build_print_params.
    perform display_alv_report.
    *&      Form  BUILD_FIELDCATALOG
    *       Build Fieldcatalog for ALV Report
    form build_fieldcatalog.
    * There are a number of ways to create a fieldcat.
    * For the purpose of this example i will build the fieldcatalog manualy
    * by populating the internal table fields individually and then
    * appending the rows. This method can be the most time consuming but can
    * also allow you  more control of the final product.
    * Beware though, you need to ensure that all fields required are
    * populated. When using some of functionality available via ALV, such as
    * total. You may need to provide more information than if you were
    * simply displaying the result
    *               I.e. Field type may be required in-order for
    *                    the 'TOTAL' function to work.
      fieldcatalog-fieldname   = 'EBELN'.
      fieldcatalog-seltext_m   = 'Purchase Order'.
      fieldcatalog-col_pos     = 0.
      fieldcatalog-outputlen   = 10.
      fieldcatalog-emphasize   = 'X'.
      fieldcatalog-key         = 'X'.
    *  fieldcatalog-do_sum      = 'X'.
    *  fieldcatalog-no_zero     = 'X'.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'EBELP'.
      fieldcatalog-seltext_m   = 'PO Item'.
      fieldcatalog-col_pos     = 1.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'STATU'.
      fieldcatalog-seltext_m   = 'Status'.
      fieldcatalog-col_pos     = 2.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'AEDAT'.
      fieldcatalog-seltext_m   = 'Item change date'.
      fieldcatalog-col_pos     = 3.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'MATNR'.
      fieldcatalog-seltext_m   = 'Material Number'.
      fieldcatalog-col_pos     = 4.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'MENGE'.
      fieldcatalog-seltext_m   = 'PO quantity'.
      fieldcatalog-col_pos     = 5.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'MEINS'.
      fieldcatalog-seltext_m   = 'Order Unit'.
      fieldcatalog-col_pos     = 6.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'NETPR'.
      fieldcatalog-seltext_m   = 'Net Price'.
      fieldcatalog-col_pos     = 7.
      fieldcatalog-outputlen   = 15.
      fieldcatalog-datatype     = 'CURR'.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'PEINH'.
      fieldcatalog-seltext_m   = 'Price Unit'.
      fieldcatalog-col_pos     = 8.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
    endform.                    " BUILD_FIELDCATALOG
    *&      Form  BUILD_LAYOUT
    *       Build layout for ALV grid report
    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  DISPLAY_ALV_REPORT
    *       Display report using ALV grid
    form display_alv_report.
      gd_repid = sy-repid.
      call function 'REUSE_ALV_GRID_DISPLAY'
           exporting
                i_callback_program      = gd_repid
                i_callback_top_of_page   = 'TOP-OF-PAGE'  "see FORM
                i_callback_user_command = 'USER_COMMAND'
    *            i_grid_title           = outtext
                is_layout               = gd_layout
                it_fieldcat             = fieldcatalog[]
    *            it_special_groups       = gd_tabgroup
                it_events               = gt_events
                is_print                = gd_prntparams
                i_save                  = 'X'
    *            is_variant              = z_template
           tables
                t_outtab                = it_ekko
           exceptions
                program_error           = 1
                others                  = 2.
      if sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      endif.
    endform.                    " DISPLAY_ALV_REPORT
    *&      Form  DATA_RETRIEVAL
    *       Retrieve data form EKPO table and populate itab it_ekko
    form data_retrieval.
    select ebeln ebelp statu aedat matnr menge meins netpr peinh
    up to 10 rows
      from ekpo
      into table it_ekko.
    endform.                    " DATA_RETRIEVAL
    * Form  TOP-OF-PAGE                                                 *
    * ALV Report Header                                                 *
    Form top-of-page.
    *ALV Header declarations
    data: t_header type slis_t_listheader,
          wa_header type slis_listheader,
          t_line like wa_header-info,
          ld_lines type i,
          ld_linesc(10) type c.
    * Title
      wa_header-typ  = 'H'.
      wa_header-info = 'EKKO Table Report'.
      append wa_header to t_header.
      clear wa_header.
    * Date
      wa_header-typ  = 'S'.
      wa_header-key = 'Date: '.
      CONCATENATE  sy-datum+6(2) '.'
                   sy-datum+4(2) '.'
                   sy-datum(4) INTO wa_header-info.   "todays date
      append wa_header to t_header.
      clear: wa_header.
    * Total No. of Records Selected
      describe table it_ekko lines ld_lines.
      ld_linesc = ld_lines.
      concatenate 'Total No. of Records Selected: ' ld_linesc
                        into t_line separated by space.
      wa_header-typ  = 'A'.
      wa_header-info = t_line.
      append wa_header to t_header.
      clear: wa_header, t_line.
      call function 'REUSE_ALV_COMMENTARY_WRITE'
           exporting
                it_list_commentary = t_header.
    *            i_logo             = 'Z_LOGO'.
    endform.
    *       FORM USER_COMMAND                                          *
    *       --> R_UCOMM                                                *
    *       --> RS_SELFIELD                                            *
    FORM user_command USING r_ucomm LIKE sy-ucomm
                      rs_selfield TYPE slis_selfield.
    * Check function code
      CASE r_ucomm.
        WHEN '&IC1'.
    *   Check field clicked on within ALVgrid report
        IF rs_selfield-fieldname = 'EBELN'.
    *     Read data table, using index of row user clicked on
          READ TABLE it_ekko INTO wa_ekko INDEX rs_selfield-tabindex.
    *     Set parameter ID for transaction screen field
          SET PARAMETER ID 'BES' FIELD wa_ekko-ebeln.
    *     Sxecute transaction ME23N, and skip initial data entry screen
          CALL TRANSACTION 'ME23N' AND SKIP FIRST SCREEN.
        ENDIF.
      ENDCASE.
    ENDFORM.
    *&      Form  BUILD_EVENTS
    *       Build events table
    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_end_of_page
                               into ls_event.
      if sy-subrc = 0.
        move 'END_OF_PAGE' to ls_event-form.
        append ls_event to gt_events.
      endif.
        read table gt_events with key name =  slis_ev_end_of_list
                               into ls_event.
      if sy-subrc = 0.
        move 'END_OF_LIST' to ls_event-form.
        append ls_event to gt_events.
      endif.
    endform.                    " BUILD_EVENTS
    *&      Form  BUILD_PRINT_PARAMS
    *       Setup print parameters
    form build_print_params.
      gd_prntparams-reserve_lines = '3'.   "Lines reserved for footer
      gd_prntparams-no_coverpage = 'X'.
    endform.                    " BUILD_PRINT_PARAMS
    *&      Form  END_OF_PAGE
    form END_OF_PAGE.
      data: listwidth type i,
            ld_pagepos(10) type c,
            ld_page(10)    type c.
      write: sy-uline(50).
      skip.
      write:/40 'Page:', sy-pagno .
    endform.
    *&      Form  END_OF_LIST
    form END_OF_LIST.
      data: listwidth type i,
            ld_pagepos(10) type c,
            ld_page(10)    type c.
      skip.
      write:/40 'Page:', sy-pagno .
    endform.
    <b>Reuse_alv_grid_display</b>
    *& Report  ZALVTEST                                                    *
    REPORT  ZALVTEST.
    TABLES: mara, makt.
    TYPE-POOLS: slis.
    TYPES: BEGIN OF tab,
              matnr TYPE matnr,
              matkl TYPE matkl,
              maktx TYPE maktx,
           END OF tab.
    DATA: itab TYPE TABLE OF tab,
          wa LIKE LINE OF itab.
    *ALV data declarations
    data: fieldcatalog type slis_t_fieldcat_alv with header line,
          gd_tab_group type slis_t_sp_group_alv,
          gd_layout    type slis_layout_alv,
          gd_repid     like sy-repid.
    *Start-of-selection.
    START-OF-SELECTION.
    perform data_retrieval.
    perform build_fieldcatalog.
    perform build_layout.
    perform display_alv_report.
    *&      Form  BUILD_FIELDCATALOG
    *       Build Fieldcatalog for ALV Report
    form build_fieldcatalog.
    * There are a number of ways to create a fieldcat.
    * For the purpose of this example i will build the fieldcatalog manualy
    * by populating the internal table fields individually and then
    * appending the rows. This method can be the most time consuming but can
    * also allow you  more control of the final product.
    * Beware though, you need to ensure that all fields required are
    * populated. When using some of functionality available via ALV, such as
    * total. You may need to provide more information than if you were
    * simply displaying the result
    *               I.e. Field type may be required in-order for
    *                    the 'TOTAL' function to work.
      fieldcatalog-fieldname   = 'MATNR'.
      fieldcatalog-seltext_m   = 'Material No'.
      fieldcatalog-col_pos     = 0.
      fieldcatalog-outputlen   = 10.
      fieldcatalog-emphasize   = 'X'.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'MATKL'.
      fieldcatalog-seltext_m   = 'Group'.
      fieldcatalog-col_pos     = 2.
       fieldcatalog-outputlen   = 5.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'MAKTX'.
      fieldcatalog-seltext_m   = 'Description'.
      fieldcatalog-col_pos     = 1.
      fieldcatalog-outputlen   = 8.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
    endform.                    " BUILD_FIELDCATALOG
    *&      Form  BUILD_LAYOUT
    *       Build layout for ALV grid report
    form build_layout.
      gd_layout-no_input          = 'X'.
      gd_layout-colwidth_optimize = 'X'.
    endform.                    " BUILD_LAYOUT
    *&      Form  DISPLAY_ALV_REPORT
    *       Display report using ALV grid
    form display_alv_report.
      gd_repid = sy-repid.
      call function 'REUSE_ALV_GRID_DISPLAY'
           exporting
                i_callback_program      = gd_repid
    *            i_callback_top_of_page   = 'TOP-OF-PAGE'  "see FORM
    *            i_callback_user_command = 'USER_COMMAND'
    *            i_grid_title           = outtext
                is_layout               = gd_layout
                it_fieldcat             = fieldcatalog[]
    *            it_special_groups       = gd_tabgroup
    *            IT_EVENTS                = GT_XEVENTS
                i_save                  = 'X'
    *            is_variant              = z_template
           tables
                t_outtab                = itab
           exceptions
                program_error           = 1
                others                  = 2.
      if sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      endif.
    endform.                    " DISPLAY_ALV_REPORT
    *&      Form  DATA_RETRIEVAL
    *       Retrieve data form EKPO table and populate itab it_ekko
    form data_retrieval.
    SELECT F~matnr F~matkl P~maktx
        INTO table itab
        FROM mara AS F INNER JOIN makt AS P
               ON F~matnr = P~matnr.
    endform.                    " DATA_RETRIEVAL
    Regards
    Pavan

  • User defined PF-STATUS in ALV

    Hi all,
          I am doing an ALV through an user defined pf-status.But when I am using this pf-status I am unable to find the standard application tool bar and remaining also.I have seen some threads regarding this. These threads are giving me the suggestions to copy the standard pf status of ALV into user defined pf status. How to copy this standard pf status to my program.
    Sathish Reddy.

    First of all you must copy STANDART status from any ALV example in SLIS Development Class into your report.
    You can change this status Properties. (Functions, Buttons)
    And you must add this form to Active Your Status in ALV.
    *&      Form  set_pf_status
    *       text
    *  -->  p1        text
    *  <--  p2        text
    form set_pf_status using rt_extab type slis_t_extab.
      set pf-status 'STANDARD' excluding rt_extab.
    endform.
    and you must add specified line in your callf of ALV Function.
      call function 'REUSE_ALV_LIST_DISPLAY'
           exporting
                i_callback_program = g_repid
                it_fieldcat        = gt_fieldcat[]
                it_events          = t_events[]
                i_callback_user_command = 'USER_COMMAND'
                i_callback_pf_status_set = 'SET_PF_STATUS'  <<<<<< ADD THIS
           tables
                t_outtab           = mglistoutput.
    ibrahim

  • ALV doesn't go back

    Hi Experts,
    based on the SAP ALV example for "cl_salv_table" I wrote an ALV report. The first screen is for data selection. After this the ALV grid is displayed.
    The problem is that the standard back button doesn't work as expected. So after clicking on "direct processing (F8)" in SE80 the selection screen is being opened. Here the back button works fine and it switches back to SE80.
    When having selected some values and processed the report so the ALV grid is being displayed the click on back button results in an empty screen just with the title headline of the report. There I would expect the selection screen to be.
    When clicking on the back button at this empty screen the report is being processed again and the ALV grid pops up. From there on its something like a endless loop: back to empty screen - back to ALV grid; back to empty screen - back to ALV grid; ...
    The PF Status is defined. The OK-Code is defined. After clicking on the back button the standard PAI-Module is being loaded.
    The following is the part where I declare the ALV grid:
    TRY.
      cl_salv_table=>factory(
          EXPORTING
            list_display = IF_SALV_C_BOOL_SAP=>FALSE
          IMPORTING r_salv_table = alv
          CHANGING t_table = lt_report_tab ).
      alv->set_screen_status(
        pfstatus = 'MAIN'
        report = sy-repid
        set_functions = alv->c_functions_all ).
      alv_events = alv->get_event( ).
      create object event_handler.
      set handler event_handler->on_double_click for alv_events.
    *  Set up selections.
      g_selections = alv->get_selections( ).
      g_selections->set_selection_mode( 1 ). "Single
      alv->display( ).
    CATCH cx_salv_msg.
      MESSAGE 'ALV display was not possible' TYPE 'I' DISPLAY LIKE 'E'.
    ENDTRY.
    Any Ideas what could be wrong with my coding?
    Many thanks in advance!
    Best regards
    Tobias

    The function code is: &F03
    alternativley I already tried BACK with the same result.
    Where shall I put the LEAVE TO SCREEN 0 when it's using the standard PAI Module which is NOT included within my Report?

  • In alv output i need to have different fields

    Hi all,
    how to get the different no.of output fields for first few records and
    then it should change for  another few records.
    any suggestion will be rewarded.
    regards
    cnu

    hi,
    use blocked alv.
    example:
    REPORT  ZSR_ALV_BLOCKED.
    TABLES:     ekko, mara.
    TYPE-POOLS: slis.
    *Data Declaration
    TYPES: BEGIN OF t_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 t_ekko.
    TYPES: BEGIN OF t_mara,
      matnr TYPE mara-matnr,
      mtart TYPE mara-mtart,
      matkl TYPE mara-matkl,
    END OF t_mara.
    DATA: it_ekko TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,
          it_mara TYPE STANDARD TABLE OF t_mara INITIAL SIZE 0.
    *ALV data declarations
    DATA: fieldcatalog1 TYPE slis_t_fieldcat_alv WITH HEADER LINE,
          fieldcatalog2 TYPE slis_t_fieldcat_alv WITH HEADER LINE,
          gd_layout     TYPE slis_layout_alv,
          gt_events_ekko TYPE slis_t_event,
          xs_event      TYPE slis_alv_event,
          gt_events_mara TYPE slis_t_event,
          gd_repid       TYPE sy-repid,
          gt_print TYPE slis_print_alv.
    START-OF-SELECTION
    START-OF-SELECTION.
      PERFORM data_retrival.
      PERFORM build_fieldcat.
      PERFORM build_layout.
      PERFORM events_ekko.
      PERFORM events_mara.
      PERFORM display_alv_report.
    *SUBROUTINES
    *&      Form  data_retrival
    FORM data_retrival .
      SELECT ebeln ebelp statu aedat matnr menge meins netpr peinh
       UP TO 10 ROWS
        FROM ekpo
        INTO TABLE it_ekko.
      SELECT matnr mtart matkl
       UP TO 10 ROWS
        FROM mara
        INTO TABLE it_mara.
    ENDFORM.                    " data_retrival
    *&      Form  build_fieldcat
    FORM build_fieldcat .
    FOR EKKO
      fieldcatalog1-fieldname   = 'EBELN'.
      fieldcatalog1-seltext_m   = 'Purchase Order'.
      fieldcatalog1-col_pos     = 0.
      fieldcatalog1-outputlen   = 20.
      fieldcatalog1-emphasize   = 'X'.
      fieldcatalog1-key         = 'X'.
      APPEND fieldcatalog1 TO fieldcatalog1.
      CLEAR  fieldcatalog1.
      fieldcatalog1-fieldname   = 'EBELP'.
      fieldcatalog1-seltext_m   = 'PO Item'.
      fieldcatalog1-col_pos     = 1.
      APPEND fieldcatalog1 TO fieldcatalog1.
      CLEAR  fieldcatalog1.
      fieldcatalog1-fieldname   = 'STATU'.
      fieldcatalog1-seltext_m   = 'Status'.
      fieldcatalog1-col_pos     = 2.
      APPEND fieldcatalog1 TO fieldcatalog1.
      CLEAR  fieldcatalog1.
      fieldcatalog1-fieldname   = 'AEDAT'.
      fieldcatalog1-seltext_m   = 'Item change date'.
      fieldcatalog1-col_pos     = 3.
      APPEND fieldcatalog1 TO fieldcatalog1.
      CLEAR  fieldcatalog1.
      fieldcatalog1-fieldname   = 'MATNR'.
      fieldcatalog1-seltext_m   = 'Material Number'.
      fieldcatalog1-col_pos     = 4.
      APPEND fieldcatalog1 TO fieldcatalog1.
      CLEAR  fieldcatalog1.
      fieldcatalog1-fieldname   = 'MENGE'.
      fieldcatalog1-seltext_m   = 'PO quantity'.
      fieldcatalog1-col_pos     = 5.
      APPEND fieldcatalog1 TO fieldcatalog1.
      CLEAR  fieldcatalog1.
      fieldcatalog1-fieldname   = 'MEINS'.
      fieldcatalog1-seltext_m   = 'Order Unit'.
      fieldcatalog1-col_pos     = 6.
      APPEND fieldcatalog1 TO fieldcatalog1.
      CLEAR  fieldcatalog1.
      fieldcatalog1-fieldname   = 'NETPR'.
      fieldcatalog1-seltext_m   = 'Net Price'.
      fieldcatalog1-col_pos     = 7.
      fieldcatalog1-outputlen   = 15.
      fieldcatalog1-do_sum      = 'X'.        "Display column total
      fieldcatalog1-datatype     = 'CURR'.
      APPEND fieldcatalog1 TO fieldcatalog1.
      CLEAR  fieldcatalog1.
      fieldcatalog1-fieldname   = 'PEINH'.
      fieldcatalog1-seltext_m   = 'Price Unit'.
      fieldcatalog1-col_pos     = 8.
      APPEND fieldcatalog1 TO fieldcatalog1.
      CLEAR  fieldcatalog1.
    FOR MARA
      fieldcatalog2-fieldname   = 'MATNR'.
      fieldcatalog2-seltext_m   = 'Material No'.
      fieldcatalog2-col_pos     = 0.
      fieldcatalog2-outputlen   = 10.
      fieldcatalog2-emphasize   = 'X'.
      fieldcatalog2-key         = 'X'.
      APPEND fieldcatalog2 TO fieldcatalog2.
      CLEAR  fieldcatalog1.
      fieldcatalog2-fieldname   = 'MTART'.
      fieldcatalog2-seltext_m   = 'Material type'.
      fieldcatalog2-col_pos     = 1.
      APPEND fieldcatalog2 TO fieldcatalog2.
      CLEAR  fieldcatalog2.
      fieldcatalog2-fieldname   = 'MATKL'.
      fieldcatalog2-seltext_m   = 'Material Group'.
      fieldcatalog2-col_pos     = 2.
      APPEND fieldcatalog2 TO fieldcatalog2.
      CLEAR  fieldcatalog2.
    ENDFORM.                    " build_fieldcat
    *&      Form  build_layout
    FORM build_layout .
      gd_layout-no_input          = 'X'.
      gd_layout-colwidth_optimize = 'X'.
      gd_layout-totals_text       = 'Totals'(201).
    ENDFORM.                    " build_layout
    *&      Form  events_ekko
    FORM events_ekko .
      CLEAR xs_event.
      xs_event-name = slis_ev_top_of_page.
      xs_event-form = 'TOP_OF_PAGE-EKKO'.
      APPEND xs_event TO gt_events_ekko.
      CLEAR xs_event.
      xs_event-name = slis_ev_end_of_list.
      xs_event-form = 'END_OF_LIST_EKKO'.
      APPEND xs_event TO gt_events_ekko.
    ENDFORM.                    " events_ekko
    *&      Form  TOP_OF_PAGE-EKKO
    FORM top_of_page-ekko.
      WRITE: / 'TOP OF PAGE : Purchase Order'.
    ENDFORM.                    "XTOP_OF_PAGE
    *&      Form  END_OF_LIST_EKKO
    FORM end_of_list_ekko.
      WRITE: / 'end OF list : Purchase Order'.
    ENDFORM.                    "END_OF_LIST_EKKO
    *&      Form  events_mara
    FORM events_mara .
      CLEAR xs_event.
      xs_event-name = slis_ev_top_of_list.
      xs_event-form = 'TOP_OF_LIST-MARA'.
      APPEND xs_event TO gt_events_mara.
      CLEAR xs_event.
      xs_event-name = slis_ev_end_of_page.
      xs_event-form = 'END_OF_PAGE_MARA'.
      APPEND xs_event TO gt_events_mara.
    ENDFORM.                    "events_mara
    *&      Form  TOP_OF_LIST-MARA
    FORM top_of_list-mara.
      WRITE: / 'TOP OF LIST : Material Master'.
    ENDFORM.                    "TOP_OF_LIST-MARA
    *&      Form  END_OF_PAGE_MARA
    FORM end_of_page_mara.
      WRITE: / 'End OF Page : Material Master'.
    ENDFORM.                    "END_OF_PAGE_MARA
    *&      Form  display_alv_report
    FORM display_alv_report .
      gd_repid = sy-repid.
      CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'
        EXPORTING
          i_callback_program = sy-repid.
      CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
        EXPORTING
          is_layout                        = gd_layout
         it_fieldcat                      = fieldcatalog1[]
          i_tabname                        = 'it_ekko'
          it_events                        = gt_events_ekko
        TABLES
          t_outtab                         = it_ekko
       EXCEPTIONS
         program_error                    = 1
         maximum_of_appends_reached       = 2
         OTHERS                           = 3
      IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
        EXPORTING
          is_layout                        = gd_layout
          it_fieldcat                      = fieldcatalog2[]
          i_tabname                        = 'it_mara'
          it_events                        = gt_events_mara
        TABLES
          t_outtab                         = it_mara
       EXCEPTIONS
         program_error                    = 1
         maximum_of_appends_reached       = 2
         OTHERS                           = 3
      IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      gt_print-reserve_lines = 2.
      CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_DISPLAY'.
       EXPORTING
         is_print = gt_print.
    ENDFORM.                    " display_alv_report

  • Row color in ALV

    Hi all,
    I am trying to display some selected rows in my report in a different color.
    But its not working.
    I have .....
    i_gs_layout-info_fieldname = 'COLOR_LINE'.
    my internal table to be displayed is...
    DATA: BEGIN OF T_DISPLAY OCCURS 0,
               MATNR              TYPE MARA-MATNR,
               LOSMENGE       TYPE QALS-LOSMENGE,
               SLMENGE         TYPE MSEG-MENGE,
               SL_PPM            TYPE P DECIMALS 2,
               COLOR_LINE(4) TYPE C,
               END OF T_DISPLAY.
    On some conditions I am filling the field COLOR_LINE with 'C610'.
    The following function module is used for display.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          i_callback_program             = i_g_repid
          i_callback_user_command  = ''
          i_callback_pf_status_set     = ''
          i_grid_title                          = l_title
          is_layout                           = i_gs_layout
          it_events                           = i_gt_events[]
          it_fieldcat                          = i_gt_fieldcat[]
          it_sort                               = i_gt_sort[]
          i_save                               = 'A'
        TABLES
          t_outtab                            = T_DISPLAY.
    Here everything is working fine except the color.
    Eventhough I have the value C610 in my internal table in most of the rows, no row is getting displayed in this color.
    Should I use some other function module or am I missing something in this code..?

    Hi,
    Check this link..
    http://www.sap-img.com/abap/line-color-in-alv-example.htm
    Check this simple example..
    Macro definition
    DEFINE m_fieldcat.
      add 1 to ls_fieldcat-col_pos.
      ls_fieldcat-fieldname   = &1.
      ls_fieldcat-ref_tabname = &2.
      append ls_fieldcat to lt_fieldcat.
    END-OF-DEFINITION.
    TYPE-POOLS: slis.                      " ALV Global types
    TYPES:
      BEGIN OF ty_vbak,
        vkorg TYPE vbak-vkorg,             " Sales organization
        kunnr TYPE vbak-kunnr,             " Sold-to party
        vbeln TYPE vbak-vbeln,             " Sales document
        netwr TYPE vbak-netwr,             " Net Value of the Sales Order
        line_color(4),                     " Line color
      END OF ty_vbak.
    DATA:
    Data displayed
      gt_vbak TYPE TABLE OF ty_vbak.
    START-OF-SELECTION.
      PERFORM f_read_data.
      PERFORM f_fill_color.
      PERFORM f_display_data.
         Form  f_read_data
    FORM f_read_data.
      SELECT * INTO CORRESPONDING FIELDS OF TABLE gt_vbak
               FROM vbak UP TO 100 ROWS.
    ENDFORM.                               " F_READ_DATA
         Form  f_fill_color
    FORM f_fill_color.
      DATA l_rnd_value TYPE integer2.
      FIELD-SYMBOLS <vbak> TYPE ty_vbak.
      LOOP AT gt_vbak ASSIGNING <vbak>.
      Random value
        CALL FUNCTION 'RANDOM_I2'
          EXPORTING
            rnd_min   = 0
            rnd_max   = 3
          IMPORTING
            rnd_value = l_rnd_value.
        CASE l_rnd_value.
          WHEN 0.
            <vbak>-line_color = 'C100'.   " Blue.
          WHEN 1.
            <vbak>-line_color = 'C300'.   " Yellow.
          WHEN 2.
            <vbak>-line_color = 'C500'.   " Green.
          WHEN 3.
            <vbak>-line_color = 'C600'.   " Red.
        ENDCASE.
      ENDLOOP.
    ENDFORM.                               " F_FILL_COLOR
         Form  f_display_data
    FORM f_display_data.
      DATA:
        ls_layout   TYPE slis_layout_alv,
        ls_fieldcat TYPE slis_fieldcat_alv,
        lt_fieldcat TYPE slis_t_fieldcat_alv.
    Build the field catalog
      m_fieldcat 'VKORG' 'VBAK'.
      m_fieldcat 'KUNNR' 'VBAK'.
      m_fieldcat 'VBELN' 'VBAK'.
      m_fieldcat 'NETWR' 'VBAK'.
    Fill Layout - Name of the field with color
      ls_layout-info_fieldname = 'LINE_COLOR'.
    Display the list
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          is_layout   = ls_layout
          it_fieldcat = lt_fieldcat
        TABLES
          t_outtab    = gt_vbak.
    ENDFORM.                               " F_DISPLAY_DATA
    Thanks,
    Naren

  • Hierarchial ALV report

    Hi Friends,
    I have created a Hierarchial ALV report using OOP concept (Class Builder). The output is OK but it is displaying the unwanted columns in the header part.
    The code written is as follows.
    =====================================================
    REPORT ZMMSTKH.
    DATA: G_ALV_TREE         TYPE REF TO CL_GUI_ALV_TREE,
          G_CUSTOM_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER.
    DATA: GT_ZSD_BILLINFO      TYPE ZSD_BILLINFO  OCCURS 0,      "Output-Table
          OK_CODE LIKE SY-UCOMM,
          SAVE_OK LIKE SY-UCOMM,           "OK-Code
          G_MAX TYPE I VALUE 255.
    DATA  CCONTAINER1.
    DATA LS_FIELDCAT TYPE LVC_S_FCAT.
    DATA GT_FIELDCAT_LVC TYPE LVC_S_FCAT OCCURS 0.
    DATA IT_FIELDCATALOG TYPE LVC_S_FCAT OCCURS 0.
    END-OF-SELECTION.
      CALL SCREEN 100.
    *&      Module  PBO  OUTPUT
          process before output
    MODULE PBO OUTPUT.
      SET PF-STATUS 'MAIN100'.
      SET TITLEBAR 'MAINTITLE'.
      IF G_ALV_TREE IS INITIAL.
        PERFORM INIT_TREE.
        CALL METHOD CL_GUI_CFW=>FLUSH
          EXCEPTIONS
            CNTL_SYSTEM_ERROR = 1
            CNTL_ERROR        = 2.
        IF SY-SUBRC NE 0.
          CALL FUNCTION 'POPUP_TO_INFORM'
            EXPORTING
              TITEL = 'Automation Queue failure'(801)
              TXT1  = 'Internal error:'(802)
              TXT2  = 'A method in the automation queue'(803)
              TXT3  = 'caused a failure.'(804).
        ENDIF.
      ENDIF.
    ENDMODULE.                             " PBO  OUTPUT
    *&      Module  PAI  INPUT
          process after input
    MODULE PAI INPUT.
      SAVE_OK = OK_CODE.
      CLEAR OK_CODE.
      CASE SAVE_OK.
        WHEN 'EXIT' OR 'BACK' OR 'CANC'.
          PERFORM EXIT_PROGRAM.
        WHEN OTHERS.
          CALL METHOD CL_GUI_CFW=>DISPATCH.
      ENDCASE.
      CALL METHOD CL_GUI_CFW=>FLUSH.
    ENDMODULE.                             " PAI  INPUT
    *&      Form  init_tree
          text
    -->  p1        text
    <--  p2        text
    FORM INIT_TREE.
      DATA: L_TREE_CONTAINER_NAME(30) TYPE C.
      L_TREE_CONTAINER_NAME = 'CCONTAINER1'(001).
      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.
      IF SY-SUBRC <> 0.
        MESSAGE X208(00) WITH 'ERROR'(100).
      ENDIF.
      CREATE OBJECT G_ALV_TREE
        EXPORTING
            PARENT              = G_CUSTOM_CONTAINER
            NODE_SELECTION_MODE = CL_GUI_COLUMN_TREE=>NODE_SEL_MODE_SINGLE
            ITEM_SELECTION      = 'X'
            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.
      IF SY-SUBRC <> 0.
        MESSAGE X208(00) WITH 'ERROR'.                          "#EC NOTEXT
      ENDIF.
      DATA L_HIERARCHY_HEADER TYPE TREEV_HHDR.
      PERFORM BUILD_HIERARCHY_HEADER CHANGING L_HIERARCHY_HEADER.
      PERFORM ZF_CREATE_FIELDCAT.
      CALL METHOD G_ALV_TREE->SET_TABLE_FOR_FIRST_DISPLAY
        EXPORTING
          I_STRUCTURE_NAME    = 'zsd_billinfo'
          IS_HIERARCHY_HEADER = L_HIERARCHY_HEADER
        CHANGING
          IT_OUTTAB           = GT_ZSD_BILLINFO. "table must be empty !
      IT_FIELDCATALOG = GT_FIELDCAT_LVC[].
      PERFORM CREATE_HIERARCHY.
      CALL METHOD G_ALV_TREE->FRONTEND_UPDATE.
    ENDFORM.                               " init_tree
    *&      Form  build_hierarchy_header
    FORM BUILD_HIERARCHY_HEADER CHANGING
                                   P_HIERARCHY_HEADER TYPE TREEV_HHDR.
      P_HIERARCHY_HEADER-HEADING = 'Region / Material'(300).
    p_hierarchy_header-tooltip = 'PO No'(400).
      P_HIERARCHY_HEADER-WIDTH = 30.
      P_HIERARCHY_HEADER-WIDTH_PIX = ' '.
    ENDFORM.                               " build_hierarchy_header
    *&      Form  exit_program
          free object and leave program
    FORM EXIT_PROGRAM.
      CALL METHOD G_CUSTOM_CONTAINER->FREE.
      LEAVE PROGRAM.
    ENDFORM.                               " exit_program
    *&      Form  create_hierarchy
          text
    -->  p1        text
    <--  p2        text
    FORM CREATE_HIERARCHY.
      DATA: LS_ZSD_BILLINFO TYPE ZSD_BILLINFO,
            LT_ZSD_BILLINFO TYPE ZSD_BILLINFO OCCURS 0,
           l_bukrs like zsd_billinfo-bukrs,
           l_vbeln like zsd_billinfo-vbeln,
           l_fkdat like zsd_billinfo-fkdat,
           l_fkart like zsd_billinfo-fkart,
           l_vkorg like zsd_billinfo-vkorg,
           l_spart like zsd_billinfo-spart,
            L_BZIRK LIKE ZSD_BILLINFO-BZIRK,
            L_BZIRK_LAST LIKE ZSD_BILLINFO-BZIRK,
           l_vkbur like zsd_billinfo-vkbur,
            L_WERKS LIKE ZSD_BILLINFO-WERKS,
            L_WERKS_LAST LIKE ZSD_BILLINFO-WERKS,
            L_MATNR LIKE ZSD_BILLINFO-MATNR,
            L_MATNR_LAST LIKE ZSD_BILLINFO-MATNR,
            L_FKIMG LIKE ZSD_BILLINFO-FKIMG,
            L_NETWR LIKE ZSD_BILLINFO-NETWR.
      DATA: L_BUKRS_KEY TYPE LVC_NKEY,
            L_BZIRK_KEY TYPE LVC_NKEY,
            L_WERKS_KEY TYPE LVC_NKEY,
            L_MATNR_KEY TYPE LVC_NKEY,
           l_vbeln_key type lvc_nkey,
            L_LAST_KEY TYPE LVC_NKEY.
      SELECT BUKRS BZIRK WERKS MATNR FKIMG FROM ZSD_BILLINFO
      INTO CORRESPONDING FIELDS OF
      TABLE LT_ZSD_BILLINFO
      WHERE  SPART = 'CT' AND
             FKART = 'ZVAT'.
    select * from zsd_billinfo    into table lt_zsd_billinfo
    where  spart = 'CT' and
            fkart = 'ZVAT'.
      SORT LT_ZSD_BILLINFO BY BZIRK WERKS MATNR.
      LOOP AT LT_ZSD_BILLINFO INTO LS_ZSD_BILLINFO.
        L_BZIRK = LS_ZSD_BILLINFO-BZIRK.
        L_WERKS = LS_ZSD_BILLINFO-WERKS.
        L_MATNR = LS_ZSD_BILLINFO-MATNR.
        IF L_BZIRK <> L_BZIRK_LAST.
          L_BZIRK_LAST = L_BZIRK.
          PERFORM ADD_BZIRK USING    L_BZIRK
                                 CHANGING L_BZIRK_KEY.
          CLEAR L_WERKS_LAST.
        ENDIF.
        IF L_WERKS <> L_WERKS_LAST.
          L_WERKS_LAST = L_WERKS.
          PERFORM ADD_WERKS_LINE USING    LS_ZSD_BILLINFO
                                      L_WERKS_KEY
                              CHANGING L_WERKS_KEY.
          IF L_MATNR <> L_MATNR_LAST.
            L_MATNR_LAST = L_MATNR.
            PERFORM ADD_MATNR_LINE USING    LS_ZSD_BILLINFO
                                        L_MATNR_KEY
                                CHANGING L_MATNR_KEY.
          ENDIF.
          PERFORM ADD_COMPLETE_LINE USING  LS_ZSD_BILLINFO
                                           L_MATNR_KEY
                                  CHANGING L_LAST_KEY.
        ENDIF.
    *if l_matnr <> l_matnr_last.
         l_matnr_last = l_matnr.
             perform add_matnr_line using    ls_zsd_billinfo
                                         l_matnr_key
                                 changing l_matnr_key.
       endif.
       perform add_complete_line using  ls_zsd_billinfo
                                        l_matnr_key
                               changing l_last_key.
      ENDLOOP.
    ENDFORM.                               " create_hierarchy
    *&      Form  add_month
    *&      Form  add_ebeln
    FORM ADD_BZIRK  USING     P_BZIRK TYPE C
                              P_RELAT_KEY TYPE LVC_NKEY
                    CHANGING  P_NODE_KEY TYPE LVC_NKEY.
      DATA: L_NODE_TEXT TYPE LVC_VALUE,
            LS_ZSD_BILLINFO TYPE ZSD_BILLINFO,
            L_BZIRK(12) TYPE C.            "output string for month
      CALL METHOD G_ALV_TREE->ADD_NODE
        EXPORTING
          I_RELAT_NODE_KEY = P_RELAT_KEY
          I_RELATIONSHIP   = CL_GUI_COLUMN_TREE=>RELAT_LAST_CHILD
          I_NODE_TEXT      = L_NODE_TEXT
          IS_OUTTAB_LINE   = LS_ZSD_BILLINFO
        IMPORTING
          E_NEW_NODE_KEY   = P_NODE_KEY.
    ENDFORM.                               " add_month
    FORM ADD_WERKS_LINE USING     PS_ZSD_BILLINFO TYPE ZSD_BILLINFO
                                   P_RELAT_KEY TYPE LVC_NKEY
                         CHANGING  P_NODE_KEY TYPE LVC_NKEY.
      DATA: L_NODE_TEXT TYPE LVC_VALUE,
            LS_ZSD_BILLINFO TYPE ZSD_BILLINFO.
      L_NODE_TEXT =  PS_ZSD_BILLINFO-WERKS.
      CALL METHOD G_ALV_TREE->ADD_NODE
        EXPORTING
          I_RELAT_NODE_KEY = P_RELAT_KEY
          I_RELATIONSHIP   = CL_GUI_COLUMN_TREE=>RELAT_LAST_CHILD
          I_NODE_TEXT      = L_NODE_TEXT
          IS_OUTTAB_LINE   = LS_ZSD_BILLINFO
        IMPORTING
          E_NEW_NODE_KEY   = P_NODE_KEY.
    ENDFORM.                               " add_carrid_line
    FORM ADD_MATNR_LINE USING     PS_ZSD_BILLINFO TYPE ZSD_BILLINFO
                                   P_RELAT_KEY TYPE LVC_NKEY
                         CHANGING  P_NODE_KEY TYPE LVC_NKEY.
      DATA: L_NODE_TEXT TYPE LVC_VALUE,
            LS_ZSD_BILLINFO TYPE ZSD_BILLINFO.
      L_NODE_TEXT =  PS_ZSD_BILLINFO-MATNR.
      CALL METHOD G_ALV_TREE->ADD_NODE
        EXPORTING
          I_RELAT_NODE_KEY = P_RELAT_KEY
          I_RELATIONSHIP   = CL_GUI_COLUMN_TREE=>RELAT_LAST_CHILD
          I_NODE_TEXT      = L_NODE_TEXT
          IS_OUTTAB_LINE   = LS_ZSD_BILLINFO
        IMPORTING
          E_NEW_NODE_KEY   = P_NODE_KEY.
    ENDFORM.                               " add_carrid_line
    **&      Form  add_complete_line
    FORM ADD_COMPLETE_LINE USING   PS_ZSD_BILLINFO TYPE ZSD_BILLINFO
                                   P_RELAT_KEY TYPE LVC_NKEY
                         CHANGING  P_NODE_KEY TYPE LVC_NKEY.
      DATA: L_NODE_TEXT TYPE LVC_VALUE.
      WRITE PS_ZSD_BILLINFO-BZIRK TO L_NODE_TEXT.
      CALL METHOD G_ALV_TREE->ADD_NODE
        EXPORTING
          I_RELAT_NODE_KEY = P_RELAT_KEY
          I_RELATIONSHIP   = CL_GUI_COLUMN_TREE=>RELAT_LAST_CHILD
          IS_OUTTAB_LINE   = PS_ZSD_BILLINFO
          I_NODE_TEXT      = L_NODE_TEXT
        IMPORTING
          E_NEW_NODE_KEY   = P_NODE_KEY.
    ENDFORM.                               " add_complete_line
    *&      Form  zf_create_fieldcat
          text
    FORM ZF_CREATE_FIELDCAT.
      CLEAR LS_FIELDCAT.
      LS_FIELDCAT-FIELDNAME = 'FKIMG'.
      LS_FIELDCAT-REF_TABLE = 'zsd_billinfo'.
      LS_FIELDCAT-NO_OUT = 'X'.
      LS_FIELDCAT-KEY = ''.
      APPEND LS_FIELDCAT TO GT_FIELDCAT_LVC.
    ENDFORM. " ZF_CREATE_FIELDCAT
    =================================================
    Kindly look into the code and guide me the solution.
    TIA.
    Regards,
    Mark K

    hi
    good
    i tried your ALV report but it is giving some error due to some ztable you have used in your progam,
    you can go to se38 and give there BCALV* and press f4, you ll find lots of ALV example related to OOP concept, you can test them and use them as per your requirement.
    thnaks
    mrutyun^

  • Need information regarding Hierarchical ALV display

    How to total sub items in an Heirarchical ALV List display?

    Hi,
    I have one Hierarchical alv example .. please see it. Also check B*ALV in se38.
    *& Report  ZLAXMI_ALVEXER4                                             *
    REPORT  ZLAXMI_ALVEXER4    MESSAGE-ID ZZ        .
    *& TABLES DECLARATION                                                  *
    TABLES: VBAK, VBAP.
    *& TYPE POOLS DECLARATION                                              *
    TYPE-POOLS: SLIS.
                          DATA DECLARATIONS                             *
    DATA: V_FLAG TYPE C.                        "Flag to display the header
    DATA: V_REPID TYPE SY-REPID.
    *& INTERNAL TABLE DECLARATION                                          *
    DATA: BEGIN OF IT_VBAK OCCURS 0,
           VBELN LIKE VBAK-VBELN,
           AUDAT LIKE VBAK-AUDAT,
           AUART LIKE VBAK-AUART,
           NETWR LIKE VBAK-NETWR,
           EXPAND(1),
          END OF IT_VBAK.
    DATA: BEGIN OF IT_VBAP OCCURS 0,
           VBELN LIKE VBAP-VBELN,
           POSNR LIKE VBAP-POSNR,
           MATNR LIKE VBAP-MATNR,
           PSTYV LIKE VBAP-PSTYV,
           CHARG LIKE VBAP-CHARG,
         END OF IT_VBAP.
    DATA: IT_FLDCAT TYPE SLIS_T_FIELDCAT_ALV,
          IT_FLDCAT1 TYPE SLIS_T_FIELDCAT_ALV,
    *events
          IT_EVENTS TYPE SLIS_T_EVENT WITH HEADER LINE,
          V_CALL TYPE C,
          X_USER TYPE  SLIS_EXIT_BY_USER,
          IT_VARIANT LIKE  DISVARIANT OCCURS 0 WITH HEADER LINE,
          X_KEYINFO TYPE SLIS_KEYINFO_ALV,
    *layout
          X_LAYOUT TYPE SLIS_LAYOUT_ALV,
    *sort
          IT_SORT TYPE SLIS_T_SORTINFO_ALV,
          WA_SORT LIKE LINE OF IT_SORT,
          X_CAT TYPE SLIS_FIELDCAT_ALV,
          V_TABIX LIKE SY-TABIX.
          Selection screen Declaration
    *--BLOCK1
    SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
    SELECT-OPTIONS: S_VBELN FOR VBAK-VBELN,
                    S_AUART FOR VBAK-AUART.
    SELECTION-SCREEN END OF BLOCK B1.
    AT SELECTION-SCREEN                                                 *
    *- Validations
    AT SELECTION-SCREEN.
      PERFORM VALIDATE_SCREEN.
                  START OF SELECTION                                    *
    START-OF-SELECTION.
    *- To get data from VBAK
      PERFORM GET_DATA.
    *to get data from VBAP
      PERFORM GET_DATA_VBAP.
      PERFORM PREPARE_ALV.
                  END OF SELECTION                                    *
    END-OF-SELECTION.
      PERFORM DISPLAY_REPORT.
    *&      Form  VALIDATE_SCREEN
          text
    -->  p1        text
    <--  p2        text
    FORM VALIDATE_SCREEN .
      DATA: LV_VBELN LIKE VBAK-VBELN,
            LV_AUART LIKE VBAK-AUART.
      IF NOT S_VBELN[] IS INITIAL.
        SELECT VBELN
               INTO LV_VBELN
               FROM VBAK
               WHERE VBELN IN S_VBELN.
        ENDSELECT.
        IF SY-SUBRC <> 0.
          MESSAGE E000 WITH 'INVALID SALES DOC'(002).
        ENDIF.
      ENDIF.
      IF NOT S_AUART[] IS INITIAL.
        SELECT AUART
               INTO LV_AUART
               FROM VBAK
               WHERE AUART IN S_AUART.
        ENDSELECT.
        IF SY-SUBRC <> 0.
          MESSAGE E000 WITH 'INVALID SALES DOC TYPE'(003).
        ENDIF.
      ENDIF.
    ENDFORM.                    " VALIDATE_SCREEN
    *&      Form  GET_DATA
          text
    -->  p1        text
    <--  p2        text
    FORM GET_DATA .
      SELECT VBELN
             AUDAT
             AUART
             NETWR
             FROM VBAK
             INTO TABLE IT_VBAK
             WHERE VBELN IN S_VBELN
             AND AUART IN S_AUART.
      IF SY-SUBRC = 0.
        SORT IT_VBAK BY VBELN.
      ENDIF.
    ENDFORM.                    " GET_DATA
    *&      Form  GET_DATA_VBAP
          text
    -->  p1        text
    <--  p2        text
    FORM GET_DATA_VBAP .
      SELECT VBELN
             POSNR
             MATNR
             PSTYV
             CHARG
             INTO TABLE IT_VBAP
             FROM VBAP
             FOR ALL ENTRIES IN IT_VBAK
             WHERE VBELN = IT_VBAK-VBELN.
      IF SY-SUBRC = 0.
        SORT IT_VBAP BY VBELN POSNR.
      ENDIF.
    ENDFORM.                    " GET_DATA_VBAP
    *&      Form  prepare_alv
          text
    -->  p1        text
    <--  p2        text
    FORM PREPARE_ALV .
    Prepare field catalog .
      PERFORM PREPARE_CATALOG.
    Modify catalog
      PERFORM CHANGE_ATTR_OF_CATALOG.
    Modify Layout
      PERFORM MODIFY_LAYOUT.
    Sort Catalog
      PERFORM SORT_CATALOG.
    ENDFORM.                    " prepare_alv
    *&      Form  prepare_catalog
          text
    -->  p1        text
    <--  p2        text
    FORM PREPARE_CATALOG .
      CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
        EXPORTING
          I_PROGRAM_NAME         = SY-REPID
          I_INTERNAL_TABNAME     = 'IT_VBAK'
          I_INCLNAME             = SY-REPID
        CHANGING
          CT_FIELDCAT            = IT_FLDCAT1[]
        EXCEPTIONS
          INCONSISTENT_INTERFACE = 1
          PROGRAM_ERROR          = 2
          OTHERS                 = 3.
      IF SY-SUBRC <> 0.
        MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      APPEND LINES OF IT_FLDCAT1 TO IT_FLDCAT.
      CLEAR: IT_FLDCAT1[].
      CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
        EXPORTING
          I_PROGRAM_NAME         = SY-REPID
          I_INTERNAL_TABNAME     = 'IT_VBAP'
          I_INCLNAME             = SY-REPID
        CHANGING
          CT_FIELDCAT            = IT_FLDCAT1[]
        EXCEPTIONS
          INCONSISTENT_INTERFACE = 1
          PROGRAM_ERROR          = 2
          OTHERS                 = 3.
      IF SY-SUBRC <> 0.
        MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      APPEND LINES OF IT_FLDCAT1 TO IT_FLDCAT.
    ENDFORM.                    " prepare_catalog
    *&      Form  change_attr_of_catalog
          text
    -->  p1        text
    <--  p2        text
    FORM CHANGE_ATTR_OF_CATALOG .
      LOOP AT IT_FLDCAT INTO X_CAT.
        V_TABIX = SY-TABIX.
        CASE X_CAT-FIELDNAME.
          WHEN  'EXPAND'.
            IF X_CAT-TABNAME = 'IT_VBAK'.
              X_CAT-NO_OUT = 'X'.
            ENDIF.
         when  'VBELN'.
           if x_cat-tabname = 'IT_VBAK'.
             x_cat-no_out = 'X'.
           endif.
          WHEN  'VBELN'.
            IF X_CAT-TABNAME = 'IT_VBAK'.
              X_CAT-COL_POS   = '1'.
              X_CAT-SELTEXT_M = 'SALES DOC'.
              X_CAT-SELTEXT_L = 'SALES DOC'.
              X_CAT-SELTEXT_S = 'SALES DOC'.
              X_CAT-OUTPUTLEN = '10'.
            ENDIF.
          WHEN  'AUDAT'.
            IF X_CAT-TABNAME = 'IT_VBAK'.
              X_CAT-COL_POS   = '2'.
              X_CAT-SELTEXT_M = 'DOC DATE'.
              X_CAT-SELTEXT_L = 'DOC DATE'.
              X_CAT-SELTEXT_S = 'DOC DATE'.
              X_CAT-OUTPUTLEN = '8'.
            ENDIF.
          WHEN  'AUART'.
            IF X_CAT-TABNAME = 'IT_VBAK'.
              X_CAT-COL_POS   = '3'.
              X_CAT-SELTEXT_M = 'ORDER REASON'.
              X_CAT-SELTEXT_L = 'ORDER REASON'.
              X_CAT-SELTEXT_S = 'ORDER REASON'.
              X_CAT-OUTPUTLEN = '5'.
            ENDIF.
          WHEN  'NETWR'.
            IF X_CAT-TABNAME = 'IT_VBAK'.
              X_CAT-COL_POS   = '4'.
              X_CAT-SELTEXT_M = 'NET PRICE'.
              X_CAT-SELTEXT_L = 'NET PRICE'.
              X_CAT-SELTEXT_S = 'NET PRICE'.
              X_CAT-OUTPUTLEN = '15'.
            ENDIF.
        ENDCASE.
        MODIFY IT_FLDCAT FROM X_CAT.
        CLEAR X_CAT.
      ENDLOOP.
    ENDFORM.                    " change_attr_of_catalog
    *&      Form  modify_layout
          text
    -->  p1        text
    <--  p2        text
    FORM MODIFY_LAYOUT .
      X_LAYOUT-DEFAULT_ITEM = 'X'.
      X_LAYOUT-ZEBRA = 'X'.
      X_LAYOUT-EXPAND_FIELDNAME = 'EXPAND'.
    ENDFORM.                    " modify_layout
    *&      Form  sort_catalog
          text
    -->  p1        text
    <--  p2        text
    FORM SORT_CATALOG .
      CLEAR WA_SORT.
      WA_SORT-SPOS = '01'.
      WA_SORT-FIELDNAME = 'VBELN' .
      WA_SORT-TABNAME   = 'IT_VBAP'.
      WA_SORT-UP        = 'X'.
      APPEND WA_SORT TO IT_SORT.
      CLEAR  WA_SORT.
      WA_SORT-SPOS = '02'.
      WA_SORT-FIELDNAME = 'POSNR' .
      WA_SORT-TABNAME   = 'IT_VBAP'.
      WA_SORT-UP        = 'X'.
      APPEND WA_SORT TO IT_SORT.
    ENDFORM.                    " sort_catalog
    *&      Form  DISPLAY_REPORT
          text
    -->  p1        text
    <--  p2        text
    FORM DISPLAY_REPORT .
      IT_VARIANT-REPORT = SY-REPID.
      SORT IT_VBAK BY VBELN.
      SORT IT_VBAP BY VBELN POSNR.
      CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'
        EXPORTING
          I_CALLBACK_PROGRAM      = SY-REPID
          IS_LAYOUT               = X_LAYOUT
          IT_FIELDCAT             = IT_FLDCAT[]
          IT_SORT                 = IT_SORT
          IS_VARIANT              = IT_VARIANT
          IT_EVENTS               = IT_EVENTS[]
          I_TABNAME_HEADER        = 'IT_VBAK'
          I_TABNAME_ITEM          = 'IT_VBAP'
          IS_KEYINFO              = X_KEYINFO
        IMPORTING
          E_EXIT_CAUSED_BY_CALLER = V_CALL
          ES_EXIT_CAUSED_BY_USER  = X_USER
        TABLES
          T_OUTTAB_HEADER         = IT_VBAK
          T_OUTTAB_ITEM           = IT_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.
    ENDFORM.                    " DISPLAY_REPORT
    Regards,
    Laxmi.

  • What is alv report?

    hi guys, i would like to know the functionality of ALV reports.Please help me in this regard.
    reward points if answered.
    thanks in advance.

    Hi,
      ALV is ABAP LIST VIEWER.
    To have more functionalities like totals, subtotals,logos,etc we choose ALVs compared to reports.
    Check this:
    Documentation on alv:
    you can check out:
    http://www.****************/Tutorials/ALV/ALVMainPage.htm
    http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCSRVALV/BCSRVALV.pdf
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/e8a1d690-0201-0010-b7ad-d9719a415907
    http://help.sap.com/saphelp_nw2004s/helpdata/en/43/41341147041806e10000000a1553f6/frameset.htm
    ABAP List Viewer
    The common features of report are column alignment, sorting, filtering, subtotals, totals etc. To implement these, a lot of coding and logic is to be put. To avoid that we can use a concept called ABAP List Viewer (ALV).
    This helps us to implement all the features mentioned very effectively.
    Using ALV, We can have three types of reports:
    1. Simple Report
    2. Block Report
    3. Hierarchical Sequential Report
    There are some function modules which will enable to produce the above reports without much effort.
    All the definitions of internal tables, structures and constants are declared in a type-pool called SLIS.
    1. SIMPLE REPORT.
    The important function modules are
    a. Reuse_alv_list_display
    b. Reuse_alv_fieldcatalog_merge
    c. Reuse_alv_events_get
    d. Reuse_alv_commentary_write
    e. Reuse_alv_grid_display
    A. REUSE_ALV_LIST_DISPLAY : This is the function module which prints the data.
    The important parameters are :
    I. Export :
    i. I_callback_program : report id
    ii. I_callback_pf_status_set : routine where a user can set his own pf status or change the functionality of the existing pf status
    iii. I_callback_user_command : routine where the function codes are handled
    iv. I_structure name : name of the dictionary table
    v. Is_layout : structure to set the layout of the report
    vi. It_fieldcat : internal table with the list of all fields and their attributes which are to be printed (this table can be populated automatically by the function module REUSE_ALV_FIELDCATALOG_MERGE
    vii. It_events : internal table with a list of all possible events of ALV and their corresponding form names.
    II. Tables :
    i. t_outtab : internal table with the data to be output
    B. REUSE_ALV_FIELDCATALOG_MERGE : This function module is used to
    populate a fieldcatalog which is essential to display the data in ALV.
    If the output data is from a single dictionary table and all the
    columns are selected, then we need not exclusively create the field cat
    alog. Its enough to mention the table name as a parameter
    (I_structure name) in the REUSE_ALV_LIST_DISPLAY. But in other cases
    we need to create it.
    The Important Parameters are :
    I. Export :
    i. I_program_name : report id
    ii. I_internal_tabname : the internal output table
    iii. I_inclname : include or the report name where all the dynamic forms are handled.
    II Changing
    ct_fieldcat : an internal table with the type SLIS_T_FIELDCAT_ALV which is
    declared in the type pool SLIS.
    C. REUSE_ALV_EVENTS_GET : Returns table of possible events for a list type
    Parameters :
    I. Import :
    Et_Events : The event table is returned with all possible CALLBACK events
    for the specified list type (column 'NAME'). For events to be processed by Callback, their 'FORM' field must be filled. If the field is initialized, the event is ignored. The entry can be read from the event table, the field 'FORM' filled and the entry modified using constants from the type pool SALV.
    II. Export :
    I_List_type :
    0 = simple list REUSE_ALV_LIST_DISPLAY
    1 = hierarchcal-sequential list REUSE_ALV_HIERSEQ_LIST_DISPLAY
    2 = simple block list REUSE_ALV_BLOCK_LIST_APPEND
    3 = hierarchical-sequential block list
    REUSE_ALV_BLOCK_LIST_HS_APPEND
    D. REUSE_ALV_COMMENTARY_WRITE : This is used in the Top-of-page event to print the headings and other comments for the list.
    Parameters :
    I. it_list_commentary : internal table with the headings of the type slis_t_listheader.
    This internal table has three fields :
    Typ : ‘H’ – header, ‘S’ – selection , ‘A’ - action
    Key : only when typ is ‘S’.
    Info : the text to be printed
    E. REUSE_ALV_GRID_DISPLAY : A new function in 4.6 version, to display the results in grid rather than as a preview.
    Parameters : same as reuse_alv_list_display
    This is an example for simple list.
    2. BLOCK REPORT
    This is used to have multiple lists continuously.
    The important functions used in this report are:
    A. REUSE_ALV_BLOCK_LIST_INIT
    B. REUSE_ALV_BLOCK_LIST_APPEND
    C. REUSE_ALV_BLOCK_LIST_HS_APPEND
    D. REUSE_ALV_BLOCK_LIST_DISPLAY
    A. REUSE_ALV_BLOCK_LIST_INIT
    Parameters:
    I. I_CALLBACK_PROGRAM
    II. I_CALLBACK_PF_STATUS_SET
    III. I_CALLBACK_USER_COMMAND
    This function module is used to set the default gui status etc.
    B. REUSE_ALV_BLOCK_LIST_APPEND
    Parameters :
    Export :
    I. is_layout : layout settings for block
    II. it_fieldcat : field catalog
    III. i_tabname : internal table name with output data
    IV. it_events : internal table with all possible events
    Tables :
    i. t_outtab : internal table with output data.
    This function module adds the data to the block.
    Repeat this function for all the different blocks to be displayed one after the other.
    C. REUSE_ALV_BLOCK_LIST_HS_APPEND
    This function module is used for hierarchical sequential blocks.
    D. REUSE_ALV_BLOCK_LIST_DISPLAY
    Parameters : All the parameters are optional.
    This function module display the list with data appended by the above function.
    Here the functions REUSE_ALV_FIELDCATALOG_MERGE, REUSE_ALV_EVENTS_GET, REUSE_ALV_COMMENTARY_WRITE can be used.
    3. Hierarchical reports :
    Hierarchical sequential list output.
    The function module is
    A. REUSE_ALV_HIERSEQ_LIST_DISPLAY
    Parameters:
    I. Export:
    i. I_CALLBACK_PROGRAM
    ii. I_CALLBACK_PF_STATUS_SET
    iii. I_CALLBACK_USER_COMMAND
    iv. IS_LAYOUT
    v. IT_FIELDCAT
    vi. IT_EVENTS
    vii. i_tabname_header : Name of the internal table in the program containing the
    output data of the highest hierarchy level.
    viii. i_tabname_item : Name of the internal table in the program containing the
    output data of the lowest hierarchy level.
    ix. is_keyinfo : This structure contains the header and item table field
    names which link the two tables (shared key).
    II. Tables
    i. t_outtab_header : Header table with data to be output
    ii. t_outtab_item : Name of the internal table in the program containing the
    output data of the lowest hierarchy level.
    slis_t_fieldcat_alv : This internal table contains the field attributes. This internal table can be populated automatically by using ‘REUSE_ALV_FIELDCATALOG_MERGE’.
    Important Attributes :
    A. col_pos : position of the column
    B. fieldname : internal fieldname
    C. tabname : internal table name
    D. ref_fieldname : fieldname (dictionary)
    E. ref_tabname : table (dictionary)
    F. key(1) : column with key-color
    G. icon(1) : icon
    H. symbol(1) : symbol
    I. checkbox(1) : checkbox
    J. just(1) : (R)ight (L)eft (C)ent.
    K. do_sum(1) : sum up
    L. no_out(1) : (O)blig.(X)no out
    M. outputlen : output length
    N. seltext_l : long key word
    O. seltext_m : middle key word
    P. seltext_s : short key word
    Q. reptext_ddic : heading (ddic)
    R. ddictxt(1) : (S)hort (M)iddle (L)ong
    S. datatype : datatype
    T. hotspot(1) : hotspot
    some theory regarding alv:
    This table tells ALV which events are processed by the caller by CALLBACK.
    The table of possible events per list type can be initialized using the module REUSE_ALV_EVENTS_GET.
    You can display the names of the constants in the type pools SLIS which represent the individual events using the individual test function in the function module
    REUSE_ALV_EVENT_NAMES_GET. Only events with a form routine name are processed.
    The table structure contains the fields:
    • IT_EVENTS-NAME
    Name of the Callback event.
    Possible Callback events:
    • Action
    USER_COMMAND USING R_UCOMM LIKE SY-UCOMM RS_SELFIELD TYPE SLIS_SELFIELD
    Process actions on the list
    As this is a frequently-used Callback event, the form routine can also be passed directly in the interface in the IMPORTING parameter I_CALLBACK_USER_COMMAND.
    PF_STATUS_SET USING RT_EXTAB TYPE SLIS_T_EXTAB
    If a user list status is to be set, it must be done in the form routine assigned to this event. The ALV function codes, which must not be active, are in the Parameter RT_EXTAB. This table must be passed with the SET PF-STATUS command (with inactive user function codes as well, if necessary).
    The STANDARD status of the function group SALV should be used as a template for a user-specific status.
    As this is a frequently-used Callback event, its form routine can also be passed directly in the interface in the IMPORTING parameter I_CALLBACK_PF_STATUS_SET.
    ITEM_DATA_EXPAND USING RS_SELFIELD TYPE SLIS_SELFIELD RFLG_ALL TYPE C
    Only relevant for hierarchical-sequential lists using the layout parameter IS_LAYOUT-EXPAND_FIELDNAME of the structure IS_LAYOUT.
    Exit for passing item entries (ITEM table) for a header record which was expanded interactively by the user.
    RS_SELFIELD-TABINDEX contains the header table index for which the item entries are to be put in the global item output table (T_OUTTAB_SLAVE). The Callback is only called if ALV has no items for a header which is to be expanded.
    RFLG_ALL is passed with 'X' if the user shows all items. The application must ensure that entries are not repeated in the item table. RS_SELFIELD is initial in this case.
    CALLER_EXIT USING RS_DATA Is called at the beginning of the function module to make special settings. It is not usually used.
    • List processing events
    IMPORTANT: The application Callback routine must not manipulate the internal output table and/or its header record. This restriction applies to all Callbacks which are called in the list output and run under the 'List processing events'.
    TOP_OF_LIST no USING parameter. Information output at the start of the list
    END_OF_LIST no USING parameter. Information output at the end of the list
    TOP_OF_PAGE no USING parameter
    Equivalent to the list processing TOP-OF-PAGE event
    END_OF_PAGE no USING parameter. Not available for hierarchical-sequential lists.
    Information output at the end of a page. This is only called for printing.
    TOP_OF_COVERPAGE no USING parameter
    The selection information and list status are output together (if they exist) on a separate page by default. See also the documentation of the parameters:
    IS_PRINT-NO_COVERPAGE
    IS_PRINT-NO_PRINT_SELINFOS
    IS_PRINT-NO_PRINT_LISTINFOS
    IS_LAYOUT-GET_SELINFOS
    The user can format the header area of the 'cover page' himself or herself by specifying a Callback routine for this event.
    END_OF_COVERPAGE no USING parameter
    Analogously to TOP_OF_COVERPAGE the user can add other information to the information output by ALV (selection information, list status) at this event.
    FOREIGN_TOP_OF_PAGE no USING parameter
    The Top-of-page event is always processed in ALV and is only passed to the caller via the Callback mechanism. This is still the case if the caller, e.g. by a user action, processes a branch list which was not formatted by ALV (e.g. a popup with additional information about the list record selected and displayed by ALV).
    In this case, top-of-page cannot be formatted by ALV analogously to the basic list, it must be handled completely by the caller. The event top-of-page still occurs in ALV. When ALV notices a top-of-page which was not caused by an ALV output, the form routine in FOREIGN_TOP_OF_PAGE is called.
    FOREIGN_END_OF_PAGE no USING parameter
    The event end-of-page is always processed in ALV and only passed to the caller via callback. This is still the case, e.g. when the caller processes a details list which was not formatted by ALV (e.g. a popup with further information about selected list records which were displayed by ALV).
    In this case, end-of-page cannot be formatted by ALV analogously to the basic list, it must be handled completely by the caller. The event end-of-page still occurs in ALV. When ALV notices an end-of-page that was not caused by an ALV output, the form routine in FOREIGN_END_OF_PAGE is called.
    BEFORE_LINE_OUTPUT USING RS_LINEINFO TYPE SLIS_LINEINFO
    Output information before each output line. Should only be used in justified cases because it costs a lot of performance.
    AFTER_LINE_OUTPUT USING RS_LINEINFO TYPE SLIS_LINEINFO
    Output information after each output line. Should only be used in justified cases because it costs a lot of performance.
    • Internal use only
    LIST_MODIFY USING R_TABNAME TYPE SLIS_TABNAME
    R_INDEX LIKE SY-TABIX
    R_INDEX_ITEM LIKE SY-TABIX
    R_INDEX_SUM LIKE SY-TABIX
    • IT_EVENTS-FORM
    Name of the form routine which should be called in the calling program at the event.
    Field_catalog:
    Field catalog with field descriptions
    2.7.1. Description
    Field catalog containing descriptions of the list output fields (usually a subset of the internal output table fields). A field catalog is required for every ALV list output.
    The field catalog for the output table is built-up in the caller's coding. The build-up can be completely or partially automated by calling the REUSE_ALV_FIELDCATALOG_MERGE module
    See also the documentation of the function module REUSE_ALV_FIELDCATALOG_MERGE.
    The minimal field catalog is documented under 'default'. The caller can use the other optional parameters to assign output attributes to a field which differ from the default.
    A field catalog need not be built-up and passed explicitly only under the following conditions:
    • The internal table to be output has the same structure as a Data Dictionary structure which is referred to in the internal table declaration using LIKE or INCLUDE STRUCTURE.
    • all fields in this structure are to be output
    • the structure name is passed to ALV in the parameter I_STRUCTURE_NAME.
    See also the documentation of the IMPORTING paramter I_STRUCTURE_NAME.
    Positioning
    • row_pos (row position)
    value set: 0, 1 - 3
    Only relevant if the list output is to be multi-line (two or three lines) by default.
    A multi-line list can also be defined by the user interactively if the default list is one-line.
    The parameter specifies the relative output line of the column in a multi-line list.
    • col_pos (column position)
    value set: 0, 1 - 60
    only relevant when the default relative column positions differ from the field catalog field sequence. The parameter specifies the relative column position of the field in the list output. The column order can be changed interactively by the user. If this parameter is initial for all field catalog entries, columns appear in the field catalog field sequence.
    Identification
    • fieldname (field name)
    value set: internal output table field name (required parameter)
    Name of the internal output table field which is described by this field catalog entry
    • tabname (internal output table)
    value set: SPACE, internal output table name
    This parameter is used in 'manual' field catalog build-up only for hierarchical-sequential lists.
    Name of the internal output table which contains the field FIELDCAT-FIELDNAME.
    Data Dictionary reference
    • ref_fieldname (reference field name)
    value set: SPACE, Data Dictionary field name
    Name of the Data Dictionary field referred to.
    This parameter is only used when the internal output table field described by the current field catalog entry has a reference to the Data Dictionary (not a program field), and the field name in the internal output table is different from the name of the field in the Data Dictionary. If the field names are identical, naming the Data Dictionary structure or table in the FIELDCAT-REF_TABNAME parameter is sufficient.
    • ref_tabname (reference table/structure field name)
    value set: SPACE, name of a Data Dictionary structure or table
    Structure or table name of the referred Data Dictionary field.
    This parameter is only used when the internal output table field described by the current field catalog entry has a Data Dictionary reference (not a program field).
    Reference to fields with currency/measurement unit
    Each internal output table sum or quantity field whose decimal places are to be formatted appropriately for the unit in the list must follow the convention:
    • the field is of data type QUAN or CURR (internal type P) (the field must really have this physical data type. Overwriting the physical data type with the parameter FIELDCAT-DATATYPE has no effect)
    • There is a field in the internal output table which contains the associated unit.
    • There is also an entry in the field catalog for the unit field.
    (If the unit is not to appear as a column in the list, and cannot be interactively displayed as a column, e.g. because it is always unambiguous and is therefore explicitly output by the caller in the list header, the field catalog units field entry can take the parameter FIELDCAT-TECH = 'X'.
    The association of a value field to a unit affects the output as follows:
    • appropriate decimal places display for the unit
    • an initialized field with a link to a non-initial unit is output as '0' for the unit (if FIELDCAT-NO_ZERO is initial). When this field is summed, this unit affects whether the units are homogeneous.
    • an initialized field with a link to an initial unit is output as SPACE. When this field is summed, the unit SPACE does not affect the homogeneity of the units.
    • When non-initial fields with an initial unit are summed, the unit SPACE is considered to be a unit.
    Link to currency unit
    • cfieldname (currency unit field name)
    value set: SPACE, output table field name
    Only relevant for amount columns with associated unit.
    Name of the internal output table field containing the currency unit associated with the amount field FIELDCAT-FIELDNAME. The field in FIELDCAT-CFIELDNAME must have its own field catalog entry.
    • ctabname (internal currency unit field output table)
    value set: SPACE, output table field name
    only relevant for hierarchical-sequential lists
    Name of the internal output table containing the FIELDCAT-CFIELDNAME field.
    Link to measurement unit
    • qfieldname (measurement unit field name)
    value set: SPACE, output table field name
    only relevant for quantity columns with unit link.
    Name of the internal output table field containing the measurement unit associated with the quantity field FIELDCAT-FIELDNAME.
    The field in FIELDCAT-QFIELDNAME must have its own field catalog entry.
    • qtabname (internal measurement unit field output table)
    value set: SPACE, output table field name
    only relevant for hierarchical-sequential lists
    Name of the internal output table containing the FIELDCAT-QFIELDNAME field.
    Column output options
    • outputlen (column width)
    value set: 0 (initial), n
    For fields with a Data Dictionary link this parameter can be left initial.
    For fields without a Data Dictionary link (program field) the parameter must be given the value of the desired field list output length (column width).
    initial = column width is the output length of the referred Data Dictionary field (domain).
    n = column width is n characters
    • key (key column)
    value set: SPACE, 'X' 'X' = kex field (key field output in color)
    Key fields can not be interactively hidden. Parameter FIELDCAT-NO_OUT must be left initial.
    For exceptions see the documentation of the FIELDCAT-KEY_SEL parameter.
    • key_sel (hideable key column)
    value set: SPACE, 'X'
    only relevant when FIELDCAT-KEY = 'X'
    Key field which can be hidden interactively.
    The key column sequence cannot be changed interactively by the user.
    The output is controlled by the FIELDCAT-NO_OUT parameter analogously to non-key fields.
    • no_out (field in field list)
    value set: SPACE, 'X' 'X' = field is not displayed in the current list.
    The user can interactively choose the field for output from the field list.
    The user can display the contents of these fields at line level using the 'Detail' function.
    See also the 'Detail screen' documentation of the parameter IS_LAYOUT.
    • tech (technical field)
    value set: SPACE, 'X' 'X' = technical field
    Field cannot be output in the list and cannot be displayed interactively.
    Field can only be used in the field catalog (not in IT_SORT, ...).
    • emphasize (highlight columns in color)
    value set: SPACE, 'X' or 'Cxyz' (x:'1'-'9'; y,z: '0'=off '1'=on)
    'X' = column is colored with the default column highlight color.
    'Cxyz' = column is colored with a coded color:
    • C: Color (coding must begin with C)
    • x: color number
    • y: bold
    • z: inverse
    • hotspot (column as hotspot)
    value set: SPACE, 'X'
    'X' = column cells are output as hotspots
    • fix_column (fix column)
    value set: SPACE, 'X'
    Not relevant for block lists (output of several lists consecutively)
    'X' = column fixed (does not scroll horizontally)
    All columns to be fixed must have this flag, starting from the left. If a column without this flag is output, only the columns to the left of this column are fixed. The user can change the column fixing interactively. See also the documentation of the Layout parameter
    IS_LAYOUT-NO_KEYFIX of the IMPORTING paramter IS_LAYOUT.
    • do_sum (sum over column)
    value set: SPACE, 'X' 'X' = a sum is to be calculated over this internal output table field.
    This function can also be called by the user interactively.
    • no_sum (sums forbidden)
    value set: SPACE, 'X' 'X' = no sum can be calculated over this field, although the data type of the field would allow summing.
    • input (column ready for input)
    Function not available
    Format column contents
    • icon
    value set: SPACE, 'X' 'X' = column contents to be output as an icon.
    The caller must consider the printability of icons.
    • symbol
    value set: SPACE, 'X' 'X' = column contents are to be output as a symbol.
    The internal output table column must be a valid symbol character.
    The caller must consider the printability of symbols.
    Symbols can usually be printed, but may not always be output correctly, depending on the printer configuration.
    • just (justification)
    value set: SPACE, 'R', 'L', 'C'
    Only relevant for fields of data type CHAR or NUMC
    ' ' = default justification for this data type
    'R' = right-justified output
    'L' = left-justified output
    'C' = centered output
    The justification of the column header always follows the justification of the columns. Independent justification of the column neader is not possible.
    • lzero (leading zeros)
    value set: SPACE, 'X'
    Only relevant for fields of data type NUMC
    ALV outputs NUMC fields right-justified without leading zeros by default.
    'X' = output with leading zeros
    Note: If a NUMC field is output left-justified or centered by FIELDCAT-JUST, leading zeros are output. If the output of leading zeros is suppressed by a Data Dictionary reference ALPHA conversion exit, the output is always left-justified.
    • no_sign (no +/- sign) Only relevant for value fields
    value set: SPACE, 'X' 'X' = value output without +/ sign
    • no_zero (suppress zeros) Only relevant for value fields
    value set: SPACE, 'X' 'X' = suppress zeros
    • edit_mask (field formatting)
    value set: SPACE, template
    template = see documentation of WRITE formatting option USING EDIT MASK template
    The output conversion conv can be made by template = '== conv'.
    Texts
    The following text parameters should be specified for program fields without a Data Dictionary reference. The texts are taken from the Data Dictionary for fields with a Data Dictionary reference. If this is not desired, the text parameters can also be specified. The Data Dictionary texts are then ignored. If the user changes the column width interactively, the column header text with the appropriate length is always used. The interactive function 'Optimize column width' takes account of both the field contents and the column headers: if all field contents are shorter than the shortest column header, the column width depends on the column header.
    The 'long field label' is also used in display variant definition, sort, etc. popups.
    • seltext_l (long field label)
    • seltext_m (medium field label)
    • seltext_s (short field label)
    • reptext_ddic (header)
    analogous to the Data element maintenance 'Header'
    The specified text is not necessarily output in the list, an optimum among all texts is sought.
    • ddictxt (specify text)
    value set: SPACE, 'L', 'M', 'S'
    You can specify with values 'L', 'M', and 'S', the keyword that should always be used as column header. If the column width changes, no attempt is made in this case to find an appropriate header for the new output width.
    Parameters for program fields without Data Dictionary reference
    see also 'Text' parameters
    • datatype (data type)
    value set: SPACE, Data Dictionary data type (CHAR, NUMC,...)
    Only relevant for fields without Data Dictionary reference
    Program field data type
    • ddic_outputlen (external output length)
    value set: 0 (initial), n
    Only relevant for fields without Data Dictionary reference whose output is nevertheless to be modified by a conversion exit.
    Prerequisites:
    • FIELDCAT-EDIT_MASK = '==conv'
    see also the documentation of the parameter FIELDCAT-EDIT_MASK
    • FIELDCAT-INTLEN = n
    see also the documentation of the parameter FIELDCAT-INTLEN
    n = external format field output length
    The column width FIELDCAT-OUTPUTLEN need not be the same as the external format output length (FIELDCAT-DDIC_OUTPUTLEN).
    • intlen (internal output length)
    value set: 0 (initial), n
    Only relevant for fields without Data Dictionary reference whose output is nevertheless to be modified by a conversion exit.
    Prerequisites:
    • FIELDCAT-EDIT_MASK = '==conv'
    see also the documentation of the parameter FIELDCAT-EDIT_MASK
    • FIELDCAT-DDIC_OUTPUTLEN = n
    see also the documentation of the parameter FIELDCAT-DDIC_OUTPUTLEN
    n = internal format field output length
    • rollname (data element)
    value set: SPACE, Data Dictionary data element name
    F1 help can be provided for a program field without a Data Dictionary reference, or F1 help which differs from the Data Dictionary help can be provided for a field with a Data Dictionary reference, using this parameter.
    When F1 help is called for this field, the documentation of the specified data element is displayed.
    If the FIELDCAT-ROLLNAME is initial for fields with a Data Dictionary reference, the documentation of the data element of the referred Data Dictionary field is output.
    Others
    • sp_group (field group key)
    value set: SPACE, CHAR(1)
    Field group key.
    Keys are assigned to group names in the IT_SPECIAL_GROUPS parameter (see also the documentation of the parameter IT_SPECIAL_GROUPS).
    When such an assignment is made in the field catalog and in IT_SPECIAL_GROUPS, the fields are grouped correspondingly in the display variant popup.
    • reprep (Report/Report interface selection criterion)
    value set: SPACE, 'X'
    Prerequisites:
    • The system contains the Report/Report interface (function group RSTI, table TRSTI)
    • Parameter LAYOUT-REPREP = 'X'
    (see also the documentation of the parameter LAYOUT-REPREP of the IMPORTING parameter IS_LAYOUT )
    'X' = When the Report/Report interface is called, the value of this field is passed in the selected interface start record as a selection criterion.
    2.7.2. Default
    • The following entries are usually sufficient for internal table fields with a reference to a field defined in the Data Dictionary :
    • fieldname
    • ref_tabname
    Notes:
    ALV gets the remaining information from the Data Dictionary.
    If no relative column position (COL_POS) is specified, the fields are output in the list in the order in which they were added to the field catalog.
    REF_FIELDNAME need only be specifid when the name of the internal table field differs from the name of the referred Data Dictionary field.
    Information which is explicitly entered in the field catalog is not overwritten by information from the Data Dictionary.
    Priority rule:
    Entries in the field catalog have priority over differing entries in the Data Dictionary.
    • The following entries are usually sufficient for internal table fields without a reference to the Data Dictionary (program fields):
    • fieldname
    • outputlen
    • datatype
    • seltext_s
    • seltext_m
    • seltext_l
    Notes:
    F1 help can be provided for program fields by assigning a data element to the parameter ROLLNAME.
    If the parameters SELTEXT_S, SELTEXT_M, SELTEXT_L, and REPTEXT_DDIC contain appropriate field labels, the program field column headers are also adjusted appropriately when the column width changes
    sites :
    http://www.sapdevelopment.co.uk/reporting/alv/alv_variousfcat.htm
    Check out these links : top one is on slis specifcally,
    How to know about these SLIS types?
    Re: sap alv examples
    ALV reporting - Step by step
    http://help.sap.com/saphelp_nw04/helpdata/en/8d/e994374c9cd355e10000009b38f8cf/frameset.htm
    Go through with these links :
    ALV
    http://www.geocities.com/mpioud/Abap_programs.html
    ALV Group Heading
    http://www.sap-img.com/fu037.htm
    ALVGRID with refresh
    http://www.geocities.com/mpioud/Z_DEMO_ALV_REFRESH_BUTTON.htm
    Editable ALV
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webas/abap/abap%20code%20samples/alv%20grid/abap%20code%20sample%20to%20edit%20alv%20grid.doc
    -->download the PDF from following link.
    www.abap4.it/download/ALV.pdf
    http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCSRVALV/BCSRVALV.pdf
    OOPS ALV tutorial.
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/e8a1d690-0201-0010-b7ad-d9719a415907
    Sample programs:
    http://www.geocities.com/victorav15/sapr3/abap_ood.html#d_grid
    http://www.sapdevelopment.co.uk/reporting/alv/alvgrid_color.htm
    http://www.sapdevelopment.co.uk/reporting/alvhome.htm
    You can get all demo programs for ALV:
    Go to se38 and type BCALV* and press F4 for all demo porgrams.
    Check out these links
    http://www.sap-img.com/abap/what-is-alv-programming.htm
    https://www.sdn.sap.com/irj/sdn/wiki?path=/display/home/alv&
    http://www.sap-img.com/abap/an-interactive-alv-report.htm
    https://www.sdn.sap.com/irj/sdn/weblogs?blog=/cs/user/view/cs_msg/18628
    Regards

  • Merge row in ALV

    hello everyone, im having a problem woth my ALV, how can i merge rows in ALV,
    example i want to merge row 3 and row 4?
    Another 1 how can I format a certain row in ALV?
    example row 5, I want the displayed value be centered, or right aligned, or left aligned...
    thank you very much

    Christopher,
    I am not sure what is the functionality you are trying to achieve by merging rows. If you SORT the rows, there should be a option (Iam not sure whether it is in the field catalog or the layout most probably in the layout), where the rows with the same for specific columns will automatically get merged. However, it does not make sense if the entire row is duplicated. You probably can delete the adjacent duplicates by sorting the table even before displaying the data.
    I am not sure the formatting that you are asking, but you can trying passing different values to LVC_T_STYLE type table which has to be a part of you data internal table. So, for a specific row, you append the column names and the specific style that you want for individual columns.
    Regards,
    Ravi
    Note : Please reward points if this helps you.

  • ALV F8 event + Checkbox?

    Hi,
    1. How to catch F8 event in an ALV?
    2. How to determine witch checkbox is checked.
    tnx!
    Simple ALV example:
    TYPE-POOLS: slis.
    DATA: g_repid LIKE sy-repid,
    gs_print            TYPE slis_print_alv,
    gt_list_top_of_page TYPE slis_t_listheader,
    gt_events           TYPE slis_t_event,
    gt_sort             TYPE slis_t_sortinfo_alv,
    gs_layout           TYPE slis_layout_alv,
    gt_fieldcat         TYPE slis_t_fieldcat_alv,
    fieldcat_ln LIKE LINE OF gt_fieldcat,
    col_pos TYPE i.
    DATA: BEGIN OF itab,
    sel,
      field1(5) TYPE c,
      field2(5) TYPE c,
      field3(5) TYPE p DECIMALS 2,
    END OF itab.
    DATA: BEGIN OF itab1 OCCURS 0.
            INCLUDE STRUCTURE itab.
    DATA: END OF itab1.
    DATA: BEGIN OF itab_fieldcat OCCURS 0.
            INCLUDE STRUCTURE itab.
    DATA: END OF itab_fieldcat.
    INITIALIZATION.
      g_repid = sy-repid.
    " PERFORM print_build    USING gs_print.      "Print PARAMETERS
      gs_layout-box_fieldname = 'SEL'.
    START-OF-SELECTION.
    * TEST DATA
      MOVE 'TEST1' TO itab1-field1.
      MOVE 'TEST1' TO itab1-field2.
      MOVE '10.00' TO itab1-field3.
      APPEND itab1.
      MOVE 'TEST2' TO itab1-field1.
      MOVE 'TEST2' TO itab1-field2.
      MOVE '20.00' TO itab1-field3.
      APPEND itab1.
      DO 5 TIMES.
        APPEND itab1.
      ENDDO.
    END-OF-SELECTION.
      PERFORM build.
      PERFORM call_alv.
    *&      Form  BUILD
    *       text
    FORM build.
    * DATA FIELD CATALOG
    * Explain Field Description to ALV
      DATA: fieldcat_in TYPE slis_fieldcat_alv.
      CLEAR fieldcat_in.
      fieldcat_ln-fieldname = 'FIELD1'.
      fieldcat_ln-tabname   = 'ITAB1'.
    *FIELDCAT_LN-NO_OUT    = 'X'.  "FIELD NOT DISPLAY, CHOOSE FROM LAYOUT
      fieldcat_ln-key       = ' '.   "SUBTOTAL KEY
      fieldcat_ln-no_out    = ' '.
      fieldcat_ln-seltext_l = 'HEAD1'.
      APPEND fieldcat_ln TO gt_fieldcat.
      CLEAR fieldcat_in.
      fieldcat_ln-fieldname = 'FIELD2'.
      fieldcat_ln-tabname   = 'ITAB1'.
      fieldcat_ln-no_out    = 'X'.
      fieldcat_ln-seltext_l = 'HEAD2'.
      APPEND fieldcat_ln TO gt_fieldcat.
      CLEAR fieldcat_in.
      fieldcat_ln-fieldname     = 'FIELD3'.
      fieldcat_ln-tabname       = 'ITAB1'.
      fieldcat_ln-ref_fieldname = 'MENGE'. "<- REF FIELD IN THE DICTIONNARY
      fieldcat_ln-ref_tabname   = 'MSEG'.  "<- REF TABLE IN THE DICTIONNARY
      fieldcat_ln-no_out        = ' '.
      fieldcat_ln-do_sum        = 'X'.   "SUM UPON DISPLAY
      APPEND fieldcat_ln TO gt_fieldcat.
    * DATA SORTING AND SUBTOTAL
      DATA: gs_sort TYPE slis_sortinfo_alv.
      CLEAR gs_sort.
      gs_sort-fieldname = 'FIELD1'.
      gs_sort-spos      = 1.
      gs_sort-up        = 'X'.
      gs_sort-subtot    = 'X'.
      APPEND gs_sort TO gt_sort.
      CLEAR gs_sort.
      gs_sort-fieldname = 'FIELD2'.
      gs_sort-spos      = 2.
      gs_sort-up        = 'X'.
    *GS_SORT-SUBTOT    = 'X'.
      APPEND gs_sort TO gt_sort.
    ENDFORM.                    "BUILD
    *&      Form  CALL_ALV
    *       text
    FORM call_alv.
    * ABAP List Viewer
      CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
      EXPORTING
      i_callback_program = g_repid
    * I_CALLBACK_PF_STATUS_SET = ' '
    * I_CALLBACK_USER_COMMAND = ' '
      i_structure_name = 'ITAB1'
      is_layout =  gs_layout
      it_fieldcat = gt_fieldcat[]
        it_sort = gt_sort[]
        it_events = gt_events[]
        is_print = gs_print
      TABLES
      t_outtab = itab1
      EXCEPTIONS
      program_error = 1
      OTHERS = 2.
    ENDFORM.                    "CALL_ALV

    Hi,
    stil not working..:(
    Please, could you use my code and fil up with yours?
    TYPE-POOLS: slis.
    DATA: g_repid LIKE sy-repid,
    gs_print            TYPE slis_print_alv,
    gt_list_top_of_page TYPE slis_t_listheader,
    gt_events           TYPE slis_t_event,
    gt_sort             TYPE slis_t_sortinfo_alv,
    gs_layout           TYPE slis_layout_alv,
    gt_fieldcat         TYPE slis_t_fieldcat_alv,
    fieldcat_ln LIKE LINE OF gt_fieldcat,
    col_pos TYPE i.
    DATA: BEGIN OF itab,
    sel,
      field1(5) TYPE c,
      field2(5) TYPE c,
      field3(5) TYPE p DECIMALS 2,
    END OF itab.
    DATA: BEGIN OF itab1 OCCURS 0.
            INCLUDE STRUCTURE itab.
    DATA: END OF itab1.
    DATA: BEGIN OF itab_fieldcat OCCURS 0.
            INCLUDE STRUCTURE itab.
    DATA: END OF itab_fieldcat.
    INITIALIZATION.
      g_repid = sy-repid.
      " PERFORM print_build    USING gs_print.      "Print PARAMETERS
      gs_layout-box_fieldname = 'SEL'.
    START-OF-SELECTION.
    * TEST DATA
      MOVE 'TEST1' TO itab1-field1.
      MOVE 'TEST1' TO itab1-field2.
      MOVE '10.00' TO itab1-field3.
      APPEND itab1.
      MOVE 'TEST2' TO itab1-field1.
      MOVE 'TEST2' TO itab1-field2.
      MOVE '20.00' TO itab1-field3.
      APPEND itab1.
      DO 5 TIMES.
        APPEND itab1.
      ENDDO.
      gs_layout-get_selinfos = 'X'.
    END-OF-SELECTION.
      PERFORM build.
      PERFORM call_alv.
    *&      Form  BUILD
    *       text
    FORM build.
    * DATA FIELD CATALOG
    * Explain Field Description to ALV
      DATA: fieldcat_in TYPE slis_fieldcat_alv.
      CLEAR fieldcat_in.
      fieldcat_ln-fieldname = 'FIELD1'.
      fieldcat_ln-tabname   = 'ITAB1'.
    *FIELDCAT_LN-NO_OUT    = 'X'.  "FIELD NOT DISPLAY, CHOOSE FROM LAYOUT
      fieldcat_ln-key       = ' '.   "SUBTOTAL KEY
      fieldcat_ln-no_out    = ' '.
      fieldcat_ln-seltext_l = 'HEAD1'.
      APPEND fieldcat_ln TO gt_fieldcat.
      CLEAR fieldcat_in.
      fieldcat_ln-fieldname = 'FIELD2'.
      fieldcat_ln-tabname   = 'ITAB1'.
      fieldcat_ln-no_out    = 'X'.
      fieldcat_ln-seltext_l = 'HEAD2'.
      APPEND fieldcat_ln TO gt_fieldcat.
      CLEAR fieldcat_in.
      fieldcat_ln-fieldname     = 'FIELD3'.
      fieldcat_ln-tabname       = 'ITAB1'.
      fieldcat_ln-ref_fieldname = 'MENGE'. "<- REF FIELD IN THE DICTIONNARY
      fieldcat_ln-ref_tabname   = 'MSEG'.  "<- REF TABLE IN THE DICTIONNARY
      fieldcat_ln-no_out        = ' '.
      fieldcat_ln-do_sum        = 'X'.   "SUM UPON DISPLAY
      APPEND fieldcat_ln TO gt_fieldcat.
    * DATA SORTING AND SUBTOTAL
      DATA: gs_sort TYPE slis_sortinfo_alv.
      CLEAR gs_sort.
      gs_sort-fieldname = 'FIELD1'.
      gs_sort-spos      = 1.
      gs_sort-up        = 'X'.
      gs_sort-subtot    = 'X'.
      APPEND gs_sort TO gt_sort.
      CLEAR gs_sort.
      gs_sort-fieldname = 'FIELD2'.
      gs_sort-spos      = 2.
      gs_sort-up        = 'X'.
    *GS_SORT-SUBTOT    = 'X'.
      APPEND gs_sort TO gt_sort.
    ENDFORM.                    "BUILD
    *&      Form  CALL_ALV
    *       text
    FORM call_alv.
    * ABAP List Viewer
      CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
      EXPORTING
      i_callback_program = g_repid
    * I_CALLBACK_PF_STATUS_SET = ' '
      i_callback_user_command = 'form_user'
      i_structure_name = 'ITAB1'
      is_layout =  gs_layout
      it_fieldcat = gt_fieldcat[]
      it_sort = gt_sort[]
      it_events = gt_events[]
      is_print = gs_print
      TABLES
      t_outtab = itab1
      EXCEPTIONS
      program_error = 1
      OTHERS = 2.
    ENDFORM.                    "CALL_ALV
    *&      Form  form_user
    *       text
    FORM form_user.
      CASE sy-ucomm.
        WHEN 'ENTER' OR 'SPACE'.                                " for F8
    ***do coding
      ENDCASE.
    ENDFORM.                    "form_user

  • What is the procedure to create field catalog in alv

    what is the procedure to create field catalog in alv?
    with a example please.

    Hi,
    U can use the function module REUSE_ALV_FIELDCAT_MERGE...If we use a structure that is exactly
    identical to the datadictionary other wise u hav to hard code as in the following example.
    **ALV EXAMPLE
    *& Report  ZJE_ALV_EXAMPLE
    REPORT  zje_alv_example.
    TYPE-POOLS: slis.
    *type declaration for values from ekko
    TYPES: BEGIN OF i_ekko,
              ebeln LIKE ekko-ebeln,
              aedat LIKE ekko-aedat,
              bukrs LIKE ekko-bukrs,
              bsart LIKE ekko-bsart,
              lifnr LIKE ekko-lifnr,
           END OF i_ekko.
    *type declaration for values from ekpo
    TYPES: BEGIN OF i_ekpo,
              ebeln LIKE ekpo-ebeln,
              ebelp LIKE ekpo-ebelp,
              matnr LIKE ekpo-matnr,
              menge LIKE ekpo-menge,
              meins LIKE ekpo-meins,
              netpr LIKE ekpo-netpr,
           END OF i_ekpo.
    DATA: it_ekko TYPE STANDARD TABLE OF i_ekko INITIAL SIZE 0,
          wa_ekko TYPE i_ekko.
    DATA: it_ekpo TYPE STANDARD TABLE OF i_ekpo INITIAL SIZE 0,
          wa_ekpo TYPE i_ekpo .
    *variable for Report ID
    DATA: v_repid LIKE sy-repid .
    *declaration for fieldcatalog
    DATA: i_fieldcat TYPE slis_t_fieldcat_alv,
          wa_fieldcat TYPE slis_fieldcat_alv.
    DATA: it_listheader TYPE slis_t_listheader.
    declaration for events table where user comand or set PF status will
    be defined
    DATA: v_events TYPE slis_t_event,
          wa_event TYPE slis_alv_event.
    declartion for layout
    DATA: alv_layout TYPE slis_layout_alv.
    declaration for variant(type of display we want)
    DATA: i_variant TYPE disvariant,
          i_variant1 TYPE disvariant,
          i_save(1) TYPE c.
    *PARAMETERS : p_var TYPE disvariant-variant.
    *Title displayed when the alv list is displayed
    DATA: i_title_ekko TYPE lvc_title VALUE 'FIRST LIST DISPLAYED'.
    DATA: i_title_ekpo TYPE lvc_title VALUE 'SECONDRY LIST DISPLAYED'.
    INITIALIZATION.
      v_repid = sy-repid.
      PERFORM build_fieldcatlog.
      PERFORM event_call.
      PERFORM populate_event.
    START-OF-SELECTION.
      PERFORM data_retrieval.
      PERFORM build_listheader USING it_listheader.
      PERFORM display_alv_report.
    *& Form BUILD_FIELDCATLOG
    Fieldcatalog has all the field details from ekko
    FORM build_fieldcatlog.
      wa_fieldcat-tabname = 'IT_EKKO'.
      wa_fieldcat-fieldname = 'EBELN'.
      wa_fieldcat-seltext_m = 'PO NO.'.
      APPEND wa_fieldcat TO i_fieldcat.
      CLEAR wa_fieldcat.
      wa_fieldcat-tabname = 'IT_EKKO'.
      wa_fieldcat-fieldname = 'AEDAT'.
      wa_fieldcat-seltext_m = 'DATE.'.
      APPEND wa_fieldcat TO i_fieldcat.
      CLEAR wa_fieldcat.
      wa_fieldcat-tabname = 'IT_EKKO'.
      wa_fieldcat-fieldname = 'BUKRS'.
      wa_fieldcat-seltext_m = 'COMPANY CODE'.
      APPEND wa_fieldcat TO i_fieldcat.
      CLEAR wa_fieldcat.
      wa_fieldcat-tabname = 'IT_EKKO'.
      wa_fieldcat-fieldname = 'BUKRS'.
      wa_fieldcat-seltext_m = 'DOCMENT TYPE'.
      APPEND wa_fieldcat TO i_fieldcat.
      CLEAR wa_fieldcat.
      wa_fieldcat-tabname = 'IT_EKKO'.
      wa_fieldcat-fieldname = 'LIFNR'.
      wa_fieldcat-no_out = 'X'.
      wa_fieldcat-seltext_m = 'VENDOR CODE'.
      APPEND wa_fieldcat TO i_fieldcat.
      CLEAR wa_fieldcat.
    ENDFORM. "BUILD_FIELDCATLOG
    *& Form EVENT_CALL
    we get all events - TOP OF PAGE or USER COMMAND in table v_events
    FORM event_call.
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
      EXPORTING
      i_list_type = 0
      IMPORTING
      et_events = v_events
    EXCEPTIONS
    LIST_TYPE_WRONG = 1
    OTHERS = 2
      IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM. "EVENT_CALL
    *& Form POPULATE_EVENT
    Events populated for TOP OF PAGE & USER COMAND
    FORM populate_event.
      READ TABLE v_events INTO wa_event WITH KEY name = 'TOP_OF_PAGE'.
      IF sy-subrc EQ 0.
        wa_event-form = 'TOP_OF_PAGE'.
        MODIFY v_events FROM wa_event TRANSPORTING form WHERE name =
        wa_event-form.
      ENDIF.
      READ TABLE v_events INTO wa_event WITH KEY name = 'USER_COMMAND'.
      IF sy-subrc EQ 0.
        wa_event-form = 'USER_COMMAND'.
        MODIFY v_events FROM wa_event TRANSPORTING form WHERE name =
        wa_event-name.
      ENDIF.
    ENDFORM. "POPULATE_EVENT
    *& Form data_retrieval
    retreiving values from the database table ekko
    FORM data_retrieval.
      SELECT ebeln aedat bukrs bsart lifnr
             FROM ekko
             INTO TABLE it_ekko.
    ENDFORM. "data_retrieval
    *& Form bUild_listheader
    text
    -->I_LISTHEADEtext
    FORM build_listheader USING i_listheader TYPE slis_t_listheader.
      DATA hline TYPE slis_listheader.
      hline-info = 'this is my first alv pgm'.
      hline-typ = 'H'.
    ENDFORM. "build_listheader
    *& Form display_alv_report
    text
    FORM display_alv_report.
      v_repid = sy-repid.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
      EXPORTING
      i_callback_program = v_repid
    I_CALLBACK_PF_STATUS_SET = ' '
      i_callback_user_command = 'USER_COMMAND'
      i_callback_top_of_page = 'TOP_OF_PAGE'
      i_grid_title = i_title_ekko
    I_GRID_SETTINGS =
    IS_LAYOUT = ALV_LAYOUT
      it_fieldcat = i_fieldcat[]
    IT_EXCLUDING =
    IT_SPECIAL_GROUPS =
    IT_SORT =
    IT_FILTER =
    IS_SEL_HIDE =
    i_default = 'ZLAY1'
      i_save = 'A'
    is_variant = i_variant
      it_events = v_events
      TABLES
      t_outtab = it_ekko
    EXCEPTIONS
    PROGRAM_ERROR = 1
    OTHERS = 2
      IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM. "display_alv_report
    *& Form TOP_OF_PAGE
    text
    FORM top_of_page.
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
      EXPORTING
      it_list_commentary = it_listheader
    i_logo =
    I_END_OF_LIST_GRID =
    ENDFORM. "TOP_OF_PAGE
    *& Form USER_COMMAND
    text
    -->R_UCOMM text
    -->, text
    -->RS_SLEFIELDtext
    FORM user_command USING r_ucomm LIKE sy-ucomm
    rs_selfield TYPE slis_selfield.
      CASE r_ucomm.
        WHEN '&IC1'.
          READ TABLE it_ekko INTO wa_ekko INDEX rs_selfield-tabindex.
          PERFORM build_fieldcatlog_ekpo.
          PERFORM event_call_ekpo.
          PERFORM populate_event_ekpo.
          PERFORM data_retrieval_ekpo.
          PERFORM build_listheader_ekpo USING it_listheader.
          PERFORM display_alv_ekpo.
      ENDCASE.
    ENDFORM. "user_command
    *& Form BUILD_FIELDCATLOG_EKPO
    text
    FORM build_fieldcatlog_ekpo.
      wa_fieldcat-tabname = 'IT_EKPO'.
      wa_fieldcat-fieldname = 'EBELN'.
      wa_fieldcat-seltext_m = 'PO NO.'.
      APPEND wa_fieldcat TO i_fieldcat.
      CLEAR wa_fieldcat.
      wa_fieldcat-tabname = 'IT_EKPO'.
      wa_fieldcat-fieldname = 'EBELP'.
      wa_fieldcat-seltext_m = 'LINE NO'.
      APPEND wa_fieldcat TO i_fieldcat.
      CLEAR wa_fieldcat.
      wa_fieldcat-tabname = 'I_EKPO'.
      wa_fieldcat-fieldname = 'MATNR'.
      wa_fieldcat-seltext_m = 'MATERIAL NO.'.
      APPEND wa_fieldcat TO i_fieldcat.
      CLEAR wa_fieldcat.
      wa_fieldcat-tabname = 'I_EKPO'.
      wa_fieldcat-fieldname = 'MENGE'.
      wa_fieldcat-seltext_m = 'QUANTITY'.
      APPEND wa_fieldcat TO i_fieldcat.
      CLEAR wa_fieldcat.
      wa_fieldcat-tabname = 'I_EKPO'.
      wa_fieldcat-fieldname = 'MEINS'.
      wa_fieldcat-seltext_m = 'UOM'.
      APPEND wa_fieldcat TO i_fieldcat.
      CLEAR wa_fieldcat.
      wa_fieldcat-tabname = 'I_EKPO'.
      wa_fieldcat-fieldname = 'NETPR'.
      wa_fieldcat-seltext_m = 'PRICE'.
      APPEND wa_fieldcat TO i_fieldcat.
      CLEAR wa_fieldcat.
    ENDFORM. "BUILD_FIELDCATLOG_EKPO
    *& Form event_call_ekpo
    we get all events - TOP OF PAGE or USER COMMAND in table v_events
    FORM event_call_ekpo.
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
      EXPORTING
      i_list_type = 0
      IMPORTING
      et_events = v_events
    EXCEPTIONS
    LIST_TYPE_WRONG = 1
    OTHERS = 2
      IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM. "event_call_ekpo
    *& Form POPULATE_EVENT
    Events populated for TOP OF PAGE & USER COMAND
    FORM populate_event_ekpo.
      READ TABLE v_events INTO wa_event WITH KEY name = 'TOP_OF_PAGE'.
      IF sy-subrc EQ 0.
        wa_event-form = 'TOP_OF_PAGE'.
        MODIFY v_events FROM wa_event TRANSPORTING form WHERE name =
        wa_event-form.
      ENDIF.
    ENDFORM. "POPULATE_EVENT
    *& Form TOP_OF_PAGE
    text
    FORM f_top_of_page.
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
      EXPORTING
      it_list_commentary = it_listheader
    i_logo =
    I_END_OF_LIST_GRID =
    ENDFORM. "TOP_OF_PAGE
    *& Form USER_COMMAND
    text
    -->R_UCOMM text
    -->, text
    -->RS_SLEFIELDtext
    *retreiving values from the database table ekko
    FORM data_retrieval_ekpo.
      SELECT ebeln ebelp matnr menge meins netpr
             FROM ekpo
             INTO TABLE it_ekpo.
    ENDFORM.                    "DATA_RETRIEVAL_EKPO
    *&      Form  BUILD_LISTHEADER_EKPO
          text
         -->I_LISTHEADER  text
    FORM build_listheader_ekpo USING i_listheader TYPE slis_t_listheader.
      DATA: hline1 TYPE slis_listheader.
      hline1-typ = 'H'.
      hline1-info = 'CHECKING PGM'.
    ENDFORM.                    "BUILD_LISTHEADER_EKPO
    *&      Form  DISPLAY_ALV_EKPO
          text
    FORM display_alv_ekpo.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
      EXPORTING
    I_INTERFACE_CHECK = ' '
    I_BYPASSING_BUFFER = ' '
    I_BUFFER_ACTIVE = ' '
      i_callback_program = v_repid
    I_CALLBACK_PF_STATUS_SET = ' '
    I_CALLBACK_USER_COMMAND = 'F_USER_COMMAND'
      i_callback_top_of_page = 'TOP_OF_PAGE'
    I_CALLBACK_HTML_TOP_OF_PAGE = ' '
    I_CALLBACK_HTML_END_OF_LIST = ' '
    I_STRUCTURE_NAME =
    I_BACKGROUND_ID = ' '
      i_grid_title = i_title_ekpo
    I_GRID_SETTINGS =
    IS_LAYOUT =
      it_fieldcat = i_fieldcat[]
    IT_EXCLUDING =
    IT_SPECIAL_GROUPS =
    IT_SORT =
    IT_FILTER =
    IS_SEL_HIDE =
    I_DEFAULT =
      i_save = 'A'
    IS_VARIANT =
      it_events = v_events
      TABLES
      t_outtab = it_ekpo
      EXCEPTIONS
      program_error = 1
      OTHERS = 2
      IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                    "DISPLAY_ALV_EKPO
    Reward if Helpful

  • ABAP WD ALV  set cursor /focus to ALV cell

    G'day guys,
    We have a requirement to position/focus the cursor to a cell in the WD ALV.
    example: the user inserts a new line into the ALV and wants to immediately start typing in the first cell (column) of the new row in the ALV. Currently, the user must use the mouse and click, or tab, to that first cell before typing.
    Any help/suggestions is appreciated
    Cheers,
    Mick.

    I need a solution for this too.... Can anyone help?

Maybe you are looking for

  • Can't sync to my ipod touch - keep getting error code 13019 (Windows 7)?

    can't sync songs (or anything else) from my itunes library to my ipod touch. I keep getting an error message - 13019. Have gone back to sync options under devices but nothing seem to help. Although it appears to be an itune error message I think it h

  • Indd 5.5: When using drop shadow or lower opacity in object, I lose fills

    I have ugraded to InDesign 5.5 (v. 7.5) for Mac OS. Here is my problem: If I have object "A" with transparency (lower than 100% opacity) or a drop shadow (which also uses a transparency) overlapping object "B", then "B" loses it fill when printing to

  • All programs not available for Z10!!!

    Dear all All the application am trying to download its keep telling me that unavailable for your device and I can't update my z10 I don't know why each time I try it will say you've got the latest software. Is there any way to upgrade my software ple

  • Reader v11.1.2 unable to find epson wireless printer on home network?

    I downloaded 11.7.2 version of the Adobe reader android application from google Play store and found the application can't find my wireless Epson printer? Can someone help in resolving this issue. I currently have the S G III phone.

  • Photo edits not being recognized by developers

    i have edited several of my photos (sepia, black/white, antique, etc) while keeping the original too. each edited photo is given a different name (such as "img18412.jpg") in the "get info" tab of "photos." at the bottom left of iphoto window, under i