SAP-Dialog详解编程语言

1.T1

1.主窗体和子窗体之间执行顺序 
 
主窗体PAI->子窗体PAI->主窗体->PBO->子窗体PBO 
 
造成问题: 
因此如果在主窗体和子窗体共用同一个组件,在主窗体修改后回车数据还是之前数据,并没有更新. 

2.T2

*&---------------------------------------------------------------------* 
*& Modulpool ZWXT_10 
*&---------------------------------------------------------------------* 
*& 
*&---------------------------------------------------------------------* 
PROGRAM ZWXT_10. 
 
INCLUDE ZWXT_10_TOP. 
 
INCLUDE ZWXT_10_PBO. 
 
INCLUDE ZWXT_10_PAI. 
 
*&SPWizard: Include inserted by SP Wizard. DO NOT CHANGE THIS LINE! 
INCLUDE ZWXT_10_SUB. 
 
INCLUDE ZWXT_10_FRM.

3.TOP

*&---------------------------------------------------------------------* 
*& 包含               ZWXT_10_TOP 
*&---------------------------------------------------------------------* 
 
DATA:GV_ZCODE  TYPE ZWXSTUDENT_02-ZCODE, 
     GV_ZNAME  TYPE ZWXSTUDENT_02-ZNAME, 
     GV_ZSEX   TYPE ZWXSTUDENT_02-ZSEX, 
     GV_ZSCHOOL TYPE ZWXSTUDENT_02-ZSCHOOL, 
     GV_ZWEIGHT TYPE ZWXSTUDENT_02-ZWEIGHT, 
     GV_ZUNIT   TYPE ZWXSTUDENT_02-ZUNIT, 
     GV_DATE   TYPE D, 
     GV_TIME   TYPE T. 
 
TYPES: BEGIN OF GTY_STUDENT. 
TYPES: SEQ TYPE I. 
INCLUDE STRUCTURE ZWXSTUDENT_02. 
TYPES: END OF GTY_STUDENT. 
 
DATA:GT_STUDENT TYPE STANDARD TABLE OF GTY_STUDENT, 
     GS_STUDENT TYPE GTY_STUDENT. 
 
"排除的STATUS 
DATA STATUS TYPE STANDARD TABLE OF SY-UCOMM WITH HEADER LINE. 
"光标位置 
DATA CURSOR_FLAG TYPE C. 
"TITLEBAR 
DATA TITLEBAR TYPE C LENGTH 10 VALUE '新建'. 
 
TYPES:BEGIN OF GTY_STUDENT_02, 
      CHECK TYPE C, 
      SEQ   TYPE I. 
INCLUDE STRUCTURE ZWXSTUDENT_02. 
TYPES:END OF GTY_STUDENT_02. 
 
DATA:GT_STUDENT_02 TYPE STANDARD TABLE OF GTY_STUDENT_02, 
     GS_STUDENT_02 TYPE GTY_STUDENT_02. 
 
*&SPWIZARD: FUNCTION CODES FOR TABSTRIP 'TAB_CTRL_100' 
CONSTANTS: BEGIN OF C_TAB_CTRL_100, 
             TAB1 LIKE SY-UCOMM VALUE 'TAB_CTRL_100_FC1', 
             TAB2 LIKE SY-UCOMM VALUE 'TAB_CTRL_100_FC2', 
             TAB3 LIKE SY-UCOMM VALUE 'TAB_CTRL_100_FC3', 
             TAB4 LIKE SY-UCOMM VALUE 'TAB_CTRL_100_FC4', 
           END OF C_TAB_CTRL_100. 
*&SPWIZARD: DATA FOR TABSTRIP 'TAB_CTRL_100' 
CONTROLS:  TAB_CTRL_100 TYPE TABSTRIP. 
DATA:      BEGIN OF G_TAB_CTRL_100, 
             SUBSCREEN   LIKE SY-DYNNR, 
             PROG        LIKE SY-REPID VALUE 'ZWXT_10', 
             PRESSED_TAB LIKE SY-UCOMM VALUE C_TAB_CTRL_100-TAB1, 
           END OF G_TAB_CTRL_100. 
DATA:      OK_CODE LIKE SY-UCOMM. 
DATA:      OK_SAVE LIKE SY-UCOMM. 
 
*&SPWIZARD: DECLARATION OF TABLECONTROL 'TAB_CTRL_130' ITSELF 
CONTROLS: TAB_CTRL_130 TYPE TABLEVIEW USING SCREEN 0130. 
 
*&SPWIZARD: LINES OF TABLECONTROL 'TAB_CTRL_130' 
DATA:     G_TAB_CTRL_130_LINES  LIKE SY-LOOPC. 
 
