Application Development 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: 

need help on hot-spot in alv grid

Former Member
0 Kudos
1,789

Hello everyone,

I displayed a alv grid report using classes.

Now in that report I have a hot-spot for Material column.If a user selects a cell containing the material number,the material number is passed to transaction mm03 to display the material.

Can anyone please give me a sample code resembling the above specification.

Thanks in advance.

1 ACCEPTED SOLUTION

Former Member
0 Kudos
503

check in below code I am calling two diffrent T codes depends on two diffrent fields

METHODS: handle_double_click

FOR EVENT double_click OF cl_gui_alv_grid

IMPORTING e_column

es_row_no.

----


  • METHOD handle_double_click.

----


  • To set call transaction for VD03 and VF03

----


METHOD handle_double_click.

DATA: ls_final_table TYPE gty_final,

lv_vbeln TYPE bsid-vbeln.

  • To set Jump target with call transaction for VD03 and VF03

READ TABLE gt_final

INTO ls_final_table

INDEX es_row_no-row_id.

IF sy-subrc EQ 0.

CLEAR gs_bsid.

READ TABLE gt_bsid INTO gs_bsid

WITH KEY vbeln = ls_final_table-vbeln.

IF sy-subrc EQ 0.

CLEAR: lv_vbeln.

MOVE gs_bsid-vbeln TO lv_vbeln.

ELSE.

READ TABLE gt_bsid INTO gs_bsid

WITH KEY belnr = ls_final_table-vbeln.

IF sy-subrc EQ 0.

CLEAR: lv_vbeln.

MOVE gs_bsid-belnr TO lv_vbeln.

ENDIF.

ENDIF. " READ TABLE gt_bsid

IF lv_vbeln IS NOT INITIAL.

IF e_column EQ 'KUNNR'.

READ TABLE gt_vbrp INTO gs_vbrp WITH KEY vbeln = lv_vbeln BINARY SEARCH.

IF sy-subrc = 0 .

  • Call Transaction VD03

SET PARAMETER ID 'KUN' FIELD gs_bsid-kunnr.

SET PARAMETER ID 'VKO' FIELD gs_vbrp-vkorg_auft.

SET PARAMETER ID 'VTW' FIELD gs_vbrp-vtweg_auft.

SET PARAMETER ID 'SPA' FIELD gs_vbrp-spart.

CALL TRANSACTION 'VD03' AND SKIP FIRST SCREEN.

ENDIF.

ELSEIF e_column EQ 'VBELN'.

  • Call Transaction VF03

SET PARAMETER ID 'VF' FIELD lv_vbeln.

CALL TRANSACTION 'VF03' AND SKIP FIRST SCREEN.

ENDIF. " e_column EQ 'KUNNR'.

ENDIF. " IF lv_vbeln IS NOT INITIAL.

ENDIF. " READ TABLE gt_final

ENDMETHOD. "handle_data_changed_finished

For more details check

SE38 with BCALV * or RSDEMO*

Rewards if useful................

Minal

6 REPLIES 6

Former Member
0 Kudos
504

check in below code I am calling two diffrent T codes depends on two diffrent fields

METHODS: handle_double_click

FOR EVENT double_click OF cl_gui_alv_grid

IMPORTING e_column

es_row_no.

----


  • METHOD handle_double_click.

----


  • To set call transaction for VD03 and VF03

----


METHOD handle_double_click.

DATA: ls_final_table TYPE gty_final,

lv_vbeln TYPE bsid-vbeln.

  • To set Jump target with call transaction for VD03 and VF03

READ TABLE gt_final

INTO ls_final_table

INDEX es_row_no-row_id.

IF sy-subrc EQ 0.

CLEAR gs_bsid.

READ TABLE gt_bsid INTO gs_bsid

WITH KEY vbeln = ls_final_table-vbeln.

IF sy-subrc EQ 0.

CLEAR: lv_vbeln.

MOVE gs_bsid-vbeln TO lv_vbeln.

ELSE.

