技术开发 频道

屏幕增强操作步骤

【IT168 技术文章】

    1. SMOD -> 按F4-> SAP Applications ->选择增强所在的模块->记住出口名称
    2. CMOD -> 创建项目用ZXXXX  -> 选enhancement assignments ,输入增强名称,回车 ->
    选择组件 ,双击Screen exit后的名称。-> 在PAI 中调用要显示的子屏幕,在属性中选择子屏幕,回到最初界面激活。
    3.在页面下调用现有内容页面,在PBO中写CALL SUBSCREEN AREA INCLUDING 'ZCO03' '0120'. 这里'ZCO03'是程序名,  '0120'是子屏幕号。
    在PAI中写CALL SUBSCREEN AREA.
    注意:找屏幕出口可以用程序:
    REPORT YSMOD2 .
    TABLES: MODSAP,MODACT, TSTC.
    PARAMETERS: INPUT1 LIKE TSTC-TCODE DEFAULT ' ',
    INPUT2 LIKE MODSAP-TYP DEFAULT ' '.
    DATA: SEARCH1(6),
    SEARCH2(3),
    SEARCH3 LIKE MODSAP-MEMBER.
    DATA : FIRST_ROW VALUE 'Y'.
    CONCATENATE: '%' INPUT1 '%' INTO SEARCH1,'%' INPUT2 INTO SEARCH2.
    SELECT * FROM TSTC WHERE TCODE LIKE SEARCH1.
    FIRST_ROW = 'Y'.
    CHECK TSTC-PGMNA NE SPACE.
    CONCATENATE '%' TSTC-PGMNA '%' INTO SEARCH3.
    SELECT * FROM MODSAP WHERE TYP LIKE SEARCH2 AND MEMBER LIKE SEARCH3.
    SELECT SINGLE * FROM MODACT WHERE MEMBER = MODSAP-NAME.IF FIRST_ROW EQ 'Y'.
    WRITE: /0 TSTC-TCODE, 6 TSTC-PGMNA, 16 MODSAP-NAME, 32 MODSAP-TYP,
    45 MODSAP-MEMBER, 70 MODACT-NAME.   FIRST_ROW = 'N'.ELSE.
    WRITE: /16 MODSAP-NAME, 32 MODSAP-TYP, 45 MODSAP-MEMBER, 70 MODACT-NAME.
    ENDIF.
    CLEAR : MODSAP, MODACT.ENDSELECT.
    IF SY-SUBRC NE 0.
    WRITE : /0 TSTC-TCODE, 6 TSTC-PGMNA, 30 'No exits found'.
    ENDIF.
    CLEAR TSTC.
    ENDSELECT.
    END-OF-SELECTION.
    CLEAR: SEARCH1, SEARCH2, SEARCH3.
    4.修改页面名称在菜单出口(Menu exit).
    路径:CMOD->输入项目名称->组件,双击菜单出口名称后,在函数文本中写入。如"客户出口".
    5. CMOD->输入项目名称->组件。双击功能退出后面的FUNCTION后,双击INCLUDE后的名称,在里面写入自己代码。写代码时,参考IMPORT,EXPORT里面的参数。如(出口名称PPCO0012)
    *&---------------------------------------------------------------------*
    *&  包括                ZXCO1U11
    *&---------------------------------------------------------------------*
    tables:CAUFVD,AFPOD,afpo.
    data: begin of itab occurs 0,
    kdauf like afpo-kdauf,
    kdpos like afpo-kdpos,
    end of itab.
    select kdauf  kdpos into table itab from afpo where aufnr = I_CAUFVD-aufnr.
    EXPORT ITAB TO MEMORY ID 'ID1'.
    SUBMIT ZCO03 AND RETURN.  注意:ZCO03是自己创建的程序.
    *包括 ZXCO1U11 中代码 到这里为止。
    注意:ZCO03中的屏幕属性选择子屏幕。
    ZCO03 代码如下:
    *&---------------------------------------------------------------------*
    *& Report  ZCO03
    *&
    *&---------------------------------------------------------------------*
    *&
    *&
    *&---------------------------------------------------------------------*
    REPORT  ZCO03.
    tables: afpo,caufvd.
    DATA: OK_CODE LIKE  SY-UCOMM.
    DATA: SAVE_OK LIKE SY-UCOMM.
    data aufnr like caufvd-aufnr.
    data: begin of itab occurs 0,
    kdauf like afpo-kdauf,
    kdpos like afpo-kdpos,
    end of itab.
    *&---------------------------------------------------------------------*
    *&      Module  STATUS_0120  OUTPUT
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    *module STATUS_0120 output.
    **  SET PF-STATUS 'xxxxxxxx'.
    **  SET TITLEBAR 'xxx'.
    *
    *endmodule.                 " STATUS_0120  OUTPUT
    *INCLUDE ZCO03_USER_COMMAND_0120I01.
    *&SPWIZARD: DECLARATION OF TABLECONTROL 'ITA' ITSELF
    CONTROLS: ITA TYPE TABLEVIEW USING SCREEN 0120.
    *&SPWIZARD: LINES OF TABLECONTROL 'ITA'
    DATA:     G_ITA_LINES  LIKE SY-LOOPC.
    *&SPWIZARD: OUTPUT MODULE FOR TC 'ITA'. DO NOT CHANGE THIS LINE!
    *&SPWIZARD: UPDATE LINES FOR EQUIVALENT SCROLLBAR
    MODULE ITA_CHANGE_TC_ATTR OUTPUT.
    DESCRIBE TABLE ITAB LINES ITA-lines.
    ENDMODULE.
    *&SPWIZARD: OUTPUT MODULE FOR TC 'ITA'. DO NOT CHANGE THIS LINE!
    *&SPWIZARD: GET LINES OF TABLECONTROL
    MODULE ITA_GET_LINES OUTPUT.
    G_ITA_LINES = SY-LOOPC.
    ENDMODULE.
    *&SPWIZARD: INPUT MODULE FOR TC 'ITA'. DO NOT CHANGE THIS LINE!
    *&SPWIZARD: PROCESS USER COMMAND
    MODULE ITA_USER_COMMAND INPUT.
    OK_CODE = SY-UCOMM.
    PERFORM USER_OK_TC USING    'ITA'
    'ITAB'
    ' '
    CHANGING OK_CODE.
    SY-UCOMM = OK_CODE.
    ENDMODULE.
    *----------------------------------------------------------------------*
    *   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
    *&---------------------------------------------------------------------*
    *&      Module  STATUS_0120  OUTPUT
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    module STATUS_0120 output.
    *  SET PF-STATUS 'xxxxxxxx'.
    *  SET TITLEBAR 'xxx'.
    IMPORT ITAB   FROM MEMORY ID 'ID1'.
    endmodule.                 " STATUS_0120  OUTPUT
    *&---------------------------------------------------------------------*
    *&      Module  USER_COMMAND_0120  INPUT
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    module USER_COMMAND_0120 input.
    endmodule.                 " USER_COMMAND_0120  INPUT
    注意:在屏幕的属性里面要选子屏幕。
    最后,激活所有东西。

0
相关文章