*&SPWIZARD: DECLARATION OF TABLECONTROL 'TAB_CTRL_120' ITSELF 
CONTROLS: TAB_CTRL_120 TYPE TABLEVIEW USING SCREEN 0120. 
 
*&SPWIZARD: LINES OF TABLECONTROL 'TAB_CTRL_120' 
DATA:     G_TAB_CTRL_120_LINES  LIKE SY-LOOPC. 
 
 
SELECTION-SCREEN BEGIN OF SCREEN 0111 AS SUBSCREEN. 
  SELECT-OPTIONS S_ZCODE FOR GS_STUDENT-ZCODE. 
SELECTION-SCREEN END OF SCREEN 0111.

4.PBO

*&---------------------------------------------------------------------* 
*& 包含               ZWXT_10_PBO 
*&---------------------------------------------------------------------* 
 
*&SPWIZARD: OUTPUT MODULE FOR TS 'TAB_CTRL_100'. DO NOT CHANGE THIS LINE 
*&SPWIZARD: SETS ACTIVE TAB 
MODULE TAB_CTRL_100_ACTIVE_TAB_SET OUTPUT. 
  TAB_CTRL_100-ACTIVETAB = G_TAB_CTRL_100-PRESSED_TAB. 
  CASE G_TAB_CTRL_100-PRESSED_TAB. 
    WHEN C_TAB_CTRL_100-TAB1. 
      G_TAB_CTRL_100-SUBSCREEN = '0110'. 
    WHEN C_TAB_CTRL_100-TAB2. 
      G_TAB_CTRL_100-SUBSCREEN = '0120'. 
    WHEN C_TAB_CTRL_100-TAB3. 
      G_TAB_CTRL_100-SUBSCREEN = '0130'. 
    WHEN C_TAB_CTRL_100-TAB4. 
      G_TAB_CTRL_100-SUBSCREEN = '0140'. 
    WHEN OTHERS. 
*&SPWIZARD:      DO NOTHING 
  ENDCASE. 
ENDMODULE. 
*&---------------------------------------------------------------------* 
*& Module SET_STATUS OUTPUT 
*&---------------------------------------------------------------------* 
*& 
*&---------------------------------------------------------------------* 
MODULE set_status_0100 OUTPUT. 
 SET PF-STATUS '0100_STATUS' EXCLUDING STATUS. 
 SET TITLEBAR '0100_TITLEBAR' WITH TITLEBAR. 
ENDMODULE. 
*&---------------------------------------------------------------------* 
*& Module DATA_INIT_0110 OUTPUT 
*&---------------------------------------------------------------------* 
*& 
*&---------------------------------------------------------------------* 
MODULE data_init_0110 OUTPUT. 
  GV_DATE = SY-DATUM. 
  GV_TIME = SY-UZEIT. 
  CASE CURSOR_FLAG. 
    WHEN 'A'. 
      SET CURSOR FIELD 'GV_ZCODE'. 
    WHEN 'B'. 
      SET CURSOR FIELD 'GV_ZSCHOOL'. 
    WHEN 'C'. 
      SET CURSOR FIELD 'GV_ZNAME'. 
    WHEN 'D'. 
      SET CURSOR FIELD 'GV_ZSEX'. 
    WHEN 'E'. 
      SET CURSOR FIELD 'GV_ZWEIGHT'. 
    WHEN 'F'. 
      SET CURSOR FIELD 'GV_ZUNIT'. 
    WHEN '1'. 
    SET CURSOR FIELD 'GV_ZSCHOOL'. 
    WHEN '2'. 
    SET CURSOR FIELD 'GV_ZNAME'. 
  ENDCASE. 
ENDMODULE. 
 
*&SPWIZARD: OUTPUT MODULE FOR TC 'TAB_CTRL_130'. DO NOT CHANGE THIS LINE 
*&SPWIZARD: UPDATE LINES FOR EQUIVALENT SCROLLBAR 
MODULE TAB_CTRL_130_CHANGE_TC_ATTR OUTPUT. 
  DESCRIBE TABLE GT_STUDENT LINES TAB_CTRL_130-lines. 
ENDMODULE. 
 
*&SPWIZARD: OUTPUT MODULE FOR TC 'TAB_CTRL_130'. DO NOT CHANGE THIS LINE 
*&SPWIZARD: GET LINES OF TABLECONTROL 
MODULE TAB_CTRL_130_GET_LINES OUTPUT. 
  G_TAB_CTRL_130_LINES = SY-LOOPC. 