READ TABLE gt_bsid INTO gs_bsid

WITH KEY belnr = ls_final_table-vbeln.

IF sy-subrc EQ 0.

CLEAR: lv_vbeln.

MOVE gs_bsid-belnr TO lv_vbeln.

ENDIF.

ENDIF. " READ TABLE gt_bsid

IF lv_vbeln IS NOT INITIAL.

IF e_column EQ 'KUNNR'.

READ TABLE gt_vbrp INTO gs_vbrp WITH KEY vbeln = lv_vbeln BINARY SEARCH.

IF sy-subrc = 0 .

  • Call Transaction VD03

SET PARAMETER ID 'KUN' FIELD gs_bsid-kunnr.

SET PARAMETER ID 'VKO' FIELD gs_vbrp-vkorg_auft.

SET PARAMETER ID 'VTW' FIELD gs_vbrp-vtweg_auft.

SET PARAMETER ID 'SPA' FIELD gs_vbrp-spart.

CALL TRANSACTION 'VD03' AND SKIP FIRST SCREEN.

ENDIF.

ELSEIF e_column EQ 'VBELN'.

  • Call Transaction VF03

SET PARAMETER ID 'VF' FIELD lv_vbeln.

CALL TRANSACTION 'VF03' AND SKIP FIRST SCREEN.

ENDIF. " e_column EQ 'KUNNR'.

ENDIF. " IF lv_vbeln IS NOT INITIAL.

ENDIF. " READ TABLE gt_final

ENDMETHOD. "handle_data_changed_finished

For more details check

SE38 with BCALV * or RSDEMO*

Rewards if useful................

Minal

Former Member
0 Kudos
503

Hello dinesh,

Firstly set the field HOTSPOT in the field catalog for material. Then u have to code hot spot event and a mechanism to execute the action...

The event has three parameters in its interface out of which use es_row_no and id. “es_row_no” is of type “LVC_S_ROID” and passes information about the row index at “es_row_no-row_id”, and “e_column_id” of type “LVC_S_COL” which returns the column fieldname at “e_column_id-fieldname”. Utilizing these parameters you know where the user clicked and trigger your action.

FORM handle_hotspot_click USING i_row_id TYPE lvc_s_row

i_column_id TYPE lvc_s_col

is_row_no TYPE lvc_s_roid.

READ TABLE gt_list INDEX is_row_no-row_id .

IF sy-subrc = 0 AND i_column_id-fieldname = 'SEATSOCC' .

CALL SCREEN 200 . "Details about passenger-seat matching

ENDIF .

ENDFORM .

Former Member
0 Kudos
503

Hello

Try this

<b>Fieldcatalogue

-


</b>

CLEAR gst_fcat.

gst_fcat-fieldname = 'KUNNR'.

gst_fcat-ref_table = 'KNA1'.

gst_fcat-coltext = 'Customer Number'.

gst_fcat-hotspot = 'X'.

APPEND gst_fcat TO gt_fcat.

----


  • CLASS lcl_event_handler DEFINITION

----


  • ........ *

<b>----


CLASS lcl_event_handler DEFINITION.</b>

PUBLIC SECTION.

DATA: r1 TYPE i.

METHODS: handle_hotspot FOR EVENT hotspot_click OF cl_gui_alv_grid

IMPORTING e_row_id e_column_id.

METHODS: handle_dblclick FOR EVENT double_click OF cl_gui_alv_grid

IMPORTING e_row e_column.

PRIVATE SECTION.

DATA : gst_cust LIKE LINE OF gt_cust.

ENDCLASS.

----


  • CLASS lcl_event_handler IMPLEMENTATION

----


  • ........ *

----


CLASS lcl_event_handler IMPLEMENTATION.

METHOD handle_hotspot.

READ TABLE gt_cust INTO gst_cust INDEX e_row_id.

SET PARAMETER ID 'KUN' FIELD gst_cust-kunnr.

CALL TRANSACTION 'XD03' AND SKIP FIRST SCREEN.

