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: 

In ALV O/p , need Editable Checkbox for particular cell based on signal lig

Former Member
0 Kudos

Hi,

I have requiremnt liek this in my ALV

There are 4 records in the output consisting of fields checkbox , traffic lights. here, 2 are Red and 2 are Green.

now Green light checkboxes should be (Enabled mode)checked with Edit mode. Red light check boxes should be diabled mode with unchecked. how to do this..

I had wriiteen the following code but it is giving me the dump.

DATA : ls_listrow LIKE LINE OF i_final,

ls_stylerow TYPE lvc_s_styl,

ls_styletab TYPE lvc_t_styl.

LOOP AT i_final INTO wa_final.

IF wa_final-light = '1'. "Disabled

ls_stylerow-fieldname = 'CHK'.

ls_stylerow-style = cl_gui_alv_grid=>mc_style_disabled.

ELSEIF wa_final-light = '3'. "Enabled

ls_stylerow-fieldname = 'CHK'.

ls_stylerow-style = cl_gui_alv_grid=>mc_style_enabled.

ENDIF.

APPEND ls_stylerow TO ls_styletab.

INSERT LINES OF ls_styletab INTO TABLE ls_listrow-cellstyles.

MODIFY i_final FROM ls_listrow.

ENDLOOP.

Iam getting DUMP at INSERT line stmt.

Awaiting for ur reply.

Regards,

Deepthi.

5 REPLIES 5

former_member382216
Participant
0 Kudos

TYPES : BEGIN OF type_i_final.

*add the fields of i_final

TYPES : cell_style TYPE lvc_t_styl,

END OF type_i_final.

DATA : wa_final type type_i_final,

ls_stylerow TYPE lvc_s_styl.

LOOP AT i_final INTO wa_final.

IF wa_final-light = '1'. "Disabled

ls_stylerow-fieldname = 'CHK'.

ls_stylerow-style = cl_gui_alv_grid=>mc_style_disabled.

ELSEIF wa_final-light = '3'. "Enabled

ls_stylerow-fieldname = 'CHK'.

ls_stylerow-style = cl_gui_alv_grid=>mc_style_enabled.

ENDIF.

INSERT ls_stylerow INTO TABLE

wa_final-cell_style.

MODIFY i_final FROM wa_final.

ENDLOOP.

Edited by: shakeela Shibu on Sep 24, 2008 11:47 AM

Former Member
0 Kudos

Check this sample code..may be it will give u some idea...



*& Report  Z_DEMO_JG1
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT  z_demo_jg1 LINE-COUNT 10(2) NO STANDARD PAGE HEADING.


TABLES: ekko.

TYPE-POOLS: slis.

"ALV Declarations
TYPES: BEGIN OF t_ekko,
ebeln TYPE ekpo-ebeln,
ebelp TYPE ekpo-ebelp,
statu TYPE ekpo-statu,
aedat TYPE ekpo-aedat,
matnr TYPE ekpo-matnr,
menge TYPE ekpo-menge,
meins TYPE ekpo-meins,
netpr TYPE ekpo-netpr,
peinh TYPE ekpo-peinh,
field_style TYPE lvc_t_styl,
END OF t_ekko.

DATA: it_ekko TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,
wa_ekko TYPE t_ekko.

*ALV data declarations
DATA: fieldcatalog TYPE slis_t_fieldcat_alv WITH HEADER LINE.
DATA: it_fieldcat TYPE lvc_t_fcat,
wa_fieldcat TYPE lvc_s_fcat,
gd_tab_group TYPE slis_t_sp_group_alv,
gd_layout TYPE lvc_s_layo, "slis_layout_alv,
gd_repid LIKE sy-repid.

*Start-of-selection.
START-OF-SELECTION.

PERFORM data_retrieval.

PERFORM set_specific_field_attributes.

PERFORM build_fieldcatalog.

PERFORM build_layout.