ENDMODULE. 
*&---------------------------------------------------------------------* 
*& Module DATA_INIT_130 OUTPUT 
*&---------------------------------------------------------------------* 
*& 
*&---------------------------------------------------------------------* 
MODULE data_init_0130 OUTPUT. 
  DATA LV_DIG TYPE I. 
  SELECT * 
    INTO CORRESPONDING FIELDS OF TABLE GT_STUDENT 
    FROM ZWXSTUDENT_02 
    WHERE ZCODE IN S_ZCODE. 
  CLEAR LV_DIG. 
  LOOP AT GT_STUDENT INTO GS_STUDENT. 
    LV_DIG = LV_DIG + 1. 
    GS_STUDENT-SEQ = LV_DIG. 
    MODIFY GT_STUDENT FROM GS_STUDENT. 
  ENDLOOP. 
ENDMODULE. 
 
*&SPWIZARD: OUTPUT MODULE FOR TC 'TAB_CTRL_120'. DO NOT CHANGE THIS LINE 
*&SPWIZARD: UPDATE LINES FOR EQUIVALENT SCROLLBAR 
MODULE TAB_CTRL_120_CHANGE_TC_ATTR OUTPUT. 
  DESCRIBE TABLE GT_STUDENT_02 LINES TAB_CTRL_120-lines. 
ENDMODULE. 
 
*&SPWIZARD: OUTPUT MODULE FOR TC 'TAB_CTRL_120'. DO NOT CHANGE THIS LINE 
*&SPWIZARD: GET LINES OF TABLECONTROL 
MODULE TAB_CTRL_120_GET_LINES OUTPUT. 
  G_TAB_CTRL_120_LINES = SY-LOOPC. 
ENDMODULE. 
*&---------------------------------------------------------------------* 
*& Module DATA_INIT_0120 OUTPUT 
*&---------------------------------------------------------------------* 
*& 
*&---------------------------------------------------------------------* 
MODULE data_init_0120 OUTPUT. 
  IF GT_STUDENT_02[] IS INITIAL. 
    SELECT * 
      INTO CORRESPONDING FIELDS OF TABLE GT_STUDENT_02 
      FROM ZWXSTUDENT_02. 
    CLEAR LV_DIG. 
    LOOP AT GT_STUDENT_02 INTO GS_STUDENT_02. 
      LV_DIG = LV_DIG + 1. 
      GS_STUDENT_02-SEQ = LV_DIG. 
      MODIFY GT_STUDENT_02 FROM GS_STUDENT_02. 
    ENDLOOP. 
  ENDIF. 
ENDMODULE.

5.PAI

*&---------------------------------------------------------------------* 
*& 包含               ZWXT_10_PAI 
*&---------------------------------------------------------------------* 
 
*&SPWIZARD: INPUT MODULE FOR TS 'TAB_CTRL_100'. DO NOT CHANGE THIS LINE! 
*&SPWIZARD: GETS ACTIVE TAB 
MODULE TAB_CTRL_100_ACTIVE_TAB_GET INPUT. 
  OK_CODE = SY-UCOMM. 
  CLEAR STATUS[]. 
  CASE OK_CODE. 
    WHEN C_TAB_CTRL_100-TAB1. 
      TITLEBAR = '新建'. 
      G_TAB_CTRL_100-PRESSED_TAB = C_TAB_CTRL_100-TAB1. 
    WHEN C_TAB_CTRL_100-TAB2. 
      APPEND 'SAVE' TO STATUS. 
      TITLEBAR = '修改'. 
      G_TAB_CTRL_100-PRESSED_TAB = C_TAB_CTRL_100-TAB2. 
    WHEN C_TAB_CTRL_100-TAB3. 
      APPEND 'SAVE' TO STATUS. 
      TITLEBAR = '显示'. 
      G_TAB_CTRL_100-PRESSED_TAB = C_TAB_CTRL_100-TAB3. 
    WHEN C_TAB_CTRL_100-TAB4. 
      APPEND 'SAVE' TO STATUS. 
      TITLEBAR = '删除'. 
      G_TAB_CTRL_100-PRESSED_TAB = C_TAB_CTRL_100-TAB4. 
    WHEN OTHERS. 
*&SPWIZARD:      DO NOTHING 
  ENDCASE. 