ENDMETHOD.

METHOD handle_dblclick.

r1 = e_row.

CALL SCREEN 9001.

ENDMETHOD.

ENDCLASS.

CREATE OBJECT objhandler.

SET HANDLER objhandler->handle_hotspot FOR cust_alv.

SET HANDLER objhandler->handle_dblclick FOR cust_alv.

Like this u can handle the event

Reaward if helpful,

Regards,

LIJO

Former Member
0 Kudos
503

hi,

take this reference...

REPORT ZSD_STO_DETAILS LINE-SIZE 500 NO STANDARD PAGE HEADING LINE-COUNT 65 .

--


Table DECLARATION--

TABLES: EKKO,EKPO,EKBE.

--


DATA DECLARATION--

DATA: BEGIN OF IT_PO OCCURS 0,

EBELN LIKE EKKO-EBELN,

BEDAT LIKE EKKO-BEDAT,

EBELP LIKE EKPO-EBELP,

END OF IT_PO.

DATA: BEGIN OF IT_EKBE OCCURS 0,

EBELN LIKE EKBE-EBELN, "S.T.O NO

EBELP LIKE EKBE-EBELP, "LINE ITEM NO

  • BEDAT LIKE EKKO-BEDAT, "S.T.O DATE

BEDAT(12), "S.T.O DATE

BELNR LIKE EKBE-BELNR, "G.T.N. NO

BUZEI LIKE EKBE-BUZEI, "G.T.N ITEM NO

CPUDT LIKE EKBE-CPUDT, "G.T.N DATE

MENGE LIKE EKBE-MENGE, "QUANTITY

DMBTR LIKE EKBE-DMBTR, "AMOUNT

WERKS LIKE EKBE-WERKS, "PLANT CODE

NAME1 LIKE T001W-NAME1, "PLANT NAME

MATNR LIKE EKBE-MATNR, "MATERIAL NO

MAKTX LIKE MAKT-MAKTX, "MATERIAL DESCRIPTION

FREIGHT LIKE KOMV-KWERT, "FREIGHT

TRANS(40), "TRANSPORTER NAME

GRNO(30), "GR NO

VEHICAL(40), "VECHICAL NO

REMARKS(40), "REMARKS

END OF IT_EKBE.

data: name like thead-tdname,

lines like tline occurs 0 with header line.

***********************************************************************

  • ALV VARIABLES AND INTERNAL TABLES

************************************************************************

TYPE-POOLS: slis.

DATA:st_layout TYPE slis_layout_alv,

it_fieldcat TYPE slis_t_fieldcat_alv,

it_listheader TYPE slis_t_listheader,

it_event TYPE slis_t_event,

keyinfo TYPE slis_keyinfo_alv,

lt_sort type SLIS_T_SORTINFO_ALV,

ls_sort type slis_sortinfo_alv.

DATA:ls_selfield TYPE slis_selfield.

--


SELECTION SCREEN DEFINITIONS--

SELECTION-SCREEN BEGIN OF BLOCK A WITH FRAME TITLE TEXT-001.

SELECT-OPTIONS : SO_WERKS for EKBE-WERKS, "Plant

SO_MATNR for EKPO-MATNR, "Material Number

SO_EBELN for EKPO-EBELN, "S.T.O NUMBER

SO_BEDAT FOR EKKO-BEDAT. "S.T.O DATE

SELECTION-SCREEN END OF BLOCK A.

--


START-OF-SELECTION--

START-OF-SELECTION.

*GETS ALL THE STO DETAILS

PERFORM STO_DETAILS.

*GETS ALL THE TEXT INFORMATIONS

PERFORM GET_TEXTS.

--


END-OF-SELECTION--

END-OF-SELECTION.

*DISPLAYING IN ALV FORMAT

PERFORM DISPLAY.

*FREE THE SPACE

*PERFORM FREE.

&----


*& Form STO_DETAILS

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM STO_DETAILS .

*FOR GETTING ONLY THE STO NUMBERS

