This website is not affiliated with, sponsored by, or approved by SAP AG.

ALV - Checkbox display in GRID

Development (ABAP Development WorkBench, ABAP/4 programming)

Moderators: Snowy, thx4allthefish, YuriT, Gothmog

ALV - Checkbox display in GRID

Postby tandt » Fri Jan 16, 2004 5:31 am

Hello All,

How can I make check box enabled/disabled in ALV report, as I have a requirement in such a way that whenever user executes the report by specifying the selection screen, the checkbox should be enabled/disabled depending on the data in the database table. If the single character field is 'X' in the database table, check box should be disabled and whereas the single character field is space, check box should be enabled.

Thanks
TandT
tandt
 
Posts: 136
Joined: Tue Oct 29, 2002 1:41 am

Postby ultravioletu » Fri Jan 16, 2004 8:08 am

When building field catalog for ALV, set for the needed field
ls_fieldcat-icon = true.
ls_fieldcat-outputlen = 2.

Then, before calling 'REUSE_ALV...' stuff, modify your data: instead of 'X' put the relevant icon (for instance icon_okay - be sure to include type pools icon statement).
ultravioletu
 
Posts: 122
Joined: Wed Jan 14, 2004 9:19 am
Location: Heidelberg

Style Table

Postby Lubomir Lojka » Tue Jan 20, 2004 9:11 am

You have to have in the Output Table:

Types: begin of lt_io.
include structure mara. " Your Structure
Types: style_table type lvc_t_style.
Types: end of lt_io.

data: lt_io type table of lt_io,
ls_layout type lvc_s_layo,
lt_fcat type lvc_t_fcat,
lo_grid type ref to cl_gui_alv_grid.

field-symbols: <io> type lt_io,
<fcat> type lvc_s_fcat.

... fill your output table ....

ls_layout-stylefname = 'STYLE_TABLE'.

loop at lt_io assigning <io>.
PERFORM set_style USING 'CHECKBOX' "Your Filename
CHANGING <io>.
endloop.

... Fill Your Field Catalog lt_fcat

read table lt_fcat assigning <fcat>
where fieldname = 'CHECKBOX'.
<fcat>-checkbox = 'X'.

...
create grid control lo_grid.
...
CALL METHOD lo_grid->set_table_for_first_display
EXPORTING
is_layout = ls_layout
CHANGING
it_fieldcatalog = lt_fcat
it_outtab = lt_io[].

...

FORM set_button_to_line
USING iv_fieldname TYPE lvc_fname
CHANGING cs_io TYPE io.

DATA: ls_style TYPE lvc_s_styl,
lt_style TYPE lvc_t_styl.

ls_style-fieldname = iv_fieldname.
if cs_io-checkbox = ' '.
ls_style-style = cl_gui_alv_grid=>mc_style_enabled.
else.
ls_style-style = cl_gui_alv_grid=>mc_style_disabled.
endif.
ls_style-maxlen = 2.
INSERT ls_style INTO TABLE io-style_table.

ENDFORM. "set_icon_to_status_line
[/code].

Thats all :lol:
Best Regards,
Lubo :-)
Lubomir Lojka
 
Posts: 21
Joined: Wed Apr 09, 2003 3:14 am
Location: Slovak Republic

Postby Lubomir Lojka » Tue Jan 20, 2004 9:16 am

Sorry, the form is:

FORM set_style, not set_button_to_line.
Best Regards,
Lubo :-)
Lubomir Lojka
 
Posts: 21
Joined: Wed Apr 09, 2003 3:14 am
Location: Slovak Republic

Postby Vitamin » Tue Jul 25, 2006 12:10 pm

Hi Guys,

With referred to Lubomir Lojka's reply above, it is using
statement "ls_style-style = cl_gui_alv_grid=>mc_style_enabled" to change the attribute of the output table.

Im having a requirement that need to assign more than one style to a output field. Thus im using ls_style-style and ls_style-style2. But system will not have effect on the value assigned in ls_style-style2.

Pls comment if i missed out any steps...

Thanks in advance.
Vitamin
 
Posts: 106
Joined: Mon Aug 25, 2003 2:10 am


Return to ABAP

Who is online

Users browsing this forum: No registered users and 13 guests





loading...


This website is not affiliated with, sponsored by, or approved by SAP AG.