Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

How to call module pool through interactive ALV

Former Member
0 Likes
2,161

Moderator message: do not post in ALL CAPITALS.

Hi all,

I want to create an interactive report in which some parameters on selection-screen when i fill those & press f8 then an alv list is generated from ddic and when user double click on any row then a tcode get call which call a module pool program how can i do so please help me for that

Ketan pande

Abap consultant.

Edited by: Matt on Feb 13, 2009 1:33 PM - Switched to sentence case

Edited by: Matt on Feb 13, 2009 1:34 PM

Moderator message: do not post in ALL CAPITALS.

Hi all,

I want to create an interactive report in which some parameters on selection-screen when i fill those & press f8 then an alv list is generated from ddic and when user double click on any row then a tcode get call which call a module pool program how can i do so please help me for that

Ketan pande

Abap consultant.

Edited by: Matt on Feb 13, 2009 1:33 PM - Switched to sentence case

Edited by: Matt on Feb 13, 2009 1:34 PM

6 REPLIES 6
Read only

Former Member
0 Likes
1,260

Hi

Just use CALL TRANSACTION

Cheers

Ravish

Read only

Former Member
0 Likes
1,260

First create Modulepool program and assign a T.Code to that modulepool program

Check whether that T.code working properly or not

Then create ur ALV interactive report then call that Transaction from ur ALV report

For that u can use Call Transaction.

Try this...

Read only

Former Member
0 Likes
1,260

Modify this code to add Hot spots or double click action.

This code will dynamically list the data of any DB table.


REPORT yptc_dynamic_alv_table_display .

TABLES: dd02t.
TYPE-POOLS: slis. " ALV Global Types*data declaration for dynamic
* internal table and alv
DATA: l_structure                TYPE REF TO data,
      l_table                    TYPE REF TO data,
      struc_desc                 TYPE REF TO cl_abap_structdescr,
      lt_layout                  TYPE slis_layout_alv,
      ls_lvc_fieldcatalogue      TYPE lvc_s_fcat,
      lt_lvc_fieldcatalogue      TYPE lvc_t_fcat,
      ls_fieldcatalogue          TYPE slis_fieldcat_alv,
      lt_fieldcatalogue          TYPE slis_t_fieldcat_alv,
      g_repid                    LIKE sy-repid,
      g_list_top_of_page         TYPE slis_t_listheader,
      g_events                   TYPE slis_t_event,
      g_events_ex                TYPE slis_t_event_exit.
*field symbols declaration
FIELD-SYMBOLS :
  <it_table> TYPE STANDARD TABLE,
  <dyn_str> TYPE ANY,
  <str_comp> TYPE abap_compdescr.
*declarations for grid title
DATA : t1(30),
       t2(10),
       t3(50).
*selection screen declaration for table input
PARAMETERS : p_table LIKE dd02l-tabname.
*initialization event
INITIALIZATION.
*start of selection event
START-OF-SELECTION.
*texts for grid title
  t1 = 'Dynamic ALV display for table'.
  t2 = p_table. CONCATENATE t1 t2 INTO t3 SEPARATED BY space.
* dynamic  creation of a structure
  CREATE DATA l_structure TYPE (p_table).
  ASSIGN l_structure->* TO <dyn_str>.
* fields structure
  struc_desc ?= cl_abap_typedescr=>describe_by_data( <dyn_str> ).
  LOOP AT struc_desc->components ASSIGNING <str_comp>.
*    build fieldcatalog
    ls_lvc_fieldcatalogue-fieldname = <str_comp>-name.
    ls_lvc_fieldcatalogue-ref_table = p_table.
    APPEND ls_lvc_fieldcatalogue TO lt_lvc_fieldcatalogue.

*    build fieldcatalog
    ls_fieldcatalogue-fieldname = <str_comp>-name.
    ls_fieldcatalogue-ref_tabname = p_table.
    APPEND ls_fieldcatalogue TO lt_fieldcatalogue.
  ENDLOOP.

*  create internal table dynamic
  CALL METHOD cl_alv_table_create=>create_dynamic_table
    EXPORTING
      it_fieldcatalog = lt_lvc_fieldcatalogue
    IMPORTING
      ep_table = l_table.
  ASSIGN l_table->* TO <it_table>.
* read data from the table selected.
  SELECT * FROM (p_table)
    INTO CORRESPONDING FIELDS OF TABLE <it_table>.
* alv layout
  lt_layout-zebra = 'X'.
  lt_layout-colwidth_optimize = 'X'.
  lt_layout-window_titlebar = t3.
* Events
  PERFORM eventtab_build     USING g_events[]
                                   g_events_ex[].
  g_repid = sy-repid.
*alv output
  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
       EXPORTING
            i_callback_program       = g_repid
            is_layout     = lt_layout
            it_fieldcat   = lt_fieldcatalogue
            it_events     = g_events[]
*            it_excluding  = g_exclude
       TABLES
            t_outtab      = <it_table>
       EXCEPTIONS
            program_error = 1
            OTHERS        = 2.
  IF sy-subrc NE 0.
*    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
*    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.