SELECT AEBELN ABEDAT B~EBELP INTO TABLE IT_PO

FROM EKKO AS A INNER JOIN EKPO AS B ON AEBELN = BEBELN

WHERE A~EBELN IN SO_EBELN

AND A~BSART = 'UB'

AND A~BEDAT IN SO_BEDAT

AND B~MATNR IN SO_MATNR

AND B~WERKS IN SO_WERKS.

IF SY-SUBRC = 0.

  • GETS ALL THE DETAILS ABOUT THE STO WHICH HAS A GI

SELECT EBELN EBELP BELNR BUZEI MENGE DMBTR WERKS MATNR CPUDT FROM EKBE INTO CORRESPONDING FIELDS OF TABLE IT_EKBE

FOR ALL ENTRIES IN IT_PO

WHERE EBELN = IT_PO-EBELN

AND EBELP = IT_PO-EBELP

AND BEWTP = 'U'.

ELSE.

  • IF NO DATA ISSUE THE MESSAGE

MESSAGE 'No Date found for given selection criteria.' TYPE 'I'.

LEAVE PROGRAM.

ENDIF.

ENDFORM. " STO_DETAILS

&----


*& Form GET_TEXTS

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM GET_TEXTS.

LOOP AT IT_EKBE.

MOVE IT_EKBE-EBELN TO NAME.

              • FOR THE TRANSPORTER NAME FROM THE TEXT.

            • CALL FUNCTION 'READ_TEXT'

            • EXPORTING

            • CLIENT = SY-MANDT

              • ID = 'Z002'

            • LANGUAGE = SY-LANGU

            • NAME = NAME

              • OBJECT = 'VBBK'

            • TABLES

            • LINES = 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.

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

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

            • ELSE.

            • READ TABLE LINES INDEX 1.

            • IF SY-SUBRC = 0.

            • MOVE LINES-TDLINE+0(40) TO IT_EKBE-TRANS.

            • ELSE.

            • READ TABLE LINES INDEX 2.

            • IF SY-SUBRC = 0.

            • MOVE LINES-TDLINE+0(40) TO IT_EKBE-TRANS.

            • ENDIF..

            • ENDIF.

******

            • ENDIF.

******

            • CLEAR LINES.

            • REFRESH LINES.

******

******

              • FOR THE GRNO FROM THE TEXT.

            • CALL FUNCTION 'READ_TEXT'

            • EXPORTING

            • CLIENT = SY-MANDT

              • ID = 'Z002'

            • LANGUAGE = SY-LANGU

            • NAME = NAME

              • OBJECT = 'VBBK'

            • TABLES

            • LINES = 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.

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

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

            • ELSE.

            • READ TABLE LINES INDEX 1.

            • IF SY-SUBRC = 0.

            • MOVE LINES-TDLINE+0(40) TO IT_EKBE-GRNO.

            • ELSE.

            • READ TABLE LINES INDEX 2.

            • IF SY-SUBRC = 0.

            • MOVE LINES-TDLINE+0(40) TO IT_EKBE-GRNO.

            • ENDIF..

            • ENDIF.

******

            • ENDIF.

******

            • CLEAR LINES.

            • REFRESH LINES.

******

******

              • FOR THE VEHICAL NUMBER FROM THE TEXT.

            • CALL FUNCTION 'READ_TEXT'

            • EXPORTING

            • CLIENT = SY-MANDT

              • ID = 'Z002'

            • LANGUAGE = SY-LANGU

            • NAME = NAME

              • OBJECT = 'VBBK'

            • TABLES

            • LINES = 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.

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

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

            • ELSE.

            • READ TABLE LINES INDEX 1.

            • IF SY-SUBRC = 0.

            • MOVE LINES-TDLINE+0(40) TO IT_EKBE-VEHICAL.

            • ELSE.

            • READ TABLE LINES INDEX 2.

            • IF SY-SUBRC = 0.

            • MOVE LINES-TDLINE+0(40) TO IT_EKBE-VEHICAL.

            • ENDIF..

            • ENDIF.

