on 2024 Aug 17 9:10 AM
I WANT TO DISABLE ONLY SINGLE CHECKBOX WHICH USER SELECTS FROM WHOLE COLUMN WHILE ENTERING DATA INTO MAKTX AND CLICK ON CHECKDATA BUTTON. I AM USING LVC_S_STYLE AND REUSE ALV GRID DISPLAY LVC WITH CL_GUI_ALV_GRID=>MC_STYLE_DISABLED. THANKS!
CODE FOR REFERENCE:
*&---------------------------------------------------------------------*
*& Report Z_TASK4_OOPS
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT z_task4_oops.
TABLES: mara, marc, mard, makt.
TYPE-POOLS: slis.
TYPES : BEGIN OF TY_FINAL,
matnr TYPE mara-matnr,
ersda TYPE mara-ersda,
ernam TYPE mara-ernam,
mtart TYPE mara-mtart,
werks TYPE marc-werks,
lgort TYPE mard-lgort,
xchar TYPE marc-xchar,
maktx TYPE makt-maktx,
check TYPE c,
line_color(4),
col_field TYPE LVC_T_SCOL,
celltab TYPE lvc_t_styl,
END OF TY_FINAL.
TYPES: BEGIN OF ty_mara,
matnr TYPE mara-matnr,
ersda TYPE mara-ersda,
ernam TYPE mara-ernam,
mtart TYPE mara-mtart,
END OF ty_mara.
TYPES : BEGIN OF ty_makt,
matnr TYPE makt-matnr,
maktx TYPE makt-maktx,
END OF ty_makt.
TYPES : BEGIN OF ty_marc,
matnr TYPE marc-matnr,
werks TYPE marc-werks,
xchar TYPE marc-xchar,
END OF ty_marc.
TYPES : BEGIN OF ty_mard,
matnr TYPE mard-matnr,
werks TYPE mard-werks,
lgort TYPE mard-lgort,
END OF ty_mard.
TYPES : BEGIN OF ty_mtart,
mtart TYPE mara-mtart,
END OF ty_mtart.
TYPES : BEGIN OF ty_matnr,
matnr TYPE mara-matnr,
END OF ty_matnr.
*DATA DECLARATIONS
DATA: LT_FINAL TYPE STANDARD TABLE OF TY_FINAL INITIAL SIZE 0,
LS_FINAL LIKE LINE OF LT_FINAL.
DATA :lt_mara TYPE STANDARD TABLE OF ty_mara,
ls_mara TYPE ty_mara.
DATA :lt_makt TYPE STANDARD TABLE OF ty_makt,
ls_makt TYPE ty_makt.
DATA :lt_marc TYPE STANDARD TABLE OF ty_marc,
ls_marc TYPE ty_marc.
DATA :lt_mard TYPE STANDARD TABLE OF ty_mard,
ls_mard TYPE ty_mard.
DATA: lt_event TYPE slis_t_event,
ls_event TYPE slis_alv_event.
DATA: LS_COL_FIELD TYPE SLIS_SPECIALCOL_ALV.
DATA: lt_fcat TYPE lvc_t_fcat,
ls_fcat TYPE lvc_s_fcat.
DATA: lt_layout TYPE LVC_S_LAYO,
LS_TABCOLOR TYPE LVC_S_SCOL,
LS_STYLE TYPE LVC_S_STYL,
LT_STYLE TYPE LVC_T_STYL,
LO_GRID TYPE REF TO CL_GUI_ALV_GRID,
G_CUSTOM_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
LT_FINAL_TEMP LIKE LT_FINAL,
pos TYPE i,
FIELDCAT TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE.
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME.
PARAMETER: p_matnr TYPE mara-matnr.
SELECT-OPTIONS: s_mtart FOR mara-mtart.
SELECTION-SCREEN END OF BLOCK b1.
START-OF-SELECTION.
PERFORM get_material.
PERFORM get_plant.
PERFORM get_storage.
PERFORM get_description.
PERFORM prepare_output.
END-OF-SELECTION.
PERFORM get_layout.
PERFORM get_fieldcat.
PERFORM display_alv.
*&---------------------------------------------------------------------*
*& Form GET_FIELDCAT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM get_fieldcat .
pos = pos + 1.
CLEAR lt_fcat.
CLEAR ls_fcat.
ls_fcat-fieldname = 'CHECK'.
ls_fcat-coltext = ' '.
ls_fcat-checkbox = 'X'.
ls_fcat-col_pos = pos.
ls_fcat-tabname = 'LT_FINAL'.
ls_fcat-edit = 'X'.
ls_fcat-style = ls_fcat-style bit-xor
cl_gui_alv_grid=>MC_STYLE_disabled.
APPEND ls_fcat TO lt_fcat.
CLEAR ls_fcat.
ls_fcat-fieldname = 'MATNR'.
ls_fcat-coltext = 'MATERIAL NUMBER'.
ls_fcat-tabname = 'LT_FINAL'.
ls_fcat-col_pos = pos.
APPEND ls_fcat TO lt_fcat.
CLEAR ls_fcat.
ls_fcat-fieldname = 'WERKS'.
ls_fcat-coltext = 'Plant'.
ls_fcat-tabname = 'LT_FINAL'.
ls_fcat-col_pos = pos.
APPEND ls_fcat TO lt_fcat.
CLEAR ls_fcat.
ls_fcat-fieldname = 'lGORT'.
ls_fcat-coltext = 'Storage Location'.
ls_fcat-tabname = 'LT_FINAL'.
ls_fcat-col_pos = pos.
APPEND ls_fcat TO lt_fcat.
CLEAR ls_fcat.
ls_fcat-fieldname = 'MTART'.
ls_fcat-coltext = 'Material Type'.
ls_fcat-tabname = 'LT_FINAL'.
ls_fcat-col_pos = pos.
APPEND ls_fcat TO lt_fcat.
CLEAR ls_fcat.
ls_fcat-fieldname = 'XCHAR'.
ls_fcat-coltext = 'Batch No.'.
ls_fcat-col_pos = pos.
ls_fcat-tabname = 'LT_FINAL'.
LS_FCAT-emphasize = 'C500'.
APPEND ls_fcat TO lt_fcat.
CLEAR ls_fcat.
ls_fcat-fieldname = 'MAKTX'.
ls_fcat-coltext = 'Material Description'.
ls_fcat-tabname = 'LT_FINAL'.
ls_fcat-edit = 'X'.
ls_fcat-col_pos = pos.
APPEND ls_fcat TO lt_fcat.
CLEAR ls_fcat.
ENDFORM. " GET_FIELDCAT
*&---------------------------------------------------------------------*
*& Form GET_MATERIAL
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM get_material .
SELECT matnr ersda ernam mtart
FROM mara
INTO TABLE lt_mara.
* WHERE MATNR = P_MATNR
* AND MTART IN S_MTART.
IF sy-subrc IS INITIAL.
SORT lt_mara BY matnr.
ENDIF.
ENDFORM. " GET_MATERIAL
*&---------------------------------------------------------------------*
*& Form GET_PLANT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM get_plant .
IF lt_mara IS NOT INITIAL.
SELECT matnr werks xchar
FROM marc
INTO TABLE lt_marc
FOR ALL ENTRIES IN lt_mara
WHERE matnr = lt_mara-matnr.
IF sy-subrc IS INITIAL.
SORT lt_marc BY matnr.
ENDIF.
ENDIF.
ENDFORM. " GET_PLANT
*&---------------------------------------------------------------------*
*& Form GET_STORAGE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM get_storage .
IF lt_marc IS NOT INITIAL.
SELECT matnr werks lgort
FROM mard
INTO TABLE lt_mard
FOR ALL ENTRIES IN lt_marc
WHERE matnr = lt_marc-matnr
AND werks = lt_marc-werks.
IF sy-subrc IS INITIAL.
SORT lt_mard BY matnr.
ENDIF.
ENDIF.
ENDFORM. " GET_STORAGE
*&---------------------------------------------------------------------*
*& Form GET_DESCRIPTION
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM get_description .
IF lt_mara IS NOT INITIAL.
SELECT matnr maktx
FROM makt
INTO TABLE lt_makt
FOR ALL ENTRIES IN lt_mara
WHERE matnr = lt_mara-matnr
AND spras = 0.
IF sy-subrc IS INITIAL.
SORT lt_makt BY matnr.
ENDIF.
ENDIF.
ENDFORM. " GET_DESCRIPTION
*&---------------------------------------------------------------------*
*& Form PREPARE_OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM prepare_output .
LOOP AT lt_mara INTO ls_mara.
ls_final-matnr = ls_mara-matnr.
ls_final-ersda = ls_mara-matnr.
ls_final-ernam = ls_mara-ernam.
ls_final-mtart = ls_mara-mtart.
READ TABLE lt_makt INTO ls_makt
WITH KEY matnr = ls_mara-matnr.
IF sy-subrc IS INITIAL.
ls_final-maktx = ls_makt-maktx.
ENDIF.
READ TABLE lt_marc INTO ls_marc
WITH KEY matnr = ls_mara-matnr.
IF sy-subrc = 0.
ls_final-werks = ls_marc-werks.
ls_final-xchar = ls_marc-xchar.
ENDIF.
READ TABLE lt_mard INTO ls_mard
WITH KEY matnr = ls_marc-matnr.
IF sy-subrc = 0.
ls_final-lgort = ls_mard-lgort.
ENDIF.
APPEND ls_final TO lt_final.
CLEAR ls_final.
ENDLOOP.
LOOP AT LT_FINAL INTO LS_FINAL WHERE MTART = 'ROH'.
CLEAR LS_TABCOLOR.
LS_TABCOLOR-fname = 'MTART'.
LS_TABCOLOR-color-col = 6.
APPEND LS_TABCOLOR TO LS_FINAL-col_field.
MODIFY LT_FINAL FROM LS_FINAL.
ENDLOOP.
ENDFORM. " PREPARE_OUTPUT
*&---------------------------------------------------------------------*
*& Form DISPLAY_ALV
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM display_alv .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
EXPORTING
i_callback_program = sy-repid
I_CALLBACK_PF_STATUS_SET = 'PF_STATUS'
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
* I_CALLBACK_TOP_OF_PAGE = ' '
* I_CALLBACK_HTML_TOP_OF_PAGE = ' '
* I_CALLBACK_HTML_END_OF_LIST = ' '
* I_STRUCTURE_NAME =
* I_BACKGROUND_ID = ' '
* I_GRID_TITLE =
* I_GRID_SETTINGS =
is_layout_lvc = lt_layout
it_fieldcat_lvc = lt_fcat
TABLES
t_outtab = lt_final
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
ENDFORM. " DISPLAY_ALV
*&---------------------------------------------------------------------*
*& Form GET_LAYOUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM get_layout .
lt_layout-zebra = 'X'.
lt_layout-col_opt = 'X'.
LT_LAYOUT-cwidth_opt = 'X'.
LT_LAYOUT-info_fname = 'LINE_COLOR'.
LT_LAYOUT-ctab_fname = 'COL_FIELD'.
LT_LAYOUT-stylefname = 'CELLTAB'.
ENDFORM. " GET_LAYOUT
FORM pf_status USING rt_extab TYPE slis_t_extab.
SET PF-STATUS 'STANDARD' EXCLUDING rt_extab.
ENDFORM.
FORM user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
Data ref1 type ref to cl_gui_alv_grid.
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
E_GRID = ref1.
call method ref1->check_changed_data.
CASE R_UCOMM.
WHEN 'CHECKDATA'.
LS_STYLE-fieldname = 'CHECK'.
LS_STYLE-STYLE = cl_gui_alv_grid=>mc_style_disabled.
APPEND LS_STYLE TO LS_FINAL-CELLTAB.
MODIFY LT_FINAL FROM LS_FINAL INDEX 5 TRANSPORTING CELLTAB.
* READ TABLE LT_FINAL INTO LS_FINAL INDEX RS_SELFIELD-TABINDEX." WITH KEY CHECK = 'X'.
* IF LS_FINAL-CHECK = 'X' AND LS_FINAL-MAKTX NE ' '.
* DATA: ANS TYPE C.
*
* CALL FUNCTION 'POPUP_WITH_2_BUTTONS_TO_CHOOSE'
* EXPORTING
** DEFAULTOPTION = '1'
* diagnosetext1 = ' '
** DIAGNOSETEXT2 = ' '
** DIAGNOSETEXT3 = ' '
* textline1 = 'INPUT IS INVALID'
** TEXTLINE2 = ' '
** TEXTLINE3 = ' '
* text_option1 = 'YES'
* text_option2 = 'NO'
* titel = ' '
* IMPORTING
* ANSWER = ANS
* .
* IF ANS = '1'.
*
* ELSEIF ANS = '2'.
* LEAVE TO SCREEN 0.
* ENDIF.
WHEN 'EXIT' OR 'CANCEL'.
LEAVE PROGRAM.
WHEN 'BACK'.
LEAVE PROGRAM.
WHEN '&IC1'.
READ TABLE lt_final INTO ls_final INDEX rs_selfield-tabindex.
CASE rs_selfield-fieldname.
WHEN 'MATNR'.
IF ls_final-matnr IS NOT INITIAL.
SET PARAMETER ID 'MAT' FIELD ls_final-matnr.
CALL TRANSACTION 'MM03' AND SKIP FIRST SCREEN.
ENDIF.
ENDCASE.
ENDCASE.
ENDFORM.
Request clarification before answering.
User | Count |
---|---|
78 | |
30 | |
10 | |
8 | |
8 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.