EDIT_CELL

*&---------------------------------------------------------------------*
*& Report Z_SALAH_EDIT_CELLS
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT Z_SALAH_EDIT_CELLS.
**********************************************************************
*REPORT DESCRIBE:單元格可編輯
*DEVELOPER:SALAH
*DEVELOP DATE:20191014
*MODIFY DATE:
*FUNCTION SPEC:
*KEY USER:
**********************************************************************
TYPE-POOLS:SLIS.

TYPES:BEGIN OF TYP_01,
        PER_KEY(20TYPE C,
        PER_NOR(20TYPE C,
        SEL_STY     TYPE LVC_T_STYL,
        CBOX        TYPE C,
      END OF TYP_01.
DATA IS_SEL_STY TYPE LVC_S_STYL.
DATA GT_01 TYPE TABLE OF TYP_01.
DATA GS_01 TYPE TYP_01.
DATA IT_FIELDCAT TYPE LVC_T_FCAT .
DATA IS_FIELDCAT TYPE LVC_S_FCAT .
DATA IS_LAYOUT TYPE LVC_S_LAYO.
DATA IS_GRID_SET TYPE LVC_S_GLAY.

GS_01-PER_KEY 'test key one'.
GS_01-PER_NOR 'test normal one'.
APPEND GS_01 TO GT_01.


GS_01-PER_KEY 'test key two'.
GS_01-PER_NOR 'test normal two'.
APPEND GS_01 TO GT_01.


IS_FIELDCAT-FIELDNAME 'per_key'.
"is_fieldcat-edit = 'X'.
IS_FIELDCAT-SCRTEXT_L '鍵值數據'.
APPEND IS_FIELDCAT TO IT_FIELDCAT.

IS_FIELDCAT-FIELDNAME 'per_nor'.
"is_fieldcat-edit = 'X'.
IS_FIELDCAT-SCRTEXT_L '非鍵值數據'.
APPEND IS_FIELDCAT TO IT_FIELDCAT.




PERFORM FRM_SET_LINE_NOEDIT.

IS_GRID_SET-EDT_CLL_CB 'X'.


IS_LAYOUT-CWIDTH_OPT 'X'.
IS_LAYOUT-EDIT 'X'.
IS_LAYOUT-STYLEFNAME 'SEL_STY'.
IS_LAYOUT-BOX_FNAME 'CBOX'.


CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
  EXPORTING
*   I_INTERFACE_CHECK        = ' '
*   I_BYPASSING_BUFFER       =
*   I_BUFFER_ACTIVE          =
    I_CALLBACK_PROGRAM       = SY-REPID
    I_CALLBACK_PF_STATUS_SET 'FRM_PF_STATUS'
    I_CALLBACK_USER_COMMAND  'FRM_USERCOMM'
*   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_GRID_SET
    IS_LAYOUT_LVC            = IS_LAYOUT
    IT_FIELDCAT_LVC          = IT_FIELDCAT
*   IT_EXCLUDING             =
*   IT_SPECIAL_GROUPS_LVC    =
*   IT_SORT_LVC              =
*   IT_FILTER_LVC            =
*   IT_HYPERLINK             =
*   IS_SEL_HIDE              =
*   I_DEFAULT                = 'X'
  " I_SAVE                   = ' '
*   IS_VARIANT               =
*   IT_EVENTS                =
*   IT_EVENT_EXIT            =
*   IS_PRINT_LVC             =
*   IS_REPREP_ID_LVC         =
*   I_SCREEN_START_COLUMN    = 0
*   I_SCREEN_START_LINE      = 0
*   I_SCREEN_END_COLUMN      = 0
*   I_SCREEN_END_LINE        = 0
*   I_HTML_HEIGHT_TOP        =
*   I_HTML_HEIGHT_END        =
*   IT_ALV_GRAPHICS          =
*   IT_EXCEPT_QINFO_LVC      =
*   IR_SALV_FULLSCREEN_ADAPTER        =
*   IMPORTING
*   E_EXIT_CAUSED_BY_CALLER  =
*   ES_EXIT_CAUSED_BY_USER   =
  TABLES
    T_OUTTAB                 = GT_01
*   EXCEPTIONS
*   PROGRAM_ERROR            = 1
*   OTHERS                   = 2
  .
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.


FORM FRM_PF_STATUS USING EXTAB.
  SET PF-STATUS 'MENU'.
ENDFORM.

FORM FRM_USERCOMM USING P_UCOMM TYPE SYUCOMM
                   CHANGING P_SEL TYPE SLIS_SELFIELD.
  DATA: LR_GRID TYPE REF TO CL_GUI_ALV_GRID,
        MYINDEX TYPE SY-TABIX.
*  Ë¢ÐÂÆÁÄ»

  CASE P_UCOMM.
    WHEN 'INS'.
      APPEND INITIAL LINE TO GT_01.
      LOOP AT GT_01 INTO GS_01.
        IF GS_01-PER_KEY IS INITIAL.
          CLEAR GS_01-SEL_STY.
          MODIFY GT_01 FROM GS_01 INDEX SY-TABIX.
        ENDIF.
      ENDLOOP.

    WHEN '&DATA_SAVE'.
      "p_sel-refresh = 'X'.
      LOOP AT GT_01 INTO GS_01.
        DATA(INDEX= SY-TABIX.
        IF GS_01-SEL_STY IS INITIAL.
          IS_SEL_STY-FIELDNAME 'per_key'.
          IS_SEL_STY-STYLE = CL_GUI_ALV_GRID=>MC_STYLE_DISABLED.
          INSERT IS_SEL_STY INTO TABLE GS_01-SEL_STY.
          IS_SEL_STY-FIELDNAME 'per_nor'.
          IS_SEL_STY-STYLE = CL_GUI_ALV_GRID=>MC_STYLE_DISABLED.
          INSERT IS_SEL_STY INTO TABLE GS_01-SEL_STY.
          MODIFY GT_01 FROM GS_01 INDEX SY-TABIX.
          ELSE.
            LOOP AT GS_01-SEL_STY INTO IS_SEL_STY.
               IS_SEL_STY-STYLE = CL_GUI_ALV_GRID=>MC_STYLE_DISABLED.
               MODIFY GS_01-SEL_STY FROM IS_SEL_STY INDEX SY-TABIX.
               ENDLOOP.
               MODIFY GT_01 FROM GS_01 INDEX INDEX.
        ENDIF.
      ENDLOOP.
    WHEN 'MOD'.
      LOOP AT GT_01 INTO GS_01.
        IF GS_01-CBOX 'X'.
          CLEAR GS_01-SEL_STY.
          CLEAR IS_SEL_STY.
          MODIFY GT_01 FROM GS_01 INDEX SY-TABIX.
        ENDIF.
      ENDLOOP.
    WHEN '&IC1'.
      READ TABLE GT_01 INTO GS_01 INDEX P_SEL-TABINDEX.
      MYINDEX = SY-TABIX.
      LOOP AT GT_01 INTO GS_01 .
        IF SY-TABIX = MYINDEX.
          CLEAR GS_01-SEL_STY.
          LOOP AT IT_FIELDCAT INTO IS_FIELDCAT .
            IF IS_FIELDCAT-FIELDNAME = P_SEL-FIELDNAME.
              IS_SEL_STY-FIELDNAME = P_SEL-FIELDNAME.
              IS_SEL_STY-STYLE = CL_GUI_ALV_GRID=>MC_STYLE_ENABLED.
              APPEND IS_SEL_STY TO GS_01-SEL_STY.
            ELSE.
              IS_SEL_STY-FIELDNAME = IS_FIELDCAT-FIELDNAME.
              IS_SEL_STY-STYLE = CL_GUI_ALV_GRID=>MC_STYLE_DISABLED.
              APPEND IS_SEL_STY TO GS_01-SEL_STY.
            ENDIF.
            MODIFY GT_01 FROM GS_01.
          ENDLOOP.
        ENDIF.
      ENDLOOP.
  ENDCASE.
  ".ALV»Øµ÷
*  CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
*    IMPORTING
*      e_grid = lr_grid.
*  CALL METHOD lr_grid->check_changed_data.
  P_SEL-REFRESH 'X'.
ENDFORM.
*&---------------------------------------------------------------------*
*&      Form  FRM_SET_LINE_NOEDIT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM FRM_SET_LINE_NOEDIT .
  LOOP AT GT_01 INTO GS_01.
    IS_SEL_STY-FIELDNAME 'per_key'.
    IS_SEL_STY-STYLE = CL_GUI_ALV_GRID=>MC_STYLE_DISABLED.
    INSERT IS_SEL_STY INTO TABLE GS_01-SEL_STY.
    IS_SEL_STY-FIELDNAME 'per_nor'.
    IS_SEL_STY-STYLE = CL_GUI_ALV_GRID=>MC_STYLE_DISABLED.
    INSERT IS_SEL_STY INTO TABLE GS_01-SEL_STY.
    MODIFY GT_01 FROM GS_01 INDEX SY-TABIX.
    CLEAR IS_SEL_STY.
  ENDLOOP.

ENDFORM.
ui

本站公眾號
   歡迎關注本站公眾號,獲取更多信息