******

            • ENDIF.

******

            • CLEAR LINES.

            • REFRESH LINES.

******

              • FOR THE REMARKS FROM THE TEXT.

            • CALL FUNCTION 'READ_TEXT'

            • EXPORTING

            • CLIENT = SY-MANDT

              • ID = 'Z002'

            • LANGUAGE = SY-LANGU

            • NAME = NAME

              • OBJECT = 'VBBK'

            • TABLES

            • LINES = 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.

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

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

            • ELSE.

            • READ TABLE LINES INDEX 1.

            • IF SY-SUBRC = 0.

            • MOVE LINES-TDLINE+0(40) TO IT_EKBE-REMARKS.

            • ELSE.

            • READ TABLE LINES INDEX 2.

            • IF SY-SUBRC = 0.

            • MOVE LINES-TDLINE+0(40) TO IT_EKBE-REMARKS.

            • ENDIF..

            • ENDIF.

******

            • ENDIF.

******

            • CLEAR LINES.

            • REFRESH LINES.

*FOR THE PLANT NAME

SELECT SINGLE NAME1 FROM T001W INTO IT_EKBE-NAME1 WHERE WERKS = IT_EKBE-WERKS.

*FOR MATERIAL DESCRIPTION

SELECT SINGLE MAKTX FROM MAKT INTO IT_EKBE-MAKTX WHERE MATNR = IT_EKBE-MATNR.

*FOR S.T.O DATE

READ TABLE IT_PO WITH KEY EBELN = IT_EKBE-EBELN EBELP = IT_EKBE-EBELP.

IF SY-SUBRC = 0.

CALL FUNCTION 'CONVERSION_EXIT_PDATE_OUTPUT'

EXPORTING

INPUT = IT_PO-BEDAT

IMPORTING

OUTPUT = IT_EKBE-BEDAT

.

ENDIF.

MODIFY IT_EKBE.

CLEAR IT_EKBE.

ENDLOOP.

ENDFORM. " GET_TEXTS

&----


*& Form DISPLAY

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM DISPLAY .

PERFORM fill_layout_structure.

PERFORM fill_field_catalog_table.

PERFORM get_event USING it_event.

PERFORM SORT_EVENT.

PERFORM fill_listheader USING it_listheader.

perFORM call_alv_function.

ENDFORM. " DISPLAY

&----


*& Form fill_layout_structure

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM fill_layout_structure .

st_layout-zebra = 'X'.

ENDFORM. " fill_layout_structure

&----


*& Form fill_field_catalog_table

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM fill_field_catalog_table .

SORT IT_EKBE BY BEDAT.

PERFORM fill_field_catalog USING :

'BEDAT' 'S.T.O Date ' 'IT_EKBE' space space '10' space,

'EBELN' 'S.T.O. Number' 'IT_EKBE' 'X' space '10' 'X',

'BELNR' 'G.T.N No' 'IT_EKBE' space space '10' space,

'CPUDT' 'G.T.N Date' 'IT_EKBE' space space '10' space,

'MENGE' 'Quantity' 'IT_EKBE' space space '17' space,

'DMBTR' 'Value' 'IT_EKBE' space space '17' space,

'FREIGHT' 'Freight' 'IT_EKBE' space space '17' space,

'NAME1' 'Destination' 'IT_EKBE' space space '40' space,

'MAKTX' 'Product' 'IT_EKBE' space space '40' space,

'TRANS' 'Transporter Name' 'IT_EKBE' space space '40' space,

'GRNO' 'GR No' 'IT_EKBE' space space '30' space,

'VEHICAL' 'Vehical No' 'IT_EKBE' space space '30' space,

'REMARKS' 'Remarks' 'IT_EKBE' space space '30' space.

ENDFORM. " fill_field_catalog_table

&----


*& Form fill_field_catalog

&----


  • text

----


  • -->P_0643 text

  • -->P_0644 text

  • -->P_0645 text

  • -->P_SPACE text

  • -->P_SPACE text

  • -->P_0648 text

  • -->P_SPACE text

