Skip to Content
0
Former Member
Apr 10, 2007 at 07:21 PM

Need help on ALV Grid Control

13 Views

Hi,

I have written a program to display the details of customer in ALV Grid. I have also added code to add a hyperlink to the field name - KTOKD of the table KNA1. It would be helpful if anyone could tell me what is wrong with the code. The list is correctly displayed but the hyperlink is not working.

tables kna1.

data: BEGIN OF itkna1 OCCURS 0,

ktokd like kna1-ktokd,

kunnr like kna1-kunnr,

name1 like kna1-name1,

name2 like kna1-name2,

ktokd_hdl type int4,

end of itkna1.

*creating an instance of grid

data it_custom_control_name type scrfname value 'C_C_ALV'.

data it_container type ref to cl_gui_custom_container.

data it_alvgrid type ref to cl_gui_alv_grid.

data it_lyo type lvc_s_layo.

data it_fcat type lvc_t_fcat.

data tmp_fcat like LINE OF it_fcat.

data it_hype type lvc_t_hype.

data tmp_hype type lvc_s_hype.

Selection-screen begin of block Enter_data with frame title text-001.

PARAMETERS pktokd like KNA1-ktokd OBLIGATORY.

SELECT-OPTIONS skunnr FOR KNA1-kunnr.

Selection-screen end of block Enter_data.

SELECT ktokd kunnr name1 name2

FROM kna1 into CORRESPONDING FIELDS OF TABLE itkna1

WHERE ktokd = pktokd AND kunnr IN skunnr.

*prepare field catalog

clear: it_fcat, tmp_fcat.

tmp_fcat-fieldname = 'KTOKD'.

tmp_fcat-ref_table = 'KNA1'.

tmp_fcat-ref_field = 'KTOKD'.

tmp_fcat-col_pos = '1'.

tmp_fcat-web_field = 'ktokd_hdl'.

append tmp_fcat to it_fcat.

tmp_fcat-fieldname = 'KUNNR'.

tmp_fcat-ref_table = 'KNA1'.

tmp_fcat-ref_field = 'KUNNR'.

tmp_fcat-col_pos = '2'.

append tmp_fcat to it_fcat.

tmp_fcat-fieldname = 'NAME1'.

tmp_fcat-ref_table = 'KNA1'.

tmp_fcat-ref_field = 'NAME1'.

tmp_fcat-col_pos = '3'.

append tmp_fcat to it_fcat.

tmp_fcat-fieldname = 'NAME2'.

tmp_fcat-ref_table = 'KNA1'.

tmp_fcat-ref_field = 'NAME2'.

tmp_fcat-col_pos = '4'.

append tmp_fcat to it_fcat.

data: c_lines type I, count type I.

DESCRIBE table itkna1 LINES c_lines.

loop at itkna1.

count = count + 1.

tmp_hype-handle = count.

tmp_hype-href = itkna1-ktokd.

APPEND tmp_hype to it_hype.

itkna1-ktokd_hdl = count.

MODIFY itkna1.

ENDLOOP.

*prepare layout

it_lyo-grid_title = 'Custormer details'.

call screen 200.

module status_0200 OUTPUT.

*creating an instance of container class

CREATE OBJECT it_container

EXPORTING container_name = it_custom_control_name.

*creating an instance of the grid

create OBJECT it_alvgrid

EXPORTING i_parent = it_container.

*displaying the grid

call METHOD it_alvgrid->set_table_for_first_display

EXPORTING

is_layout = it_lyo

it_hyperlink = it_hype

CHANGING

it_outtab = itkna1[]

it_fieldcatalog = it_fcat

EXCEPTIONS

invalid_parameter_combination = 1

others = 2.

ENDMODULE.