How to print to tables in ALV grid

hi all
I have 2 internal tables with some values
i want to display the 2 internal tables in the grid one after another with some title
can anyone tell me how to do it
Thank you.

i think in grid you can not do like this (By using function module). But you can do it in OO approach for that just check the se38 with alvgrid* and search. you can findout lot of example there. And one more option is there by using alv block but it is a list display.
Just check this sample program of alv block
TYPE-POOLS : SLIS.
TABLES : EKKO,EKPO.
DATA : BEGIN OF IEKKO OCCURS 0,
       EBELN LIKE EKKO-EBELN,
       AEDAT LIKE EKKO-AEDAT,
       END OF IEKKO.
DATA : BEGIN OF IEKPO OCCURS 0,
       EBELN LIKE EKPO-EBELN,
       EBELP LIKE EKPO-EBELP,
       MATNR LIKE EKPO-MATNR,
       MENGE LIKE EKPO-MENGE,
       MEINS LIKE EKPO-MEINS,
       END OF IEKPO.
DATA : IFIELDCATEKKO TYPE SLIS_T_FIELDCAT_ALV,
       IFIELDCATEKPO TYPE SLIS_T_FIELDCAT_ALV,
       WFIELDCAT     TYPE SLIS_FIELDCAT_ALV,
       ILAYOUT       TYPE SLIS_LAYOUT_ALV,
       IEVENTHEAD    TYPE SLIS_T_EVENT,
       IEVENTITEM    TYPE SLIS_T_EVENT,
       WEVENT        TYPE SLIS_ALV_EVENT,
       ISORT         TYPE SLIS_T_SORTINFO_ALV,
       WSORT         TYPE SLIS_SORTINFO_ALV.
PARAMETERS : P_NUM(3) TYPE N DEFAULT 10.
PERFORM GET_DATA_EKKO.
PERFORM GET_DATA_EKPO.
PERFORM BUILD_FCAT_HEAD.
PERFORM BUILD_FCAT_ITEM.
PERFORM BUILD_LAYOUT.
PERFORM BUILD_EVENT_TAB.
PERFORM DISPLAY_BLOCK.
*&      Form  GET_DATA_EKKO
*       text
*  -->  p1        text
*  <--  p2        text
FORM GET_DATA_EKKO .
SELECT EBELN AEDAT INTO TABLE IEKKO FROM EKKO UP TO P_NUM ROWS WHERE EBELN LIKE '45000057%'.
ENDFORM.                    " GET_DATA_EKKO
*&      Form  GET_DATA_EKPO
*       text
*  -->  p1        text
*  <--  p2        text
FORM GET_DATA_EKPO .
IF NOT IEKKO[] IS INITIAL.
  SELECT EBELN EBELP MATNR MENGE MEINS INTO TABLE IEKPO FROM EKPO FOR ALL ENTRIES IN IEKKO
                                                  WHERE EBELN = IEKKO-EBELN.
ENDIF.
ENDFORM.                    " GET_DATA_EKPO
*&      Form  DISPLAY_BLOCK
*       text
*  -->  p1        text
*  <--  p2        text
FORM DISPLAY_BLOCK .
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'
  EXPORTING
    I_CALLBACK_PROGRAM             = SY-REPID
*   I_CALLBACK_PF_STATUS_SET       = ' '
*   I_CALLBACK_USER_COMMAND        = ' '
*   IT_EXCLUDING                   =
          CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
            EXPORTING
              IS_LAYOUT                        = ILAYOUT
              IT_FIELDCAT                      = IFIELDCATEKKO
              I_TABNAME                        = 'IEKKO'
              IT_EVENTS                        = IEVENTHEAD[]
*             IT_SORT                          =
*             I_TEXT                           = ' '
            TABLES
              T_OUTTAB                         = IEKKO
           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                        = ILAYOUT
    IT_FIELDCAT                      = IFIELDCATEKPO
    I_TABNAME                        = 'IEKPO'
    IT_EVENTS                        = IEVENTITEM
*   IT_SORT                          =
*   I_TEXT                           = ' '
  TABLES
    T_OUTTAB                         = IEKPO
* 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_DISPLAY'
* EXPORTING
*   I_INTERFACE_CHECK             = ' '
*   IS_PRINT                      =
*   I_SCREEN_START_COLUMN         = 0
*   I_SCREEN_START_LINE           = 0
*   I_SCREEN_END_COLUMN           = 0
*   I_SCREEN_END_LINE             = 0
* IMPORTING
*   E_EXIT_CAUSED_BY_CALLER       =
*   ES_EXIT_CAUSED_BY_USER        =
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_BLOCK
*&      Form  BUILD_FCAT_HEAD
*       text
*  -->  p1        text
*  <--  p2        text
FORM BUILD_FCAT_HEAD .
WFIELDCAT-FIELDNAME = 'EBELN'.
WFIELDCAT-TABNAME   = 'IEKKO'.
WFIELDCAT-SELTEXT_L = 'Pur. Doc no'.
WFIELDCAT-OUTPUTLEN = 15.
APPEND WFIELDCAT TO IFIELDCATEKKO.
CLEAR WFIELDCAT.
WFIELDCAT-FIELDNAME = 'AEDAT'.
WFIELDCAT-TABNAME   = 'IEKKO'.
WFIELDCAT-SELTEXT_L = 'Pur. doc date'.
WFIELDCAT-OUTPUTLEN = 15.
APPEND WFIELDCAT TO IFIELDCATEKKO.
CLEAR WFIELDCAT.
ENDFORM.                    " BUILD_FCAT_HEAD
*&      Form  BUILD_FCAT_ITEM
*       text
*  -->  p1        text
*  <--  p2        text
FORM BUILD_FCAT_ITEM .
WFIELDCAT-FIELDNAME = 'EBELN'.
WFIELDCAT-TABNAME   = 'IEKPO'.
WFIELDCAT-SELTEXT_L = 'Pur. Doc no'.
WFIELDCAT-OUTPUTLEN = 15.
APPEND WFIELDCAT TO IFIELDCATEKPO.
CLEAR WFIELDCAT.
WFIELDCAT-FIELDNAME = 'EBELP'.
WFIELDCAT-TABNAME   = 'IEKPO'.
WFIELDCAT-SELTEXT_L = 'Pur. Doc item'.
*wfieldcat-do_sum = 'X'.
WFIELDCAT-OUTPUTLEN = 15.
APPEND WFIELDCAT TO IFIELDCATEKPO.
CLEAR WFIELDCAT.
WFIELDCAT-FIELDNAME = 'MATNR'.
WFIELDCAT-TABNAME   = 'IEKPO'.
WFIELDCAT-SELTEXT_L = 'Material no'.
WFIELDCAT-OUTPUTLEN = 18.
APPEND WFIELDCAT TO IFIELDCATEKPO.
CLEAR WFIELDCAT.
WFIELDCAT-FIELDNAME = 'MENGE'.
WFIELDCAT-TABNAME   = 'IEKPO'.
WFIELDCAT-SELTEXT_L = 'P.O. Qty'.
wfieldcat-do_sum = 'X'.
*WFIELDCAT-DATATYPE = 'QUAN'.
WFIELDCAT-OUTPUTLEN = 15.
APPEND WFIELDCAT TO IFIELDCATEKPO.
CLEAR WFIELDCAT.
WFIELDCAT-FIELDNAME = 'MEINS'.
WFIELDCAT-TABNAME   = 'IEKPO'.
WFIELDCAT-SELTEXT_L = 'UOM'.
WFIELDCAT-OUTPUTLEN = 3.
APPEND WFIELDCAT TO IFIELDCATEKPO.
CLEAR WFIELDCAT.
ENDFORM.                    " BUILD_FCAT_ITEM
*&      Form  BUILD_LAYOUT
*       text
*  -->  p1        text
*  <--  p2        text
FORM BUILD_LAYOUT .
ILAYOUT-COLWIDTH_OPTIMIZE = 'X'.
ENDFORM.                    " BUILD_LAYOUT
*&      Form  BUILD_EVENT_TAB
*       text
*  -->  p1        text
*  <--  p2        text
FORM BUILD_EVENT_TAB .
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
   I_LIST_TYPE           = 0