ENDMODULE. 
*&---------------------------------------------------------------------* 
*&      Module  USER_COMMAND_0100  INPUT 
*&---------------------------------------------------------------------* 
*       text 
*----------------------------------------------------------------------* 
MODULE user_command_0100 INPUT. 
  OK_SAVE = SY-UCOMM. 
  CLEAR SY-UCOMM. 
  CLEAR OK_CODE. 
  CASE OK_SAVE. 
    WHEN 'BACK'. 
      LEAVE TO SCREEN 0. 
    WHEN 'EXIT'. 
      LEAVE PROGRAM. 
    WHEN 'CANCEL'. 
      LEAVE PROGRAM. 
    WHEN 'SAVE'. 
      DATA LS_STUDENT TYPE ZWXSTUDENT_02. 
      "插入数据库 
      CLEAR GS_STUDENT. 
      LS_STUDENT-ZCODE = GV_ZCODE. 
      LS_STUDENT-ZSCHOOL = GV_ZSCHOOL. 
      LS_STUDENT-ZNAME = GV_ZNAME. 
      LS_STUDENT-ZSEX = GV_ZSEX. 
      LS_STUDENT-ZWEIGHT = GV_ZWEIGHT. 
      LS_STUDENT-ZUNIT = GV_ZUNIT. 
      INSERT INTO ZWXSTUDENT_02 VALUES LS_STUDENT. 
      IF SY-SUBRC = 0. 
        MESSAGE '插入成功' TYPE 'S'. 
      ELSE. 
        MESSAGE '插入失败' TYPE 'S' DISPLAY LIKE 'E'. 
      ENDIF. 
  ENDCASE. 
ENDMODULE. 
*&---------------------------------------------------------------------* 
*&      Module  CHECK_ZCODE_0110  INPUT 
*&---------------------------------------------------------------------* 
*       text 
*----------------------------------------------------------------------* 
MODULE check_zcode_0110 INPUT. 
  SELECT SINGLE * 
    INTO CORRESPONDING FIELDS OF GS_STUDENT 
    FROM ZWXSTUDENT_02 
    WHERE ZCODE = GV_ZCODE. 
  IF SY-SUBRC <> 0. 
    CURSOR_FLAG = '1'. 
    MESSAGE '该学号可用!' TYPE 'S'. 
  ELSE. 
    CURSOR_FLAG = 'A'. 
    MESSAGE '该学号不可用!' TYPE 'S' DISPLAY LIKE 'E'. 
  ENDIF. 
ENDMODULE. 
*&---------------------------------------------------------------------* 
*&      Module  CHECK_ZSCHOOL_0110  INPUT 
*&---------------------------------------------------------------------* 
*       text 
*----------------------------------------------------------------------* 
MODULE check_zschool_0110 INPUT. 
  SELECT SINGLE * 
    INTO CORRESPONDING FIELDS OF GS_STUDENT 
    FROM ZWXSCHOOL_01 
    WHERE ZSCHOOL = GV_ZSCHOOL. 
  IF SY-SUBRC = 0. 
    CURSOR_FLAG = '2'. 
    MESSAGE '该学校编号存在,可用!' TYPE 'S'. 
  ELSE. 
    CURSOR_FLAG = 'B'. 
    MESSAGE '该学校编号不存在,不可用!' TYPE 'S' DISPLAY LIKE 'E'. 
  ENDIF. 
ENDMODULE. 
*&---------------------------------------------------------------------* 
*&      Module  CHECK_NOT_EMPTY_0110  INPUT 
*&---------------------------------------------------------------------* 
*       text 
*----------------------------------------------------------------------* 
MODULE check_not_empty_0110 INPUT. 
  IF GV_ZNAME IS INITIAL. 
    CURSOR_FLAG = 'C'. 
    MESSAGE '姓名不可为空!' TYPE 'S' DISPLAY LIKE 'E'. 
  ELSEIF GV_ZSEX IS INITIAL. 
    CURSOR_FLAG = 'D'. 
    MESSAGE '性别不可为空!' TYPE 'S' DISPLAY LIKE 'E'. 
  ELSEIF GV_ZWEIGHT IS INITIAL. 
    CURSOR_FLAG = 'E'. 
    MESSAGE '体重不可为空!' TYPE 'S' DISPLAY LIKE 'E'. 
  ELSEIF GV_ZUNIT IS INITIAL. 
    CURSOR_FLAG = 'F'. 
    MESSAGE '单位不可为空!' TYPE 'S' DISPLAY LIKE 'E'. 
  ENDIF. 
ENDMODULE. 
 
*&SPWIZARD: INPUT MODULE FOR TC 'TAB_CTRL_130'. DO NOT CHANGE THIS LINE! 
*&SPWIZARD: PROCESS USER COMMAND 
MODULE TAB_CTRL_130_USER_COMMAND INPUT. 
  OK_CODE = SY-UCOMM. 
  PERFORM USER_OK_TC USING    'TAB_CTRL_130' 
                              'GT_STUDENT' 
                              ' ' 
                     CHANGING OK_CODE. 
  SY-UCOMM = OK_CODE. 
ENDMODULE. 
 
*&SPWIZARD: INPUT MODULE FOR TC 'TAB_CTRL_120'. DO NOT CHANGE THIS LINE! 
*&SPWIZARD: MODIFY TABLE 
MODULE TAB_CTRL_120_MODIFY INPUT. 
  MODIFY GT_STUDENT_02 
    FROM GS_STUDENT_02 
    INDEX TAB_CTRL_120-CURRENT_LINE. 
