Posted: Tue Jan 15, 2008 2:10 pm Post subject: Display/Change mode of Editable fields in ALV
Display/Change mode of Editable fields in ALV using Function Modules but not Custom Containers
Chandrasekhar jagarlamudi
When we have an editable field in ALV , we get stuck when we use ALV GRID Function Module regarding how to make an editable field in display mode
To overcome that we go for Custom containers.
Here is a simple solution for that.
The below program will make the first 5 fields disabled and the next 7 enabled.
Code:
REPORT zalv_display_change.
TABLES :t247.
TYPE-POOLS slis. "Type definitions for alv report
DATA: it_fieldcat TYPE lvc_t_fcat,
wa_fieldcat TYPE lvc_s_fcat.
DATA: wa_layout TYPE lvc_s_layo.
DATA : BEGIN OF it_final OCCURS 0,
check(1),
celltab TYPE lvc_t_styl, " Switch between display/change
mnr LIKE t247-mnr,
ltx LIKE t247-ltx,
END OF it_final.
DATA : wa_final LIKE it_final.
DATA : w_repid LIKE sy-repid.
w_repid = sy-repid.
REFRESH it_final.
SELECT mnr ltx
FROM t247
INTO CORRESPONDING FIELDS OF TABLE it_final
WHERE spras EQ 'E'.
DATA: wa_celltab TYPE lvc_s_styl,
it_celltab TYPE lvc_t_styl,
l_index TYPE i.
CLEAR : wa_celltab,wa_final,it_celltab.
REFRESH it_celltab.
*Initialize the celltab table
LOOP AT it_final INTO wa_final.
l_index = sy-tabix.
wa_celltab-fieldname = 'CHECK'.
wa_celltab-style = cl_gui_alv_grid=>mc_style_enabled.
INSERT wa_celltab INTO TABLE it_celltab.
INSERT LINES OF it_celltab INTO TABLE wa_final-celltab.
MODIFY it_final FROM wa_final INDEX l_index.
ENDLOOP.
*Make the first five 5 rows as disabled
CLEAR l_index.
LOOP AT it_final INTO wa_final.
l_index = sy-tabix.
IF sy-tabix LE 5.
LOOP AT wa_final-celltab INTO wa_celltab.
IF wa_celltab-fieldname EQ 'CHECK' .
wa_celltab-style = cl_gui_alv_grid=>mc_style_disabled.
MODIFY wa_final-celltab FROM wa_celltab.
MODIFY it_final INDEX l_index FROM wa_final TRANSPORTING celltab.
ENDIF.
ENDLOOP.
ENDIF.
ENDLOOP.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG. SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG. Every effort is made to ensure content integrity. Use information on this site at your own risk.