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

Drop Down Alv Grid

Former Member
0 Likes
948

Hi,

I have a requirement where i have to define a dropdown listbox for all cells of one column in an editable ALV

Grid Control. iam using the function module REUSE_ALV_GRID_DISPLAY. can anybody send me a sample code for doing this . i dont want to go for object oriented Alv.

Thanks In Advance,

Neha

Hi,

I have a requirement where i have to define a dropdown listbox for all cells of one column in an editable ALV

Grid Control. iam using the function module REUSE_ALV_GRID_DISPLAY. can anybody send me a sample code for doing this . i dont want to go for object oriented Alv.

Thanks In Advance,

Neha

7 REPLIES 7
Read only

gopi_narendra
Active Contributor
0 Likes
762

use the function module VRM_SET_VALUE to make the drop down list for that particular cell in ALV.

Regards

- Gopi

Read only

0 Likes
762

Hi Gopi,

Can u give me a sample code , how to use this function module in the program.

Thanks,

Neha

Read only

0 Likes
762

Hi

data : NAME type VRM_ID,

LIST type VRM_VALUES,

VALUE like line of LIST.

NAME = 'FIELDNAME'.

loop at IT_TAB into IS_TAB.

VALUE-KEY = IS_TAB-FIELD.

append VALUE to LIST.

clear IS_TAB.

endloop.

call function 'VRM_SET_VALUES'

exporting

ID = NAME

VALUES = LIST.

clear LIST.

THIS WILL CREATE A DROP DOWN LIST.

Regards

- Gopi

Read only

0 Likes
762

Hi,

I tried using the function module 'VRM_SET_VALUES' but iam not getting the drop down for the coulmn in the output.

plz check the code below which i used.

REPORT zbaditest .

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

  • TYPE POOLS *

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

*

TYPE-POOLS : slis, VRM.

TYPES: BEGIN OF x_header,

bukrs TYPE bukrs,

belnr TYPE belnr_d,

gjahr TYPE gjahr,

blart TYPE blart,

END OF x_header.

TYPES: BEGIN OF x_line,

bukrs TYPE bukrs,

belnr TYPE belnr_d,

gjahr TYPE gjahr,

buzei TYPE buzei,

koart TYPE koart,

zuonr TYPE dzuonr,

hkont TYPE hkont,

vertn TYPE ranl,

END OF x_line,

BEGIN OF x_contract,

bukrs TYPE bukrs,

belnr TYPE belnr_d,

gjahr TYPE gjahr,

buzei TYPE buzei,

hkont TYPE hkont,

vertn TYPE ranl,

END OF x_contract.

DATA: t_header TYPE STANDARD TABLE OF x_header,

w_header TYPE x_header,

t_line TYPE STANDARD TABLE OF x_line,

w_line TYPE x_line,

t_contract TYPE STANDARD TABLE OF x_contract,

w_contract TYPE x_contract,

t_fieldcat TYPE slis_t_fieldcat_alv, "fieldcatalog table

w_fieldcat TYPE slis_fieldcat_alv. "workarea for fieldcatalog

DATA: l_buzei TYPE buzei,

l_vertn TYPE ranl,

l_index TYPE sy-index,

l_index1 TYPE sy-index.

data : NAME type VRM_ID,

LIST type VRM_VALUES,

VALUE like line of LIST.

START-OF-SELECTION.

SELECT bukrs belnr gjahr blart FROM bkpf INTO TABLE t_header

WHERE bukrs = 'HU01'

AND belnr = '1300000542'

AND gjahr = '2006'.

IF NOT t_header IS INITIAL.

SELECT bukrs

belnr

gjahr

buzei

koart

zuonr

hkont

vertn

FROM bseg INTO TABLE t_line

FOR ALL ENTRIES IN t_header

WHERE bukrs = t_header-bukrs

AND belnr = t_header-belnr

AND gjahr = t_header-gjahr.

IF sy-subrc EQ 0.

SORT t_line BY bukrs belnr gjahr.

ENDIF.

ENDIF.

IF NOT t_line IS INITIAL.

SELECT bukrs

belnr

gjahr

buzei

hkont

vertn

FROM bseg INTO TABLE t_contract

FOR ALL ENTRIES IN t_line

WHERE bukrs = t_line-bukrs

AND belnr = t_line-belnr

AND gjahr = t_line-gjahr

AND buzei = t_line-buzei

AND hkont = t_line-hkont.

IF sy-subrc EQ 0.

SORT t_contract BY bukrs belnr gjahr.

ENDIF.

ENDIF.

NAME = 'KOART'.

loop at T_LINE into W_LINE.

VALUE-KEY = W_LINE-KOART.

append VALUE to LIST.

clear W_LINE.

endloop.

call function 'VRM_SET_VALUES'

exporting

ID = NAME

VALUES = LIST.

clear LIST.

perform fill_fieldcat.

READ TABLE t_header INTO w_header WITH KEY blart = 'SC'.

IF sy-subrc EQ 0.

LOOP AT t_line INTO w_line WHERE belnr = w_header-belnr

AND koart = 'S'.

IF w_line-hkont+3(1) = '7'.

l_index = 1.

DO.

