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

interactive alv

Former Member
0 Likes
370

hi,

this is my requirement

iam displaying an alv.when the user double clicks on any row it has to call a module pool screen.

please send me the code which will solve this purpose

thanks in advance

2 REPLIES 2
Read only

Former Member
0 Likes
344

&----


*& Report ZTEST10ALVETEST

*&

&----


*&

*&

&----


REPORT ztest10alvetest.

TABLES: but000,

but0id.

TYPE-POOLS:slis.

DATA: itab LIKE but000 OCCURS 0 WITH HEADER LINE.

DATA:itab1 LIKE but0id OCCURS 0 WITH HEADER LINE.

DATA: it_events TYPE slis_t_event.

DATA: wa_it_events TYPE slis_t_event .

DATA : BEGIN OF wa_events,

name(30),

form(30),

END OF wa_events.

DATA: idx TYPE sy-tabix.

DATA: it_list_commentary TYPE slis_listheader OCCURS 1.

DATA: BEGIN OF wa_it_list_commentary,

typ(1) TYPE c, " H = Header, S = Selection, A = Action

key(20) TYPE c,

info TYPE slis_entry,

END OF wa_it_list_commentary.

DATA: wa_slis_sortinfo_alv TYPE slis_sortinfo_alv.

DATA: it_sort TYPE slis_sortinfo_alv OCCURS 1.

DATA: is_layout TYPE slis_layout_alv.

INITIALIZATION.

  • wa_it_list_commentary-typ = 'H'.

  • wa_it_list_commentary-key = 'MANAS'.

  • wa_it_list_commentary-info = 'FIRST LIST---1'.

  • APPEND wa_it_list_commentary TO it_list_commentary.

wa_slis_sortinfo_alv-spos = 1.

wa_slis_sortinfo_alv-fieldname = 'TYPE'.

wa_slis_sortinfo_alv-up = 'X'.

APPEND wa_slis_sortinfo_alv TO it_sort.

wa_slis_sortinfo_alv-spos = 2.

wa_slis_sortinfo_alv-fieldname = 'PARTNER'.

wa_slis_sortinfo_alv-down = 'X'.

APPEND wa_slis_sortinfo_alv TO it_sort.

is_layout-totals_only = ' '.

  • CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

*EXPORTING

  • i_list_type = 0

  • IMPORTING

  • et_events = it_events

    • EXCEPTIONS

    • LIST_TYPE_WRONG = 1

    • OTHERS = 2

  • .

  • IF sy-subrc <> 0.

    • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

    • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

  • ENDIF.

    • IF it_events-slis_ev_top_of_page

  • READ TABLE it_events INTO wa_events WITH KEY name = 'top_of_page'.

    • IF sy-subrc = 0.

  • idx = 3.

  • wa_events-form = 'TOPPAGE'.

  • MODIFY it_events INDEX idx FROM wa_events

  • TRANSPORTING form.

    • MODIFY TABLE it_events TRANSPORTING from wa_it_events.

***ENDIF.

*

START-OF-SELECTION.

SELECT * FROM but000 INTO CORRESPONDING FIELDS OF TABLE itab UP TO 50 ROWS.

END-OF-SELECTION.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER = ' '

  • I_BUFFER_ACTIVE = ' '

i_callback_program = sy-repid

  • I_CALLBACK_PF_STATUS_SET = ' '

i_callback_user_command = 'USERCOMMAND'

i_callback_top_of_page = 'TOPPAGE'

  • I_CALLBACK_HTML_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_END_OF_LIST = ' '

i_structure_name = 'but000'

  • I_BACKGROUND_ID = ' '

  • I_GRID_TITLE =

  • I_GRID_SETTINGS =

is_layout = is_layout

  • IT_FIELDCAT =

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

it_sort = it_sort

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT = 'X'

  • I_SAVE = ' '

  • IS_VARIANT =

it_events = it_events

  • IT_EVENT_EXIT =

  • IS_PRINT =

  • IS_REPREP_ID =

  • I_SCREEN_START_COLUMN = 0

  • I_SCREEN_START_LINE = 0

  • I_SCREEN_END_COLUMN = 0

  • I_SCREEN_END_LINE = 0

  • I_HTML_HEIGHT_TOP = 0

  • I_HTML_HEIGHT_END = 0

  • IT_ALV_GRAPHICS =

  • IT_HYPERLINK =

  • IT_ADD_FIELDCAT =

  • IT_EXCEPT_QINFO =

  • IR_SALV_FULLSCREEN_ADAPTER =

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

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.

&----


*& Form call_back

&----


  • text

----


*FORM toppage.

*

  • CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

  • EXPORTING

  • it_list_commentary = it_list_commentary

    • I_LOGO =

    • I_END_OF_LIST_GRID =

    • I_ALV_FORM =

  • .

**

    • WRITE: / 'TESTING'.

*ENDFORM. "call_back

&----


