Using user_command in reuse_alv

hai ,
        please help to solve this prob. after i used layout-list_append = 'X '.
to out put 3 alv's in one page .  use user_command is not working is  their any possible way to do this .

You can take the following approach to create multiple ALV in a single screen:
PROCESSES:
1.     Declare two input table ( gt_ekko, gt_mara) . One for Purchase Order and One for material master.
2.     Retrive data:
1.     select records from ekko to gt_ekko
2.     select records from mara to gt_mara
3.     Declare two fieldcat table one for preparing the field catalog of purchase order and other for material master.
4.     Built those two field catalog:
1.     filedcatalog1 for purchase order
2.     fieldcatalog2 for material master
5.     Build the layout.
6.     Build event for the two alv
1.     events_ekko for events of ekko.
For  xs_event-form = 'TOP_OF_PAGE-EKKO'.
And xs_event-form =  ‘END_OF_LIST_EKKO'.
We have to build two form 'TOP_OF_PAGE-EKKO' and ‘END_OF_LIST_EKKO'.
2.     events_mara for events of mara.
For  xs_event-form = 'TOP_OF_LIST-MARA'.
And xs_event-form =  'TOP_OF_PAGE-MARA'.
We have to build two form 'TOP_OF_LIST-MARA'and 'TOP_OF_PAGE-MARA'.
7.     Call the following FM’s to display the ALVs:
1.     REUSE_ALV_BLOCK_LIST_INIT : Pass only the report id.
2.     REUSE_ALV_BLOCK_LIST_APPEND for ekko and pass
I.     Fommon layout
II.     Field catalof for ekko
III.     Input table name for ekko
IV.     Event table for ekko
V.     Input table ekko
3.     REUSE_ALV_BLOCK_LIST_APPEND for mara and pass
VI.     Fommon layout
VII.     Field catalof for mara
VIII.     Input table name for mara
IX.     Event table for mara
X.     Input table mara
4.       REUSE_ALV_BLOCK_LIST_DISPLAY: Pass only is_print parameter.
REPORT  zdemoab.
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   = 10.
  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

