[Series] ABAP SAP ABAP OOALV dynamically set whether the cell editor

No public: SAP Technical
Author: Matinal
 

 

The preface

We can focus on my public number, the number public in the layout better, read more comfortable.

Body part

For OOALV Some columns allow customers to enter, but when the user input, or to determine whether certain conditions are met before ALV display, if satisfied, then they would set up a separate line or a few lines of this field can not be edited or editing, effects If you like this: 

Implementation steps 
1. Add field within a table or the table type shown in 
CELLTAB TYPE LVC_T_STYL. 

 

E.g:

TYPES : BEGIN OF T_SC,
  BUKRS   LIKE  ANLZ-BUKRS,
  ANLN1   LIKE  ANLA-ANLN1,         "模具编号
  ANLN2   LIKE  ANLA-ANLN2,
  CELLTAB TYPE  LVC_T_STYL,
END OF T_SC.

​

2. Add layout code setting 
XXX_LAYOUT-STYLEFNAME = 'CELLTAB'.

3. Edit Properties achieve control code

FORM FRM_INIT_STYLE_TAB .
  DATA: LT_SFLIGHT  TYPE TABLE OF SFLIGHT WITH HEADER LINE,
        LT_CELLTAB  TYPE LVC_T_STYL,
        LS_CELLTAB  TYPE LVC_S_STYL,
        L_INDEX     TYPE I.
  LOOP AT IT_TAB INTO WA_TAB.
    CLEAR : WA_TAB-CELLTAB.  "不为空会报错
    IF WA_TAB-CELLTAB IS INITIAL.
      L_INDEX = SY-TABIX.
      REFRESH LT_CELLTAB.
      LS_CELLTAB-FIELDNAME = 'ZCWCZD'.

      IF WA_TAB-ZCWCZI IS NOT INITIAL AND
          WA_TAB-ZCXCZI IS INITIAL.
        LS_CELLTAB-STYLE = CL_GUI_ALV_GRID=>MC_STYLE_DISABLED.
      ELSE.
        LS_CELLTAB-STYLE = CL_GUI_ALV_GRID=>MC_STYLE_ENABLED.
      ENDIF.
      INSERT LS_CELLTAB INTO TABLE LT_CELLTAB.

      INSERT LINES OF LT_CELLTAB INTO TABLE WA_TAB-CELLTAB.
      MODIFY IT_TAB FROM WA_TAB INDEX L_INDEX.
    ENDIF.
  ENDLOOP.
ENDFORM.                    " FRM_INIT_STYLE_TAB

4. In the calling code where the need to display 
in each place that you need to re-edit the cell is determined whether the call, such as:

MODULE DISPLAY_FINANCIAL_DISPOSAL OUTPUT.
  "设置可编辑字段
  PERFORM FRM_INIT_STYLE_TAB.
  "展示avl
  PERFORM DISPLAY_FINANCIAL_DISPOSAL.
ENDMODULE.             " DISPLAY_FINANCIAL_DISPOSAL  OUTPUT

The actual situation with the event data used to modify

Guess you like

Origin www.cnblogs.com/SAPmatinal/p/11184343.html