*---------------------------------------------------------------------*
*       FORM eventtab_build                                           *
*---------------------------------------------------------------------*
FORM eventtab_build
    USING e03_lt_events TYPE slis_t_event
          e03_lt_events_ex TYPE slis_t_event_exit.
  CONSTANTS:
    gc_formname_top_of_page   TYPE slis_formname VALUE 'TOP_OF_PAGE',
    gc_formname_user_command   TYPE slis_formname VALUE 'USER_COMMAND'.

  DATA: ls_event      TYPE slis_alv_event,
        ls_event_exit LIKE LINE OF e03_lt_events_ex.
*
  CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
       EXPORTING
            i_list_type = 1
       IMPORTING
            et_events   = e03_lt_events.
  READ TABLE e03_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 e03_lt_events.
  ENDIF.
ENDFORM.                    " build_events_table
*---------------------------------------------------------------------*
*       FORM top_of_page                                              *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
FORM top_of_page.
*
  DATA: ls_line TYPE slis_listheader.
*
  SELECT SINGLE * FROM dd02t
    WHERE tabname = p_table
      AND ddlanguage = sy-langu.

  CLEAR g_list_top_of_page[].
  CLEAR ls_line.
  ls_line-typ  = 'H'.
  CONCATENATE p_table '-' dd02t-ddtext INTO ls_line-info
    SEPARATED BY space.
*  ls_line-info = p_table.
  APPEND ls_line TO g_list_top_of_page.
  PERFORM build_sub_headings
      USING g_list_top_of_page.
*
  CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
       EXPORTING
            it_list_commentary = g_list_top_of_page[].
*
ENDFORM.                    " top_of_page
*---------------------------------------------------------------------*
*       FORM build_sub_headings                                       *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
*  -->  E07_TOP_OF_PAGE                                               *
*---------------------------------------------------------------------*
FORM build_sub_headings
        USING e07_top_of_page TYPE slis_t_listheader.
  DATA: ls_line TYPE slis_listheader.
*
  CLEAR ls_line.
  ls_line-typ  = 'S'.
  ls_line-key = 'Run Info'.
  CONCATENATE  sy-sysid sy-uname sy-mandt
        INTO ls_line-info
        SEPARATED BY space.
  APPEND ls_line TO e07_top_of_page.
*
ENDFORM.                    "build_sub_headings

Read only

Former Member
0 Likes
1,260

Hi Ketan,

In your ALV program ,

Create a user command to capture the user actions by;

-->Passing the form name 'comm' in the function module Reuse_alv_grid_display ' s this parameter:

i_callback_user_command = 'COMM'

FORM comm USING ucomm LIKE sy-ucomm selfield TYPE slis_selfield.

DATA: okcode TYPE sy-ucomm.

okcode = ucomm.

CASE okcode.

endcase.

There you can catch TABINDEX value which will give the current row selected by the user.

And on that click,

You can use statement CALL TRANSACTION (your module pool t-code name) SKIP FIRST SCREEN.

Hope it helps

Regrds

Mansi

Read only

matt
Active Contributor
0 Likes
1,260

Please do not post in ALL CAPITALS.

Read only

I355602
Product and Topic Expert
Product and Topic Expert
0 Likes
1,260

Hi,

For interactive ALV follow:-

When you double-click on any cell of alv grid, use this code to fetch the data of the line that you currently clicked, its working:-

When you double click on the ALV grid line, you will have sy-ucomm = '&IC1'.

So when you define a i_callback_user_command for the FM reuse_alv_grid_display, and create it as:-


FORM command USING ucomm LIKE sy-ucomm selfield TYPE slis_selfield.
  DATA : ok_code TYPE sy-ucomm.
  ok_code = ucomm.
  CASE ok_code.
    WHEN '&IC1'. "for double click on alv grid line
      " your code
      "use the concept of SET/GET PARAMETER ID
      "and SET the value for fields on module pool application using SET PARAMETER ID ' ' FIELD ' '.
      "and then use code like:-
      "SET PARAMETER ID: 'MAT' FIELD ctr_matnr,
      "                  'WRK' FIELD ctr_werks,
      "                  'MXX' FIELD ctr_mtsta.
      "CALL TRANSACTION 'MM03' AND SKIP FIRST SCREEN.
  ENDCASE.
ENDFORM.

As you have used selfield TYPE slis_selfield, the field selfield will hold all the values.

To know on which row you have clicked and to retain that line, use code:-

Suppose you are currently displaying data from internal table itab and corresponding to it you have work area wa.


read table itab into wa index selfield-tabindex. "index value of line you clicked
" now you have the contents of line that you double clicked currently

Now to know the field name that you clicked, use:-


selfield-fieldname " will fetch you the name of field that you clicked

Now using the work-area and the name of field that you clicked, you can easily make out the details of the field i.e., field name and field value and you can code as per your requirement.

Now here you can create a new field catalog and call another FM 'REUSE_ALV_GRID_DISPLAY' to display further information in the next grid based on the value obtained when user double clicks a cell.

Hope this solves your problem.

Thanks & Regards,

Tarun Gambhir