본문 바로가기
ABAP

ALV 특정 Cell EDIT

by clode 2023. 2. 21.
728x90
반응형

1. ALV에 출력되는 INT에 STYLE 필드 추가

DATA: BEGIN OF gs_tab.
        INCLUDE STRUCTURE zed03_alv_t1.
DATA: style type lvc_t_styl,
      END OF gs_tab,
      gt_tab LIKE TABLE OF gs_tab.
FORM layo .
  gs_layo-stylefname = 'STYLE'.
ENDFORM."
FORM add_row .
  DATA: ls_edit TYPE lvc_s_styl,
        lt_edit TYPE lvc_t_styl,
        l_tabix TYPE sy-tabix.

  CLEAR gs_tab, gs_tab-style.

  APPEND gs_tab TO gt_tab.

  READ TABLE gt_tab INTO gs_tab INDEX sy-tabix.

*  LOOP AT gt_tab INTO gs_tab .
  CLEAR ls_edit.
  REFRESH lt_edit.

  l_tabix = sy-tabix.

  ls_edit-fieldname = 'VKORG'.
  ls_edit-style = cl_gui_alv_grid=>mc_style_enabled. "disabled.
  INSERT ls_edit INTO TABLE lt_edit.

  ls_edit-fieldname = 'KUNNR'.
  ls_edit-style = cl_gui_alv_grid=>mc_style_enabled.
  INSERT ls_edit INTO TABLE lt_edit.

  INSERT LINES OF lT_edit INTO TABLE gs_tab-style.
  MODIFY gt_tab FROM gs_tab INDEX L_tabix.
*    MODIFY gt_tab FROM gs_tab INDEX L_tabix TRANSPORTING style.
*  ENDLOOP.

ENDFORM.

전체 edit 시 주석 해제

간단하게

PERFORM SET_CELLTAB USING GS_S0100-CELLTAB: 'WERKS'   GC_X.

FORM SET_CELLTAB USING    PT_CELLTAB TYPE LVC_T_STYL
                           PV_FNAME
                           PV_DISABLE.

  DELETE PT_CELLTAB WHERE FIELDNAME = PV_FNAME.

  INSERT VALUE #( FIELDNAME = PV_FNAME
                  STYLE     = COND #( WHEN PV_DISABLE = GC_X  THEN CL_GUI_ALV_GRID=>MC_STYLE_DISABLED
                                      ELSE                         CL_GUI_ALV_GRID=>MC_STYLE_ENABLED  )
                ) INTO TABLE PT_CELLTAB.

ENDFORM.

2. 필드카탈로그 EDIT = 'X'. 추가

3. SET_READY_FOR_INPUT

      CALL METHOD PO_GRID->SET_READY_FOR_INPUT
        EXPORTING
          I_READY_FOR_INPUT = 1.
728x90
반응형

'ABAP' 카테고리의 다른 글

Working day function  (0) 2023.02.21
ALV Top-of-Page  (0) 2023.02.21
ALV Data changed Event  (0) 2023.02.20
ALV 툴바 버튼 Add & Exclude  (0) 2023.02.20
ALV 조회, 변경 mode  (0) 2023.02.20

댓글