ALV Checkbox 单行灰显
生活随笔
收集整理的這篇文章主要介紹了
ALV Checkbox 单行灰显
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
用 Function Module REUSE_ALV_GRID_DISPLAY 處理 ALV Checkbox 時,只能整列灰顯Checkbox。
而用 Function Module REUSE_ALV_GRID_DISPLAY_LVC 以及 OO 的方法才能實現特定行的灰顯Checkbox。
OO 方法實現可參考程序: BCALV_EDIT_05。
用 Function Module REUSE_ALV_GRID_DISPLAY_LVC 的示例如下:
FORM?frm_output_data?.
??DATA:?lv_repid?LIKE?sy-repid.
??DATA:?lt_fieldcat?TYPE?lvc_t_fcat.
??DATA:?lv_fieldcat?TYPE?lvc_s_fcat.
??DATA:?lv_layout?TYPE?lvc_s_layo.
??DATA:?lt_events?TYPE?slis_t_event.
??DATA:?wa_grid_set?TYPE?lvc_s_glay.
??DEFINE?p1f.
????if?lt_fieldcat[]?is?initial.
??????lv_fieldcat-col_pos?=?1.
????else.
??????add?1?to?lv_fieldcat-col_pos.
????endif.
????lv_fieldcat-fieldname?=??&1.
????lv_fieldcat-tabname?=?'IT_OUT'.
????lv_fieldcat-scrtext_l?=?&2.
????lv_fieldcat-outputlen?=?&3?.
????if?lv_fieldcat-fieldname?=?'BOX'.
??????lv_fieldcat-edit??????????=?'X'.
??????lv_fieldcat-checkbox??????=?'X'.
????else.
??????clear?lv_fieldcat-checkbox.
??????clear?lv_fieldcat-edit.
????endif.
????lv_fieldcat-fix_column?=?''.
????append?lv_fieldcat?to?lt_fieldcat.
??END-OF-DEFINITION.
??"mark?items?that?already?exist?in?the?table?as?pink,
??"and?grey?out?the?checkbox?of?items?that?already?exist?in?the?table?or?quantity?equal?zero.
??PERFORM?display_color.
??lv_repid?=?sy-repid.
??lv_layout-info_fname?=?'COLOR'.?????"?identify?the?field?of?color?setting
??lv_layout-stylefname?=?'IT_STYLE'.??"?identify?the?sub?internal?table?of?style?setting.
??REFRESH?lt_fieldcat.
*Populate?structure?of?ALV?field?category
??p1f?'BOX'?''?2.
??p1f?'MATNR'?'Material?No.'?????18.
??p1f?'MAKTX'?'Material?Description'????40.
??p1f?'WERKS'?'Plant'???4.
??p1f?'LGORT'?'Storage?Location'???4.
??p1f?'SERNR'?'Serial?No.'???18.
??p1f?'SOBKZ'?'Special?Stock'?????1.
??p1f?'VBELN'?'Sales?Order'???10.
??p1f?'POSNR'?'Item?No.'???6.
??p1f?'KALAB'?'Quantity'???13.
??p1f?'MEINS'?'Unit'???3.
??wa_grid_set-edt_cll_cb?=?'X'.
*Call?'Reuse?function?module'?to?display?list?as?ALV?format,?this?function?module?can?be?used?to?grey?out?specified?field.
??CALL?FUNCTION?'REUSE_ALV_GRID_DISPLAY_LVC'
????EXPORTING
??????i_callback_program??????????=?lv_repid
??????i_save??????????????????????=?'X'
??????i_callback_pf_status_set????=?'SET_PF_STATUS'
??????i_callback_user_command?????=?'USER_COMMAND'
??????is_layout_lvc???????????????=?lv_layout
??????it_fieldcat_lvc?????????????=?lt_fieldcat
??????i_callback_html_end_of_list?=?'FRM_END_OF_LIST'
*??????it_events???????????????????=?lt_events
??????I_GRID_SETTINGS?????????????=?wa_grid_set
????TABLES
??????t_outtab????????????????????=?it_out
????EXCEPTIONS
??????program_error???????????????=?1
??????OTHERS??????????????????????=?2.
??IF?sy-subrc?<>?0.
??ENDIF.
ENDFORM.????????????????????"?FRM_OUTPUT_DATA
FORM?display_color?.
??DATA:?wa_style?TYPE?lvc_s_styl.
??IF?it_out[]?IS?NOT?INITIAL.
????CLEAR:?it_zrtnstc,?it_zrtnstc[].
????SELECT?*
??????INTO?TABLE?it_zrtnstc
??????FROM?zrtnstc
??????FOR?ALL?ENTRIES?IN?it_out
??????WHERE?matnr?=?it_out-matnr
????????AND?sernr?=?it_out-sernr.
????SORT?it_zrtnstc?BY?matnr?sernr.
??ENDIF.
??LOOP?AT?it_out.
????READ?TABLE?it_zrtnstc?WITH?KEY?matnr?=?it_out-matnr?sernr?=?it_out-sernr?BINARY?SEARCH.
????IF?sy-subrc?=?0.
??????IF?it_zrtnstc-flag?=?'X'.?"?material?by?which?the?po?was?created?don't?need?to?be?stored?again.
????????DELETE?it_out.
????????CONTINUE.
??????ELSE.
????????it_out-color?=?'C600'.?"?mark?the?items?which?are?already?in?the?table?ZRTNSTC?as?pink.
????????MODIFY?it_out?TRANSPORTING?color.
??????ENDIF.
????ENDIF.
????"?if?quantity?equals?zero?or?already?exist?in?the?table,?then?grey?out?the?check?box.
????IF?it_out-kalab?=?0?OR?it_out-color?IS?NOT?INITIAL.
??????CLEAR:?wa_style,?it_out-it_style.
??????wa_style-fieldname?=?'BOX'.
??????wa_style-style?=?cl_gui_alv_grid=>mc_style_disabled.
??????APPEND?wa_style?TO?it_out-it_style.
??????MODIFY?it_out?TRANSPORTING?it_style.
????ENDIF.
??ENDLOOP.
ENDFORM.????????????????????"?display_color
顯示效果如下:
而用 Function Module REUSE_ALV_GRID_DISPLAY_LVC 以及 OO 的方法才能實現特定行的灰顯Checkbox。
OO 方法實現可參考程序: BCALV_EDIT_05。
用 Function Module REUSE_ALV_GRID_DISPLAY_LVC 的示例如下:
FORM?frm_output_data?.
??DATA:?lv_repid?LIKE?sy-repid.
??DATA:?lt_fieldcat?TYPE?lvc_t_fcat.
??DATA:?lv_fieldcat?TYPE?lvc_s_fcat.
??DATA:?lv_layout?TYPE?lvc_s_layo.
??DATA:?lt_events?TYPE?slis_t_event.
??DATA:?wa_grid_set?TYPE?lvc_s_glay.
??DEFINE?p1f.
????if?lt_fieldcat[]?is?initial.
??????lv_fieldcat-col_pos?=?1.
????else.
??????add?1?to?lv_fieldcat-col_pos.
????endif.
????lv_fieldcat-fieldname?=??&1.
????lv_fieldcat-tabname?=?'IT_OUT'.
????lv_fieldcat-scrtext_l?=?&2.
????lv_fieldcat-outputlen?=?&3?.
????if?lv_fieldcat-fieldname?=?'BOX'.
??????lv_fieldcat-edit??????????=?'X'.
??????lv_fieldcat-checkbox??????=?'X'.
????else.
??????clear?lv_fieldcat-checkbox.
??????clear?lv_fieldcat-edit.
????endif.
????lv_fieldcat-fix_column?=?''.
????append?lv_fieldcat?to?lt_fieldcat.
??END-OF-DEFINITION.
??"mark?items?that?already?exist?in?the?table?as?pink,
??"and?grey?out?the?checkbox?of?items?that?already?exist?in?the?table?or?quantity?equal?zero.
??PERFORM?display_color.
??lv_repid?=?sy-repid.
??lv_layout-info_fname?=?'COLOR'.?????"?identify?the?field?of?color?setting
??lv_layout-stylefname?=?'IT_STYLE'.??"?identify?the?sub?internal?table?of?style?setting.
??REFRESH?lt_fieldcat.
*Populate?structure?of?ALV?field?category
??p1f?'BOX'?''?2.
??p1f?'MATNR'?'Material?No.'?????18.
??p1f?'MAKTX'?'Material?Description'????40.
??p1f?'WERKS'?'Plant'???4.
??p1f?'LGORT'?'Storage?Location'???4.
??p1f?'SERNR'?'Serial?No.'???18.
??p1f?'SOBKZ'?'Special?Stock'?????1.
??p1f?'VBELN'?'Sales?Order'???10.
??p1f?'POSNR'?'Item?No.'???6.
??p1f?'KALAB'?'Quantity'???13.
??p1f?'MEINS'?'Unit'???3.
??wa_grid_set-edt_cll_cb?=?'X'.
*Call?'Reuse?function?module'?to?display?list?as?ALV?format,?this?function?module?can?be?used?to?grey?out?specified?field.
??CALL?FUNCTION?'REUSE_ALV_GRID_DISPLAY_LVC'
????EXPORTING
??????i_callback_program??????????=?lv_repid
??????i_save??????????????????????=?'X'
??????i_callback_pf_status_set????=?'SET_PF_STATUS'
??????i_callback_user_command?????=?'USER_COMMAND'
??????is_layout_lvc???????????????=?lv_layout
??????it_fieldcat_lvc?????????????=?lt_fieldcat
??????i_callback_html_end_of_list?=?'FRM_END_OF_LIST'
*??????it_events???????????????????=?lt_events
??????I_GRID_SETTINGS?????????????=?wa_grid_set
????TABLES
??????t_outtab????????????????????=?it_out
????EXCEPTIONS
??????program_error???????????????=?1
??????OTHERS??????????????????????=?2.
??IF?sy-subrc?<>?0.
??ENDIF.
ENDFORM.????????????????????"?FRM_OUTPUT_DATA
FORM?display_color?.
??DATA:?wa_style?TYPE?lvc_s_styl.
??IF?it_out[]?IS?NOT?INITIAL.
????CLEAR:?it_zrtnstc,?it_zrtnstc[].
????SELECT?*
??????INTO?TABLE?it_zrtnstc
??????FROM?zrtnstc
??????FOR?ALL?ENTRIES?IN?it_out
??????WHERE?matnr?=?it_out-matnr
????????AND?sernr?=?it_out-sernr.
????SORT?it_zrtnstc?BY?matnr?sernr.
??ENDIF.
??LOOP?AT?it_out.
????READ?TABLE?it_zrtnstc?WITH?KEY?matnr?=?it_out-matnr?sernr?=?it_out-sernr?BINARY?SEARCH.
????IF?sy-subrc?=?0.
??????IF?it_zrtnstc-flag?=?'X'.?"?material?by?which?the?po?was?created?don't?need?to?be?stored?again.
????????DELETE?it_out.
????????CONTINUE.
??????ELSE.
????????it_out-color?=?'C600'.?"?mark?the?items?which?are?already?in?the?table?ZRTNSTC?as?pink.
????????MODIFY?it_out?TRANSPORTING?color.
??????ENDIF.
????ENDIF.
????"?if?quantity?equals?zero?or?already?exist?in?the?table,?then?grey?out?the?check?box.
????IF?it_out-kalab?=?0?OR?it_out-color?IS?NOT?INITIAL.
??????CLEAR:?wa_style,?it_out-it_style.
??????wa_style-fieldname?=?'BOX'.
??????wa_style-style?=?cl_gui_alv_grid=>mc_style_disabled.
??????APPEND?wa_style?TO?it_out-it_style.
??????MODIFY?it_out?TRANSPORTING?it_style.
????ENDIF.
??ENDLOOP.
ENDFORM.????????????????????"?display_color
顯示效果如下:
總結
以上是生活随笔為你收集整理的ALV Checkbox 单行灰显的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: GET_GLOBALS_FROM_SLV
- 下一篇: Stumble