zoukankan      html  css  js  c++  java
  • SAP Table control

     

    REPORT RSDEMO02.
    * demostrates the use of table controls
    * unsolved problems: attributes left_col and v_scroll do not work
    *                    correctly
    TABLES: SPFLI.                         "flight connections, flights
    DATA: FCODE2(4), FCODE(4).             "ok-code
    CONTROLS: TC_SPFLI TYPE TABLEVIEW USING SCREEN 100,      "flights
              TC_COLS TYPE TABLEVIEW USING SCREEN 100.       "column props
    DATA:  COL TYPE CXTAB_COLUMN.          "column of table control
    TABLES: DEMO_CPROP, DEMO_TPROP.        "structures for displaying
    *                                    global and column specific props
    DATA: BEGIN OF IT_SPFLI OCCURS  20,    "flight connections
            MARKED.                        "Check box
            INCLUDE STRUCTURE SPFLI.
    DATA: END OF IT_SPFLI.
    DATA  LINNO TYPE I.                    "line number at cursor position
    DATA  FLD(20).                         "field name at cursor position
    DATA  OFF TYPE I.                      "offset of cursor position
    
    START-OF-SELECTION.
    * read flight connections
      SELECT *  FROM SPFLI UP TO 100 ROWS.
        MOVE-CORRESPONDING SPFLI TO IT_SPFLI.
        APPEND IT_SPFLI.
      ENDSELECT.
      DESCRIBE TABLE IT_SPFLI LINES TC_SPFLI-LINES.
      TC_COLS-LINES = 6.
    * display flights with table control
      CALL SCREEN 100.
    *&---------------------------------------------------------------------*
    *&      Module  FCODE_100  INPUT
    *&---------------------------------------------------------------------*
    *       handle user command                                            *
    *----------------------------------------------------------------------*
    MODULE FCODE_100 INPUT.
      DATA: FLDNAME(100),FLDNAME2(100),FLDNAME3(100).
    * copy global property changes made by the user
      TC_SPFLI-FIXED_COLS = DEMO_TPROP-FIXED_COLS.
      TC_SPFLI-LINES = DEMO_TPROP-LINES.
      TC_SPFLI-LINE_SEL_MODE = DEMO_TPROP-LINE_SEL_M.
      TC_SPFLI-COL_SEL_MODE = DEMO_TPROP-COL_SEL_MO.
      TC_SPFLI-LINE_SELECTOR = DEMO_TPROP-LINE_SELEC.
      TC_SPFLI-V_SCROLL = DEMO_TPROP-V_SCROLL.
      TC_SPFLI-H_GRID = DEMO_TPROP-H_GRID.
      TC_SPFLI-V_GRID = DEMO_TPROP-V_GRID.
      FCODE2 = FCODE.
      CLEAR FCODE.
    * handle ok code
      CASE FCODE2.
        WHEN 'INFO'.                       "display online docu
          CALL FUNCTION 'RS_TOOL_ACCESS'
               EXPORTING
                    OPERATION           = 'DOCS'
                    OBJECT_NAME         = 'RSDEMO02'
                    OBJECT_TYPE         = 'PROG'
    *               ENCLOSING_OBJECT    =
    *               position            = '1 1'
    *               DEVCLASS            =
    *               INCLUDE             =
    *               MONITOR_ACTIVATION  = 'X'
    *          IMPORTING
    *               NEW_NAME            =
    *          TABLES
    *               OBJLIST             =
               EXCEPTIONS
                    NOT_EXECUTED        = 1
                    INVALID_OBJECT_TYPE = 2
                    OTHERS              = 3.
    
    
        WHEN 'SORT'.
          DATA: FLD_LIST LIKE TC_SPFLI-COLS.
    * search for selected columns.
          REFRESH FLD_LIST.
          LOOP AT TC_SPFLI-COLS INTO COL.
            IF COL-SELECTED = 'X'.
              APPEND COL TO FLD_LIST.
            ENDIF.
          ENDLOOP.
          SORT FLD_LIST BY INDEX.
          CLEAR:FLDNAME, FLDNAME2, FLDNAME3.
          READ TABLE FLD_LIST INDEX 1 INTO COL.
          FLDNAME = COL-SCREEN-NAME+9.
          READ TABLE FLD_LIST INDEX 2 INTO COL.
          FLDNAME2 = COL-SCREEN-NAME+9.
          READ TABLE FLD_LIST INDEX 3 INTO COL.
          FLDNAME3 = COL-SCREEN-NAME+9.
          SORT IT_SPFLI BY (FLDNAME) (FLDNAME2) (FLDNAME3).
        WHEN 'BACK'.
          SET SCREEN 0.
          LEAVE SCREEN.
        WHEN 'DELL'.
    * remove marked lines
          LOOP AT IT_SPFLI WHERE MARKED = 'X'.
            DELETE IT_SPFLI.
          ENDLOOP.
          IF SY-SUBRC <> 0.
            GET CURSOR FIELD FLD LINE LINNO OFFSET OFF.
            SET CURSOR FIELD FLD LINE LINNO OFFSET OFF.
            IF FLD CP 'IT_SPFLI*' AND SY-SUBRC = 0.
              LINNO = LINNO + TC_SPFLI-TOP_LINE - 1.
              DELETE IT_SPFLI INDEX LINNO.
              TC_SPFLI-LINES = TC_SPFLI-LINES - 1.
            ENDIF.
          ENDIF.
        WHEN 'INSL'.
    * insert line above cursor position
          GET CURSOR FIELD FLD LINE LINNO OFFSET OFF.
          SET CURSOR FIELD FLD LINE LINNO OFFSET OFF.
          IF FLD CP 'IT_SPFLI*' AND SY-SUBRC = 0.
            IF LINNO >= 1.
              LINNO = LINNO + TC_SPFLI-TOP_LINE - 1.
              CLEAR IT_SPFLI.
              INSERT IT_SPFLI INDEX LINNO.
              TC_SPFLI-LINES = TC_SPFLI-LINES + 1.
            ELSE.
              CLEAR IT_SPFLI.
              APPEND IT_SPFLI.
              TC_SPFLI-LINES = TC_SPFLI-LINES + 1.
            ENDIF.
          ENDIF.
      ENDCASE.
    ENDMODULE.                             " FCODE_100  INPUT
    *&---------------------------------------------------------------------*
    *&      Module  INIT_100  OUTPUT
    *&---------------------------------------------------------------------*
    *                                        *
    *----------------------------------------------------------------------*
    MODULE INIT_100 OUTPUT.
      SET PF-STATUS 'S100'.
    * make global props visible
      MOVE:
      TC_SPFLI-FIXED_COLS TO DEMO_TPROP-FIXED_COLS,
      TC_SPFLI-LINES TO DEMO_TPROP-LINES,
      TC_SPFLI-TOP_LINE TO DEMO_TPROP-TOP_LINE,
      TC_SPFLI-CURRENT_LINE TO DEMO_TPROP-CURRENT_LI,
      TC_SPFLI-LEFT_COL TO DEMO_TPROP-LEFT_COL,
      TC_SPFLI-LINE_SEL_MODE TO DEMO_TPROP-LINE_SEL_M,
      TC_SPFLI-COL_SEL_MODE TO DEMO_TPROP-COL_SEL_MO,
      TC_SPFLI-LINE_SELECTOR TO DEMO_TPROP-LINE_SELEC,
      TC_SPFLI-V_SCROLL TO DEMO_TPROP-V_SCROLL,
      TC_SPFLI-H_GRID TO DEMO_TPROP-H_GRID,
      TC_SPFLI-V_GRID TO DEMO_TPROP-V_GRID.
    ENDMODULE.                             " INIT_100  OUTPUT
    *&---------------------------------------------------------------------*
    *&      Module  MODIFY_IT_SPFLI  INPUT
    *&---------------------------------------------------------------------*
    *       transport changes to internal table                        *
    *----------------------------------------------------------------------*
    MODULE MODIFY_IT_SPFLI INPUT.
      MODIFY IT_SPFLI INDEX TC_SPFLI-CURRENT_LINE.
    ENDMODULE.                             " MODIFY_IT_SPFLI  INPUT
    *&---------------------------------------------------------------------*
    *&      Module  READ_COLS  OUTPUT
    *&---------------------------------------------------------------------*
    *       Read according column property and make it visible         *
    *----------------------------------------------------------------------*
    MODULE READ_COLS OUTPUT.
      READ TABLE TC_SPFLI-COLS INDEX TC_COLS-CURRENT_LINE INTO COL.
      IF SY-SUBRC <> 0.
        EXIT FROM STEP-LOOP.
      ENDIF.
      MOVE:
       COL-SCREEN-NAME TO DEMO_CPROP-NAME,
       COL-SCREEN-GROUP1 TO DEMO_CPROP-GROUP1,
       COL-SCREEN-GROUP2 TO DEMO_CPROP-GROUP2,
       COL-SCREEN-GROUP3 TO DEMO_CPROP-GROUP3,
       COL-SCREEN-GROUP4 TO DEMO_CPROP-GROUP4,
       COL-SCREEN-REQUIRED TO DEMO_CPROP-REQUIRED,
       COL-SCREEN-INPUT TO DEMO_CPROP-INPUT,
       COL-SCREEN-OUTPUT TO DEMO_CPROP-OUTPUT,
       COL-SCREEN-INTENSIFIED TO DEMO_CPROP-INTENS,
       COL-SCREEN-INVISIBLE TO DEMO_CPROP-INVISIBLEV,
       COL-SCREEN-LENGTH TO      DEMO_CPROP-LENGTH,
       COL-SCREEN-ACTIVE TO      DEMO_CPROP-ACTIVE,
       COL-INDEX TO      DEMO_CPROP-INDEX,
       COL-SELECTED TO     DEMO_CPROP-SELECTED,
       COL-VISLENGTH TO DEMO_CPROP-VISLENGTH,
       COL-INVISIBLE TO DEMO_CPROP-INVISIBLEC.
    
    ENDMODULE.                             " READ_COLS  OUTPUT
    *&---------------------------------------------------------------------*
    *&      Module  MODIFY_COLS  INPUT
    *&---------------------------------------------------------------------*
    *       text                                                           *
    *----------------------------------------------------------------------*
    MODULE MODIFY_COLS INPUT.
      CLEAR COL.
      READ TABLE TC_SPFLI-COLS INDEX TC_COLS-CURRENT_LINE INTO COL.
      COL-SCREEN-GROUP1      = DEMO_CPROP-GROUP1.
      COL-SCREEN-GROUP2      = DEMO_CPROP-GROUP2.
      COL-SCREEN-GROUP3      = DEMO_CPROP-GROUP3.
      COL-SCREEN-GROUP4      = DEMO_CPROP-GROUP4.
      COL-SCREEN-REQUIRED    = DEMO_CPROP-REQUIRED.
      COL-SCREEN-INPUT       = DEMO_CPROP-INPUT.
      COL-SCREEN-OUTPUT      = DEMO_CPROP-OUTPUT.
      COL-SCREEN-INTENSIFIED = DEMO_CPROP-INTENS.
      COL-SCREEN-INVISIBLE   = DEMO_CPROP-INVISIBLEV.
      COL-SCREEN-LENGTH      = DEMO_CPROP-LENGTH.
      COL-SCREEN-ACTIVE      = DEMO_CPROP-ACTIVE.
      COL-INVISIBLE          = DEMO_CPROP-INVISIBLEC.
    * update column specific property changes made by the user
      MODIFY TC_SPFLI-COLS INDEX TC_COLS-CURRENT_LINE FROM COL.
    ENDMODULE.                             " MODIFY_COLS  INPUT
  • 相关阅读:
    Nginx模块fastcgi_cache的几个注意点
    Nginx的fastcgi_cache
    Nginx Location 语法,与简单配置[转]
    nginx location 匹配顺序
    Amoeba基本配置
    LVS的DR模式配置
    Keepalived安装及初步使用
    HAProxy安装及初步使用
    lvs nginx HAProxy优缺点
    Redis安装及初步使用
  • 原文地址:https://www.cnblogs.com/JackeyLove/p/13650386.html
Copyright © 2011-2022 走看看