----


FORM fill_field_catalog USING f d t p S o h.

DATA: wa_fieldcat TYPE slis_fieldcat_alv.

STATICS v_pos TYPE i VALUE 1.

wa_fieldcat-row_pos = 1.

wa_fieldcat-col_pos = v_pos.

wa_fieldcat-fieldname = f.

wa_fieldcat-seltext_m = d.

wa_fieldcat-tabname = t.

wa_fieldcat-hotspot = h.

wa_fieldcat-outputlen = o.

  • wa_fieldcat-fix_column = p.

APPEND wa_fieldcat TO it_fieldcat.

v_pos = v_pos + 1.

ENDFORM. "fill_field_catalog

&----


*& Form get_event

&----


  • text

----


  • -->P_IT_EVENT text

----


FORM get_event USING P_IT_EVENT TYPE slis_t_event.

DATA : wa_event TYPE slis_alv_event.

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

EXPORTING

I_LIST_TYPE = 0

IMPORTING

ET_EVENTS = it_event.

READ TABLE it_event WITH KEY name = slis_ev_top_of_page INTO wa_event.

IF SY-SUBRC = 0.

MOVE 'TOP_OF_PAGE' to wa_event-form.

APPEND wa_event to it_event.

ENDIF.

ENDFORM. " get_event

********************************************************************

*FORM FOR TOP_OF_PAGE(to assign form for the top-of-page event)

********************************************************************

FORM top_of_page.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

it_list_commentary = it_listheader.

ENDFORM. "top_of_page

&----


*& Form fill_listheader

&----


  • text

----


  • -->P_IT_LISTHEADER text

----


FORM fill_listheader USING P_IT_LISTHEADER TYPE slis_t_listheader.

DATA : wa_listheader TYPE slis_listheader.

CLEAR wa_listheader.

wa_listheader-typ = 'S'.

wa_listheader-info ='S.T.O REPORT '.

APPEND wa_listheader TO it_listheader.

ENDFORM. " fill_listheader

&----


*& Form call_alv_function

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM call_alv_function .

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 = 'CALL_TCODE'

  • I_STRUCTURE_NAME =

IS_LAYOUT = st_layout

IT_FIELDCAT = it_fieldcat[]

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

IT_SORT = lt_sort

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT = 'X'

  • I_SAVE = ' '

  • IS_VARIANT =

IT_EVENTS = it_event[]

  • 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

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

TABLES

T_OUTTAB = IT_EKBE

  • 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. " call_alv_function

*********************************************************************

*FORM FOR ALV CALL_TCODE

*********************************************************************

FORM call_tcode USING r_ucomm ls_selfield LIKE ls_selfield.

CASE r_ucomm.

WHEN '&IC1'.

IF ls_selfield-fieldname = 'EBELN'.

SET PARAMETER ID 'BES' FIELD ls_selfield-value.

CALL TRANSACTION 'ME23N' AND SKIP FIRST SCREEN.

ENDIF.

ENDCASE.

ENDFORM.

&----


*& Form SORT_EVENT

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM SORT_EVENT .

CLEAR ls_sort.

ls_sort-spos = 1.

ls_sort-fieldname = 'BEDAT'. "Give the field name that you do the sum'.

ls_sort-tabname = 'IT_EKBE'.

ls_sort-up = 'X'.

ls_sort-subtot = 'X'.

APPEND ls_sort TO lt_sort.

CLEAR ls_sort.

*ls_sort-spos = 1.

ls_sort-fieldname = 'MENGE'. "Give the field name that you do the sum'.

ls_sort-tabname = 'IT_EKBE'.

ls_sort-subtot = 'X'.

APPEND ls_sort TO lt_sort.

ENDFORM. " SORT_EVENT

regards,

Former Member
0 Kudos
503

hi,

try this.

it will sure work.

REPORT zint_alv.

TYPE-POOLS:slis.

TABLES:mara,