IMPORTING
   ET_EVENTS             = IEVENTHEAD
* 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.
IEVENTITEM = IEVENTHEAD.
READ TABLE IEVENTHEAD INTO WEVENT WITH KEY NAME = 'TOP_OF_PAGE'.
IF SY-SUBRC = 0.
WEVENT-FORM = 'TOPOFPAGEHEAD'.
MODIFY IEVENTHEAD FROM WEVENT INDEX SY-TABIX.
ENDIF.
READ TABLE IEVENTHEAD INTO WEVENT WITH KEY NAME = 'USER_COMMAND'.
IF SY-SUBRC = 0.
WEVENT-FORM = 'USERCOMMAND'.
MODIFY IEVENTHEAD FROM WEVENT INDEX SY-TABIX.
ENDIF.
READ TABLE IEVENTITEM INTO WEVENT WITH KEY NAME = 'TOP_OF_PAGE'.
IF SY-SUBRC = 0.
WEVENT-FORM = 'TOPOFPAGEITEM'.
MODIFY IEVENTITEM FROM WEVENT INDEX SY-TABIX.
ENDIF.
ENDFORM.                    " BUILD_EVENT_TAB
FORM USERCOMMAND USING PUCOMM LIKE SY-UCOMM SELFIELD TYPE SLIS_SELFIELD.
CASE PUCOMM.
WHEN '&IC1'.
WHEN 'OTHERS'.
ENDCASE.
ENDFORM.
FORM TOPOFPAGEHEAD.
DATA : ILIST TYPE SLIS_T_LISTHEADER,
       WLIST TYPE SLIS_LISTHEADER.
WLIST-INFO = 'Header data with P.O. no and creating date'.
WLIST-TYP  = 'H'.
APPEND WLIST TO ILIST.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
  EXPORTING
    IT_LIST_COMMENTARY       = ILIST
*   I_LOGO                   =
*   I_END_OF_LIST_GRID       =
ENDFORM.
FORM TOPOFPAGEITEM.
DATA : ILIST TYPE SLIS_T_LISTHEADER,
       WLIST TYPE SLIS_LISTHEADER.
WLIST-INFO = 'Item data with P.O.item material no and qty'.
WLIST-TYP  = 'H'.
APPEND WLIST TO ILIST.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
  EXPORTING
    IT_LIST_COMMENTARY       = ILIST
*   I_LOGO                   =
*   I_END_OF_LIST_GRID       =
ENDFORM.
regards
shiba dutta