ENDMODULE. 
 
*&SPWIZARD: INPUT MODUL FOR TC 'TAB_CTRL_120'. DO NOT CHANGE THIS LINE! 
*&SPWIZARD: MARK TABLE 
MODULE TAB_CTRL_120_MARK INPUT. 
  DATA: g_TAB_CTRL_120_wa2 like line of GT_STUDENT_02. 
    if TAB_CTRL_120-line_sel_mode = 1 
    and GS_STUDENT_02-CHECK = 'X'. 
     loop at GT_STUDENT_02 into g_TAB_CTRL_120_wa2 
       where CHECK = 'X'. 
       g_TAB_CTRL_120_wa2-CHECK = ''. 
       modify GT_STUDENT_02 
         from g_TAB_CTRL_120_wa2 
         transporting CHECK. 
     endloop. 
  endif. 
  MODIFY GT_STUDENT_02 
    FROM GS_STUDENT_02 
    INDEX TAB_CTRL_120-CURRENT_LINE 
    TRANSPORTING CHECK. 
ENDMODULE. 
 
*&SPWIZARD: INPUT MODULE FOR TC 'TAB_CTRL_120'. DO NOT CHANGE THIS LINE! 
*&SPWIZARD: PROCESS USER COMMAND 
MODULE TAB_CTRL_120_USER_COMMAND INPUT. 
  OK_CODE = SY-UCOMM. 
  PERFORM USER_OK_TC USING    'TAB_CTRL_120' 
                              'GT_STUDENT_02' 
                              'CHECK' 
                     CHANGING OK_CODE. 
  SY-UCOMM = OK_CODE. 
ENDMODULE. 
*&---------------------------------------------------------------------* 
*&      Module  USER_COMMAND_0120  INPUT 
*&---------------------------------------------------------------------* 
*       text 
*----------------------------------------------------------------------* 
MODULE user_command_0120 INPUT. 
  CASE SY-UCOMM. 
    WHEN 'NAME_EDIT'. 
      PERFORM MODIFY_COL. 
  ENDCASE. 
ENDMODULE.

6.SUB

*&---------------------------------------------------------------------* 
*& Include ZWXT_10_SUB 
*&---------------------------------------------------------------------* 
 
*----------------------------------------------------------------------* 
*   INCLUDE TABLECONTROL_FORMS                                         * 
*----------------------------------------------------------------------* 
 
*&---------------------------------------------------------------------* 
*&      Form  USER_OK_TC                                               * 
*&---------------------------------------------------------------------* 
 FORM USER_OK_TC USING    P_TC_NAME TYPE DYNFNAM 
                          P_TABLE_NAME 
                          P_MARK_NAME 
                 CHANGING P_OK      LIKE SY-UCOMM. 
 
*&SPWIZARD: BEGIN OF LOCAL DATA----------------------------------------* 
   DATA: L_OK              TYPE SY-UCOMM, 
         L_OFFSET          TYPE I. 
*&SPWIZARD: END OF LOCAL DATA------------------------------------------* 
 
*&SPWIZARD: Table control specific operations                          * 
*&SPWIZARD: evaluate TC name and operations                            * 
   SEARCH P_OK FOR P_TC_NAME. 
   IF SY-SUBRC <> 0. 
     EXIT. 
   ENDIF. 
   L_OFFSET = STRLEN( P_TC_NAME ) + 1. 
   L_OK = P_OK+L_OFFSET. 
*&SPWIZARD: execute general and TC specific operations                 * 
   CASE L_OK. 
     WHEN 'INSR'.                      "insert row 
       PERFORM FCODE_INSERT_ROW USING    P_TC_NAME 
                                         P_TABLE_NAME. 
       CLEAR P_OK. 
 
     WHEN 'DELE'.                      "delete row 
       PERFORM FCODE_DELETE_ROW USING    P_TC_NAME 
                                         P_TABLE_NAME 
                                         P_MARK_NAME. 
       CLEAR P_OK. 
 
     WHEN 'P--' OR                     "top of list 
          'P-'  OR                     "previous page 
          'P+'  OR                     "next page 
          'P++'.                       "bottom of list 
       PERFORM COMPUTE_SCROLLING_IN_TC USING P_TC_NAME 
                                             L_OK. 
       CLEAR P_OK. 