makt,

mseg.

DATA:BEGIN OF itab OCCURS 0,

matnr LIKE mara-matnr,

maktx LIKE makt-maktx,

END OF itab.

DATA:BEGIN OF itab1 OCCURS 0,

mblnr LIKE mseg-mblnr,

menge LIKE mseg-menge,

meins LIKE mseg-meins,

werks LIKE mseg-werks,

END OF itab1.

DATA:fcat TYPE slis_t_fieldcat_alv,

fcat1 TYPE slis_t_fieldcat_alv,

eve TYPE slis_t_event,

eve1 TYPE slis_t_event.

DATA:t_mat LIKE mara-matnr.

SELECTION-SCREEN:BEGIN OF BLOCK blk1 WITH FRAME TITLE text-001.

SELECT-OPTIONS:mat FOR mara-matnr.

SELECTION-SCREEN:END OF BLOCK blk1.

INITIALIZATION.

PERFORM build_fcat USING fcat.

PERFORM build_eve.

START-OF-SELECTION.

PERFORM get_data.

PERFORM dis_data.

&----


*& Form build_fcat

&----


  • text

----


  • -->T_FCAT text

----


FORM build_fcat USING t_fcat TYPE slis_t_fieldcat_alv.

DATA:wa_fcat TYPE slis_fieldcat_alv.

wa_fcat-tabname = 'ITAB'.

wa_fcat-fieldname = 'MATNR'.

wa_fcat-seltext_m = 'Material'.

wa_fcat-hotspot = 'X'.

APPEND wa_fcat TO t_fcat.

CLEAR wa_fcat.

wa_fcat-tabname = 'ITAB'.

wa_fcat-fieldname = 'MAKTX'.

wa_fcat-seltext_m = 'Description'.

APPEND wa_fcat TO t_fcat.

CLEAR wa_fcat.

ENDFORM. "build_fcat

&----


*& Form build_eve

&----


  • text

----


FORM build_eve.

DATA:t_eve TYPE slis_alv_event.

CALL FUNCTION 'REUSE_ALV_EVENTS_GET'

EXPORTING

i_list_type = 0

IMPORTING

et_events = eve

  • 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.

READ TABLE eve INTO t_eve WITH KEY name = 'USER_COMMAND'.

IF sy-subrc = 0.

t_eve-form = 'USER_COMMAND'.

MODIFY eve FROM t_eve TRANSPORTING form WHERE name = t_eve-name.

ENDIF.

ENDFORM. "build_eve

&----


*& Form get_data

&----


  • text

----


FORM get_data.

SELECT maramatnr maktmaktx INTO CORRESPONDING FIELDS OF TABLE itab

FROM mara INNER JOIN makt

ON maramatnr = maktmatnr

WHERE mara~matnr IN mat.

ENDFORM. "get_data

&----


*& Form dis_data

&----


  • text

----


FORM dis_data.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = 'ZINT_ALV'

i_callback_user_command = 'USER_COMMAND'

i_grid_title = 'Interactive ALV'

it_fieldcat = fcat

it_events = eve

TABLES

t_outtab = itab

  • EXCEPTIONS

  • PROGRAM_ERROR = 1

  • OTHERS = 2

.

IF sy-subrc <> 0.

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

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

ENDIF.

ENDFORM. "dis_data

&----


*& Form user_command

&----


  • text

----


  • -->U_COM text

----


FORM user_command USING u_com LIKE sy-ucomm sel_field TYPE slis_selfield.

CLEAR fcat1.

CASE u_com.

WHEN '&IC1'.

READ TABLE itab INDEX sel_field-tabindex.

IF sy-subrc = 0.

t_mat = itab-matnr.

ENDIF.

SET PARAMETER ID 'MAT' FIELD t_mat.

CALL TRANSACTION 'MM03' AND SKIP FIRST SCREEN.

ENDCASE.

ENDFORM. "user_command

0 Kudos
503

Hi shah

Thanks for the code.But i need to implement using classes and methods.