Similar Messages

  • How to enable excel downloading in ALV grid report.

    Hi all,
    How to enable excal downing in ALV grid report?
    Thanks in Advance.
    Siva Sankar.

    hi
    check the following code
    Example of a Simple ALV Grid Report
    REPORT  ZTUFI091                                .
    *& Report  ZDEMO_ALVGRID                                               *
    *& Example of a simple ALV Grid Report                                 *
    *& The basic requirement for this demo is to display a number of       *
    *& fields from the EKKO table.                                         *
    *REPORT  zdemo_alvgrid                 .
    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.
    hope it will help you
    regards
    sreelatha gullapalli

  • How to trigger left_click_run event on ALV GRID

    Hiiiiiiii........
    Can any of u please tell me how to trigger left_click_run event on ALV GRID.
         There is an event LEFT_CLICK_RUN and  its a public accessed event. But the problem is , the corresponding  attribute of this event  "EVENT_LEFT_CLICK_RUN" which is needed to registered that event (We need to register our events through a method set_register_events  using table of type cntl_simple_events...) is protect accessed. So I am unable to use that attribute...Could u please tell  me is there any alternative way to register that event.......ANY POSSIBLE WAY?
    Thanks in advance,
    Rams

    I think you should use event selection_changed. Note that you shouldn't allow multiple selection for the tree at the same time, i.e. use: create object g_tree exporting \[...\] node_selection_mode = cl_gui_column_tree=&gt;node_sel_mode_single.
    For more information, see this thread: Urgently required :  cl_gui_alv_tree single_click event...

  • Show dynamic table in ALV grid

    Hi !
    how do I show a dynamic table in ALV GRID ?
    I used the following commands:
    call method cl_alv_table_create=>create_dynamic_table
      exporting
        it_fieldcatalog = it_fieldcat[]
      importing
        ep_table        = gt_new_table.
      assign gt_new_table->* to <l_table>.
      create data gs_new_line like line of <l_table>.
      assign gs_new_line->* to <l_line>.
    I added records into the table
    Now I got a dynamic table.
    How do I show it in ALV GRID ?
    thanks
      Adi

    Hi,
    Check these links
    Re: Dynamic table
    http://sap.ittoolbox.com/code/d.asp?a=s&d=3038
    http://www.sap4.com/codigo-138.html
    http://www.sapassist.com/code/d.asp?a=s&d=3365
    There is an example in the report BCALV_TABLE_CREATE
    report BCALV_TABLE_CREATE.
    data: ok_code like sy-ucomm,
         g_container type scrfname value 'BCALV_GRID_DEMO_0100_CONT1',
         grid1  type ref to cl_gui_alv_grid,
         g_custom_container type ref to cl_gui_custom_container.
    data: gt_fieldcat type lvc_t_fcat.
    data: gp_table type ref to data.
    field-symbols: <gt_table> type table.
    parameters: n type i.
    if n > 100.
    message a000(0k) with 'N <= 100'.
    endif.
    perform fieldcat_build.
    call method cl_alv_table_create=>create_dynamic_table
                            exporting it_fieldcatalog = gt_fieldcat
                            importing ep_table = gp_table.
    assign gp_table->* to <gt_table>.
    perform fill_table.
    call screen 100.

  • How can I call functionality of ALV Grid by event of button outside grid?

    Hello,
    How can I call functionality of ALV Grid by event of button located outside ALV Grid? For example how to fire printing of this ALV Grid by button click elsewhere on the screen (not in toolbar of ALV Grid).
    Best regards,
    Josef Motl

    hi Motl,
    these are steps to create a button in ALV and trigger an event from it..
    1.Use the parameter i_callback_pf_status_set in the function module REUSE_ALV_GRID_DISPLAY
    i_callback_program = gd_repid
    i_callback_pf_status_set = 'SET_PF_STATUS'
    form set_pf_status using rt_extab type slis_t_extab.
    set pf-status 'NEWALVSTATUS'.
    endform.
    You have to copy the standard ALV pf stauts to 'NEWALVSTATUS' and add your button.
    2.You have to do the following to process the new button click.
    i_callback_user_command = 'USER_COMMAND'
    form user_command using i_ucomm like sy-ucomm
    is_selfield type slis_selfield.
    case i_ucomm.
    3. to copy the standard pf status to a new one.go to the ALV screen and take the menu System -> Status.  Then look for the standard pf status. Copy this to Z range and then add your new button.
    reward points if helpful
    regards
    satesh

  • How to get f4 help in alv grid in container-urgent

    hi,
    how to get f4 help in alv grid in container using abap objects
    ganesh

    Hi Ganesh,
    Did you have a look at sample report BCALV_TEST_GRID_F4_HELP ?
    Here is part of the header documentation:
    *& Report  BCALV_GRID_F4_HELP                                          *
    Purpose:
    ~~~~~~~~
    This report illustrates the use of f4-Help in an alv grid control.
    Background:
    ~~~~~~~~~~~
    There a two possibilities to implement an f4-Help in the alv grid
    control: one can either use standard f4-help or write one by Hand.
    For the former there is nothing to do at all. This report shows how
    to implement user-defined f4-help.
    I am sure you will find within this report the solution you are looking for.
    Reward points if this Helps.
    Manish

  • Modifying database table in ALV Grid

    Hi all.
    I need to be able to modify the database table in ALV Grid. Here's the code. The database table, that is displayed is 'zng_so_head', it's internal table is 'res_tab'. In the program i tried to create a button 'CHANGE' on the ALV-toolbar, but when executing the program there's no such button (why?). What code, screens, screen elements, etc. should be added to this program to provide a possibility of changing data of the database table 'zng_so_head' (i mean changing existing data, adding new lines and saving changes)?
    CODE:
    & Report  ZNG_ALV_TC_EDIT_SIMP&
    REPORT  ZNG_ALV_TC_EDIT_SIMP.
    *-- GLOBAL DATA DECLARATIONS FOR ALV
    DATA gr_alvgrid TYPE REF TO cl_gui_alv_grid.
    DATA gc_custom_control_name TYPE scrfname VALUE 'CC_ALV'.
    DATA gr_ccontainer TYPE REF TO cl_gui_custom_container.
    DATA gt_fieldcat TYPE lvc_t_fcat.
    DATA gs_layout TYPE lvc_s_layo.
    TABLES: zng_so_head, zng_cust, zng_vendors.
    *-- STRUCTURE OF INTERNAL TABLE
    TYPES: BEGIN OF in_tab,
            so_num TYPE zng_so_head-so_num,          "type numc
            vend_num TYPE zng_so_head-vend_num,      "type numc
            cust_num TYPE zng_so_head-cust_num,      "type numc
            so_date TYPE zng_so_head-so_date,        "type dats
           END OF in_tab.
    *-- INTERNAL TABLE HOLDING LIST DATA
    DATA res_tab TYPE TABLE OF in_tab WITH HEADER LINE.
    *-- FILLING IN INTERNAL TABLE
    SELECT hso_num hvend_num hcust_num hso_date
    INTO TABLE res_tab FROM zng_so_head AS h.
    *&      Form  prepare_field_catalog
    FORM prepare_field_catalog CHANGING pt_fieldcat TYPE lvc_t_fcat.
      DATA ls_fcat TYPE lvc_s_fcat.
      ls_fcat-fieldname = 'SO_NUM'.
      ls_fcat-inttype = 'N'.
      ls_fcat-ref_table = 'zng_so_head'.
      ls_fcat-outputlen = '12'.
      ls_fcat-coltext = 'SO_NUM'.
      ls_fcat-seltext = 'SO_NUM'.
      APPEND ls_fcat TO pt_fieldcat.
      CLEAR ls_fcat.
      ls_fcat-fieldname = 'VEND_NUM'.
      ls_fcat-inttype = 'N'.
      ls_fcat-ref_table = 'zng_so_head'.
      ls_fcat-outputlen = '12'.
      ls_fcat-coltext = 'VEND_NUM'.
      ls_fcat-seltext = 'VEND_NUM'.
      APPEND ls_fcat TO pt_fieldcat.
      CLEAR ls_fcat.
      ls_fcat-fieldname = 'CUST_NUM'.
      ls_fcat-inttype = 'N'.
      ls_fcat-ref_table = 'zng_so_head'.
      ls_fcat-outputlen = '12'.
      ls_fcat-coltext = 'CUST_NUM'.
      ls_fcat-seltext = 'CUST_NUM'.
      APPEND ls_fcat TO pt_fieldcat.
      CLEAR ls_fcat.
      ls_fcat-fieldname = 'SO_DATE'.
      ls_fcat-inttype = 'D'.
      ls_fcat-ref_table = 'zng_so_head'.
      ls_fcat-outputlen = '12'.
      ls_fcat-coltext = 'SO_DATE'.
      ls_fcat-seltext = 'SO_DATE'.
      APPEND ls_fcat TO pt_fieldcat.
    ENDFORM.                    "prepare_field_catalog
    *&      Form  display_alv
    FORM display_alv.
      IF gr_alvgrid IS INITIAL.
        CREATE OBJECT gr_ccontainer
        EXPORTING container_name = gc_custom_control_name.
        CREATE OBJECT gr_alvgrid
        EXPORTING i_parent = gr_ccontainer.
        PERFORM prepare_field_catalog CHANGING gt_fieldcat.
        CALL METHOD gr_alvgrid->set_table_for_first_display
          EXPORTING
            is_layout       = gs_layout
          CHANGING
            it_outtab       = res_tab[]
            it_fieldcatalog = gt_fieldcat.
      ELSE.
        CALL METHOD gr_alvgrid->refresh_table_display.
      ENDIF.
    ENDFORM.                    "display_alv
          CLASS lcl_event_handler DEFINITION
    CLASS lcl_event_handler DEFINITION.
      PUBLIC SECTION.
        METHODS:
        handle_toolbar
          FOR EVENT toolbar OF cl_gui_alv_grid
            IMPORTING e_object
                      e_interactive.
    ENDCLASS.             "lcl_event_handler DEFINITION
          CLASS lcl_event_handler IMPLEMENTATION
    CLASS lcl_event_handler IMPLEMENTATION.
      METHOD handle_toolbar.
        DATA: ls_toolbar TYPE stb_button.
        MOVE 3 TO ls_toolbar-butn_type.
        APPEND ls_toolbar TO e_object->mt_toolbar.
        CLEAR ls_toolbar.
        MOVE 'CHANGE' TO ls_toolbar-function.
        MOVE icon_change TO ls_toolbar-icon.
        MOVE 'change' TO ls_toolbar-quickinfo.
        MOVE 'change' TO ls_toolbar-text.
        APPEND ls_toolbar TO e_object->mt_toolbar.
      ENDMETHOD.                    "handle_toolbar
    ENDCLASS.                    "lcl_event_handler IMPLEMENTATION
    DATA object_ref TYPE REF TO lcl_event_handler.
    START-OF-SELECTION.
      CALL SCREEN 100.
    MODULE STATUS_0100 OUTPUT
    MODULE display_alv OUTPUT.
      SET PF-STATUS 'SCREEN_100'.
      PERFORM display_alv.
      CREATE OBJECT object_ref.
      SET HANDLER object_ref->handle_toolbar FOR gr_alvgrid.
    ENDMODULE.                    "display_alv OUTPUT
    MODULE USER_COMMAND_0100 INPUT
    MODULE user_command_0100 INPUT.
      IF sy-ucomm = 'BACK' OR
         sy-ucomm = 'EXIT' OR
         sy-ucomm = 'CANCEL'.
        LEAVE PROGRAM.
      ELSE.
        CALL METHOD object_ref->handle_toolbar.
      ENDIF.
    ENDMODULE.                    "status_0100 INPUT
    END OF CODE
    Thanks all.

    Hi,
    For the button on the toolbar,here is the code:
    CLASS lcl_eh IMPLEMENTATION.
    *METHOD:      HANDLE_TOOLBAR
    *DESCRIPTION: This method provides the necessary detail required to
                 create an extra button in the toolbar.
      METHOD handle_toolbar.
        CLEAR ls_toolbar.
        MOVE 'CHANGE' TO ls_toolbar-function.
        MOVE 0 TO ls_toolbar-butn_type.
        MOVE CHANGETO ls_toolbar-text.
        MOVE 'ICON_DETAIL' TO ls_toolbar-icon.
        MOVE 'CHANGE' TO ls_toolbar-quickinfo.
        APPEND ls_toolbar TO e_object->mt_toolbar.
      ENDMETHOD.                    "handle_toolbar
    Also,if you are using the CHANGE button to record changes in the DB,then in the local class that you have defined,you should use the following method and then write the logic:
    *METHOD:      HANDLE_USER_COMMAND
      METHOD handle_user_command.
        CASE e_ucomm.
          WHEN 'CHANGE'.
    CHECK_CHANGED_DATA
    REFRESH_TABLE_DISPLAY
    Now call the methods that i have given in my previous post.This function code will be checked at the event you click the button 'CHANGE'.I think you have done this in an ELSE condition in the PAI of the screen.Not too sure if it works in the PAI.
    Regards,
    Beejal
    **Reward if this helps

  • Problem when printing icons of an ALV grid

    I made an Alv grid report that has some icons.When i printed i don't see the icons but isee some characters ...
    What can i do ?
    Thanks a lot ....

    hi good
    if you take the print out of a alv grid report it wont show you the icon pictures in your paper,it wll show you the respective characters for those icons,
    Thanks
    mrutyun^

  • How to print some data in alv which is not in table.

    hi all,
    Please can any one tell me how to print some text in the existing alv program to the second line of every record.
    the header is there but it is empty.In the data,
    there are two lines printing for a normal alv.the same text should be  printed in every second line of each record.Please reply soon.its urgent.

    This is not possible in ALV.
    When you say some text I assume the text is not in the same columnar format as the list is.
    ALV supports only a columnar format (except for subtotals).
    You can add the text to the ITAB by parsing the text to the record. It is not going to look good if you do that.

  • How to Transfer Data from editable ALV grid control to internal table?

    Hi,
    Can anyone give me a simple example by which I can transfer data from editable alv grid control back to the internal table. The ALV has been created by OO approach.
    I would appreciate if the solution is provided without handling any events.
    Regards,
    Auro

    Hello Auro
    You simply need to call method <b>go_grid->check_changed_data</b> at PAI of the dynpro displaying the ALV grid. If data have been changed on the editable ALV grid then this method will raise event DATA_CHANGED. If you do not want or need to handle this event (e.g. for validating the edited values) then you do not define any event handler method.
    Regards
      Uwe

  • Print Issue with Sorted ALV Grid

    Hi Team,
    I am using ALV display for my Program. Iam using REUSE_ALV_GRID_DISPLAY. Also i have a Sorting condition for my ALV grid. So iam filling the Sort table & passing it to the Function module. The data is displayed correctly with Sorting as required in the Output.
    Now the issue is with: Print from this ALV. When we try to print the data, The requirement is that the Print should be same as how it is displayed in the ALV. "Grouped Columns"..... But now, the Print is that all the data is filled in all the columns. But user wants the Print also to appear  same as it is shown in a Sorted ALV display.(With some similar column data missing in succeding sort columns until new entry starts)
    Please suggest a solution to acheive the same.
    Thanks & regards,
    Chaitanya

    Look at Q#19 in the note 1009650. Merging functionality is available only for ALV grid display.
    Related Note: 447055
    Work around would be to display the excel in the SAP window (Excel in Place)  and print it from Excel. Read the following thread to make the necessary settings to make it work. Download Report exactly same as seems with Layout set !!
    Edited by: Jeevan Sagar on Jan 19, 2012 12:38 AM

  • How to focus a cell on ALV grid display

    hi,
    I need to set the focus to the first cell on the first row in the ALV grid.I am using object oriented ALV grid control.Can anyone help me out in this regard.
    Regards,
    Anil.

    Re: simple Grid display
    Have a look at below links. It contains sample code for alv grid.
    http://www.erpgenie.com/abap/controls/alvgrid.htm#Complete%20code%20for%20the%20ALV%20grid%20example
    http://www.sap-img.com/abap/sample-programs-on-alv-grid.htm
    http://sap.niraj.tripod.com/id64.html
    Also have a look at below for OO alv grid:
    http://help.sap.com/saphelp_erp2004/helpdata/en/0a/b5533cd30911d2b467006094192fe3/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 catalog. 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
    Simple ALV report
    http://www.sapgenie.com/abap/controls/alvgrid.htm
    http://wiki.ittoolbox.com/index.php/Code:Ultimate_ALV_table_toolbox
    ALV
    1. Please give me general info on ALV.
    http://www.sapfans.com/forums/viewtopic.php?t=58286
    http://www.sapfans.com/forums/viewtopic.php?t=76490
    http://www.sapfans.com/forums/viewtopic.php?t=20591
    http://www.sapfans.com/forums/viewtopic.php?t=66305 - this one discusses which way should you use - ABAP Objects calls or simple function modules.
    2. How do I program double click in ALV?
    http://www.sapfans.com/forums/viewtopic.php?t=11601
    http://www.sapfans.com/forums/viewtopic.php?t=23010
    3. How do I add subtotals (I have problem to add them)...
    http://www.sapfans.com/forums/viewtopic.php?t=20386
    http://www.sapfans.com/forums/viewtopic.php?t=85191
    http://www.sapfans.com/forums/viewtopic.php?t=88401
    http://www.sapfans.com/forums/viewtopic.php?t=17335
    4. How to add list heading like top-of-page in ABAP lists?
    http://www.sapfans.com/forums/viewtopic.php?t=58775
    http://www.sapfans.com/forums/viewtopic.php?t=60550
    http://www.sapfans.com/forums/viewtopic.php?t=16629
    5. How to print page number / total number of pages X/XX in ALV?
    http://www.sapfans.com/forums/viewtopic.php?t=29597 (no direct solution)
    6. ALV printing problems. The favourite is: The first page shows the number of records selected but I don't need this.
    http://www.sapfans.com/forums/viewtopic.php?t=64320
    http://www.sapfans.com/forums/viewtopic.php?t=44477
    7. How can I set the cell color in ALV?
    http://www.sapfans.com/forums/viewtopic.php?t=52107
    8. How do I print a logo/graphics in ALV?
    http://www.sapfans.com/forums/viewtopic.php?t=81149
    http://www.sapfans.com/forums/viewtopic.php?t=35498
    http://www.sapfans.com/forums/viewtopic.php?t=5013
    9. How do I create and use input-enabled fields in ALV?
    http://www.sapfans.com/forums/viewtopic.php?t=84933
    http://www.sapfans.com/forums/viewtopic.php?t=69878
    10. How can I use ALV for reports that are going to be run in background?
    http://www.sapfans.com/forums/viewtopic.php?t=83243
    http://www.sapfans.com/forums/viewtopic.php?t=19224
    11. How can I display an icon in ALV? (Common requirement is traffic light icon).
    http://www.sapfans.com/forums/viewtopic.php?t=79424
    http://www.sapfans.com/forums/viewtopic.php?t=24512
    12. How can I display a checkbox in ALV?
    http://www.sapfans.com/forums/viewtopic.php?t=88376
    http://www.sapfans.com/forums/viewtopic.php?t=40968
    http://www.sapfans.com/forums/viewtopic.php?t=6919
    Go thru these programs they may help u to try on some hands on
    ALV Demo program
    BCALV_DEMO_HTML
    BCALV_FULLSCREEN_DEMO ALV Demo: Fullscreen Mode BCALV_FULLSCREEN_DEMO_CLASSIC ALV demo: Fullscreen mode BCALV_GRID_DEMO Simple ALV Control Call Demo Program BCALV_TREE_DEMO Demo for ALV tree control BCALV_TREE_SIMPLE_DEMO BC_ALV_DEMO_HTML_D0100
    Reward If useful

  • How to print long text in ALV

    i want to print a description in text  mode which is 5-6 lines some times it have a blank line also so
    how to print in ALV .i m using READ_TEXT function but sumtime it not works when text exceed 4-5 lines
    what i sud do.

    hi,
    there is another way u can use yours internal table field like long text field. that is.
    parameters: salno type vbak-vbeln.
    data: begin of itab occurs 0,
      vbeln type vbak-vbeln,
      matnr type vbap-matnr,
      longtext type thead occurs 0,
      end of itab.
      data: itabstxl type standard table of stxl with header line.
      select single vbakvbeln vbapmatnr into (itab-vbeln, itab-matnr)
                                     from vbak inner join vbap
                                       on vbakvbeln = vbapvbeln
                                        where vbak~vbeln = salno.
        select single tdobject tdname tdid tdspras from stxl
                                                     into (itabstxl-tdobject,itabstxl-tdname,itabstxl-tdid,itabstxl-tdspras)
                                                           where relid = 'TX'
                                                            and  tdobject = 'VBBK'
                                                            and tdname = salno    "YOUR OWN TDNAME e,g
                                                            and tdid = 'Z003'
                                                            and tdspras = 'EN'.
    call function 'READ_TEXT'
      exporting
      CLIENT                        = SY-MANDT
        id                            = itabstxl-tdid
        language                      = itabstxl-tdspras
        name                          = itabstxl-tdname
        object                        = itabstxl-tdobject
      ARCHIVE_HANDLE                = 0
      LOCAL_CAT                     = ' '
    IMPORTING
      HEADER                        =
      tables
        lines                         = itab-longtext
    EXCEPTIONS
      ID                            = 1
      LANGUAGE                      = 2
      NAME                          = 3
      NOT_FOUND                     = 4
      OBJECT                        = 5
      REFERENCE_CHECK               = 6
      WRONG_ACCESS_TO_ARCHIVE       = 7
      OTHERS                        = 8
    if sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    endif.
    break abaper.
    I HOPE THIS WILL SOLVE THIS WILL SOLVE THE PROBLEM OF THE OTHERS AS WELL.

  • How to print the data in the grid?

    Hi all,
    I'm new to java. So, I need some helps.
    I want to print the data in the grid. Data could be more than one page. But I have no idea how to start writing code.
    Please let me know if you know.
    Thank you.
    DT.

    Follow this steps.
    1- the Grid which you wish to print must locate in a class which implements Printable() interface.
    e.g.
    import javax.swing.table.*;
    import java.awt.print.*;
    import javax.infobus.*;
    public class myGridControl extends GridControl implements Printable{
    // add the following statements in the definition section of your class
    int m_maxNumPage =1;
    JTable m_table;
    TableModel m_tableModel;
    ScrollableRowsetAccess myRs;
    // add the folowing statemnts in the
    //constructor or init method or start method
    //(Notice:if you couldn't print, possible
    //you didn't put these stetment on the right
    //location and one or all of them
    //are "null".change the location and make
    //sure they are not null when you issue a
    //print order)
    m_table = new JTable();
    m_table = masterGrid.getTable();
    m_tableModel = m_table.getModel();
    myRs = (ScrollableRowsetAccess)masterGrid.getDataItem();
    3- add following methods to your class(myGridControl). just cut and paste.
    // Print Methods
    public void printData() {
    try {
    PrinterJob prnJob = PrinterJob.getPrinterJob();
    prnJob.setPrintable(this);
    if (!prnJob.printDialog())
    return;
    prnJob.print();
    catch (PrinterException e) {
    e.printStackTrace();
    System.err.println("Printing error: "+e.toString());
    public int print(Graphics pg, PageFormat pageFormat,int pageIndex) throws PrinterException {
    JLabel m_title=new JLabel("Alexus Report : "+titleName);
    if (pageIndex >= m_maxNumPage)
    return NO_SUCH_PAGE;
    pg.translate((int)pageFormat.getImageableX(),
    (int)pageFormat.getImageableY());
    int wPage = 0;
    int hPage = 0;
    if (pageFormat.getOrientation() == pageFormat.PORTRAIT) {
    wPage = (int)pageFormat.getImageableWidth();
    hPage = (int)pageFormat.getImageableHeight();
    else {
    wPage = (int)pageFormat.getImageableWidth();
    wPage += wPage/2;
    hPage = (int)pageFormat.getImageableHeight();
    pg.setClip(0,0,wPage,hPage);
    int y = 0;
    pg.setFont(m_title.getFont());
    pg.setColor(Color.black);
    Font fn = pg.getFont();
    FontMetrics fm = pg.getFontMetrics();
    y += fm.getAscent();
    pg.drawString(m_title.getText(), 0, y);
    y += 20; // space between title and table headers
    Font headerFont = m_table.getFont().deriveFont(Font.BOLD);
    pg.setFont(headerFont);
    fm = pg.getFontMetrics();
    TableColumnModel colModel = m_table.getColumnModel();
    int nColumns = colModel.getColumnCount();
    int x[] = new int[nColumns];
    x[0] = 0;
    int h = fm.getAscent();
    y += h; // add ascent of header font because of baseline
    // positioning (see figure 2.10)
    int nRow, nCol;
    for (nCol=0; nCol<nColumns; nCol++) {
    TableColumn tk = colModel.getColumn(nCol);
    int width = tk.getWidth();
    if (x[nCol] + width > wPage) {
    nColumns = nCol;
    break;
    if (nCol+1<nColumns)
    x[nCol+1] = x[nCol] + width;
    String title = (String)tk.getIdentifier();
    pg.drawString(title, x[nCol], y);
    pg.setFont(m_table.getFont());
    fm = pg.getFontMetrics();
    int header = y;
    h = fm.getHeight();
    int rowH = Math.max((int)(h*1.5), 10);
    int rowPerPage = (hPage-header)/rowH;
    m_maxNumPage = Math.max((int)Math.ceil(m_table.getRowCount()/
    (double)rowPerPage), 1);
    int iniRow = pageIndex*rowPerPage;
    int endRow = Math.min(m_table.getRowCount(),
    iniRow+rowPerPage);
    // take an array to store columns header
    String colNames[] = new String[nColumns];
    for (nCol=0; nCol<nColumns; nCol++) {
    colNames[nCol] = myRs.getColumnName(nCol+1).toString();
    try{
    for (nRow=iniRow; nRow<endRow; nRow++) {
    y += h;
    // set RowSet on the specific row
    myRs.absolute(nRow+1);
    for (nCol=0; nCol<nColumns; nCol++) {
    /* the next 3 lines are old code
    int col = m_table.getColumnModel().getColumn(nCol).getModelIndex();
    Object obj = m_tableModel.getValueAt(nRow, col);
    String str = obj.toString();
    // take the values column by columns
    ImmediateAccess ia = (ImmediateAccess)myRs.getColumnItem(colNames[nCol]);
    String str = ia.getValueAsString();
    if (str.equals("")) str=" ";
    /* this if is usefull if we'd like to have coloring in printing
    if (obj instanceof ColorData)
    pg.setColor(((ColorData)obj).m_color);
    else
    pg.setColor(Color.black);
    pg.drawString(str, x[nCol], y);
    }catch(Exception e){
    e.printStackTrace();
    System.gc();
    return PAGE_EXISTS;
    public void printData() {
    try {
    PrinterJob prnJob = PrinterJob.getPrinterJob();
    prnJob.setPrintable(this);
    if (!prnJob.printDialog())
    return;
    prnJob.print();
    catch (PrinterException e) {
    e.printStackTrace();
    System.err.println("Printing error: "+e.toString());
    public int print(Graphics pg, PageFormat pageFormat,int pageIndex) throws PrinterException {
    JLabel m_title=new JLabel("Alexus Report : "+titleName);
    if (pageIndex >= m_maxNumPage)
    return NO_SUCH_PAGE;
    pg.translate((int)pageFormat.getImageableX(),
    (int)pageFormat.getImageableY());
    int wPage = 0;
    int hPage = 0;
    if (pageFormat.getOrientation() == pageFormat.PORTRAIT) {
    wPage = (int)pageFormat.getImageableWidth();
    hPage = (int)pageFormat.getImageableHeight();
    else {
    wPage = (int)pageFormat.getImageableWidth();
    wPage += wPage/2;
    hPage = (int)pageFormat.getImageableHeight();
    pg.setClip(0,0,wPage,hPage);
    int y = 0;
    pg.setFont(m_title.getFont());
    pg.setColor(Color.black);
    Font fn = pg.getFont();
    FontMetrics fm = pg.getFontMetrics();
    y += fm.getAscent();
    pg.drawString(m_title.getText(), 0, y);
    y += 20; // space between title and table headers
    Font headerFont = m_table.getFont().deriveFont(Font.BOLD);
    pg.setFont(headerFont);
    fm = pg.getFontMetrics();
    TableColumnModel colModel = m_table.getColumnModel();
    int nColumns = colModel.getColumnCount();
    int x[] = new int[nColumns];
    x[0] = 0;
    int h = fm.getAscent();
    y += h; // add ascent of header font because of baseline
    // positioning (see figure 2.10)
    int nRow, nCol;
    for (nCol=0; nCol<nColumns; nCol++) {
    TableColumn tk = colModel.getColumn(nCol);
    int width = tk.getWidth();
    if (x[nCol] + width > wPage) {
    nColumns = nCol;
    break;
    if (nCol+1<nColumns)
    x[nCol+1] = x[nCol] + width;
    String title = (String)tk.getIdentifier();
    pg.drawString(title, x[nCol], y);
    pg.setFont(m_table.getFont());
    fm = pg.getFontMetrics();
    int header = y;
    h = fm.getHeight();
    int rowH = Math.max((int)(h*1.5), 10);
    int rowPerPage = (hPage-header)/rowH;
    m_maxNumPage = Math.max((int)Math.ceil(m_table.getRowCount()/
    (double)rowPerPage), 1);
    int iniRow = pageIndex*rowPerPage;
    int endRow = Math.min(m_table.getRowCount(),
    iniRow+rowPerPage);
    // take an array to store columns header
    String colNames[] = new String[nColumns];
    for (nCol=0; nCol<nColumns; nCol++) {
    colNames[nCol] = myRs.getColumnName(nCol+1).toString();
    try{
    for (nRow=iniRow; nRow<endRow; nRow++) {
    y += h;
    // set RowSet on the specific row
    myRs.absolute(nRow+1);
    for (nCol=0; nCol<nColumns; nCol++) {
    /* the next 3 lines are old code
    int col = m_table.getColumnModel().getColumn(nCol).getModelIndex();
    Object obj = m_tableModel.getValueAt(nRow, col);
    String str = obj.toString();
    // take the values column by columns
    ImmediateAccess ia = (ImmediateAccess)myRs.getColumnItem(colNames[nCol]);
    String str = ia.getValueAsString();
    if (str.equals("")) str=" ";
    /* this if is usefull if we'd like to have coloring in printing
    if (obj instanceof ColorData)
    pg.setColor(((ColorData)obj).m_color);
    else
    pg.setColor(Color.black);
    pg.drawString(str, x[nCol], y);
    }catch(Exception e){
    e.printStackTrace();
    System.gc();
    return PAGE_EXISTS;
    4- execute printData() method to print.
    e.g. myGridControl.printData();
    let me know if you still cannot print.
    Ali

  • How to print Page No. in ALV footer.

    I am using the follwoing code but when I got print the page numbers are not displaying. I was copy the code from one of group message.
    Please tell where I am making mistakes means why page numbers are not displaying at footer.
    I want to print 30 rows on each page and display the page no. in footer of each page.
    REPORT  zift_test_alv.
    Report Name: PS Report                                               *
    Created by: IALI                                                     *
    Tables ( To support selection screen )
    TABLES:
           MSEG.
         S E L E C T I O N   S C R E E N        *
    *SELECT-OPTIONS: PostDate FOR BSIS-BUDAT.
    SELECTION-SCREEN: Begin of block B01 WITH FRAME TITLE TITLE01.
    SELECT-OPTIONS: so_plant                              FOR mseg-werks. " Plant
    SELECTION-SCREEN: end of block B01.
          D A T A   D E C L A R A T I O N       *
    Types
    types: begin of slis_print_alv1,
             no_print_selinfos(1) type c,  " display no selection infos
             no_coverpage(1) type c,                            "
             no_new_page(1) type c,                             "
             reserve_lines type i,         " lines reserved for end of page
             no_print_listinfos(1) type c, " display no listinfos
             no_change_print_params(1) type c,  " don't change linesize
             no_print_hierseq_item(1) type c,  "don't expand item
             print_ctrl type ALV_S_Pctl,
           end of slis_print_alv1.
    types: begin of slis_print_alv.
    include type alv_s_prnt.
    include type slis_print_alv1.
    types: end of slis_print_alv.
    types: begin of slis_alv_event,
            name(30),
            form(30),
          end of slis_alv_event.
    types: slis_t_event type slis_alv_event occurs 0.
    TYPES: BEGIN OF ty_mseg,
          WBS         type mseg-PS_PSP_PNR,
          MSEG_WERKS  TYPE MSEG-WERKS, " Plant
          ABLAD       TYPE MSEG-ABLAD, " Unloading Point
          WEMPF       TYPE MSEG-WEMPF, " Goods Receiptent
          MBLNR       TYPE MSEG-MBLNR, " Material Do Number
        end of ty_mseg.
    Internal tables and work areas
    DATA:
          IT_MSEG         type table of TY_MSEG,
          GV_TITLE       type LVC_TITLE.
    DATA: gt_events type slis_t_event,
    gd_prntparams type slis_print_alv.
         r_alv_template type ref to ZCL_BT_ALV_TEMPLATE.
    Data declarations for the ALV grid
    DATA:      r_grid      TYPE REF TO cl_gui_alv_grid.
    DATA:      alv_fieldcat TYPE slis_t_fieldcat_alv,
               wa_alv_fieldcat TYPE slis_fieldcat_alv,
               alv_layout   TYPE slis_layout_alv,
               gd_repid     LIKE sy-repid.
    Initialization.
      select single max( ddtext ) from dd02t into TITLE01 where tabname    = 'MSEG'
                                                            and ddlanguage = sy-langu."#EC *
          D A T A   S E L E C T I O N           *
    START-OF-SELECTION.
    SET COUNTRY 'PK'.
      " Getting data from MSEG
      SELECT APS_PSP_PNR AWERKS AABLAD AWEMPF A~MBLNR
          FROM mseg AS A
          INTO table it_mseg
          WHERE a~werks in so_plant.
          A~PS_PSP_PNR IN SO_WBS.
    *BREAK-POINT.
           A L V   P R O C E S S I N G          *
    END-OF-SELECTION.
    PERFORM alv_setup.
    PERFORM display_alv.
    FORM alv_setup.
      CLEAR wa_alv_fieldcat.
      REFRESH alv_fieldcat.
      wa_alv_fieldcat-key = ''.
      wa_alv_fieldcat-fieldname = 'WBS'.
      wa_alv_fieldcat-seltext_s = 'WBS'.
      wa_alv_fieldcat-seltext_m = 'WBS Element'.
      wa_alv_fieldcat-seltext_l = 'WBS Element'.
      APPEND wa_alv_fieldcat TO alv_fieldcat.
      wa_alv_fieldcat-key = ''.
      wa_alv_fieldcat-fieldname = 'ABLAD'.
      wa_alv_fieldcat-seltext_s = 'Un Ld Pnt'.
      wa_alv_fieldcat-seltext_m = 'Un Lding Pnt'.
      wa_alv_fieldcat-seltext_l = 'Un Loading Point'.
      APPEND wa_alv_fieldcat TO alv_fieldcat.
      wa_alv_fieldcat-key = ''.
      wa_alv_fieldcat-fieldname = 'MSEG_WERKS'.
      wa_alv_fieldcat-seltext_s = 'Plant'.
      wa_alv_fieldcat-seltext_m = 'Plant'.
      wa_alv_fieldcat-seltext_l = 'Plant'.
      APPEND wa_alv_fieldcat TO alv_fieldcat.
      wa_alv_fieldcat-key = ''.
      wa_alv_fieldcat-fieldname = 'WEMPF'.
      wa_alv_fieldcat-seltext_s = 'Good Rec'.
      wa_alv_fieldcat-seltext_m = 'Good Rec'.
      wa_alv_fieldcat-seltext_l = 'Good Receipt'.
      APPEND wa_alv_fieldcat TO alv_fieldcat.
      wa_alv_fieldcat-key = ''.
      wa_alv_fieldcat-fieldname = 'MBLNR'.
      wa_alv_fieldcat-seltext_s = 'Mat Doc'.
      wa_alv_fieldcat-seltext_m = 'Mat Doc'.
      wa_alv_fieldcat-seltext_l = 'Mat. Doc. No.'.
      APPEND wa_alv_fieldcat TO alv_fieldcat.
    ENDFORM.                    " alv_setup DMBTR
    FORM display_alv.
      gd_repid = sy-repid.
    Configure layout of screen
      alv_layout-colwidth_optimize = 'X'.
      alv_layout-zebra             = 'X'.
      alv_layout-no_min_linesize   = 'X'.
    Now call display function
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
          EXPORTING
               i_callback_program       = gd_repid
               i_callback_top_of_page   = 'TOP_OF_PAGE_SETUP' "Ref to form
               is_layout                = alv_layout
               it_fieldcat              = alv_fieldcat
              i_grid_title             = text-005
                  it_events = gt_events
                  is_print = gd_prntparams
                  i_save = 'X'
          TABLES
                t_outtab                = IT_mseg
         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.
    perform build_events.
    perform build_print_params.
    ENDFORM.                    " display_alv
    FORM top_of_page_setup.
      DATA: t_header TYPE slis_t_listheader,
            wa_header TYPE slis_listheader.
      wa_header-typ  = 'H'.
      wa_header-info = 'Test Report '.
      APPEND wa_header TO t_header.
      CLEAR wa_header.
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
           EXPORTING
                it_list_commentary = t_header.
    ENDFORM.                    " top_of_page_setup
    *& 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.
    Regards
    Iftikhar Ali
    Islamabad

    Hi, 
             just populate ur eventcat  like this , may be this can help u
    form zf_eventcat  using    p_it_eventcat type slis_t_event.
      data l_eventcat type slis_alv_event.
      clear l_eventcat.
    *Get all the events.
      call function 'REUSE_ALV_EVENTS_GET'
        exporting
          i_list_type     = 0
        importing
          et_events       = p_it_eventcat
        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.
    TOP-OF-PAGE FORM
      clear l_eventcat.
      read table p_it_eventcat into l_eventcat with key
                              name = slis_ev_top_of_page.
      if sy-subrc = 0.
        move 'ZF_TOP_OF_PAGE' to l_eventcat-form.
        modify p_it_eventcat from l_eventcat index sy-tabix
                                             transporting form.
      endif.
    PF_STATUS_SET FORM
      clear l_eventcat.
      read table p_it_eventcat into l_eventcat with key
                              name = slis_ev_pf_status_set.
      if sy-subrc = 0.
        move 'ZF_PF_STATUS_SET' to l_eventcat-form.
        modify p_it_eventcat from l_eventcat index sy-tabix
                                          transporting form.
      endif.
    USER_COMMAND FORM
      clear l_eventcat.
      read table p_it_eventcat into  l_eventcat with key
                               name = slis_ev_user_command.
      if sy-subrc = 0.
        move 'ZF_USER_COMMAND' to  l_eventcat-form.
        modify p_it_eventcat from l_eventcat index sy-tabix
                                          transporting form.
      endif.
    endform.                    " zf_eventcat
    reward if helpful

Maybe you are looking for

  • In WS_DOWNLOAD   , FILETYPE                      = 'WK1'

    Hi pals,         I am using WS_DOWNLOAD function module in 4.6c, with file type = 'WK1'. i am getting EXCEL(.XLS File) results with out lines(similar to EXCEL SHEET). I need to get excel format(boxes)by using same file type (WK1) Can any body suggest

  • ITunes refuses to add songs ot the library

    Just yesturday it worked just fine and today when I try to do it it is giving me an error that I don't have the permissions when finder says I do. For some reason when I upgraded itunes this started happening.

  • Import error character set conversion

    import done in US7ASCII character set and AL16UTF16 NCHAR character set import server uses AL32UTF8 character set (possible charset conversion) export client uses WE8ISO8859P1 character set (possible charset conversion) Import terminated successfully

  • This might be a dumb question

    it seems to put a border thats visible when published around the photo, any idea why and how to get rid of it?

  • How Do I Set Print Quality in PSE 10 to above 720 DPI?

    Hello Everyone, I am trying to print a 4888px x 3456px (A4 aspect ratio) to an A4 sheet from an Epson SC-P600 inkjet printer. In the PSE 10 Print Dialog Box I have set PSE to Manage Colours and selected my printer ICC profile.  From the Print Dialog