READ TABLE t_contract INTO w_contract INDEX l_index.

IF w_contract-vertn <> space.

MOVE w_contract-vertn TO l_vertn.

EXIT.

ELSE.

l_index = l_index + 1.

ENDIF.

ENDDO.

MOVE l_vertn TO w_line-zuonr.

MODIFY t_line FROM w_line TRANSPORTING zuonr WHERE

hkont+3(1) <> '7'.

IF sy-subrc EQ 0.

EXIT.

ENDIF.

ENDIF.

ENDLOOP.

ENDIF.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

IT_FIELDCAT = t_fieldcat

TABLES

t_outtab = t_line

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

w_fieldcat-col_pos = '1'.

w_fieldcat-fieldname = 'BUKRS'.

w_fieldcat-seltext_m = 'BUKRS'.

w_fieldcat-outputlen = '4'.

w_fieldcat-key = 'X'.

APPEND w_fieldcat TO t_fieldcat.

CLEAR w_fieldcat.

w_fieldcat-col_pos = '2'.

w_fieldcat-fieldname = 'BELNR'.

w_fieldcat-seltext_m = 'BELNR'(043).

w_fieldcat-outputlen = '5'.

w_fieldcat-key = 'X'.

APPEND w_fieldcat TO t_fieldcat.

CLEAR w_fieldcat.

w_fieldcat-col_pos = '3'.

w_fieldcat-fieldname = 'GJAHR'.

w_fieldcat-seltext_m = 'GJAHR'.

w_fieldcat-outputlen = '4'.

w_fieldcat-key = 'X'.

APPEND w_fieldcat TO t_fieldcat.

CLEAR w_fieldcat.

w_fieldcat-col_pos = '4'.

w_fieldcat-fieldname = 'BUZEI'.

w_fieldcat-seltext_m = 'BUZEI'.

w_fieldcat-outputlen = '3'.

w_fieldcat-key = 'X'.

APPEND w_fieldcat TO t_fieldcat.

CLEAR w_fieldcat.

w_fieldcat-col_pos = '5'.

w_fieldcat-fieldname = 'KOART'.

w_fieldcat-seltext_m = 'KOART'.

w_fieldcat-outputlen = '6'.

  • w_fieldcat-key = c_x.

APPEND w_fieldcat TO t_fieldcat.

CLEAR w_fieldcat.

w_fieldcat-col_pos = '6'.

w_fieldcat-fieldname = 'ZUONR'.

w_fieldcat-seltext_m = 'ZUONR'.

w_fieldcat-outputlen = '18'.

APPEND w_fieldcat TO t_fieldcat.

CLEAR w_fieldcat.

w_fieldcat-col_pos = '7'.

w_fieldcat-fieldname = 'HKONT'.

w_fieldcat-seltext_m = 'HKONT'.

w_fieldcat-outputlen = '18'.

APPEND w_fieldcat TO t_fieldcat.

CLEAR w_fieldcat.

w_fieldcat-col_pos = '8'.

w_fieldcat-fieldname = 'VERTN'.

w_fieldcat-seltext_m = 'VERTN'.

w_fieldcat-outputlen = '18'.

APPEND w_fieldcat TO t_fieldcat.

CLEAR w_fieldcat.

endform. " fill_fieldcat

Read only

0 Likes
762

Hi neha,

1. while defining the internal table,

if we use LIKE

eg. BUKRS LIKE T001-BUKRS,

2. then F4 will automatically come.

3. While using alv, we should take particular note

that we should use LIKE (and not type)

while defining the fields,

so that field catalogue is automatically constructed,

and F4 help can also come automatically.

*---- sample program - just copy paste

report abc.

*----


TYPE-POOLS : slis.

DATA : alvfc TYPE slis_t_fieldcat_alv.

DATA : alvfcwa TYPE slis_fieldcat_alv.

*----


data : begin of itab occurs 0.

include structure usr02.

data : end of itab.

*----


START-OF-SELECTION.

select * from usr02

into table itab.

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

EXPORTING

i_program_name = sy-repid

i_internal_tabname = 'ITAB'

i_inclname = sy-repid

CHANGING

ct_fieldcat = alvfc

EXCEPTIONS

inconsistent_interface = 1

program_error = 2

OTHERS = 3.

*----


IMPORTANT

LOOP AT ALVFC INTO ALVFCWA.

IF ALVFCWA-FIELDNAME = 'USTYP'.

ALVFCWA-NO_CONVEXT = 'X'.

MODIFY ALVFC FROM ALVFCWA.

ENDIF.

ENDLOOP.

*----


Display

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

EXPORTING

it_fieldcat = alvfc

TABLES

t_outtab = itab

EXCEPTIONS

program_error = 1

OTHERS = 2.

regards,

amit m.

Read only

0 Likes
762

Hey neha,

I have a code which is almost similar to ur code .

i am havin the same problem , i m not able to see a drop down in my column..........

if u have solved that problem , it'll be vry kind of u to help me out in that issue...

thanx n regards

Harpreet.

Read only

Former Member
0 Likes
762

Hi Neha,

Please refer the following thread for the code :

Best regards,

Prashant

Please reward all helpful answers