*     WHEN 'L--'.                       "total left 
*       PERFORM FCODE_TOTAL_LEFT USING P_TC_NAME. 
* 
*     WHEN 'L-'.                        "column left 
*       PERFORM FCODE_COLUMN_LEFT USING P_TC_NAME. 
* 
*     WHEN 'R+'.                        "column right 
*       PERFORM FCODE_COLUMN_RIGHT USING P_TC_NAME. 
* 
*     WHEN 'R++'.                       "total right 
*       PERFORM FCODE_TOTAL_RIGHT USING P_TC_NAME. 
* 
     WHEN 'MARK'.                      "mark all filled lines 
       PERFORM FCODE_TC_MARK_LINES USING P_TC_NAME 
                                         P_TABLE_NAME 
                                         P_MARK_NAME   . 
       CLEAR P_OK. 
 
     WHEN 'DMRK'.                      "demark all filled lines 
       PERFORM FCODE_TC_DEMARK_LINES USING P_TC_NAME 
                                           P_TABLE_NAME 
                                           P_MARK_NAME . 
       CLEAR P_OK. 
 
*     WHEN 'SASCEND'   OR 
*          'SDESCEND'.                  "sort column 
*       PERFORM FCODE_SORT_TC USING P_TC_NAME 
*                                   l_ok. 
 
   ENDCASE. 
 
 ENDFORM.                              " USER_OK_TC 
 
*&---------------------------------------------------------------------* 
*&      Form  FCODE_INSERT_ROW                                         * 
*&---------------------------------------------------------------------* 
 FORM fcode_insert_row 
               USING    P_TC_NAME           TYPE DYNFNAM 
                        P_TABLE_NAME             . 
 
*&SPWIZARD: BEGIN OF LOCAL DATA----------------------------------------* 
   DATA L_LINES_NAME       LIKE FELD-NAME. 
   DATA L_SELLINE          LIKE SY-STEPL. 
   DATA L_LASTLINE         TYPE I. 
   DATA L_LINE             TYPE I. 
   DATA L_TABLE_NAME       LIKE FELD-NAME. 
   FIELD-SYMBOLS <TC>                 TYPE CXTAB_CONTROL. 
   FIELD-SYMBOLS <TABLE>              TYPE STANDARD TABLE. 
   FIELD-SYMBOLS <LINES>              TYPE I. 
*&SPWIZARD: END OF LOCAL DATA------------------------------------------* 
 
   ASSIGN (P_TC_NAME) TO <TC>. 
 
*&SPWIZARD: get the table, which belongs to the tc                     * 
   CONCATENATE P_TABLE_NAME '[]' INTO L_TABLE_NAME. "table body 
   ASSIGN (L_TABLE_NAME) TO <TABLE>.                "not headerline 
 
*&SPWIZARD: get looplines of TableControl                              * 
   CONCATENATE 'G_' P_TC_NAME '_LINES' INTO L_LINES_NAME. 
   ASSIGN (L_LINES_NAME) TO <LINES>. 
 
*&SPWIZARD: get current line                                           * 
   GET CURSOR LINE L_SELLINE. 
   IF SY-SUBRC <> 0.                   " append line to table 
     L_SELLINE = <TC>-LINES + 1. 
*&SPWIZARD: set top line                                               * 
     IF L_SELLINE > <LINES>. 
       <TC>-TOP_LINE = L_SELLINE - <LINES> + 1 . 
     ELSE. 
       <TC>-TOP_LINE = 1. 
     ENDIF. 
   ELSE.                               " insert line into table 
     L_SELLINE = <TC>-TOP_LINE + L_SELLINE - 1. 
     L_LASTLINE = <TC>-TOP_LINE + <LINES> - 1. 
   ENDIF. 
*&SPWIZARD: set new cursor line                                        * 
   L_LINE = L_SELLINE - <TC>-TOP_LINE + 1. 
 
*&SPWIZARD: insert initial line                                        * 
   INSERT INITIAL LINE INTO <TABLE> INDEX L_SELLINE. 
   <TC>-LINES = <TC>-LINES + 1. 
*&SPWIZARD: set cursor                                                 * 
   SET CURSOR LINE L_LINE. 
 
 ENDFORM.                              " FCODE_INSERT_ROW 
 
*&---------------------------------------------------------------------* 
*&      Form  FCODE_DELETE_ROW                                         * 
*&---------------------------------------------------------------------* 
 FORM fcode_delete_row 
               USING    P_TC_NAME           TYPE DYNFNAM 
                        P_TABLE_NAME 
                        P_MARK_NAME   . 
 
*&SPWIZARD: BEGIN OF LOCAL DATA----------------------------------------* 
   DATA L_TABLE_NAME       LIKE FELD-NAME. 
 
   FIELD-SYMBOLS <TC>         TYPE cxtab_control. 
   FIELD-SYMBOLS <TABLE>      TYPE STANDARD TABLE. 
   FIELD-SYMBOLS <WA>. 
   FIELD-SYMBOLS <MARK_FIELD>. 