PERFORM display_alv_report.
*&---------------------------------------------------------------------
**& Form BUILD_FIELDCATALOG
*&---------------------------------------------------------------------
***Build Fieldcatalog for ALV Report
*----------------------------------------------------------------------
FORM build_fieldcatalog.
wa_fieldcat-fieldname = 'EBELN'.
wa_fieldcat-scrtext_m = 'Purchase Order'.
wa_fieldcat-col_pos = 0.
wa_fieldcat-outputlen = 10.
wa_fieldcat-emphasize = 'X'.
wa_fieldcat-key = 'X'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'EBELP'.
wa_fieldcat-scrtext_m = 'PO Item'.
wa_fieldcat-col_pos = 1.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'STATU'.
wa_fieldcat-scrtext_m = 'Status'.
wa_fieldcat-col_pos = 2.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'AEDAT'.
wa_fieldcat-scrtext_m = 'Item change date'.
wa_fieldcat-col_pos = 3.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'MATNR'.
wa_fieldcat-scrtext_m = 'Material Number'.
wa_fieldcat-col_pos = 4.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'MENGE'.
wa_fieldcat-scrtext_m = 'PO quantity'.
wa_fieldcat-col_pos = 5.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'MEINS'.
wa_fieldcat-scrtext_m = 'Order Unit'.
wa_fieldcat-col_pos = 6.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'NETPR'.
wa_fieldcat-scrtext_m = 'Net Price'.
wa_fieldcat-edit = 'X'.
"sets whole column to be editable
wa_fieldcat-col_pos = 7.
wa_fieldcat-outputlen = 15.
wa_fieldcat-datatype = 'CURR'.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.

wa_fieldcat-fieldname = 'PEINH'.
wa_fieldcat-scrtext_m = 'Price Unit'.
wa_fieldcat-col_pos = 8.
APPEND wa_fieldcat TO it_fieldcat.
CLEAR wa_fieldcat.
ENDFORM. " BUILD_FIELDCATALOG
*&---------------------------------------------------------------------
**& Form BUILD_LAYOUT
*&---------------------------------------------------------------------
***Build layout for ALV grid report
*----------------------------------------------------------------------
FORM build_layout.
*Set layout field for field attributes(i.e. input/output)
gd_layout-stylefname = 'FIELD_STYLE'.
gd_layout-zebra = 'X'.
ENDFORM. " BUILD_LAYOUT

*&---------------------------------------------------------------------
**& Form DISPLAY_ALV_REPORT
*&---------------------------------------------------------------------
*Display report using ALV grid
*----------------------------------------------------------------------
FORM display_alv_report.
gd_repid = sy-repid.
CALL
FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
EXPORTING
i_callback_program = gd_repid
i_callback_user_command = 'USER_COMMAND'
is_layout_lvc = gd_layout
it_fieldcat_lvc = it_fieldcat
i_save = 'X'
TABLES
t_outtab = it_ekko
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc ne 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " DISPLAY_ALV_REPORT
*&---------------------------------------------------------------------
**& Form DATA_RETRIEVAL
*&---------------------------------------------------------------------
***Retrieve data form EKPO table and populate itab it_ekko
*----------------------------------------------------------------------
FORM data_retrieval.
SELECT ebeln
ebelp
statu
aedat
matnr
menge
meins
netpr
peinh
UP TO 10 ROWS
FROM ekpo
INTO CORRESPONDING FIELDS OF TABLE it_ekko.

ENDFORM. " DATA_RETRIEVAL
*&---------------------------------------------------------------------
**& Form set_specific_field_attributes
*&---------------------------------------------------------------------
*populate FIELD_STYLE table with specific field attributes
*----------------------------------------------------------------------
form set_specific_field_attributes .
DATA ls_stylerow TYPE lvc_s_styl .
DATA lt_styletab TYPE lvc_t_styl .


LOOP AT it_ekko INTO wa_ekko.
IF wa_ekko-netpr GT 10.
ls_stylerow-fieldname = 'NETPR' .
ls_stylerow-style = cl_gui_alv_grid=>mc_style_disabled.
APPEND ls_stylerow TO wa_ekko-field_style.
MODIFY it_ekko FROM wa_ekko.
ENDIF.
ENDLOOP.

endform. " set_specific_field_attributes

former_member188685
Active Contributor
0 Kudos

Duplicate post.

Former Member
0 Kudos

Hi,

Thanku for your answers..

Along with the changes in MODIFY stmt..

i also need to to do the following change. int he Layout....

wa_layout-stylefname = 'CELLSTYLES'.

Thanks & Regards,

Deepthi Dandibhotla.

Former Member
0 Kudos

it is answered.please refere the points above.