*& Form USERCOMMAND

&----


  • text

----


FORM usercommand USING r_ucomm TYPE sy-ucomm

r_selfield TYPE slis_selfield.

CASE r_ucomm.

WHEN '&IC1'.

IF r_selfield-sel_tab_field = '1-PARTNER'.

<b>***Call here ur dialog program Tcode

call transaction<Tcode Name>.</b>

endcase

ENDFORM. "USERCOMMAND

&----


*& Form toppage

&----


  • text

----


FORM toppage.

REFRESH it_list_commentary.

CLEAR:wa_it_list_commentary.

wa_it_list_commentary-typ = 'H'.

wa_it_list_commentary-key = 'MANAS'.

wa_it_list_commentary-info = 'FIRST LIST---1'.

APPEND wa_it_list_commentary TO it_list_commentary.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

it_list_commentary = it_list_commentary

  • I_LOGO =

  • I_END_OF_LIST_GRID =

  • I_ALV_FORM =

.

*

  • WRITE: / 'TESTING'.

ENDFORM. "toppage

&----


*& Form TOPPAGE1

&----


  • text

----


FORM toppage1.

REFRESH it_list_commentary.

CLEAR:wa_it_list_commentary.

wa_it_list_commentary-typ = 'H'.

wa_it_list_commentary-key = 'MANAS'.

wa_it_list_commentary-info = 'SECONDARY LIST---2'.

APPEND wa_it_list_commentary TO it_list_commentary.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

it_list_commentary = it_list_commentary

  • I_LOGO =

  • I_END_OF_LIST_GRID =

  • I_ALV_FORM =

.

*

  • WRITE: / 'TESTING'.

ENDFORM. "toppage

regs

Manas

Read only

Former Member
0 Likes
344

Hi

I'm giving simple interactive code..check comments..


REPORT zpurchase_order.

***********************************************************************
* TYPE-POOLS DECLARATION
***********************************************************************
TYPE-POOLS:
slis.

***********************************************************************
* DATA DECLARATIONS
***********************************************************************

DATA:
w_ebeln TYPE ekko-ebeln,
w_prog TYPE sy-repid,
t_fieldcat TYPE slis_t_fieldcat_alv,
fs_fieldcat LIKE LINE OF t_fieldcat,
t_eventcat TYPE slis_t_event,
w_eventcat LIKE LINE OF t_eventcat.

***********************************************************************
* SELECT-OPTIONS DECLARATION
***********************************************************************
SELECT-OPTIONS:
s_ebeln FOR w_ebeln.

***********************************************************************
* INTERNAL TABLE AND FIELD-STRING DECLARATIONS
***********************************************************************

DATA:
t_ekko LIKE
STANDARD TABLE
OF ekko,
fs_ekko LIKE LINE OF t_ekko.

DATA:
t_ekpo LIKE
STANDARD TABLE
OF ekpo,
fs_ekpo LIKE LINE OF t_ekpo.

***********************************************************************
* START-OF-SELECTION
***********************************************************************
START-OF-SELECTION.
  SELECT *
  FROM ekko
  INTO TABLE t_ekko UP TO 10 ROWS
  WHERE ebeln IN s_ebeln .

  w_prog = sy-repid.

  CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
    EXPORTING
      i_callback_program      = w_prog
      i_callback_user_command = 'PICK'
      i_structure_name        = 'EKKO'
    TABLES
      t_outtab                = t_ekko
    EXCEPTIONS
      program_error           = 1
      OTHERS                  = 2.
  IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.

*&--------------------------------------------------------------------*
*& Form pick
*&--------------------------------------------------------------------*
* -->UCOMM text
* -->SELFIELD text
*---------------------------------------------------------------------*
FORM pick USING command LIKE sy-ucomm
selfield TYPE slis_selfield.
  READ TABLE t_ekko INTO fs_ekko INDEX selfield-tabindex.

  CASE command.
    WHEN '&IC1'.
       CALL TRANSACTION  'MD04' ."<<< Here you can write your t-code corresponding to your module pool
  ENDCASE. " CASE COMMAND
ENDFORM. " 
*&---------------------------------------------------------------------*
*&      Form  T_EVENTCAT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM t_eventcat.
  w_eventcat-name = 'TOP_OF_PAGE'.
  w_eventcat-form = 'TOP'.
  APPEND w_eventcat TO t_eventcat.
ENDFORM.                    "T_EVENTCAT

*&---------------------------------------------------------------------*
*&      Form  TOP
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM top.
  READ TABLE t_ekpo INTO fs_ekpo INDEX 1.
  WRITE:/ 'Purchase Document Number'(001),30 fs_ekpo-ebeln,
  / 'Company Code'(002), 30 fs_ekpo-bukrs,
  / 'Plant'(003), 30 fs_ekpo-werks,
  / 'Storage Location'(004),30 fs_ekpo-lgort.
ENDFORM.                    "TOP