*&SPWIZARD: END OF LOCAL DATA------------------------------------------* 
 
   ASSIGN (P_TC_NAME) TO <TC>. 
 
*&SPWIZARD: get the table, which belongs to the tc                     * 
   CONCATENATE P_TABLE_NAME '[]' INTO L_TABLE_NAME. "table body 
   ASSIGN (L_TABLE_NAME) TO <TABLE>.                "not headerline 
 
*&SPWIZARD: delete marked lines                                        * 
   DESCRIBE TABLE <TABLE> LINES <TC>-LINES. 
 
   LOOP AT <TABLE> ASSIGNING <WA>. 
 
*&SPWIZARD: access to the component 'FLAG' of the table header         * 
     ASSIGN COMPONENT P_MARK_NAME OF STRUCTURE <WA> TO <MARK_FIELD>. 
 
     IF <MARK_FIELD> = 'X'. 
       DELETE <TABLE> INDEX SYST-TABIX. 
       IF SY-SUBRC = 0. 
         <TC>-LINES = <TC>-LINES - 1. 
       ENDIF. 
     ENDIF. 
   ENDLOOP. 
 
 ENDFORM.                              " FCODE_DELETE_ROW 
 
*&---------------------------------------------------------------------* 
*&      Form  COMPUTE_SCROLLING_IN_TC 
*&---------------------------------------------------------------------* 
*       text 
*----------------------------------------------------------------------* 
*      -->P_TC_NAME  name of tablecontrol 
*      -->P_OK       ok code 
*----------------------------------------------------------------------* 
 FORM COMPUTE_SCROLLING_IN_TC USING    P_TC_NAME 
                                       P_OK. 
*&SPWIZARD: BEGIN OF LOCAL DATA----------------------------------------* 
   DATA L_TC_NEW_TOP_LINE     TYPE I. 
   DATA L_TC_NAME             LIKE FELD-NAME. 
   DATA L_TC_LINES_NAME       LIKE FELD-NAME. 
   DATA L_TC_FIELD_NAME       LIKE FELD-NAME. 
 
   FIELD-SYMBOLS <TC>         TYPE cxtab_control. 
   FIELD-SYMBOLS <LINES>      TYPE I. 
*&SPWIZARD: END OF LOCAL DATA------------------------------------------* 
 
   ASSIGN (P_TC_NAME) TO <TC>. 
*&SPWIZARD: get looplines of TableControl                              * 
   CONCATENATE 'G_' P_TC_NAME '_LINES' INTO L_TC_LINES_NAME. 
   ASSIGN (L_TC_LINES_NAME) TO <LINES>. 
 
 
*&SPWIZARD: is no line filled?                                         * 
   IF <TC>-LINES = 0. 
*&SPWIZARD: yes, ...                                                   * 
     L_TC_NEW_TOP_LINE = 1. 
   ELSE. 
*&SPWIZARD: no, ...                                                    * 
     CALL FUNCTION 'SCROLLING_IN_TABLE' 
          EXPORTING 
               ENTRY_ACT             = <TC>-TOP_LINE 
               ENTRY_FROM            = 1 
               ENTRY_TO              = <TC>-LINES 
               LAST_PAGE_FULL        = 'X' 
               LOOPS                 = <LINES> 
               OK_CODE               = P_OK 
               OVERLAPPING           = 'X' 
          IMPORTING 
               ENTRY_NEW             = L_TC_NEW_TOP_LINE 
          EXCEPTIONS 
*              NO_ENTRY_OR_PAGE_ACT  = 01 
*              NO_ENTRY_TO           = 02 
*              NO_OK_CODE_OR_PAGE_GO = 03 
               OTHERS                = 0. 
   ENDIF. 
 
*&SPWIZARD: get actual tc and column                                   * 
   GET CURSOR FIELD L_TC_FIELD_NAME 
              AREA  L_TC_NAME. 
 
   IF SYST-SUBRC = 0. 
     IF L_TC_NAME = P_TC_NAME. 
*&SPWIZARD: et actual column                                           * 
       SET CURSOR FIELD L_TC_FIELD_NAME LINE 1. 
     ENDIF. 
   ENDIF. 
 
*&SPWIZARD: set the new top line                                       * 
   <TC>-TOP_LINE = L_TC_NEW_TOP_LINE. 
 
 
 ENDFORM.                              " COMPUTE_SCROLLING_IN_TC 
 
*&---------------------------------------------------------------------* 
*&      Form  FCODE_TC_MARK_LINES 
*&---------------------------------------------------------------------* 
*       marks all TableControl lines 
*----------------------------------------------------------------------* 
*      -->P_TC_NAME  name of tablecontrol 
*----------------------------------------------------------------------* 
FORM FCODE_TC_MARK_LINES USING P_TC_NAME 
                               P_TABLE_NAME 
                               P_MARK_NAME. 