Similar Messages

  • How to use two ALV grids in a single program (pl read below for details)?

    Please read thoroughly::
    I have an ALV report using REUSE_ALV_GRID_DISPLAY.
    On the output of this report, when I click on a "change" button, a couple of columns should be made editable.
    I achieved this by modifying the fieldcatalog and triggering the output with another REUSE_ALV_GRID_DISPLAY.
    When I click on the back button of this second report, it is still taking me to the first one.
    How to over come this?
    Note:
    I used custom containers etc but the default buttons on the container are not controllable. I added custom buttons but could not suppress the default ones. So I did not pursue this much even though this is more comfortable to use.
    I am not able to get into the code in debug to see how the default buttons like COPY, INSERT ROW etc are working.
    Can any body throw some inputs into this?
    Thanks,
    Ven.

    >I achieved this by modifying the fieldcatalog and triggering the >output with another REUSE_ALV_GRID_DISPLAY.
    >When I click on the back button of this second report, it is still >taking me to the first one.
    >How to over come this?
    For this there is a solution
    i am thinking you are using user_command and calling the second time ALV Grid if so check this.
    form user_command using r_ucomm type sy-ucomm selfield type slis_selfield.
    case r_ucomm.
    when 'CHANGE'.
    selfield-exit = 'X'.   "use this , this will solve the problem
    "i hope you are calling the Function here
    endform.

  • Display Document in USER_COMMAND IN ALV

    Hi Experts
          In ALV am using USER_COMMAND for material document number, when i click the document it needs to open the display document(MIGO).
            But its not opening the document, by defualt its coming with Goods Receipt -> Purchase Order.
          How can we set this defualt, can you pls explain.
    Thanks in advance.
    Regards
    Rajaram

    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          i_callback_program      = v_repid
          i_callback_user_command = 'PROCESS_USER_COMMANDS'
          is_layout               = w_layout
          it_fieldcat             = i_fieldcat[]
          it_sort                 = gt_sort[]
          i_default               = 'X'
          i_save                  = 'A'
          it_events               = v_events
          is_print                = w_print
        TABLES
          t_outtab                = i_final1
        EXCEPTIONS
          program_error           = 1
          OTHERS                  = 2.
    FORM process_user_commands USING syst-ucomm LIKE syst-ucomm
                                     selfield TYPE slis_selfield.
      CASE syst-ucomm.
        WHEN '&IC1'.
          IF selfield-sel_tab_field = 'I_FINAL1-VBELN'.
            w_vbeln = selfield-value.
            SET PARAMETER ID: 'VL' FIELD w_vbeln.
            CALL TRANSACTION 'VL03N' AND SKIP FIRST SCREEN.
          ELSEIF selfield-sel_tab_field = 'I_FINAL1-ORDER'.
            v_vbeln = selfield-value.
            SET PARAMETER ID: 'AUN' FIELD v_vbeln.
            CALL TRANSACTION 'VA03' AND SKIP FIRST SCREEN.
          ELSE.
            READ TABLE i_final1 INTO w_final1 INDEX selfield-tabindex.
            IF w_final1-vbeln <> ' '.
              LOOP AT i_final INTO w_final WHERE vbeln = w_final1-vbeln.
                READ TABLE i_makt INTO w_makt WITH KEY matnr = w_final-matnr .
                IF sy-subrc = 0.
                  MOVE : w_final TO w_final2.
                  MOVE : w_makt-maktx TO w_final2-maktx.
                  APPEND w_final2 TO i_final2.
                ELSE.
                  MOVE : w_final TO w_final2.
                  MOVE : ' ' TO w_final2-maktx.
                  APPEND w_final2 TO i_final2.
                ENDIF.
              ENDLOOP.
              CLEAR w_makt.
            ELSE.
              LOOP AT i_final INTO w_final WHERE order = w_final1-order.
                READ TABLE i_makt INTO w_makt WITH KEY matnr = w_final-matnr .
                IF sy-subrc  = 0.
                  MOVE : w_final TO w_final2.
                  MOVE : w_makt-maktx TO w_final2-maktx.
                  APPEND w_final2 TO i_final2.
                ELSE.
                  MOVE : w_final TO w_final2.
                  MOVE : ' ' TO w_final2-maktx.
                  APPEND w_final2 TO i_final2.
                ENDIF.
              ENDLOOP.
              CLEAR w_makt.
            ENDIF.
            PERFORM fieldcatalog1 USING selfield .
            PERFORM event_build.
            PERFORM layout_build1.
            PERFORM grid_display1.
          ENDIF.
      ENDCASE.
    ENDFORM.                               " PROCESS_USER_COMMANDS

  • USER_COMMAND in the 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'

    HAI Experts ,
         Can anyone pls give me a sample code which displays some operation using  USER_COMMAND in the 'REUSE_ALV_HIERSEQ_LIST_DISPLAY' .
    Any small sample program will be helpful.
    Regards,
    Devendran

    hi
    Check this code:
    REPORT  Z_RE_ALV_JERARQUIA    .
    *****TABLAS
    TABLES : MARA, MAKT.
    ****TIPOS
    TYPE-POOLS: SLIS.
    ****TABLAS INTERNAS
    DATA: IT_MARA LIKE MARA OCCURS 0 WITH HEADER LINE,
          WA_MARA LIKE LINE OF  IT_MARA ,
          BEGIN OF IT_HEADER OCCURS 0,
          TIPO LIKE MARA-MTART,
          END OF IT_HEADER,
          BEGIN OF IT_ITEM OCCURS 0,
          TIPO LIKE MARA-MTART,
          MATERIAL LIKE MARA-MATNR,
          MATKL  LIKE MARA-MATKL,
          MEINS  LIKE MARA-MEINS,
          MAKTX  LIKE MAKT-MAKTX,
          END OF IT_ITEM.
    *****ALV
    DATA: IT_KEYINFO  type SLIS_KEYINFO_ALV OCCURS 0 WITH HEADER LINE,
          G_REPID LIKE SY-REPID,
          IT_LAYOUT TYPE SLIS_LAYOUT_ALV,
          IT_FIELD TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE,
          IT_EVENTS TYPE SLIS_T_EVENT  WITH HEADER LINE,
          IT_LIST_TOP_OF_PAGE TYPE SLIS_T_LISTHEADER,
          IT_LIST_END_OF_PAGE TYPE SLIS_T_LISTHEADER,
          IT_SORT TYPE SLIS_T_SORTINFO_ALV WITH HEADER LINE,
          IT_FILTER TYPE SLIS_T_FILTER_ALV WITH HEADER LINE,
          GT_SP_GROUP TYPE SLIS_T_SP_GROUP_ALV,
          ls_event type slis_alv_event,
          LS_LINE TYPE slis_listheader.
    *****VARIABLES
    DATA: TEXT(60).
    ****CONSTANTES
    CONSTANTS:
    GC_FORMNAME_TOP_OF_PAGE  TYPE SLIS_FORMNAME VALUE 'TOP_OF_PAGE',
    GC_FORMNAME_END_OF_PAGE  TYPE SLIS_FORMNAME VALUE 'END_OF_PAGE'.
    ****INITIALIZATION
    INITIALIZATION.
      G_REPID = SY-REPID.
      IT_LAYOUT-ZEBRA = 'X'.
    IT_LAYOUT-no_hotspot = ' '.
    IT_layout-colwidth_optimize = 'X'.
    ****START OF SELECTION
    START-OF-SELECTION.
      SELECT-OPTIONS: TIPO FOR MARA-MTART OBLIGATORY.
      SELECT *
      FROM MARA
      INTO TABLE IT_MARA
      WHERE MTART IN TIPO.
      IF NOT IT_MARA[] IS INITIAL.
        PERFORM FO_PROCESAR.
        PERFORM FO_KEY_INFO.
        PERFORM FO_IMPRIMIR_CABECERA USING IT_LIST_TOP_OF_PAGE[].
        PERFORM FO_SORT.
        PERFORM FO_FIELDCAT.
        PERFORM FO_FILTRAR.
        PERFORM FO_EVENTOS USING IT_events[].
        PERFORM FO_MOSTRAR_ALV_JER.
      ELSE.
        MESSAGE S000(SU) WITH  TEXT-001.
      ENDIF.
    *&      Form  FO_PROCESAR
    FORM FO_PROCESAR.
      SORT IT_MARA BY MTART ASCENDING.
      LOOP AT IT_MARA.
        MOVE-CORRESPONDING IT_MARA TO WA_MARA.
        MOVE WA_MARA-MTART TO IT_HEADER-TIPO.
        APPEND IT_HEADER.
        MOVE: IT_MARA-MTART TO IT_ITEM-TIPO,
              IT_MARA-MATNR TO IT_ITEM-MATERIAL,
              IT_MARA-MATKL TO IT_ITEM-MATKL,
              IT_MARA-MEINS TO IT_ITEM-MEINS.
        SELECT SINGLE MAKTX INTO IT_ITEM-MAKTX
        FROM MAKT
        WHERE MATNR EQ IT_MARA-MATNR
        AND SPRAS EQ 'S'.
        APPEND IT_ITEM.
        CLEAR: IT_MARA, WA_MARA, IT_ITEM, IT_HEADER.
      ENDLOOP.
      SORT IT_HEADER BY TIPO ASCENDING.
      DELETE ADJACENT DUPLICATES FROM IT_HEADER COMPARING TIPO.
    ENDFORM.                    " FO_PROCESAR
    *&      Form  FO_MOSTRAR_ALV_JER
    FORM FO_MOSTRAR_ALV_JER.
      CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'
        EXPORTING
      I_INTERFACE_CHECK              = ' '
       I_CALLBACK_PROGRAM             = G_REPID
      I_CALLBACK_PF_STATUS_SET       = ' '
       I_CALLBACK_USER_COMMAND        = 'USER_COMMAND'
         IS_LAYOUT                      = IT_LAYOUT
         IT_FIELDCAT                    = IT_FIELD[]
      IT_EXCLUDING                   =
      IT_SPECIAL_GROUPS              =
         IT_SORT                        = IT_SORT[]
       IT_FILTER                      = IT_FILTER[]
      IS_SEL_HIDE                    =
      I_SCREEN_START_COLUMN          = 10
      I_SCREEN_START_LINE            = 5
      I_SCREEN_END_COLUMN            = 45
      I_SCREEN_END_LINE              = 30
      I_DEFAULT                      = 'X'
         I_SAVE                         = 'X'
      IS_VARIANT                     =
         IT_EVENTS                      = IT_EVENTS[]
      IT_EVENT_EXIT                  =
          I_TABNAME_HEADER               = 'IT_HEADER'
          I_TABNAME_ITEM                 = 'IT_ITEM'
      I_STRUCTURE_NAME_HEADER        =
      I_STRUCTURE_NAME_ITEM          =
          IS_KEYINFO                     = IT_KEYINFO
      IS_PRINT                       =
      IS_REPREP_ID                   =
      I_BUFFER_ACTIVE                =
      I_BYPASSING_BUFFER             =
    IMPORTING
      E_EXIT_CAUSED_BY_CALLER        =
      ES_EXIT_CAUSED_BY_USER         =
        TABLES
          T_OUTTAB_HEADER                = IT_HEADER
          T_OUTTAB_ITEM                  = IT_ITEM
       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.                    " FO_MOSTRAR_ALV_JER
    *&      Form  FO_KEY_INFO
    FORM FO_KEY_INFO.
      REFRESH IT_KEYINFO. CLEAR IT_KEYINFO.
      IT_KEYINFO-header01 = 'TIPO'.
      IT_KEYINFO-item01 = 'TIPO'.
      APPEND IT_KEYINFO.
    ENDFORM.                    " FO_KEY_INFO
    *&      Form  FO_IMPRIMIR_CABECERA
    FORM FO_IMPRIMIR_CABECERA USING    TEXTO_REPORT TYPE SLIS_T_LISTHEADER.
      CLEAR: LS_line, text.
      LS_line-typ  = 'H'.
      WRITE: sy-title TO text.
      LS_line-info = text.
      APPEND LS_line TO TEXTO_REPORT.
      CLEAR: LS_line, text.
      LS_line-typ  = 'A'.
      WRITE: 'Fecha de Ejecución:' to text,
              sy-DATUM TO text+20(20).
      LS_line-info = text.
      APPEND LS_line TO TEXTO_REPORT.
      CLEAR: LS_line, text.
      LS_line-typ  = 'A'.
      WRITE: 'Usuario:' to text,
      sy-uname TO text+20(20).
      LS_line-info = text.
      APPEND LS_line TO TEXTO_REPORT.
      CLEAR LS_LINE.
      APPEND LS_line TO TEXTO_REPORT.
    ENDFORM.                    " FO_IMPRIMIR_CABECERA
    *&      Form  FO_SORT
    FORM FO_SORT.
      IT_SORT-FIELDNAME = 'TIPO'.
      IT_SORT-TABNAME = 'IT_HEADER'.
      IT_SORT-GROUP   = 'X'.
      IT_SORT-UP      = 'X'.
      IT_SORT-DOWN    = ' '.
      IT_SORT-SUBTOT  = ' '.
      APPEND IT_SORT. CLEAR  IT_SORT.
    ENDFORM.                    " FO_SORT
    *&      Form  FO_FIELDCAT
    FORM FO_FIELDCAT.
      CLEAR IT_FIELD.
      IT_FIELD-TABNAME = 'IT_ITEM'.
      IT_FIELD-FIELDNAME = 'TIPO'.
      IT_FIELD-COL_POS = '1'.
      IT_FIELD-JUST = 'L'.
      IT_FIELD-SELTEXT_L = 'Tipo Material'.
      IT_FIELD-KEY = 'X'.
      APPEND  IT_FIELD.
      CLEAR IT_FIELD.
      IT_FIELD-TABNAME = 'IT_ITEM'.
      IT_FIELD-FIELDNAME = 'MATERIAL'.
      IT_FIELD-COL_POS = '2'.
      IT_FIELD-JUST = 'L'.
      IT_FIELD-SELTEXT_L = 'Codigo Material'.
      APPEND  IT_FIELD.
      CLEAR IT_FIELD.
      IT_FIELD-TABNAME = 'IT_ITEM'.
      IT_FIELD-FIELDNAME = 'MATKL'.
      IT_FIELD-COL_POS = '3'.
      IT_FIELD-JUST = 'L'.
      IT_FIELD-SELTEXT_L = 'Grupo De Articulos'.
      APPEND  IT_FIELD.
      CLEAR IT_FIELD.
      IT_FIELD-TABNAME = 'IT_ITEM'.
      IT_FIELD-FIELDNAME = 'MEINS'.
      IT_FIELD-COL_POS = '4'.
      IT_FIELD-JUST = 'L'.
      IT_FIELD-SELTEXT_L = 'Uni. Med. Base'.
      APPEND  IT_FIELD.
      CLEAR IT_FIELD.
      IT_FIELD-TABNAME = 'IT_ITEM'.
      IT_FIELD-FIELDNAME = 'MAKTX'.
      IT_FIELD-COL_POS = '5'.
      IT_FIELD-JUST = 'L'.
      IT_FIELD-outputlen = '40'.
      IT_FIELD-SELTEXT_L = 'Descriptivo'.
      APPEND  IT_FIELD.
    ENDFORM.                    " FO_FIELDCAT
    *&      Form  FO_EVENTOS
    FORM FO_EVENTOS  USING PIT_EVENTS type slis_t_event.
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
           EXPORTING
                I_LIST_TYPE     = 0
           IMPORTING
                ET_EVENTS       = PIT_EVENTS
           EXCEPTIONS
                LIST_TYPE_WRONG = 1
                OTHERS          = 2.
      read table PIT_EVENTS with key name = SLIS_EV_TOP_OF_PAGE
                  into ls_event.
      if sy-subrc = 0.
        move gc_formname_top_of_page to ls_event-form.
        append ls_event to pIT_EVENTS.
      endif.
      CLEAR LS_EVENT.
    ENDFORM.                    " FO_EVENTOS
    *&       FORM top_of_page                                              *
    FORM TOP_OF_PAGE.
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
           EXPORTING
               i_logo             = 'ZLOGO_GRUPO_POLAR'
                IT_LIST_COMMENTARY = IT_LIST_TOP_OF_PAGE.
    ENDFORM.                    "TOP_OF_PAGE
    *&      Form  FO_FILTRAR
    FORM FO_FILTRAR.
    *IT_FILTER-FIELDNAME = 'TIPO'.
    *IT_FILTER-TABNAME = 'IT_HEADER'.
    *APPEND IT_FILTER. CLEAR IT_FILTER.
    ENDFORM.                    " FO_FILTRAR
    *&      Form  USER_COMMAND
    FORM USER_COMMAND  USING ucomm LIKE sy-ucomm
                         selfield TYPE slis_selfield.
    READ TABLE IT_ITEM INDEX SELFIELD-TABINDEX.
    IF SY-SUBRC EQ 0.
    ENDIF.
    ENDFORM.                    " USER_COMMAND
    Regards
    Gregory

  • Use of Parameter ID

    Please explain how to use the parameter Id and Search Help in Data Element Creation.

    hi,
    explain how to use the parameter Id ?
    It is used to retain the value across screens/sessions.for creating parameter ID goto sm30 give  the table TPARA->set/get parameter id
    use with example:mainly used for traversing from report to transactions.
    REPORT  ZSR_ALV_INTERACTIVE.
    TABLES : LFA1,EKKO,EKPO.
    SELECT-OPTIONS : VENDOR FOR LFA1-LIFNR.
    DATA : BEGIN OF ITAB OCCURS 0,
           LIFNR LIKE LFA1-LIFNR,
           NAME1 LIKE LFA1-NAME1,
           END OF ITAB.
    DATA : BEGIN OF JTAB OCCURS 0,
           EBELN LIKE EKKO-EBELN,
           AEDAT LIKE EKKO-AEDAT,
           END OF JTAB.
    DATA : BEGIN OF KTAB OCCURS 0,
           EBELP LIKE EKPO-EBELP,
           MATNR LIKE EKPO-MATNR,
           END OF KTAB.
    TYPE-POOLS : SLIS.
    DATA : REPID LIKE SY-REPID.
    DATA :LFA1_B TYPE SLIS_T_FIELDCAT_ALV,
          LFA1_W TYPE SLIS_FIELDCAT_ALV,
          EKKO_B TYPE SLIS_T_FIELDCAT_ALV,
          EKKO_W TYPE SLIS_FIELDCAT_ALV,
          EKPO_B TYPE SLIS_T_FIELDCAT_ALV,
          EKPO_W TYPE SLIS_FIELDCAT_ALV,
          EVENTS_B TYPE SLIS_T_EVENT,
          EVENTS_W TYPE SLIS_ALV_EVENT.
    PERFORM GET_VAL.
    REPID = SY-REPID.
    SELECT LIFNR NAME1 FROM LFA1 INTO TABLE ITAB WHERE LIFNR IN VENDOR.
    *perform val USING USER_COMMAND sel.
    CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
      EXPORTING
        I_CALLBACK_PROGRAM = REPID
        IT_FIELDCAT        = LFA1_B
        IT_EVENTS          = EVENTS_B
      TABLES
        T_OUTTAB           = ITAB.
    FORM GET_VAL.
      LFA1_W-FIELDNAME = 'LIFNR'.
      LFA1_W-REF_TABNAME = 'LFA1'.
      LFA1_W-REF_FIELDNAME = 'LIFNR'.
      APPEND LFA1_W TO LFA1_B.
      LFA1_W-FIELDNAME = 'NAME1'.
      LFA1_W-REF_TABNAME = 'LFA1'.
      LFA1_W-REF_FIELDNAME = 'NAME1'.
      APPEND LFA1_W TO LFA1_B.
      EKKO_W-FIELDNAME = 'EBELN'.
      EKKO_W-REF_TABNAME = 'EKKO'.
      EKKO_W-REF_FIELDNAME = 'EBELN'.
      APPEND EKKO_W TO EKKO_B.
      EKKO_W-FIELDNAME = 'AEDAT'.
      EKKO_W-REF_TABNAME = 'EKKO'.
      EKKO_W-REF_FIELDNAME = 'AEDAT'.
      APPEND EKKO_W TO EKKO_B.
      EKPO_W-FIELDNAME = 'EBELP'.
      EKPO_W-REF_TABNAME = 'EKPO'.
      EKPO_W-REF_FIELDNAME = 'EBELP'.
      APPEND EKPO_W TO EKPO_B.
      EKPO_W-FIELDNAME = 'MATNR'.
      EKPO_W-REF_TABNAME = 'EKPO'.
      EKPO_W-REF_FIELDNAME = 'MATNR'.
      APPEND EKPO_W TO EKPO_B.
      EVENTS_W-NAME = 'USER_COMMAND'.
      EVENTS_W-FORM = 'VAL'.
      APPEND EVENTS_W TO EVENTS_B.
    ENDFORM.                    "GET_VAL
    FORM VAL USING USER_COMMAND LIKE SY-UCOMM SEL TYPE SLIS_SELFIELD.
      DATA : VEN(10) TYPE N,
             PO(10) TYPE N.
      DATA : MAT(10) TYPE C.
      IF SEL-FIELDNAME = 'LIFNR'.
        VEN = SEL-VALUE.
        SELECT EBELN AEDAT FROM EKKO INTO TABLE JTAB WHERE LIFNR = VEN.
       CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
        EXPORTING
          I_CALLBACK_PROGRAM             = REPID
         I_STRUCTURE_NAME               = EKKO_B
          IT_FIELDCAT                    = EKKO_B
          IT_EVENTS                      = EVENTS_B
         TABLES
           T_OUTTAB                       = JTAB.
      ENDIF.
      IF SEL-FIELDNAME = 'EBELN'.
        PO = SEL-VALUE.
        SELECT EBELP MATNR FROM EKPO INTO TABLE KTAB WHERE EBELN = PO.
        CALL FUNCTION 'REUSE_ALV_POPUP_TO_SELECT'
          EXPORTING
            I_TITLE            = 'ITEM DETAILS'
            I_TABNAME          = 'EKPO'
            IT_FIELDCAT        = EKPO_B
            I_CALLBACK_PROGRAM = REPID
          IMPORTING
            ES_SELFIELD        = SEL
          TABLES
            T_OUTTAB           = KTAB.
      ENDIF.
    logic to select a record
      IF SEL-FIELDNAME = 'MATNR'.
        <b>MAT = SEL-VALUE.
        SET PARAMETER ID 'MAT' FIELD MAT.</b>    CALL TRANSACTION 'MM02' AND SKIP FIRST SCREEN.
      ENDIF.
    ENDFORM.                    "VAL
    Search Help :
    http://help.sap.com/saphelp_nw04/helpdata/en/cf/21ee38446011d189700000e8322d00/content.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/cf/21ee45446011d189700000e8322d00/content.htm
    pls go through this for search help creation
    http://help.sap.com/saphelp_nw2004s/helpdata/en/41/f6b237fec48c67e10000009b38f8cf/content.htm

  • Doubt in calltransaction in ALV

    Hi, i have doubt in calltransction in alv..In my report am using ALV grid display to display purchase order number , material docu number ..If i click on purchasing docu number it has to call transaction ME23N for the purchase order number that i have clicked and if i click material document number it has to  call trainsaction MIGO for the corresponding material document number..Here i have done some coding plz correct me if iam wrong..
    *& Report  YCALLTRANSACTIONALV                                         *
    REPORT  YCALLTRANSACTIONALV                     .
    TYPE-POOLS: icon.
    TYPE-POOLS: slis.
    TABLES: vbak,vbap,vbep, makt,lips.
    DATA: BEGIN OF gt_vbak OCCURS 0,
    vbeln LIKE vbak-vbeln,
    audat LIKE vbak-audat,
    vdatu LIKE vbak-vdatu,
    kunnr LIKE vbak-kunnr,
    posnr LIKE vbap-posnr,
    matnr LIKE vbap-matnr,
    kwmeng LIKE vbap-kwmeng,
    END OF gt_vbak.
    DATA: BEGIN OF gt_vbep OCCURS 0,
    vbeln LIKE vbep-vbeln,
    wadat LIKE vbep-wadat,
    END OF gt_vbep.
    DATA: BEGIN OF gt_lips OCCURS 0,
    vbeln LIKE lips-vbeln,
    posnr LIKE lips-posnr,
    lfimg LIKE lips-lfimg,
    vgbel LIKE lips-vgbel,
    vgpos LIKE lips-vgpos,
    END OF gt_lips.
    DATA: BEGIN OF gt_makt OCCURS 0,
    matnr LIKE makt-matnr,
    maktx LIKE makt-maktx,
    END OF gt_makt.
    DATA: gv_tab TYPE slis_tabname VALUE 'GT_REPORT'.
    DATA: BEGIN OF gt_report OCCURS 0,
    vbeln LIKE vbak-vbeln,
    posnr LIKE vbep-posnr,
    matnr LIKE vbap-matnr,
    maktx LIKE makt-maktx,
    kwmeng LIKE vbap-kwmeng,
    vdatu LIKE vbak-vdatu,
    lfimg LIKE lips-lfimg,
    wadat LIKE vbep-wadat,
    vgbel LIKE lips-vgbel,
    icon TYPE icon-id,
    tabcolor TYPE lvc_t_scol,
    END OF gt_report.
    DATA: gt_fieldcat TYPE slis_t_fieldcat_ alv,
             gs_fieldcat TYPE slis_fieldcat_ alv,
                gs_layout TYPE slis_layout_ alv,
                gt_events TYPE slis_t_event,
                  gs_events TYPE slis_alv_event,
    repid LIKE sy-repid.
    DATA: gt_lines TYPE TABLE OF tline WITH HEADER LINE,
    gv_name LIKE thead-tdname,
    gv_fld(40),gv_ fval(50).
    DATA: BEGIN OF gt_outlines OCCURS 0,
    text TYPE tdline,
    END OF gt_outlines.
    SELECTION-SCREEN BEGIN OF BLOCK b3 WITH FRAME TITLE text-006.
    SELECTION-SCREEN BEGIN OF LINE.
    PARAMETERS: p_cust RADIOBUTTON GROUP rad1 USER-COMMAND ch DEFAULT 'X'.
    SELECTION-SCREEN COMMENT 5(20) text-001.
    SELECTION-SCREEN END OF LINE.
    SELECTION-SCREEN BEGIN OF LINE.
    PARAMETERS: p_date RADIOBUTTON GROUP rad1 .
    SELECTION-SCREEN COMMENT 5(10) text-002 .
    SELECTION-SCREEN END OF LINE.
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-005.
    SELECT-OPTIONS: s_sale FOR vbak-vbeln MODIF ID cus,
    s_cust FOR vbak-kunnr MODIF ID cus.
    SELECTION-SCREEN END OF BLOCK b1.
    SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-005.
    SELECT-OPTIONS: s_sale1 FOR vbak-vbeln MODIF ID dat,
    s_dat FOR vbak-audat MODIF ID dat.
    SELECTION-SCREEN END OF BLOCK b2.
    SELECTION-SCREEN END OF BLOCK b3.
    SELECTION-SCREEN BEGIN OF BLOCK b4 WITH FRAME TITLE text-007.
    SELECTION-SCREEN BEGIN OF LINE.
    PARAMETERS: p_clas RADIOBUTTON GROUP rad2 ."USER-COMMAND ch DEFAULT'X'.
    SELECTION-SCREEN COMMENT 5(20) text-003.
    SELECTION-SCREEN END OF LINE.
    SELECTION-SCREEN BEGIN OF LINE.
    PARAMETERS: p_alv RADIOBUTTON GROUP rad2 ."USER-COMMAND ch DEFAULT'X'.
    SELECTION-SCREEN COMMENT 5(20) text-004.
    SELECTION-SCREEN END OF LINE.
    SELECTION-SCREEN END OF BLOCK b4.
    AT SELECTION-SCREEN.
    CHECK sy-ucomm = 'CH'.
    AT SELECTION-SCREEN OUTPUT.
    IF p_cust = 'X'.
    LOOP AT SCREEN.
    IF screen-group1 = 'DAT'.
    screen-active = 0.
    ELSE.
    screen-active = 1.
    ENDIF.
    MODIFY SCREEN.
    ENDLOOP.
    ELSE.
    LOOP AT SCREEN.
    IF screen-group1 = 'CUS'.
    screen-active = 0.
    ELSE.
    screen-active = 1.
    ENDIF.
    MODIFY SCREEN.
    ENDLOOP.
    ENDIF.
    START-OF-SELECTION.
    IF p_cust = 'X' .
    CLEAR gt_vbak.
    REFRESH gt_vbak.
    SELECT avbeln aaudat avdatu akunnr bposnr bmatnr b~kwmeng
    INTO TABLE gt_vbak
    FROM vbak AS a INNER JOIN vbap AS b
    ON avbeln = bvbeln
    WHERE a~vbeln IN s_sale
    AND a~kunnr IN s_cust.
    ELSEIF p_date = 'X'.
    CLEAR gt_vbak.
    REFRESH gt_vbak.
    SELECT avbeln aaudat avdatu akunnr bposnr bmatnr b~kwmeng
    INTO TABLE gt_vbak
    FROM vbak AS a INNER JOIN vbap AS b
    ON avbeln = bvbeln
    WHERE a~vbeln IN s_sale1
    AND a~audat IN s_dat.
    ENDIF.
    PERFORM sel_data.
    IF p_alv = 'X'.
    PERFORM disp_data1.
    ELSE.
    PERFORM disp_data.
    ENDIF.
    AT LINE-SELECTION.
    GET CURSOR FIELD gv_fld .
    CASE gv_fld.
    WHEN 'ICON_DISPLAY_ TEXT'.
    PERFORM concate_text.
    CLEAR gv_name.
    CONCATENATE gt_report-vbeln gt_report-posnr INTO gv_name.
    PERFORM read_text.
    PERFORM write_text.
    PERFORM disp_text.
    WHEN 'GT_REPORT-VBELN' .
    SET PARAMETER ID 'AUN' FIELD gt_report-vbeln.
    CALL TRANSACTION 'VA03' AND SKIP FIRST SCREEN.
    ENDCASE.
    *& Form sel_data
    FORM sel_data .
    CLEAR gt_vbep.
    REFRESH gt_vbep.
    IF NOT gt_vbak[] IS INITIAL.
    SELECT vbeln wadat FROM vbep INTO TABLE gt_vbep
    FOR ALL ENTRIES IN gt_vbak
    WHERE vbeln = gt_vbak-vbeln.
    CLEAR gt_lips.
    REFRESH gt_lips.
    SELECT vbeln posnr lfimg vgbel vgpos FROM lips INTO TABLE gt_lips
    FOR ALL ENTRIES IN gt_vbak
    WHERE vgbel = gt_vbak-vbeln
    AND vgpos = gt_vbak-posnr.
    CLEAR gt_makt.
    REFRESH gt_makt.
    SELECT matnr maktx FROM makt INTO TABLE gt_makt
    FOR ALL ENTRIES IN gt_vbak
    WHERE matnr = gt_vbak-matnr.
    ENDIF.
    REFRESH gt_report.
    CLEAR gt_report.
    LOOP AT gt_vbak.
    gt_report-vbeln = gt_vbak-vbeln.
    gt_report-vdatu = gt_vbak-vdatu.
    gt_report-posnr = gt_vbak-posnr.
    gt_report-matnr = gt_vbak-matnr.
    gt_report-kwmeng = gt_vbak-kwmeng.
    CLEAR gt_vbep.
    READ TABLE gt_vbep WITH KEY vbeln = gt_vbak-vbeln.
    gt_report-wadat = gt_vbep-wadat.
    CLEAR gt_lips.
    READ TABLE gt_lips WITH KEY vgbel = gt_vbak-vbeln
    vgpos = gt_vbak-posnr.
    gt_report-lfimg = gt_lips-lfimg.
    gt_report-vgbel = gt_lips-vbeln.
    CLEAR gt_makt.
    READ TABLE gt_makt WITH KEY matnr = gt_vbak-matnr.
    gt_report-maktx = gt_makt-maktx.
    CLEAR gt_report-icon.
    PERFORM concate_text.
    CLEAR gv_name.
    CONCATENATE gt_report-vbeln gt_report-posnr INTO gv_name.
    PERFORM read_text.
    IF gt_lines[] IS NOT INITIAL.
    gt_report-icon = '@0P@'.
    ENDIF.
    APPEND gt_report.
    ENDLOOP.
    ENDFORM. " sel_data
    *& Form disp_data
    FORM disp_data .
    WRITE:/(8) 'orderno.',
    (8) 'lineno.',
    (11) 'mat.',
    (27) 'matdes.',
    (10) 'ord.qty',
    (12) 'req.del.',
    (10) 'del.qty',
    (10) 'gidate',
    (10) 'delno.'.
    ULINE.
    LOOP AT gt_report.
    WRITE:/(8) gt_report-vbeln COLOR 6 HOTSPOT,
    (8) gt_report-posnr ,
    (8) gt_report-matnr,
    (25) gt_report-maktx,
    (11) gt_report-kwmeng,
    (15) gt_report-vdatu,
    (7) gt_report-lfimg,
    (10) gt_report-wadat,
    (10) gt_report-vgbel.
    PERFORM concate_text.
    CLEAR gv_name.
    CONCATENATE gt_report-vbeln gt_report-posnr INTO gv_name.
    PERFORM read_text.
    IF gt_lines[] IS NOT INITIAL.
    WRITE:120 icon_display_ text AS ICON HOTSPOT.
    HIDE: gt_report-vbeln, gt_report- posnr.
    ENDIF.
    ENDLOOP.
    ENDFORM. " disp_data
    *& Form disp_data1
    FORM disp_data1 .
    DATA :
    ls_tabcolor TYPE lvc_s_scol.
    CLEAR gs_fieldcat.
    gs_fieldcat- tabname = gv_tab.
    gs_fieldcat- fieldname = 'VBELN'.
    gs_fieldcat- hotspot = 'X'.
    gs_fieldcat- seltext_l = 'ORDERNO'.
    APPEND gs_fieldcat TO gt_fieldcat.
    CLEAR gs_fieldcat.
    gs_fieldcat- tabname = gv_tab.
    gs_fieldcat- fieldname = 'POSNR'.
    gs_fieldcat- seltext_l = 'LINENO'.
    APPEND gs_fieldcat TO gt_fieldcat.
    CLEAR gs_fieldcat.
    gs_fieldcat- tabname = gv_tab.
    gs_fieldcat- fieldname = 'MATNR'.
    gs_fieldcat- seltext_l = 'MATNO'.
    APPEND gs_fieldcat TO gt_fieldcat.
    CLEAR gs_fieldcat.
    gs_fieldcat- tabname = gv_tab.
    gs_fieldcat- fieldname = 'MAKTX'.
    gs_fieldcat- seltext_l = 'MATDESCR'.
    APPEND gs_fieldcat TO gt_fieldcat.
    CLEAR gs_fieldcat.
    gs_fieldcat- tabname = gv_tab.
    gs_fieldcat- fieldname = 'KWMENG'.
    gs_fieldcat- seltext_l = 'ORDERQTY'.
    APPEND gs_fieldcat TO gt_fieldcat.
    CLEAR gs_fieldcat.
    gs_fieldcat- tabname = gv_tab.
    gs_fieldcat- fieldname = 'VDATU'.
    gs_fieldcat- seltext_l = 'REQ.DEL.DAT' .
    APPEND gs_fieldcat TO gt_fieldcat.
    CLEAR gs_fieldcat.
    gs_fieldcat- tabname = gv_tab.
    gs_fieldcat- fieldname = 'LFIMG'.
    gs_fieldcat- seltext_l = 'QTY.DEL'.
    APPEND gs_fieldcat TO gt_fieldcat.
    CLEAR gs_fieldcat.
    gs_fieldcat- tabname = gv_tab.
    gs_fieldcat- fieldname = 'WADAT'.
    gs_fieldcat- seltext_l = 'ISS.DATE'.
    APPEND gs_fieldcat TO gt_fieldcat.
    CLEAR gs_fieldcat.
    gs_fieldcat- tabname = gv_tab.
    gs_fieldcat- fieldname = 'VGBEL'.
    gs_fieldcat- seltext_l = 'DOUC.NO'.
    APPEND gs_fieldcat TO gt_fieldcat.
    CLEAR gs_fieldcat.
    gs_fieldcat- tabname = gv_tab.
    gs_fieldcat- fieldname = 'ICON'.
    gs_fieldcat- seltext_l = 'TEXT'.
    gs_fieldcat- icon = 'X'.
    gs_fieldcat- hotspot = 'X'.
    APPEND gs_fieldcat TO gt_fieldcat.
    gs_layout-coltab_ fieldname = 'TABCOLOR'.
    gs_events-name = 'USER_COMMAND' .
    gs_events-form = 'VAL'.
    APPEND gs_events TO gt_events.
    LOOP AT gt_report.
    ls_tabcolor- fname = 'VBELN'.
    ls_tabcolor- color-col = 4.
    ls_tabcolor- color-int = 1.
    ls_tabcolor- color-inv = 0.
    INSERT ls_tabcolor INTO TABLE gt_report-tabcolor.
    MODIFY gt_report.
    ENDLOOP.
    CALL FUNCTION 'REUSE_ALV_GRID_ DISPLAY'
    EXPORTING
    i_callback_program = sy-repid
    is_layout = gs_layout
    it_fieldcat = gt_fieldcat
    it_events = gt_events
    TABLES
    t_outtab = gt_report.
    ENDFORM. " disp_data1
    *& Form READ_TEXT .
    FORM read_text .
    CLEAR gt_lines.
    REFRESH gt_lines.
    CALL FUNCTION 'READ_TEXT'
    EXPORTING
    id = '0002'
    language = sy-langu
    name = gv_name
    object = 'VBBP'
    TABLES
    lines = gt_lines
    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.
    ENDIF.
    ENDFORM. " READ_TEXT
    *& Form WRITE_TEXT.
    FORM write_text.
    REFRESH gt_outlines.
    CLEAR gt_outlines.
    CLEAR gt_lines.
    LOOP AT gt_lines .
    MOVE gt_lines-tdline TO gt_outlines- text .
    APPEND gt_outlines.
    ENDLOOP.
    CLEAR gt_outlines.
    ENDFORM. "WRITE_TEXT
    *& Form VAL .
    FORM val USING
    user_command LIKE sy-ucomm
    sel TYPE slis_selfield.
    IF sel-fieldname = 'VBELN'.
    SET PARAMETER ID 'AUN' FIELD gt_report-vbeln.
    CALL TRANSACTION 'VA03' AND SKIP FIRST SCREEN.
    ENDIF.
    IF sel-fieldname = 'ICON'.
    CLEAR gt_report.
    READ TABLE gt_report INDEX sel-tabindex.
    perform concate_text.
    CLEAR gv_name.
    CONCATENATE gt_report-vbeln gt_report-posnr INTO gv_name.
    PERFORM read_text.
    PERFORM write_text.
    PERFORM disp_text1.
    ENDIF.
    ENDFORM. "val
    *& Form disp_text
    FORM disp_text .
    CALL FUNCTION 'POPUP_WITH_ TABLE_DISPLAY_ OK'
    EXPORTING
    endpos_col = 50
    endpos_row = 30
    startpos_col = 20
    startpos_row = 20
    titletext = 'TEXT'
    TABLES
    valuetab = gt_outlines.
    ENDFORM. " disp_text
    *& Form disp_text1
    FORM disp_text1 .
    DATA: lt_fieldcat TYPE slis_t_fieldcat_ alv,
    ls_fieldcat TYPE slis_fieldcat_ alv.
    ls_fieldcat- fieldname = 'TEXT'.
    ls_fieldcat- outputlen = 40.
    ls_fieldcat- tabname = gt_outlines.
    APPEND ls_fieldcat TO lt_fieldcat.
    CALL FUNCTION 'REUSE_ALV_POPUP_ TO_SELECT'
    EXPORTING
    i_title = 'TEXT'
    i_tabname = 'TLINE'
    it_fieldcat = lt_fieldcat
    i_callback_program = sy-repid
    TABLES
    t_outtab = gt_outlines.
    ENDFORM. " disp_text1
    *& Form concate_text
    FORM concate_text .
    CLEAR gv_name.
    CONCATENATE gt_report-vbeln gt_report-posnr INTO gv_name.
    PERFORM read_text.
    ENDFORM. " concate_text
    Thanks

    Hello skk
    Here is a sample report performing the required task using OO-means. I think you will agree that the OO-based approach is much simpler and easier to understand than the FM-based approach.
    The screen '0100' has the following flow logic without any dynpro elements:
    PROCESS BEFORE OUTPUT.
      MODULE STATUS_0100.
    PROCESS AFTER INPUT.
      MODULE USER_COMMAND_0100.
    *& Report  ZUS_SDN_ALVGRID_EVENTS
    REPORT  zus_sdn_alvgrid_events.
    DATA:
      gd_okcode        TYPE ui_func,
      gt_fcat          TYPE lvc_t_fcat,
      go_docking       TYPE REF TO cl_gui_docking_container,
      go_grid1         TYPE REF TO cl_gui_alv_grid.
    DATA:
      gt_knb1          TYPE STANDARD TABLE OF knb1.
    PARAMETERS:
      p_bukrs      TYPE bukrs  DEFAULT '1000'  OBLIGATORY.
    *       CLASS lcl_eventhandler DEFINITION
    CLASS lcl_eventhandler DEFINITION.
      PUBLIC SECTION.
        CLASS-METHODS:
          handle_hotspot_click FOR EVENT hotspot_click OF cl_gui_alv_grid
            IMPORTING
              e_row_id
              e_column_id
              es_row_no
              sender.
    ENDCLASS.                    "lcl_eventhandler DEFINITION
    *       CLASS lcl_eventhandler IMPLEMENTATION
    CLASS lcl_eventhandler IMPLEMENTATION.
      METHOD handle_hotspot_click.
    *   define local data
        DATA:
          ls_knb1     TYPE knb1,
          ls_col_id   TYPE lvc_s_col.
        READ TABLE gt_knb1 INTO ls_knb1 INDEX e_row_id-index.
        CHECK ( ls_knb1-kunnr IS NOT INITIAL ).
        CASE e_column_id-fieldname.
          WHEN 'KUNNR'.
            SET PARAMETER ID 'KUN' FIELD ls_knb1-kunnr.
            SET PARAMETER ID 'BUK' FIELD ls_knb1-bukrs.
            CALL TRANSACTION 'XD03' AND SKIP FIRST SCREEN.
          WHEN 'ERNAM'.
    *        SET PARAMETER ID 'USR' FIELD ls_knb1-ernam.
    *        NOTE: no parameter id available, yet simply show the priciple
            CALL TRANSACTION 'SU01' AND SKIP FIRST SCREEN.
          WHEN OTHERS.
    *       do nothing
        ENDCASE.
    *   Set active cell to field BUKRS otherwise the focus is still on
    *   field KUNNR which will always raise event HOTSPOT_CLICK
        ls_col_id-fieldname = 'BUKRS'.
        CALL METHOD go_grid1->set_current_cell_via_id
          EXPORTING
            is_row_id    = e_row_id
            is_column_id = ls_col_id.
      ENDMETHOD.                    "handle_hotspot_click
    ENDCLASS.                    "lcl_eventhandler IMPLEMENTATION
    START-OF-SELECTION.
      SELECT        * FROM  knb1 INTO TABLE gt_knb1
             WHERE  bukrs  = p_bukrs.
    * Create docking container
      CREATE OBJECT go_docking
        EXPORTING
          parent                      = cl_gui_container=>screen0
          ratio                       = 90
        EXCEPTIONS
          OTHERS                      = 6.
      IF sy-subrc <> 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    * Create ALV grid
      CREATE OBJECT go_grid1
        EXPORTING
          i_parent          = go_docking
        EXCEPTIONS
          OTHERS            = 5.
      IF sy-subrc <> 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    * Set event handler
      SET HANDLER:
        lcl_eventhandler=>handle_hotspot_click FOR go_grid1.
    * Build fieldcatalog and set hotspot for field KUNNR
      PERFORM build_fieldcatalog_knb1.
    * Display data
      CALL METHOD go_grid1->set_table_for_first_display
        CHANGING
          it_outtab       = gt_knb1
          it_fieldcatalog = gt_fcat
        EXCEPTIONS
          OTHERS          = 4.
      IF sy-subrc <> 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    * Link the docking container to the target dynpro
      CALL METHOD go_docking->link
        EXPORTING
          repid                       = syst-repid
          dynnr                       = '0100'
    *      CONTAINER                   =
        EXCEPTIONS
          OTHERS                      = 4.
      IF sy-subrc <> 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    * ok-code field = GD_OKCODE
      CALL SCREEN '0100'.
    END-OF-SELECTION.
    *&      Module  STATUS_0100  OUTPUT
    *       text
    MODULE status_0100 OUTPUT.
      SET PF-STATUS 'STATUS_0100'.
    *  SET TITLEBAR 'xxx'.
    ENDMODULE.                 " STATUS_0100  OUTPUT
    *&      Module  USER_COMMAND_0100  INPUT
    *       text
    MODULE user_command_0100 INPUT.
      CASE gd_okcode.
        WHEN 'BACK' OR
             'END'  OR
             'CANC'.
          SET SCREEN 0. LEAVE SCREEN.
        WHEN OTHERS.
      ENDCASE.
      CLEAR: gd_okcode.
    ENDMODULE.                 " USER_COMMAND_0100  INPUT
    *&      Form  BUILD_FIELDCATALOG_KNB1
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM build_fieldcatalog_knb1 .
    * define local data
      DATA:
        ls_fcat        TYPE lvc_s_fcat.
      CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
        EXPORTING
    *     I_BUFFER_ACTIVE              =
          i_structure_name             = 'KNB1'
    *     I_CLIENT_NEVER_DISPLAY       = 'X'
    *     I_BYPASSING_BUFFER           =
    *     I_INTERNAL_TABNAME           =
        CHANGING
          ct_fieldcat                  = gt_fcat
        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.
      LOOP AT gt_fcat INTO ls_fcat
              WHERE ( fieldname = 'KUNNR'  OR
                      fieldname = 'ERNAM' ).
        ls_fcat-hotspot = abap_true.
        MODIFY gt_fcat FROM ls_fcat.
      ENDLOOP.
    ENDFORM.                    " BUILD_FIELDCATALOG_KNB1
    Regards
      Uwe

  • Edit an field in alv and save it

    i have an report in alv, i have used func module 'alv_list_display'.
      i have to make an field edit'able,(so that i can edit,change the existing data) then i have to save the data so that the data is stored in the table.

    Hi,
    you have to use fieldcat-input = 'X', and edit = 'X'.to make the fields editable in alv display.and SAVE you need the SAVE button.
    report  ztest_alv_check     message-id zz           .
    type-pools: slis.
    data: x_fieldcat type slis_fieldcat_alv,
          it_fieldcat type slis_t_fieldcat_alv,
          l_layout type slis_layout_alv,
          x_events type slis_alv_event,
          it_events type slis_t_event.
    data: begin of itab occurs 0,
          vbeln like vbak-vbeln,
          posnr like vbap-posnr,
         end of itab.
    select vbeln
           posnr
           from vbap
           up to 20 rows
           into table itab.
    x_fieldcat-fieldname = 'VBELN'.
    x_fieldcat-seltext_l = 'VBELN'.
    x_fieldcat-tabname = 'ITAB'.
    x_fieldcat-input = 'X'.
    x_fieldcat-edit = 'X'.
    x_fieldcat-col_pos = 1.
    append x_fieldcat to it_fieldcat.
    clear x_fieldcat.
    x_fieldcat-fieldname = 'POSNR'.
    x_fieldcat-seltext_l = 'POSNR'.
    x_fieldcat-tabname = 'ITAB'.
    x_fieldcat-input = 'X'.
    x_fieldcat-edit = 'X'.
    x_fieldcat-col_pos = 2.
    append x_fieldcat to it_fieldcat.
    clear x_fieldcat.
    l_layout-zebra = 'X'.
    call function 'REUSE_ALV_LIST_DISPLAY'
      exporting
        i_callback_program       = sy-repid
        is_layout                = l_layout
        i_callback_pf_status_set = 'STATUS'
        i_callback_user_command  = 'USER_COMMAND'
        it_fieldcat              = it_fieldcat
       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.
    "using the PF-status enable the SAVE button
    "give some OKCODE to SAVE button and handle it
    "using user_command form
    form status using p_extab type slis_t_extab.
    *- Pf status
      set pf-status 'STATUS'.
    endform.                 " STATUS
    form user_command using r_ucomm     like sy-ucomm
                                   rs_selfield type slis_selfield.
      case r_ucomm.
        when 'BACK' or 'CANC' or 'EXIT'.
          leave to screen 0.
        when 'SAVE'.
         "here you have to find the changed records,and   modify the DB.
      endcase.
    endform.                    "USER_COMMAND
    Regards
    vijay

  • Menu pbm in ALV......pleas see my code......& have ur point.s

    Hi all,
    I am trying to use "user_command" in ALV grid...in order to give my own functionality to the menu buttons. Program is giving my short dump.....saying "In a subroutine call, there were parameters than in the routine defination USER_COMMAND"
    <b>Here is my source code-</b>
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          i_callback_program = sy-repid
          i_structure_name = 'ZMYSTRUCT'
         I_CALLBACK_USER_COMMAND           = 'USER_COMMAND'
          i_callback_pf_status_set = 'SET_PF_STATUS'
          it_events          = it_event
          it_sort            = it_sort
        TABLES
          t_outtab           = itab.
    ENDFORM.                    "display_grid
    FORM user_command.
      CASE sy-ucomm.
        WHEN 'EXIT'.
          LEAVE PROGRAM.
      ENDCASE.
    ENDFORM.                    "USER_COMMAND
    Regards,
    pradeep phogat

    report  z_alv.
    type-pools: slis.
          Types                    Begin with TY_                       *
    *type-pools: slis.
    types  : begin of ty_billing ,
            bukrs          like bkpf-bukrs,
            gjahr          like bkpf-gjahr,
            monat          like bkpf-monat,
            blart          like bkpf-blart,
            budat          like bkpf-budat,
            belnr          like bkpf-belnr,
            hkont          like bsis-hkont,
            shkzg          like bseg-shkzg,
            dmbtr          like bseg-dmbtr,
           d_dmbtr        like bseg-dmbtr,
            d_dmbtr type p decimals 2,
            h_hkont        like bsis-hkont,
            schlw          like skas-schlw,
            s_shkzg        like bseg-shkzg,
            hkont_345      like bsis-hkont,
            shkzg_345      like bseg-shkzg,
            dmbtr_345      like bseg-dmbtr,
            txt20          like skat-txt20,
            end of ty_billing.
          Internal tables          Begin with IT_                       *
    data    : it_billing type standard table of ty_billing,
              wa_billing type ty_billing.
    data tot_d_dmbtr type p decimals 2  .
    *data : tot_D_DMBTR type p decimals 2,
          FI_TOT type p decimals 2,
          t_dmbtr type p decimals 2.
    data: hh_kont like bseg-hkont.
          Parameters              data ALV_
          Constants                ALV                                  *
    data : intrecordcount type i,  "Variable to hold the record count
           i_grid_settings type lvc_s_glay.
    data    : wa_variant like disvariant,   "Variant,
              wa_fieldcat type slis_fieldcat_alv,
              it_fieldcat type slis_t_fieldcat_alv,
              it_events   type slis_t_event,
              lwa_line type slis_listheader,
              it_list_top_of_page type slis_t_listheader,
              w_cuustock like mbew-verpr,
              w_cuustockplan like mbew-verpr,
              w_cuustockplanext like mbew-verpr,
              w_unit type string,
              w_brand type string,
              w_qty like mseg-erfmg,
              w_qty1 like mseg-erfmg,
              w_qty2 like mseg-erfmg,
              w_qty3 like mseg-erfmg,
              w_qty4 like mseg-erfmg,
              test_title type string,
              i_excluding type slis_t_extab,
              w_excluding  like line of i_excluding,
              gd_layout     type slis_layout_alv,
              gt_sort       type slis_t_sortinfo_alv,
              gt_list_top_of_page type slis_t_listheader,
              w_stock type string.
    data:  fieldcatalog  type slis_t_fieldcat_alv with header line,
          gd_tab_group  type slis_t_sp_group_alv,
         gd_layout     TYPE   lvc_s_layo,
          gt_events     type slis_t_event,
          gd_prntparams type slis_print_alv,
          gd_repid      like sy-repid,
          test_title1(70) type c,
          sp_day type string,
          sp_month type string,
          sp_year type string,
          test_date type string,
          test_date1 type string.
          Parameters              Begin with PR_
    *PARAMETERS     :                                                      *
          At selection-screen                                           *
    *AT SELECTION-SCREEN.
    selection-screen begin of block b1 with frame title text-001.
    select-options: s_comp   for wa_billing-bukrs  default 'EPFD',  " Company
                    s_fiyear for wa_billing-gjahr,     " default '2007',  " Financial year
                    s_period for wa_billing-monat.     " default '1' to '1'.    " period
    parameters     :pr_vari like disvariant-variant.
    selection-screen end of block b1 .
          S T A R T   O F   S E L E C T I O N                           *
    start-of-selection.
        perform get_bkpf.
        perform loop_table.
       perform loop_table.
          S T A R T   O F   S E L E C T I O N                           *
    start-of-selection.
        test_title = 'NOTES TO THE PAYMENT ACCOUNT '.
        test_date = date-high.
        test_date1 = date-LOW.
         sp_year = test_date+0(4).
         sp_month = test_date+4(2).
         sp_day = test_date+6(2).
       concatenate test_title '' into
       test_title1
       separated by space.
      perform build_fieldcatalog.
      perform build_layout.
      perform build_events.
      perform exclude_build.
      perform eventtab_build changing gt_events.
      perform comment_build  changing gt_list_top_of_page.
      perform build_print_params.
      perform display_alv_report.
    *Get data from BKPF                                                   *
    form get_bkpf.
          select bukrs gjahr monat blart budat belnr
               from bkpf
               into corresponding fields of wa_billing
               where bukrs   in s_comp
               and   gjahr   in s_fiyear
               and   monat   in s_period
               and   blart <> 'ZR'
               and   blart <> 'ZQ'.
             perform get_bseg.
        endselect.
    endform.
    *Get data from BSEG                                                   *
    form get_bseg.
        select hkont shkzg dmbtr
        from bseg
        into corresponding fields of wa_billing
        where gjahr = wa_billing-gjahr
        and   belnr = wa_billing-belnr
        and   hkont like '0000141%%%'.
    if wa_billing-hkont cp  '0000141*1' or wa_billing-hkont cp '00001412' or wa_billing-hkont cp '0000141*7'
       or wa_billing-hkont cp '0000141**8'.
                      select  hkont dmbtr shkzg into (wa_billing-h_hkont , wa_billing-d_dmbtr , wa_billing-s_shkzg)
                            from bseg
                            where gjahr = wa_billing-gjahr
                            and   belnr = wa_billing-belnr
                            and   hkont not like '0000141%%%'.
                            perform get_skas.
                            perform get_skat.
                            append wa_billing to it_billing.
                   endselect.
      elseif wa_billing-hkont cp  '0000141**6' .
          if wa_billing-blart = 'AB' and wa_billing-shkzg = 'S'.
                    select  hkont dmbtr shkzg into (wa_billing-h_hkont , wa_billing-d_dmbtr , wa_billing-s_shkzg)
                            from bseg
                            where gjahr = wa_billing-gjahr
                            and   belnr = wa_billing-belnr
                            and   hkont not like '0000141%%%'.
                            perform get_skas.
                            perform get_skat.
                            append wa_billing to it_billing.
                   endselect.
       elseif  wa_billing-blart <> 'AB'  and wa_billing-shkzg = 'H' .
                    select  hkont dmbtr shkzg into (wa_billing-h_hkont , wa_billing-d_dmbtr , wa_billing-s_shkzg)
                            from bseg
                            where gjahr = wa_billing-gjahr
                            and   belnr = wa_billing-belnr
                            and   hkont not like '0000141%%%'.
                            perform get_skas.
                            perform get_skat.
                            append wa_billing to it_billing.
                   endselect.
       endif.
    endif.
    endselect.
    endform.
    *Get data from SKAS                                                   *
    form get_skas.
             select single schlw
             from skas
             into wa_billing-schlw
             where saknr eq wa_billing-h_hkont
             and   spras eq 'EN'.
    endform.
    *Get data from SKAS                                                   *
    form get_skat.
             select single txt20
             from skat
             into wa_billing-txt20
             where saknr eq wa_billing-h_hkont
             and   spras eq 'EN'.
    endform.
    *end-of-selection.
    *Loop in to it billing table                                          *
    form loop_table.
    sort it_billing by hkont belnr h_hkont  .
    delete adjacent duplicates from it_billing comparing h_hkont s_shkzg d_dmbtr.
    sort it_billing by h_hkont ascending.
    loop at it_billing into wa_billing.
    endloop.
    endform.
    *&      Form  build_events
          text
    -->  p1        text
    <--  p2        text
    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.
      ls_event-name = 'USER_COMMAND'.
      ls_event-form = 'F01_USER_COMMAND'.
      append ls_event to gt_events.
    endform.                    " build_events
    form build_fieldcatalog.
        clear  fieldcatalog.
        fieldcatalog-fieldname   = 'SCHLW'.
        fieldcatalog-key = 'X'.
        fieldcatalog-seltext_m   = 'KEY WORD'.
        fieldcatalog-col_pos     = 1.
        fieldcatalog-outputlen   = 15.
        fieldcatalog-edit = ''.
    <td align=center>
    fieldcatalog-align = "right".
        append fieldcatalog to fieldcatalog.
    endform.                    " build_fieldcatalog
    *&      Form  GT_TOP_OF_PAGE
    &      ALV HEADING                                                   &
      form comment_build changing gt_top_of_page type slis_t_listheader.
      data: gs_line type slis_listheader.
      clear gs_line.
      gs_line-typ  = 'H'.
      gs_line-info = test_title.
    GS_LINE-INFO = 'NOTES TO THE RECEIPT AND PAYMENT ACCOUNT'.
      append gs_line to gt_top_of_page.
      clear gs_line.
      gs_line-typ  = 'S'.
      gs_line-key  = 'CENTRAL BANK'.
      gs_line-info =  'Finaceal Report'.
      append gs_line to gt_top_of_page.
    GS_LINE-KEY  = 'STATUS 2'.
    GS_LINE-INFO = 'INFO 2'.
    APPEND GS_LINE TO GT_TOP_OF_PAGE.
    CLEAR GS_LINE.
    GS_LINE-TYP  = 'A'.
    GS_LINE-INFO = 'ACTION'.
    APPEND GS_LINE TO  GT_TOP_OF_PAGE.
    endform.
    form top_of_page.
      call function 'REUSE_ALV_COMMENTARY_WRITE'
           exporting
                it_list_commentary = gt_list_top_of_page.
      write: sy-datum, 'Page No', sy-pagno left-justified.
    endform.
    form end_of_page.
      write at (sy-linsz) sy-pagno centered.
    endform.
    *&      Form  build_layout
          text
    -->  p1        text
    <--  p2        text
    form build_layout.
      gd_layout-colwidth_optimize = 'X'.
    gd_layout-TOTALS_TEXT = 'X' .
    endform.                    " build_layout
    *&      Form  build_print_params
          text
    -->  p1        text
    <--  p2        text
    form build_print_params.
      gd_prntparams-reserve_lines = '1'.   "Lines reserved for footer
      gd_prntparams-no_coverpage = 'X'.
    endform.                    " build_print_params
    *&      Form  display_alv_report
          text
    -->  p1        text
    <--  p2        text
    form display_alv_report.
      gd_repid = sy-repid.
      call function 'REUSE_ALV_GRID_DISPLAY'
        exporting
          i_callback_program       = gd_repid
          i_background_id          = 'ALV_BACKGROUND'
         i_grid_title             = test_title1
          it_sort                  = gt_sort[]
          it_events                = gt_events[]
         i_callback_pf_status_set = ''
          i_callback_user_command  = 'F01_USER_COMMAND'
          is_layout                = gd_layout
          it_fieldcat              = fieldcatalog[]
          i_grid_settings          = i_grid_settings
          i_save                   = 'X'
        tables
          t_outtab                 = it_billing
          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  exclude_build
    form exclude_build.
      w_excluding = '&GRAPH'. "Graphic
      append w_excluding to i_excluding.
    endform.                    " exclude_build
    HEADER FORM
    form eventtab_build changing lt_events type slis_t_event.
    constants:
    gc_formname_top_of_page type slis_formname value 'TOP_OF_PAGE'.
    *GC_FORMNAME_END_OF_PAGE TYPE SLIS_FORMNAME VALUE 'END_OF_PAGE'.
      data: ls_event type slis_alv_event.
      call function 'REUSE_ALV_EVENTS_GET'
           exporting
                i_list_type = 0
           importing
                et_events   = lt_events.
      read table lt_events with key name =  slis_ev_top_of_page
                               into ls_event.
      if sy-subrc = 0.
        move gc_formname_top_of_page to ls_event-form.
        append ls_event to lt_events.
      endif.
    define END_OF_PAGE event
    READ TABLE LT_EVENTS WITH KEY NAME =  SLIS_EV_END_OF_PAGE
                             INTO LS_EVENT.
    IF SY-SUBRC = 0.
      MOVE GC_FORMNAME_END_OF_PAGE TO LS_EVENT-FORM.
      APPEND LS_EVENT TO LT_EVENTS.
    ENDIF.
    endform.
          FORM F01_USER_COMMAND                                         *
    -->  R_UCOMM                                                       *
    -->  RS_SELFIELD                                                   *
    form show_status using p_w_perct p_w_text.
      call function 'SAPGUI_PROGRESS_INDICATOR'
        exporting
          percentage = p_w_perct
          text       = p_w_text.
    endform. " SHOW_STATUS
    regard
    nawa

  • Need help in Interactive Report

    hi,
    i am using a ALV report now i want to make it interactive. as i click on the current page i need to go MIR4 transaction. how can i do it?
    please please help on this issue.

    to make an alv interactive  i did the following steps
    try it by yourself then only u can learn dont copy and paste the code
    step1: declare an iternal table and work area of the type
    data: it_events type standard table of slis_t_alv_events,
            wa_events like line of it_data.
    step2: use the function module
                  reuse_alv_get_events
    and pass the internal table to the fm so that u will get all the events in an internal table . This internal table will have 2 fields like name and form. In the name field u will have all the names of events like
    top_of_page,end_of_page,user_command etc
    so what ever event u want to use modify the internal table according it.For example if u want to use user_command.
    read the internal table it_events into wa_events with key name eq 'USER_COMMAND'.
    after reading the internal table
    move 'f_user_command' to wa_events-form.
    then modify the internal table according to it
    modify it_events from wa_events transporting form.
    after this the internal table will have name = USER_COMMAND and
    form = 'f_user_command'.
    call this form anywhere in the program
    form f_user_command using r_ucomm like sy-ucomm
                                      rs_selfield like slis_selfield.
    case r_ucomm.
    write u r code as appropiate
    WHEN '&IC1'.
    SET parameter ID 'AUN' FIELD rs_selfield-value.( aun is the parameter id for the field for which u r clicking depending on that select the parameter id)
    CALL TRANSACTION 'VA02' AND SKIP FIRST SCREEN.
    ENDIF.

  • Doubt in ALV Grid Control

    Hi Everyone,
    I am working on ALV Grid Control, where i am facing a problem with adding new buttons and writing the new code for the button, for placing the (display) button i used the method <b>handle_tool_bar</b>, But i want to know how to write the code for this particular button (display).
    Kindly give me the solution for this

    http://www.abap4.it/download/ALV.pdf
    Add the handle so we get user command control (ie Refresh)
    perform add_handle using 'USER_COMMAND' 'PAI_USER_COMMAND'.
    Colour and hotspot the project id column
    w_fieldcat-fieldname = 'PROJECT_ID'.
    w_fieldcat-emphasize = 'C400'.
    w_fieldcat-hotspot = 'X'.
    append w_fieldcat to t_fieldcat.
    Iconify and set the length of the icon column
    clear w_fieldcat.
    w_fieldcat-fieldname = 'ZEXCEPTION'.
    w_fieldcat-icon = 'X'.
    w_fieldcat-outputlen = g_light_length.
    append w_fieldcat to t_fieldcat.
    Intensify every other line, improves readability
    t_layout-zebra = 'X'.
    Set up an exit on the refresh event, so it gets passed back to us
    wa_event_exit-ucomm = '&REFRESH'. " Refresh
    wa_event_exit-after = 'X'.
    append wa_event_exit to t_event_exit.
    call function 'REUSE_ALV_GRID_DISPLAY'
    exporting
    i_callback_program = 'ZGER_PROJECT_ID' " **CHANGE** !
    i_callback_pf_status_set = 'SET_PF_STATUS'
    i_structure_name = 'ZPROJECT_DATA'
    i_grid_title = 'Project list'
    it_event_exit = t_event_exit
    i_default = 'X'
    it_fieldcat = t_fieldcat
    is_layout = t_layout
    i_save = 'A'
    it_events = t_events
    tables
    t_outtab = t_main
    exceptions
    program_error = 1
    others = 2.

  • Save alv report as excel file directly from program

    Hello guys,
    I require this in my work.
    I want to save the ALV report tat is to be generated in the filepath that is given in the selection screen (want to save it locally eg: my windows desktop) and in the layout which is also given in the selection screen.
    your comments will be very much appreciated.
    Thanks in Advance,
    Johny

    Hi Johny,
    Actually we have an option to download report output in ALV but it does not download the specified on Selection-screen. For this Create on button for Excell download by setting PF status. and use USER_COMMAND event to trigger when u click on the button and download data to specified path.
    1.
    declare events table like this.
    data :
          i_events  type slis_t_event,
          w_events  like line of i_events.
    2.
    Build events table .
    w_events-name = 'USER_COMMAND' .
    w_events-form = 'USER_COMMAND' .
    append w_events to i_events.
    clear w_events.
    w_events-name = 'PF_STATUS_SET' .
    w_events-form = 'PF_STATUS_SET' .
    append w_events to i_events.
    clear w_events.
    3.
    pass this events table through REUSE_ALV_GRID_DISPLAY.
    4.
    USER_COMMAND and PF_STATUS_SET call back subroutines should be like this in your case. These are nowhere called using PERFORM statement in ur program.
    5.
    PF_STATUS_SET' subroutine should be like this.
    *&      Form  pf_status_set
    form pf_status_set    using extab type slis_t_extab.
    set pf-status 'STATUS1' excluding g_extab.
    "If you write like above Standard status will be gone.
    "For that u have to copy standard status of any ALV program which has standard status.
    "1. goto SE41 tcode. give program SAPLKKBL and status :STANDARD_FULLSCREEN .
    2.Click on the Copy status button below program is ur program and status ur program status.
    3. After that create your own button for Excel downlod.
    endform.                    "pf_status_set
    6.
    USER_COMMAND subroutine should be like this.
    *&      Form  user_command
    form user_command using ucomm like sy-ucomm
                      selfield type slis_selfield.
      case ucomm .
        when 'XLS_DOWN'.
        perform download_to_xls.
      endcase.
    endform.                    "user_command
    Here is the sample program to download data into Excel file with header and Columns..
    Check this program by running.
    *& Report  ZVENKAT_DOWNLOAD_XLS_WITH_HEAD
    REPORT  zvenkat_download_xls_with_head.
    "  Data retrieval related declarations
    TYPES:
         BEGIN OF t_emp_dat,
           pernr TYPE pa0001-pernr,
           persg TYPE pa0001-persg,
           persk TYPE pa0001-persk,
           plans TYPE pa0001-plans,
           stell TYPE pa0001-stell,
         END OF t_emp_dat,
         t_attachment TYPE  solisti1.
    DATA:
         w_emp_data TYPE t_emp_dat,
         w_attachment     TYPE  t_attachment.
    DATA:
         i_emp_data TYPE STANDARD TABLE OF t_emp_dat,
         i_attachment     TYPE STANDARD TABLE OF t_attachment.
    PARAMETERS: p_file TYPE string DEFAULT 'c:\tmp\test.xls'.
    "Start-of-selection.
    START-OF-SELECTION.
      PERFORM get_data.
      PERFORM build_xls_data_and_download.
      "Form  get_data from PA0001
    FORM get_data.
      SELECT pernr
             persg
             persk
             plans
             stell
       FROM pa0001
       INTO CORRESPONDING FIELDS OF TABLE i_emp_data
       UP TO 4 ROWS.
    ENDFORM.                    " get_data
    "Form  build_xls_data_and_download
    FORM build_xls_data_and_download.
      "If you have Unicode check active in program attributes then
      "you will need to declare constants as follows.
      CLASS cl_abap_char_utilities DEFINITION LOAD.
      CONSTANTS:
          con_tab  TYPE c VALUE cl_abap_char_utilities=>horizontal_tab,
          con_cret TYPE c VALUE cl_abap_char_utilities=>cr_lf.
      DATA :l_lines TYPE char10.
      DESCRIBE TABLE i_emp_data LINES l_lines.
      CONCATENATE 'Total no of records:' l_lines
             INTO  w_attachment
    SEPARATED BY  con_tab.
      CONCATENATE con_cret
                  w_attachment
             INTO w_attachment.
      APPEND w_attachment TO i_attachment.
      CLEAR  w_attachment.
      CONCATENATE 'PERNR' 'PERSG' 'PERSK' 'PLANS' 'STELL'
             INTO  w_attachment
    SEPARATED BY  con_tab.
      CONCATENATE con_cret
                  w_attachment
             INTO w_attachment.
      APPEND w_attachment TO i_attachment.
      CLEAR  w_attachment.
      LOOP AT i_emp_data INTO w_emp_data.
        CONCATENATE w_emp_data-pernr
                    w_emp_data-persg
                    w_emp_data-persk
                    w_emp_data-plans
                    w_emp_data-stell
               INTO w_attachment
       SEPARATED BY con_tab.
        CONCATENATE con_cret w_attachment
               INTO w_attachment.
        APPEND w_attachment TO i_attachment.
        CLEAR  w_attachment.
      ENDLOOP.
      CALL FUNCTION 'GUI_DOWNLOAD'
        EXPORTING
          filename              = p_file
          write_field_separator = con_tab
        TABLES
          data_tab              = i_attachment.
      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.                    "build_xls_data_and_download
    I hope that it helps u .
    Regards,
    Venkat.O

  • I have problem in Table Control?

    Hi,
    With the help of Table Control I put data on screens  but my question is " How can I read one or more rows from that list " ??
    Plz help me out.
    Thanks and Regards,
    Gagan

    Hi Gagan
    Depen on when you want to read data from list.
    You should read data in a module of PAI, but if you want to read only line which are displayed, you should put this module between LOOP/ENDLOOP of tablecontrol, if you want to read whole list you should put this module out of LOOP/ENDLOOP....
    and also depen on how you've built the fields of table control.
    IF you have called them as the fields of your internal table:
    PROCESS PBO.
    LOOP AT ITAB WITH CONTROL T_CTRL CURSOR T_CTRL-CURRENT_LINE.
    ENDLOOP.
    PROCESS PAI.
    LOOP AT ITAB.
      MODIFY_ITAB.
    ENDLOOP.
    MODULE MODIFY_ITAB.
    As the output fields of table control are called the
    internal table, its headerline is automatically filled:
      MODIFY ITAB INDEX T_CTRL-CURRENT_LINE.
    Remenber: here you can see only records which are
    displayed
    ENDMODULE.
    IF the names are different:
    PROCESS PBO.
    LOOP AT ITAB WITH CONTROL T_CTRL
                                 CURSOR T_CTRL-CURRENT_LINE.
      MODULE DISPLAY_RECORD.
    ENDLOOP.
    PROCESS PAI.
    LOOP AT ITAB.
      MODULE MODIFY_ITAB.
    ENDLOOP.
    MODULE DISPLAY_RECORD.
    FIELD_TAB_CTRL1 = ITAB-FIELD1.
    FIELD_TAB_CTRL2 = ITAB-FIELD2.
    FIELD_TAB_CTRL3 = ITAB-FIELD3.
    ENDMODULE.
    MODULE MODIFY_ITAB.
      ITAB-FIELD1 = FIELD_TAB_CTRL1.
      ITAB-FIELD2 = FIELD_TAB_CTRL2.
      ITAB-FIELD3 = FIELD_TAB_CTRL3.
      MODIFY ITAB INDEX T_CTRL-CURRENT_LINE.
    Remenber: here you can see only records which are
    displayed
    ENDMODULE.
    Now if you want to read whole list:
    PROCESS PAI.
    LOOP AT ITAB.
      MODULE MODIFY_ITAB.
    ENDLOOP.
    MODULE LOOP_TABLE.
    MODULE LOOP_TABLE.
    LOOP AT ITAB.
    ENDLOOP.
    ENDMODULE.
    But you can use USER_COMMAND module instead of LOOP_TABLE module... depend on how you prefer to do that
    Max
    Message was edited by: max bianchi
    Message was edited by: max bianchi

  • LINKING BETWEEN FUNCTION MODULE AND INTERACTIVE NO. OF BASIC LIST

    Dear Mates,
    Iam preparing Z report for BOM display of FG and SFG materials.
    Iam displaying the Basic List using the MAST table. Here i double click on the material no.
    Here iam using the function module :CS_BOM_EXPL_MAT_V2 for fetching the data from STPOX structure ,here i want to link material no. which has been from basic list and the above said function module. 
    Can anybody provide the solution for the above said linking in ALV interactive report.
    Please treat it very urgent as this report is to be presented on high priority.
    Thanks in advance
    Subbu

    Hi
    use the Function module REUSE_ALV_POPUP_TO_SELECT.
    check the below example:
    REPORT ZSR_ALV_INTERACTIVE.
    TABLES : LFA1,EKKO,EKPO.
    SELECT-OPTIONS : VENDOR FOR LFA1-LIFNR.
    DATA : BEGIN OF ITAB OCCURS 0,
    LIFNR LIKE LFA1-LIFNR,
    NAME1 LIKE LFA1-NAME1,
    END OF ITAB.
    DATA : BEGIN OF JTAB OCCURS 0,
    EBELN LIKE EKKO-EBELN,
    AEDAT LIKE EKKO-AEDAT,
    END OF JTAB.
    DATA : BEGIN OF KTAB OCCURS 0,
    EBELP LIKE EKPO-EBELP,
    MATNR LIKE EKPO-MATNR,
    END OF KTAB.
    TYPE-POOLS : SLIS.
    DATA : REPID LIKE SY-REPID.
    DATA :LFA1_B TYPE SLIS_T_FIELDCAT_ALV,
    LFA1_W TYPE SLIS_FIELDCAT_ALV,
    EKKO_B TYPE SLIS_T_FIELDCAT_ALV,
    EKKO_W TYPE SLIS_FIELDCAT_ALV,
    EKPO_B TYPE SLIS_T_FIELDCAT_ALV,
    EKPO_W TYPE SLIS_FIELDCAT_ALV,
    EVENTS_B TYPE SLIS_T_EVENT,
    EVENTS_W TYPE SLIS_ALV_EVENT.
    PERFORM GET_VAL.
    REPID = SY-REPID.
    SELECT LIFNR NAME1 FROM LFA1 INTO TABLE ITAB WHERE LIFNR IN VENDOR.
    *perform val USING USER_COMMAND sel.
    CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
    EXPORTING
    I_CALLBACK_PROGRAM = REPID
    IT_FIELDCAT = LFA1_B
    IT_EVENTS = EVENTS_B
    TABLES
    T_OUTTAB = ITAB.
    *& Form GET_VAL
    text this is to put column headings
    FORM GET_VAL.
    LFA1_W-FIELDNAME = 'LIFNR'.
    LFA1_W-REF_TABNAME = 'LFA1'.
    LFA1_W-REF_FIELDNAME = 'LIFNR'.
    APPEND LFA1_W TO LFA1_B.
    LFA1_W-FIELDNAME = 'NAME1'.
    LFA1_W-REF_TABNAME = 'LFA1'.
    LFA1_W-REF_FIELDNAME = 'NAME1'.
    APPEND LFA1_W TO LFA1_B.
    EKKO_W-FIELDNAME = 'EBELN'.
    EKKO_W-REF_TABNAME = 'EKKO'.
    EKKO_W-REF_FIELDNAME = 'EBELN'.
    APPEND EKKO_W TO EKKO_B.
    EKKO_W-FIELDNAME = 'AEDAT'.
    EKKO_W-REF_TABNAME = 'EKKO'.
    EKKO_W-REF_FIELDNAME = 'AEDAT'.
    APPEND EKKO_W TO EKKO_B.
    EKPO_W-FIELDNAME = 'EBELP'.
    EKPO_W-REF_TABNAME = 'EKPO'.
    EKPO_W-REF_FIELDNAME = 'EBELP'.
    APPEND EKPO_W TO EKPO_B.
    EKPO_W-FIELDNAME = 'MATNR'.
    EKPO_W-REF_TABNAME = 'EKPO'.
    EKPO_W-REF_FIELDNAME = 'MATNR'.
    APPEND EKPO_W TO EKPO_B.
    EVENTS_W-NAME = 'USER_COMMAND'.
    EVENTS_W-FORM = 'VAL'.
    APPEND EVENTS_W TO EVENTS_B.
    ENDFORM. "GET_VAL
    *& Form VAL
    text
    -->USER_COMMANtext
    -->SEL text for retrieving data
    FORM VAL USING USER_COMMAND LIKE SY-UCOMM SEL TYPE SLIS_SELFIELD.
    DATA : VEN(10) TYPE N,
    PO(10) TYPE N.
    DATA : MAT(10) TYPE C.
    IF SEL-FIELDNAME = 'LIFNR'.
    VEN = SEL-VALUE.
    SELECT EBELN AEDAT FROM EKKO INTO TABLE JTAB WHERE LIFNR = VEN.
    CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
    EXPORTING
    I_CALLBACK_PROGRAM = REPID
    I_STRUCTURE_NAME = EKKO_B
    IT_FIELDCAT = EKKO_B
    IT_EVENTS = EVENTS_B
    TABLES
    T_OUTTAB = JTAB.
    ENDIF.
    IF SEL-FIELDNAME = 'EBELN'.
    PO = SEL-VALUE.
    SELECT EBELP MATNR FROM EKPO INTO TABLE KTAB WHERE EBELN = PO.
    CALL FUNCTION 'REUSE_ALV_POPUP_TO_SELECT'
    EXPORTING
    I_TITLE = 'ITEM DETAILS'
    I_TABNAME = 'EKPO'
    IT_FIELDCAT = EKPO_B
    I_CALLBACK_PROGRAM = REPID
    IMPORTING
    ES_SELFIELD = SEL
    TABLES
    T_OUTTAB = KTAB.
    ENDIF.
    logic to select a record
    IF SEL-FIELDNAME = 'MATNR'.
    MAT = SEL-VALUE.
    SET PARAMETER ID 'MAT' FIELD MAT.
    CALL TRANSACTION 'MM02' AND SKIP FIRST SCREEN.
    ENDIF.
    ENDFORM. "VAL
    check my example:
    REPORT ZSR_ALV_INTERACTIVE.
    TABLES : LFA1,EKKO,EKPO.
    SELECT-OPTIONS : VENDOR FOR LFA1-LIFNR.
    DATA : BEGIN OF ITAB OCCURS 0,
    LIFNR LIKE LFA1-LIFNR,
    NAME1 LIKE LFA1-NAME1,
    END OF ITAB.
    DATA : BEGIN OF JTAB OCCURS 0,
    EBELN LIKE EKKO-EBELN,
    AEDAT LIKE EKKO-AEDAT,
    END OF JTAB.
    DATA : BEGIN OF KTAB OCCURS 0,
    EBELP LIKE EKPO-EBELP,
    MATNR LIKE EKPO-MATNR,
    END OF KTAB.
    TYPE-POOLS : SLIS.
    DATA : REPID LIKE SY-REPID.
    DATA :LFA1_B TYPE SLIS_T_FIELDCAT_ALV,
    LFA1_W TYPE SLIS_FIELDCAT_ALV,
    EKKO_B TYPE SLIS_T_FIELDCAT_ALV,
    EKKO_W TYPE SLIS_FIELDCAT_ALV,
    EKPO_B TYPE SLIS_T_FIELDCAT_ALV,
    EKPO_W TYPE SLIS_FIELDCAT_ALV,
    EVENTS_B TYPE SLIS_T_EVENT,
    EVENTS_W TYPE SLIS_ALV_EVENT.
    PERFORM GET_VAL.
    REPID = SY-REPID.
    SELECT LIFNR NAME1 FROM LFA1 INTO TABLE ITAB WHERE LIFNR IN VENDOR.
    *perform val USING USER_COMMAND sel.
    CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
    EXPORTING
    I_CALLBACK_PROGRAM = REPID
    IT_FIELDCAT = LFA1_B
    IT_EVENTS = EVENTS_B
    TABLES
    T_OUTTAB = ITAB.
    *& Form GET_VAL
    text this is to put column headings
    FORM GET_VAL.
    LFA1_W-FIELDNAME = 'LIFNR'.
    LFA1_W-REF_TABNAME = 'LFA1'.
    LFA1_W-REF_FIELDNAME = 'LIFNR'.
    APPEND LFA1_W TO LFA1_B.
    LFA1_W-FIELDNAME = 'NAME1'.
    LFA1_W-REF_TABNAME = 'LFA1'.
    LFA1_W-REF_FIELDNAME = 'NAME1'.
    APPEND LFA1_W TO LFA1_B.
    EKKO_W-FIELDNAME = 'EBELN'.
    EKKO_W-REF_TABNAME = 'EKKO'.
    EKKO_W-REF_FIELDNAME = 'EBELN'.
    APPEND EKKO_W TO EKKO_B.
    EKKO_W-FIELDNAME = 'AEDAT'.
    EKKO_W-REF_TABNAME = 'EKKO'.
    EKKO_W-REF_FIELDNAME = 'AEDAT'.
    APPEND EKKO_W TO EKKO_B.
    EKPO_W-FIELDNAME = 'EBELP'.
    EKPO_W-REF_TABNAME = 'EKPO'.
    EKPO_W-REF_FIELDNAME = 'EBELP'.
    APPEND EKPO_W TO EKPO_B.
    EKPO_W-FIELDNAME = 'MATNR'.
    EKPO_W-REF_TABNAME = 'EKPO'.
    EKPO_W-REF_FIELDNAME = 'MATNR'.
    APPEND EKPO_W TO EKPO_B.
    EVENTS_W-NAME = 'USER_COMMAND'.
    EVENTS_W-FORM = 'VAL'.
    APPEND EVENTS_W TO EVENTS_B.
    ENDFORM. "GET_VAL
    *& Form VAL
    text
    -->USER_COMMANtext
    -->SEL text for retrieving data
    FORM VAL USING USER_COMMAND LIKE SY-UCOMM SEL TYPE SLIS_SELFIELD.
    DATA : VEN(10) TYPE N,
    PO(10) TYPE N.
    DATA : MAT(10) TYPE C.
    IF SEL-FIELDNAME = 'LIFNR'.
    VEN = SEL-VALUE.
    SELECT EBELN AEDAT FROM EKKO INTO TABLE JTAB WHERE LIFNR = VEN.
    CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
    EXPORTING
    I_CALLBACK_PROGRAM = REPID
    I_STRUCTURE_NAME = EKKO_B
    IT_FIELDCAT = EKKO_B
    IT_EVENTS = EVENTS_B
    TABLES
    T_OUTTAB = JTAB.
    ENDIF.
    IF SEL-FIELDNAME = 'EBELN'.
    PO = SEL-VALUE.
    SELECT EBELP MATNR FROM EKPO INTO TABLE KTAB WHERE EBELN = PO.
    CALL FUNCTION 'REUSE_ALV_POPUP_TO_SELECT'
    EXPORTING
    I_TITLE = 'ITEM DETAILS'
    I_TABNAME = 'EKPO'
    IT_FIELDCAT = EKPO_B
    I_CALLBACK_PROGRAM = REPID
    IMPORTING
    ES_SELFIELD = SEL
    TABLES
    T_OUTTAB = KTAB.
    ENDIF.
    logic to select a record
    IF SEL-FIELDNAME = 'MATNR'.
    MAT = SEL-VALUE.
    SET PARAMETER ID 'MAT' FIELD MAT.
    CALL TRANSACTION 'MM02' AND SKIP FIRST SCREEN.
    ENDIF.
    ENDFORM. "VAL

  • ALV interactive report

    Hi,
    I have 2 questions on interactive ALV.
    1. I am using ALV_GRID_DISPLAY after updating 2 columns of the alv display. 
    USING USER_COMMAND USING R_UCOMM     TYPE  SY-UCOMM
                            RS_SELFIELD TYPE  SLIS_SELFIELD.
      CASE R_UCOMM.
        WHEN '&IC1'.
           IF RS_SELFIELD-FIELDNAME = 'XXXXXX' ( one of the column on ALV).
       After updating this i am using alv_grid_display again for changes i made update on alv screen.
    But the problem is i have 18 columns if iam updating 17th column, when i double click on 17th column  a popup box will appear and i can write something and HIT SAVE button on popup. new diplay starting from first column. not the same screen which i am before.
    If i am on 15 16 17 column and updated 17th column new display comes from 1st column not from 15th.
    2. I added a button on existing menu using se41. now the display shows new button how can I add the code to this new button. I have to diplay  first 60 fields from internal table ( 130 fields) and also PRINT button on bottom. so i  can print them.
    Thanks in advance.
    Mike.

    hi,
    u can use below code :
    SET PF-STATUS
    reward if useful.
    regards,
    raghul

  • Alv  output problem

    I have alv output with some values, now I need to put a push button  on application tool bar  if I change any values in the out put  and then press that push button  then the new values should be updated with out re execution  of the alv  program .   how to do it.

    Hi Kiran,
    <li> The below code is more than enough. It works for your requirement.
    <li>Define events
    DATA: it_events TYPE slis_t_event,
               wa_event like line of it_events.
    <li>Fill events like below.
    wa_events-name = 'PF_STATUS_SET'.
    wa_events-form = 'PF_STATUS_SET'.
    append wa_events to it_events.
    clear   wa_events.
    wa_events-name = 'USER_COMMAND'.
    wa_events-form =  'USER_COMMAND'.
    append wa_events to it_events.
    clear   wa_events.
    <li>Set pf status like below.
    FORM PF_STATUS_SET USING RT_EXTAB TYPE SLIS_T_EXTAB.
    SET PF-STATUS 'STATUS' EXCLUDING rt_extab.
    "When you set pf-status using above statement, you dont see ALV toolbar. To get back all the tools copy status of the any "program status which is using ALV in SE41 transaction code to your program with status you mentioned here.
    "Program :SAPLKKBL
    "status    :STANDARD_FULLSCREEN
    ENDFORM.
    <li>Use USER_COMMAND event like below
    *&      Form  USER_COMMAND
    FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM RS_SELFIELD TYPE SLIS_SELFIELD.
      IF R_UCOMM = 'REFRESH'."Create one button on ALV toolbar with function code REFRESH
        RS_SELFIELD-REFRESH = 'X'. "Set this one. It refreshes internal table data with new values
      ENDIF.
    ENDFORM.                    "USER_COMMAND
    <li>Call function module like below
        CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
             EXPORTING
                  i_callback_program = program
                  it_fieldcat        = it_fieldcat
                  it_events          = it_events
             TABLES
                  t_outtab           = i_mard.
    Let me know if you have any problem.
    Thanks
    Venkat.O

Maybe you are looking for