*&SPWIZARD: EGIN OF LOCAL DATA-----------------------------------------* 
  DATA L_TABLE_NAME       LIKE FELD-NAME. 
 
  FIELD-SYMBOLS <TC>         TYPE cxtab_control. 
  FIELD-SYMBOLS <TABLE>      TYPE STANDARD TABLE. 
  FIELD-SYMBOLS <WA>. 
  FIELD-SYMBOLS <MARK_FIELD>. 
*&SPWIZARD: END OF LOCAL DATA------------------------------------------* 
 
  ASSIGN (P_TC_NAME) TO <TC>. 
 
*&SPWIZARD: get the table, which belongs to the tc                     * 
   CONCATENATE P_TABLE_NAME '[]' INTO L_TABLE_NAME. "table body 
   ASSIGN (L_TABLE_NAME) TO <TABLE>.                "not headerline 
 
*&SPWIZARD: mark all filled lines                                      * 
  LOOP AT <TABLE> ASSIGNING <WA>. 
 
*&SPWIZARD: access to the component 'FLAG' of the table header         * 
     ASSIGN COMPONENT P_MARK_NAME OF STRUCTURE <WA> TO <MARK_FIELD>. 
 
     <MARK_FIELD> = 'X'. 
  ENDLOOP. 
ENDFORM.                                          "fcode_tc_mark_lines 
 
*&---------------------------------------------------------------------* 
*&      Form  FCODE_TC_DEMARK_LINES 
*&---------------------------------------------------------------------* 
*       demarks all TableControl lines 
*----------------------------------------------------------------------* 
*      -->P_TC_NAME  name of tablecontrol 
*----------------------------------------------------------------------* 
FORM FCODE_TC_DEMARK_LINES USING P_TC_NAME 
                                 P_TABLE_NAME 
                                 P_MARK_NAME . 
*&SPWIZARD: BEGIN OF LOCAL DATA----------------------------------------* 
  DATA L_TABLE_NAME       LIKE FELD-NAME. 
 
  FIELD-SYMBOLS <TC>         TYPE cxtab_control. 
  FIELD-SYMBOLS <TABLE>      TYPE STANDARD TABLE. 
  FIELD-SYMBOLS <WA>. 
  FIELD-SYMBOLS <MARK_FIELD>. 
*&SPWIZARD: END OF LOCAL DATA------------------------------------------* 
 
  ASSIGN (P_TC_NAME) TO <TC>. 
 
*&SPWIZARD: get the table, which belongs to the tc                     * 
   CONCATENATE P_TABLE_NAME '[]' INTO L_TABLE_NAME. "table body 
   ASSIGN (L_TABLE_NAME) TO <TABLE>.                "not headerline 
 
*&SPWIZARD: demark all filled lines                                    * 
  LOOP AT <TABLE> ASSIGNING <WA>. 
 
*&SPWIZARD: access to the component 'FLAG' of the table header         * 
     ASSIGN COMPONENT P_MARK_NAME OF STRUCTURE <WA> TO <MARK_FIELD>. 
 
     <MARK_FIELD> = SPACE. 
  ENDLOOP. 
ENDFORM.                                          "fcode_tc_mark_lines

7.FRM

*&---------------------------------------------------------------------* 
*& 包含               ZWXT_10_FRM 
*&---------------------------------------------------------------------* 
*&---------------------------------------------------------------------* 
*& Form MODIFY_COL 
*&---------------------------------------------------------------------* 
*& text 
*&---------------------------------------------------------------------* 
*& -->  p1        text 
*& <--  p2        text 
*&---------------------------------------------------------------------* 
FORM modify_col . 
  DATA LS_COL LIKE LINE OF TAB_CTRL_120-COLS. 
 
  LOOP AT TAB_CTRL_120-COLS INTO LS_COL. 
    IF LS_COL-INDEX = '3'. 
      IF LS_COL-SCREEN-INPUT = '1'. 
        LS_COL-SCREEN-INPUT = '0'. 
      ELSE. 
        LS_COL-SCREEN-INPUT = '1'. 
      ENDIF. 
      MODIFY TAB_CTRL_120-COLS FROM LS_COL. 
    ENDIF. 
  ENDLOOP. 
ENDFORM.

8.页面效果

SAP-Dialog详解编程语言

SAP-Dialog详解编程语言

SAP-Dialog详解编程语言

原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/tech/pnotes/18014.html

(0)
上一篇 2021年7月19日 20:43
下一篇 2021年7月19日 20:43

相关推荐

发表回复

登录后才能评论