首页 > SAP > ABAP > ABAP代码模板1
2019
11-25

ABAP代码模板1



此模板可以做为单屏幕单ALV显示操作的模板,主要优点及功能如下

1.简单查询,快速显示;

2.全屏ALV显示;

3.合适用于做为SAP的报表查询模板;

4.合适于做为单屏幕的简单功能操作模板;

5.使用OO类的AVL,功能扩展性高;

6.有错误显示显示;

7.处理完成后,可方便设置选择状态为无效,不能再被选择;

8.处理状态使用图标显示;

1.模板使用效果

ABAP代码模板1 - 第1张  | 优通SAP
ABAP代码模板1 - 第2张  | 优通SAP

2. 一、创建程序

REPORT  ZFIR_730.

INCLUDE ZFIR730_TOP.
INCLUDE ZFIR730_SCR.
INCLUDE ZFIR730_CLS.
INCLUDE ZFIR730_DYN.
INCLUDE ZFIR730_FRM.
INCLUDE ZFIR730_F01.
INCLUDE ZFIR730_F02.


INCLUDE ZSHOW_JD.
*&---------------------------------------------------------------------*
*& 包含               ZSDR034_TOP
*&---------------------------------------------------------------------*
TABLES: SSCRFIELDS.
TABLES: ZTFI_730,ZPLUSDAYS,ZEC_S_SALES_DAYS.

TYPE-POOLS SLIS.

TYPES: BEGIN OF TY_ALV,
         OBJKEY TYPE CHAR79.       "错误显示组的ID,
INCLUDE STRUCTURE ZTFI_730.
TYPES:
         ZSEL(1),  "选择行
         STATU            TYPE ICONNAME,"用于显示红黄标记
         MESSAGE TYPE MSGTX,    "短错误提示
         IDKEY TYPE CHAR79,        "行ID
         CELLSTYLES       TYPE LVC_T_STYL.

TYPES:

   END OF TY_ALV.

DATA: GT_ALV TYPE TABLE OF TY_ALV,
      GS_ALV TYPE TY_ALV.
FIELD-SYMBOLS:  <ALV> STRUCTURE GS_ALV DEFAULT GS_ALV.

TYPES: BEGIN OF TY_ALV_I,
        ZFKDH	TYPE ZFKDH01,
        BUDAT TYPE ZBUDAT,
        VBELN	TYPE VBELN,
        ZJYCK	TYPE ZJYCK,
        ZPAYID  TYPE ZPAYID,
        ZYWLX	TYPE ZDE_SKLX,
        ZSKLX TYPE ZSKLX,
        ZHHZF TYPE ZHHZF,
        ZSKFS TYPE ZSKFS,
        ZYSZK TYPE ZYSZK,
        ZFORM TYPE ZFORM,

        VALID TYPE FLAG,
         ZSEL,
         STATU            TYPE ICONNAME,
         MESSAGE(100),
         IDKEY TYPE CHAR79,        "行ID
         CELLSTYLES       TYPE LVC_T_STYL.
TYPES:

   END OF TY_ALV_I.

DATA: GT_ALV_I TYPE TABLE OF TY_ALV_I,
      GS_ALV_I TYPE TY_ALV_I.
FIELD-SYMBOLS:  <ALV_I> STRUCTURE GS_ALV_I DEFAULT GS_ALV_I.

DATA: GT_LOG LIKE TABLE OF MASSMSG,
      GS_LOG LIKE MASSMSG.
FIELD-SYMBOLS:  <LOG> STRUCTURE GS_LOG DEFAULT GS_LOG.

DATA: GT_STRUCTURE TYPE LVC_T_FCAT,
      WA_STRUCTURE TYPE LVC_S_FCAT,
      WA_LAYOUT    TYPE LVC_S_LAYO,
      S_DISVARIANT TYPE DISVARIANT,
      GR_GRID      TYPE  REF TO CL_GUI_ALV_GRID,
      G_DOCKING    TYPE REF TO CL_GUI_DOCKING_CONTAINER.

*&amp;---------------------------------------------------------------------*
*&amp;  宏定义
*&amp;---------------------------------------------------------------------*
DEFINE BULID_FIELDLOG.

  WA_STRUCTURE-FIELDNAME = &amp;1.
  WA_STRUCTURE-COLTEXT = &amp;2.
  WA_STRUCTURE-REF_TABLE  = &amp;3.
  WA_STRUCTURE-REF_FIELD = &amp;4.
  WA_STRUCTURE-EDIT = &amp;5.
  WA_STRUCTURE-LZERO = &amp;6.
  WA_STRUCTURE-NO_ZERO = &amp;7.
  WA_STRUCTURE-JUST = &amp;8.
  WA_STRUCTURE-KEY = &amp;9.

  WA_STRUCTURE-COL_OPT = 'X'.

  IF &amp;1 EQ 'ZSEL'.
    WA_STRUCTURE-CHECKBOX = 'X'.
  ENDIF.

  APPEND WA_STRUCTURE TO GT_STRUCTURE.
  CLEAR WA_STRUCTURE.
END-OF-DEFINITION.


DEFINE APPEND_ERR.
  GS_LOG-OBJKEY = &amp;1.
  GS_LOG-MSGTY = &amp;2.
  GS_LOG-MSGID = &amp;3.
  GS_LOG-MSGNO = &amp;4.
  GS_LOG-MSGV1 = &amp;5.
  GS_LOG-MSGV2 = &amp;6.
  GS_LOG-MSGV3 = &amp;7.
  GS_LOG-MSGV4 = &amp;8.
  APPEND GS_LOG TO GT_LOG.
END-OF-DEFINITION.



DATA: GV_SPLIT TYPE CHAR1 VALUE '_'."主键连接字符
*&amp;---------------------------------------------------------------------*
*&amp; 包含               ZSDR034_SCR
*&amp;---------------------------------------------------------------------*

DATA:BEGIN OF S_SCREEN,
  DYNNR  LIKE SY-DYNNR,
  ACTIVETAB(132),
  PROG LIKE SY-REPID,
  END OF S_SCREEN .


SELECTION-SCREEN BEGIN OF SCREEN 100 AS SUBSCREEN.
SELECTION-SCREEN BEGIN OF BLOCK BL10 WITH FRAME TITLE TEXT-T01.
  PARAMETERS: P_BUDAT LIKE ZPLUSDAYS-BUDAT.


SELECTION-SCREEN END OF BLOCK BL10.

SELECTION-SCREEN BEGIN OF BLOCK BL11 WITH FRAME TITLE TEXT-T02.
PARAMETERS:  P_CHK10 AS CHECKBOX MEMORY ID CHK.

SELECTION-SCREEN END OF BLOCK BL11.

SELECTION-SCREEN END OF SCREEN 100.


SELECTION-SCREEN BEGIN OF SCREEN 200 AS SUBSCREEN.
SELECTION-SCREEN BEGIN OF BLOCK BL20 WITH FRAME TITLE TEXT-T01.
SELECT-OPTIONS: S_ZFKDH   FOR ZPLUSDAYS-ZFKDH,
                S_BUDAT   FOR ZPLUSDAYS-BUDAT.


SELECTION-SCREEN END OF BLOCK BL20.
SELECTION-SCREEN END OF SCREEN 200.






* STANDARD SELECTION SCREEN
SELECTION-SCREEN: BEGIN OF TABBED BLOCK MYTAB FOR 9 LINES,
                  TAB (20) BUTTON1 USER-COMMAND PUSH1,
                  TAB (20) BUTTON2 USER-COMMAND PUSH2 ,
                  END OF BLOCK MYTAB.


INITIALIZATION.
  PERFORM INI_DEFAULT.

AT SELECTION-SCREEN OUTPUT.
  PERFORM SET_SCREEN."依据屏幕变化设置屏幕元素的相关属性



AT SELECTION-SCREEN.
  PERFORM CHECK_PAR." 检查输入的选择屏幕参数的有效性



START-OF-SELECTION.

  PERFORM GET_DATA. "读取数据


END-OF-SELECTION.

  PERFORM SHOW_ALV. "ALV显示


*&amp;---------------------------------------------------------------------*
*&amp;      Form  INI_DEFAULT
*&amp;---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM INI_DEFAULT.
  BUTTON1 = TEXT-010.
  BUTTON2 = TEXT-020.
  MYTAB-PROG = SY-REPID.
  IMPORT S_SCREEN TO S_SCREEN FROM MEMORY ID 'S_SCREEN'  .
  IF S_SCREEN-PROG = MYTAB-PROG AND SY-BATCH <> 'X'.
    MOVE-CORRESPONDING S_SCREEN TO MYTAB.
  ELSE.
    MYTAB-DYNNR = 100.
    MYTAB-ACTIVETAB = 'PUSH1'.
  ENDIF.



  P_BUDAT = SY-DATUM - 1.

  S_BUDAT-SIGN = 'I'.
  S_BUDAT-OPTION = 'EQ'.
  S_BUDAT-LOW = SY-DATUM - 1.
  APPEND S_BUDAT.

ENDFORM.                    "INI_DEFAULT


*&amp;---------------------------------------------------------------------*
*&amp;      Form  SET_SCREEN
*&amp;---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM SET_SCREEN .


ENDFORM.                    " SET_SCREEN
*&amp;---------------------------------------------------------------------*
*&amp;      Form  CHECK_PAR
*&amp;---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM CHECK_PAR .
  IF SY-UCOMM = 'ONLI' ."执行时
*    IF  P_CHK01 = 'X'.
*      IF P_ZGZRQ IS INITIAL
*          OR P_HKONT1 IS INITIAL
*          OR P_RSTGR IS INITIAL.
*        MESSAGE E105(ZDX_001).
*
*      ENDIF.

*    ENDIF.

  ENDIF.


  CASE SY-DYNNR.
    WHEN 1000.
      CASE SY-UCOMM.
        WHEN 'PUSH1'.
          MYTAB-DYNNR = 100.
          MYTAB-ACTIVETAB = 'PUSH1'.
        WHEN 'PUSH2'.
          MYTAB-DYNNR = 200.
          MYTAB-ACTIVETAB = 'PUSH2'.
      ENDCASE.
  ENDCASE.


ENDFORM.                    " CHECK_PAR
*&amp;---------------------------------------------------------------------*
*&amp; 包含               ZSDR034_CLS
*&amp;---------------------------------------------------------------------*

CLASS LCL_EVENT_RECEIVER DEFINITION.
  PUBLIC SECTION.
    CLASS-METHODS:

      TOOLBAR  FOR EVENT TOOLBAR OF CL_GUI_ALV_GRID
        IMPORTING E_OBJECT
                    E_INTERACTIVE,

      AFTER_USER_COMMAND FOR EVENT AFTER_USER_COMMAND OF CL_GUI_ALV_GRID
        IMPORTING E_UCOMM,

      HANDLE_DOUBLE_CLICK FOR EVENT DOUBLE_CLICK OF CL_GUI_ALV_GRID
        IMPORTING E_ROW E_COLUMN.

ENDCLASS.                    "LCL_EVENT_RECEIVER DEFINITION
*&amp;---------------------------------------------------------------------*
* 类的实施
*&amp;---------------------------------------------------------------------*
CLASS LCL_EVENT_RECEIVER IMPLEMENTATION.

  METHOD TOOLBAR.
    PERFORM FRM_EVENT_TOOLBAR USING E_OBJECT
          E_INTERACTIVE.
  ENDMETHOD.                    "toolbar

  METHOD AFTER_USER_COMMAND.
    CASE E_UCOMM.
      WHEN '&amp;ALL'.
        PERFORM SET_ALL_SELECTED USING 'X'.
      WHEN '&amp;SAL'.
        PERFORM SET_ALL_SELECTED USING ' '.
      WHEN '&amp;PRO_SAVE'.
        PERFORM PF_PRO_SAVE."保存
      WHEN '&amp;PRO_CHK'.
        PERFORM PF_PRO_DATA."审核
    ENDCASE.
  ENDMETHOD.                    "AFTER_USER_COMMAND

  METHOD HANDLE_DOUBLE_CLICK.

    PERFORM DILL_DOUBLE_CLICK USING E_ROW E_COLUMN.

  ENDMETHOD.  "HANDLE_DOUBLE_CLICK

ENDCLASS.                    "LCL_EVENT_RECEIVER IMPLEMENTATION
*&amp;---------------------------------------------------------------------*
*&amp; 包含               ZSDR034_DYN
*&amp;---------------------------------------------------------------------*

MODULE USER_COMMAND_9001 INPUT.
  LEAVE TO SCREEN 0.
ENDMODULE.                 " USER_EXIT  INPUT
*&amp;---------------------------------------------------------------------*
*&amp;      Module  STATUS_9001  OUTPUT
*&amp;---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE STATUS_9001 OUTPUT.

  DATA: LV_TITLE TYPE STRING.
  LV_TITLE = LINES( GT_ALV[] ).
*  lv_title = '销售价格查询报表 条目数【' &amp;&amp; lv_title &amp;&amp; '】'.
  CONCATENATE SY-TITLE ' 条目数【' LV_TITLE   '】'
        INTO LV_TITLE .

  SET PF-STATUS 'ZST'.
  SET TITLEBAR 'TITLE' WITH LV_TITLE.

ENDMODULE.                 " STATUS_9001  OUTPUT
*&amp;---------------------------------------------------------------------*
*&amp; 包含               ZSDR034_FRM
*&amp;---------------------------------------------------------------------*
*&amp;---------------------------------------------------------------------*

*&amp;---------------------------------------------------------------------*
*&amp; Form GET_DATA
*&amp;---------------------------------------------------------------------*
*&amp; text
*&amp;---------------------------------------------------------------------*
*&amp; Form SHOW_ALV
*&amp;---------------------------------------------------------------------*
*&amp; text
*&amp;---------------------------------------------------------------------*
FORM SHOW_ALV .
  IF GT_ALV IS INITIAL.
    MESSAGE S000(ZDX_001) DISPLAY LIKE 'E' ..
    LEAVE LIST-PROCESSING.
  ENDIF.

  IF SY-BATCH = 'X' OR P_CHK10 = 'X'.
    PERFORM SET_ALL_SELECTED USING 'X'.
    PERFORM PF_PRO_SAVE."
    RETURN.
  ENDIF.
  PERFORM CREATE_STRU.
  PERFORM DISPLAY_ALV.

  CALL SCREEN 9001.

ENDFORM.                    "show_alv
*&amp;---------------------------------------------------------------------*
*&amp; Form CREATE_STRU
*&amp;---------------------------------------------------------------------*
*&amp; text
*&amp;---------------------------------------------------------------------*
FORM CREATE_STRU .

  CLEAR: GT_STRUCTURE,GT_STRUCTURE[],WA_STRUCTURE.

  BULID_FIELDLOG:
  'ZSEL' '选择' '' '' 'X' '' '' '' 'X',
  'STATU' '状态' 'ICON' 'NAME' '' '' '' '' 'X',
  'MESSAGE' '消息' '' '' '' '' '' '' 'X',

  'ZFKDH' '资金付款单号' 'ZPLUSDAYS' 'BUKRS' '' '' '' '' 'X',
  'BUDAT' '订单传输日期' 'ZTFI_730' 'BUDAT  ' '' '' '' '' 'X',
  'ZSKJE01' '自营-收款金额' 'ZTFI_730' 'ZSKJE01' '' '' '' '' '',
  'ZTKJE01' '自营-退款金额' 'ZTFI_730' 'ZTKJE01' '' '' '' '' '',
  'ZSKJE02' '联营非银盈通-收款金额' 'ZTFI_730' 'ZSKJE02' '' '' '' '' '',
  'ZTKJE02' '联营非银盈通-退款金额' 'ZTFI_730' 'ZTKJE02' '' '' '' '' '',
  'ZSKJE03' '联营银盈通-收款金额' 'ZTFI_730' 'ZSKJE03' '' '' '' '' '',
  'ZTKJE03' '联营银盈通退款金额' 'ZTFI_730' 'ZTKJE03' '' '' '' '' '',
  'ZSKJE04' '联营银盈通-妥投金额' 'ZTFI_730' 'ZSKJE04' '' '' '' '' '',
  'ZTKJE04' '联营银盈通-妥投退款金额' 'ZTFI_730' 'ZTKJE04' '' '' '' '' '',
  'WAERK' 'SD 凭证货币' 'ZTFI_730' 'WAERK' '' '' '' '' '',
  'ZSPZT' '审批状态' 'ZTFI_730' 'ZSPZT' '' '' '' '' '',
  'BUKRS' '公司代码' 'ZTFI_730' 'BUKRS' '' '' '' '' '',
  'GJAHR' '会计年度' 'ZTFI_730' 'GJAHR' '' '' '' '' '',
  'BELNR' '会计凭证编号' 'ZTFI_730' 'BELNR' '' '' '' '' ''.


****设置行格式
  CLEAR WA_LAYOUT.
  WA_LAYOUT-CWIDTH_OPT = 'X'.
  WA_LAYOUT-NO_MERGING = 'X'.
  WA_LAYOUT-STYLEFNAME = 'CELLSTYLES'.
  WA_LAYOUT-ZEBRA = 'X'.
  WA_LAYOUT-SEL_MODE = 'A'.
*  wa_layout-box_fname = 'SEL'.

  CLEAR S_DISVARIANT.
  S_DISVARIANT-REPORT = SY-REPID.
  S_DISVARIANT-USERNAME = SY-UNAME.
*  s_disvariant-log_group = 'LG'.

ENDFORM.                    "create_stru
*&amp;---------------------------------------------------------------------*
*&amp; Form DISPLAY_ALV
*&amp;---------------------------------------------------------------------*
*&amp; text
*&amp;---------------------------------------------------------------------*
FORM DISPLAY_ALV .
  DATA: LT_TOOLS     TYPE TABLE OF SY-UCOMM.   "用于排除按钮

  IF G_DOCKING IS INITIAL.
    CREATE OBJECT G_DOCKING
      EXPORTING
        REPID                       = SY-REPID
        DYNNR                       = '9001'
        SIDE                        = CL_GUI_DOCKING_CONTAINER=>DOCK_AT_TOP
*       SIDE                        = 10
        EXTENSION                   = 99999
      EXCEPTIONS
        CNTL_ERROR                  = 1
        CNTL_SYSTEM_ERROR           = 2
        CREATE_ERROR                = 3
        LIFETIME_ERROR              = 4
        LIFETIME_DYNPRO_DYNPRO_LINK = 5
        OTHERS                      = 6.
    IF SY-SUBRC <> 0.
      MESSAGE S001(00) WITH '屏幕初始化失败'.
      LEAVE LIST-PROCESSING.
    ENDIF.

    CREATE OBJECT GR_GRID
      EXPORTING
        I_PARENT = G_DOCKING.
*
    SET HANDLER LCL_EVENT_RECEIVER=>TOOLBAR FOR GR_GRID.
    SET HANDLER LCL_EVENT_RECEIVER=>AFTER_USER_COMMAND FOR GR_GRID.
    SET HANDLER LCL_EVENT_RECEIVER=>HANDLE_DOUBLE_CLICK FOR GR_GRID.

    CALL METHOD GR_GRID->REGISTER_EDIT_EVENT
      EXPORTING
        I_EVENT_ID = CL_GUI_ALV_GRID=>MC_EVT_MODIFIED.

    CLEAR LT_TOOLS[].
    APPEND '&amp;LOCAL&amp;DELETE_ROW' TO LT_TOOLS.
    APPEND '&amp;LOCAL&amp;COPY_ROW' TO LT_TOOLS.
    APPEND '&amp;LOCAL&amp;COPY' TO LT_TOOLS.
    APPEND '&amp;LOCAL&amp;APPEND' TO LT_TOOLS.
    APPEND '&amp;LOCAL&amp;INSERT_ROW' TO LT_TOOLS.
    APPEND '&amp;LOCAL&amp;CUT' TO LT_TOOLS.
    APPEND '&amp;LOCAL&amp;PASTE_NEW_ROW' TO LT_TOOLS.
    APPEND '&amp;LOCAL&amp;PASTE' TO LT_TOOLS.
    APPEND '&amp;LOCAL&amp;UNDO' TO LT_TOOLS.
    APPEND '&amp;PRINT' TO LT_TOOLS.
    APPEND '&amp;GRAPH ' TO LT_TOOLS.
    APPEND '&amp;INFO' TO LT_TOOLS.

    CALL METHOD GR_GRID->SET_TABLE_FOR_FIRST_DISPLAY
      EXPORTING
        IS_LAYOUT            = WA_LAYOUT
        I_SAVE               = 'A'
        IS_VARIANT           = S_DISVARIANT
        IT_TOOLBAR_EXCLUDING = LT_TOOLS
      CHANGING
        IT_FIELDCATALOG      = GT_STRUCTURE
        IT_OUTTAB            = GT_ALV[].
  ENDIF.

ENDFORM.                    "display_alv
*&amp;---------------------------------------------------------------------*
*&amp; Form FRM_EVENT_TOOLBAR
*&amp;---------------------------------------------------------------------*
*&amp; text
*&amp;---------------------------------------------------------------------*
FORM FRM_EVENT_TOOLBAR  USING    E_OBJECT  TYPE REF TO CL_ALV_EVENT_TOOLBAR_SET
      E_INTERACTIVE TYPE C.

  PERFORM SET_TOOLBAR USING '&amp;ALL' ICON_SELECT_ALL ' ' '全选' '' '' 6 E_OBJECT.
  PERFORM SET_TOOLBAR USING '&amp;SAL' ICON_DESELECT_ALL ' ' '取消全选' '' '' 7 E_OBJECT.
  PERFORM SET_TOOLBAR USING '' '' ' ' '' '' 3 22 E_OBJECT.
  IF   MYTAB-ACTIVETAB = 'PUSH1'.
   PERFORM SET_TOOLBAR USING '&amp;PRO_SAVE' ICON_EXECUTE_OBJECT ' ' '保存付款单' '保存付款单' '' 23 E_OBJECT.
    PERFORM SET_TOOLBAR USING '&amp;PRO_CHK' ICON_EXECUTE_OBJECT ' ' '审核' '审核' '' 24 E_OBJECT.
  ELSEIF MYTAB-ACTIVETAB = 'PUSH2'.
*  PERFORM SET_TOOLBAR USING '&amp;PRO_SAVE' ICON_EXECUTE_OBJECT ' ' '保存付款单' '保存付款单' '' 23 E_OBJECT.
    PERFORM SET_TOOLBAR USING '&amp;PRO_CHK' ICON_EXECUTE_OBJECT ' ' '审核' '审核' '' 24 E_OBJECT.


  ENDIF.

ENDFORM.                    "frm_event_toolbar
*&amp;---------------------------------------------------------------------*
*&amp; Form SET_TOOLBAR
*&amp;---------------------------------------------------------------------*
*&amp; text
*&amp;---------------------------------------------------------------------*
FORM SET_TOOLBAR  USING    P_FUNCTION P_ICON
      P_DISABLED P_QUICKINFO
      P_TEXT P_TYPE P_POS
      E_OBJECT TYPE REF TO CL_ALV_EVENT_TOOLBAR_SET.

  DATA: LS_TOOLBAR  TYPE STB_BUTTON.

  CLEAR LS_TOOLBAR.
  MOVE P_FUNCTION TO LS_TOOLBAR-FUNCTION.
  MOVE P_ICON  TO LS_TOOLBAR-ICON.
*  move '更改'(111)  to ls_toolbar-quickinfo.
*  move '更改'  to ls_toolbar-text.
  MOVE P_DISABLED   TO LS_TOOLBAR-DISABLED.
  MOVE P_QUICKINFO TO LS_TOOLBAR-QUICKINFO.
  MOVE P_TYPE TO LS_TOOLBAR-BUTN_TYPE.
  MOVE P_TEXT  TO LS_TOOLBAR-TEXT.
  INSERT LS_TOOLBAR INTO E_OBJECT->MT_TOOLBAR INDEX P_POS.

  FREE: LS_TOOLBAR.

ENDFORM.                    "set_toolbar
*&amp;---------------------------------------------------------------------*
*&amp; Form SET_ALL_SELECTED
*&amp;---------------------------------------------------------------------*
*&amp; text
*&amp;---------------------------------------------------------------------*
FORM SET_ALL_SELECTED  USING    P_VALUE.

  DATA: L_STATU TYPE FLAG.

  FIELD-SYMBOLS: <F_ALV> TYPE TY_ALV.

  LOOP AT GT_ALV ASSIGNING <F_ALV>.

    PERFORM GET_ZSEL_STATU USING  <F_ALV> CHANGING L_STATU.
    IF L_STATU EQ ''.
      CONTINUE.
    ENDIF.

    IF <F_ALV>-ZSEL EQ P_VALUE.
      CONTINUE.
    ENDIF.

    <F_ALV>-ZSEL = P_VALUE.

  ENDLOOP.

  UNASSIGN: <F_ALV>.

  PERFORM REFRESH_ALV.

  FREE: L_STATU.

ENDFORM.                    "set_all_selected
*&amp;---------------------------------------------------------------------*
*&amp; Form GET_MARK_STATU
*&amp;---------------------------------------------------------------------*
*&amp; text
*&amp;---------------------------------------------------------------------*

FORM GET_ZSEL_STATU  USING  P_ALV TYPE TY_ALV
                      CHANGING E_STATU TYPE FLAG.


  DATA: LS_CELL TYPE LVC_S_STYL,
        IT_CELLSTYLES TYPE LVC_T_STYL.

  IT_CELLSTYLES = P_ALV-CELLSTYLES.

  E_STATU = 'X'.

  CLEAR LS_CELL.
  READ TABLE IT_CELLSTYLES INTO LS_CELL WITH KEY FIELDNAME = 'ZSEL'.
  CHECK SY-SUBRC EQ 0.

  IF LS_CELL-STYLE EQ '00100000'.
    E_STATU = ''.
  ENDIF.

ENDFORM.                    "get_mark_statu
*&amp;---------------------------------------------------------------------*
*&amp; Form REFRESH_ALV
*&amp;---------------------------------------------------------------------*
*&amp; text
*&amp;---------------------------------------------------------------------*
FORM REFRESH_ALV .

  DATA: STBL TYPE LVC_S_STBL.

  CHECK SY-BATCH <> 'X'.
  CHECK GR_GRID IS NOT INITIAL.

  STBL-ROW = 'X'." 基于行的稳定刷新
  STBL-COL = 'X'." 基于列的稳定刷新

  CALL METHOD GR_GRID->SET_FRONTEND_LAYOUT
    EXPORTING
      IS_LAYOUT = WA_LAYOUT.

  CALL METHOD GR_GRID->REFRESH_TABLE_DISPLAY
    EXPORTING
      IS_STABLE = STBL.

  FREE: STBL.

ENDFORM.                    " REFRESH_ALV
*&amp;---------------------------------------------------------------------*
*&amp; Form CONFIRM_DATA
*&amp;---------------------------------------------------------------------*
*&amp; text
*&amp;---------------------------------------------------------------------*
FORM CONFIRM_DATA .



  PERFORM REFRESH_ALV.

ENDFORM.                    "confirm_data
*&amp;---------------------------------------------------------------------*
*&amp; Form SET_STYLE
*&amp;---------------------------------------------------------------------*
*&amp; text
*&amp;---------------------------------------------------------------------*
FORM SET_STYLE  USING   FIELDNAME
      STYLE TYPE STRING
CHANGING   IT_STYLES TYPE LVC_T_STYL.

  DATA: LS_STYLE TYPE LVC_S_STYL.
  CLEAR LS_STYLE.

  LS_STYLE-FIELDNAME = FIELDNAME.
  IF STYLE EQ 'ENABLE'.
    LS_STYLE-STYLE = CL_GUI_ALV_GRID=>MC_STYLE_ENABLED.
  ELSE.
    LS_STYLE-STYLE = CL_GUI_ALV_GRID=>MC_STYLE_DISABLED.
  ENDIF.
  READ TABLE IT_STYLES TRANSPORTING NO FIELDS WITH KEY FIELDNAME = FIELDNAME.
  IF SY-SUBRC EQ 0.
    MODIFY IT_STYLES FROM LS_STYLE INDEX SY-TABIX.
  ELSE.
    INSERT LS_STYLE INTO TABLE IT_STYLES.
  ENDIF.

  FREE: LS_STYLE.

ENDFORM.                    "set_style
*&amp;---------------------------------------------------------------------*
*&amp; Form SET_ERROR_MESSAGE
*&amp;---------------------------------------------------------------------*
*&amp; text
*&amp;---------------------------------------------------------------------*

FORM PF_SET_ERROR_MESSAGE  USING P_MESSAGE
                              P_CHANGE_ENA" '',DIS,EN
                      CHANGING WA_ALV TYPE TY_ALV.

  WA_ALV-STATU = ICON_RED_LIGHT.
  WA_ALV-MESSAGE = P_MESSAGE.

  PERFORM PF_CREATE_LOG_1 USING WA_ALV-OBJKEY WA_ALV-MESSAGE 'E'.
  IF P_CHANGE_ENA = 'DIS'.
    PERFORM SET_STYLE USING 'ZSEL' 'DISABLE' CHANGING WA_ALV-CELLSTYLES.
  ENDIF.

ENDFORM.                    "set_error_message
*&amp;---------------------------------------------------------------------*
*&amp; Form CALL_BDC
*&amp;---------------------------------------------------------------------*
*&amp; text
*&amp;---------------------------------------------------------------------*

*&amp;---------------------------------------------------------------------*
*&amp; Form DILL_DOUBLE_CLICK
*&amp;---------------------------------------------------------------------*
*&amp; text
*&amp;---------------------------------------------------------------------*
FORM DILL_DOUBLE_CLICK  USING    P_ROW TYPE LVC_S_ROW
                               P_COLUMN TYPE LVC_S_COL.
  DATA: LT_LOG TYPE TABLE OF MASSMSG ,
        LS_LOG TYPE MASSMSG.

  DATA: LS_ALV TYPE TY_ALV.
  FIELD-SYMBOLS:  <FS> TYPE ANY,
                  <ERRID> TYPE ANY.
  DATA: L_OBJKEY TYPE TY_ALV-OBJKEY.

  CLEAR LS_ALV.
  READ TABLE GT_ALV INTO LS_ALV INDEX P_ROW-INDEX.
*  CHECK SY-SUBRC EQ 0.

  ASSIGN COMPONENT P_COLUMN-FIELDNAME OF STRUCTURE LS_ALV TO <FS>.

  IF <FS> IS INITIAL.
    RETURN.
  ENDIF.

  CASE P_COLUMN-FIELDNAME.
    WHEN 'MATNR'.
      SET PARAMETER ID 'MAT' FIELD <FS>.
      CALL TRANSACTION 'MM03' AND SKIP FIRST SCREEN.
    WHEN 'EBELN' OR 'ZFYDD'.
      CALL FUNCTION 'ME_DISPLAY_PURCHASE_DOCUMENT'
        EXPORTING
          I_EBELN              = <FS>
        EXCEPTIONS
          NOT_FOUND            = 1
          NO_AUTHORITY         = 2
          INVALID_CALL         = 3
          PREVIEW_NOT_POSSIBLE = 4
          OTHERS               = 5.
    WHEN 'vgbel'.
      SET PARAMETER ID 'AUN' FIELD <FS> .
      CALL TRANSACTION 'VA03' AND SKIP FIRST SCREEN .
    WHEN 'vbeln_'.
      SET PARAMETER ID 'VL' FIELD <FS> .
      CALL TRANSACTION 'VL03N' AND SKIP FIRST SCREEN .
    WHEN 'LIFNR' OR 'ZDPBH'.
      CALL FUNCTION 'MMPUR_VENDOR_DISPLAY'
        EXPORTING
          IM_LIFNR = <FS>
*          IM_EKORG = 'B000'
          .
    WHEN 'INFNR'.
      CALL FUNCTION 'MMPUR_INFO_RECORD_DISPLAY'
        EXPORTING
          IM_INFNR = <FS>
          IM_EKORG = ''
          IM_WERKS = ''.
    WHEN 'WERKS'.
      DATA: LS_VT001W TYPE V_T001W.
      LS_VT001W-MANDT = SY-MANDT.
      LS_VT001W-WERKS = <FS>.
      CALL FUNCTION 'VIEW_MAINTENANCE_SINGLE_ENTRY'
        EXPORTING
          ACTION    = 'SHOW'
          VIEW_NAME = 'V_T001W'
        CHANGING
          ENTRY     = LS_VT001W.
    WHEN 'BELNR'.
*      SET PARAMETER ID 'BLN' FIELD <FS> .
*      SET PARAMETER ID 'BUK' FIELD LS_ALV-BUKRS.
*      SET PARAMETER ID 'GJR' FIELD LS_ALV-GJAHR.
*      CALL TRANSACTION 'FB03' AND SKIP FIRST SCREEN .
    WHEN 'XBLNR2'.
*      SET PARAMETER ID 'BLN' FIELD <FS> .
*      SET PARAMETER ID 'BUK' FIELD LS_ALV-BUKRS.
*      SET PARAMETER ID 'GJR' FIELD LS_ALV-GJAHR.
*      CALL TRANSACTION 'FB03' AND SKIP FIRST SCREEN .
    WHEN 'AUGBL'.
*      SET PARAMETER ID 'BLN' FIELD <FS> .
*      SET PARAMETER ID 'BUK' FIELD LS_ALV-BUKRS.
*      SET PARAMETER ID 'GJR' FIELD SY-DATUM(4).
*      CALL TRANSACTION 'FB03' AND SKIP FIRST SCREEN .
    WHEN 'STATU' OR 'MESSAGE'.
      ASSIGN COMPONENT 'OBJKEY' OF STRUCTURE LS_ALV TO <ERRID>.
      CHECK SY-SUBRC = 0.
      CHECK <ERRID> IS NOT INITIAL.
      LT_LOG[] = GT_LOG[].
      DELETE LT_LOG WHERE OBJKEY <> <ERRID>.
      CHECK LT_LOG IS NOT INITIAL.
      CALL FUNCTION 'ZWINDOW_OF_LOG'
        TABLES
          IT_LOG = LT_LOG.

    WHEN OTHERS.
      "显示明细
      PERFORM PF_SHOW_ITEM USING LS_ALV.
  ENDCASE.
ENDFORM.                    "dill_double_click
*&amp;---------------------------------------------------------------------*
*&amp;      Form  PF_SHOW_ITEM
*&amp;---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_LS_ALV  text
*----------------------------------------------------------------------*
FORM PF_SHOW_ITEM  USING    P_ALV TYPE TY_ALV.
  DATA: LT_ALV_I TYPE TABLE OF TY_ALV_I,
        LS_ALV_I TYPE TY_ALV_I.
  DATA: ALV     TYPE REF TO CL_SALV_TABLE,
        ALV_EXC TYPE REF TO CX_SALV_MSG.
  LT_ALV_I = GT_ALV_I.
  DELETE LT_ALV_I WHERE IDKEY = P_ALV-IDKEY.

  CHECK LT_ALV_I IS NOT INITIAL.

  TRY.
      CL_SALV_TABLE=>FACTORY(
        IMPORTING R_SALV_TABLE = ALV
        CHANGING T_TABLE = LT_ALV_I ).
      ALV->DISPLAY( ).
    CATCH CX_SALV_MSG INTO ALV_EXC.
      MESSAGE ALV_EXC TYPE 'I' DISPLAY LIKE 'E'.
  ENDTRY.

ENDFORM.                    " PF_SHOW_ITEM
*&amp;---------------------------------------------------------------------*
*&amp;      Form  PF_SHOW_ZHTBH
*&amp;---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_ALV      text
*----------------------------------------------------------------------*

*      -->P_MSGV4    text
*----------------------------------------------------------------------*
FORM PF_CREATE_LOG TABLES PT_RETURN1  STRUCTURE BAPIRET2
                          PT_RETURN2  STRUCTURE BAPIRETURN1
                    USING P_OBJKEY  TYPE  CHAR79
                          P_MSGTY TYPE  MSGTY
                          P_MSGID TYPE  ARBGB
                          P_MSGNO TYPE  SYMSGNO
                          P_MSGV1 TYPE  SYMSGV
                          P_MSGV2 TYPE  SYMSGV
                          P_MSGV3 TYPE  SYMSGV
                          P_MSGV4 TYPE  SYMSGV.

  IF P_MSGID IS INITIAL.
    P_MSGID = 'ZDX_001'.
  ENDIF.

  IF P_MSGNO IS INITIAL.
    P_MSGNO = '100'.
  ENDIF.


  CALL FUNCTION 'ZFM_CREATE_LOG'
    EXPORTING
      I_OBJKEY   = P_OBJKEY
      I_MSGTY    = P_MSGTY
      I_MSGID    = P_MSGID
      I_MSGNO    = P_MSGNO
      I_MSGV1    = P_MSGV1
      I_MSGV2    = P_MSGV2
      I_MSGV3    = P_MSGV3
      I_MSGV4    = P_MSGV4
    TABLES
      LT_LOG     = GT_LOG
      LT_RETURN1 = PT_RETURN1
      LT_RETURN2 = PT_RETURN2.
ENDFORM.                    "PF_CREATE_LOG


*&amp;---------------------------------------------------------------------*
*&amp;      Form  PF_CREATE_LOG_1
*&amp;---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_OBJKEY   text
*      -->P_MSGTX    text
*      -->P_MSGTY    text
*----------------------------------------------------------------------*
FORM PF_CREATE_LOG_1 USING P_OBJKEY  TYPE  CHAR79
                         P_MSGTX TYPE MSGTX
                         P_MSGTY TYPE  MSGTY .
  DATA: L_MSGTX TYPE SYMSGV.

  L_MSGTX = P_MSGTX.
  CALL FUNCTION 'ZFM_CREATE_LOG'
    EXPORTING
      I_OBJKEY = P_OBJKEY
      I_MSGTY  = P_MSGTY
      I_MSGV1  = L_MSGTX
    TABLES
      LT_LOG   = GT_LOG.
ENDFORM.                    "PF_CREATE_LOG_1


*&amp;---------------------------------------------------------------------*
*&amp;      Form  ADD_FUNCKEY
*&amp;---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM ADD_FUNCKEY .

  DATA: LV_FUNCTION_KEY TYPE SMP_DYNTXT.         "功能按钮

  CLEAR LV_FUNCTION_KEY.

  LV_FUNCTION_KEY-ICON_ID   = ICON_READ_FILE.

  LV_FUNCTION_KEY-ICON_TEXT = '模版下载'.

  LV_FUNCTION_KEY-QUICKINFO = '代收款费用入账_货款清账批导模板下载'.

  SSCRFIELDS-FUNCTXT_01 = LV_FUNCTION_KEY.

ENDFORM.                    "ADD_FUNCKEY

*&amp;---------------------------------------------------------------------*

*&amp; Form FRM_EXCEL_DOWN

*&amp;---------------------------------------------------------------------*

*&amp; text

*&amp;---------------------------------------------------------------------*
*&amp;---------------------------------------------------------------------*
*&amp;      Form  GET_DATA
*&amp;---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*

FORM GET_DATA .

  DATA: LT_T001 LIKE TABLE OF T001,
        LS_T001 LIKE T001,
        LT_LFA1  LIKE TABLE OF LFA1,
        LS_LFA1  LIKE LFA1.



  IF SY-BATCH <> 'X'."不是后台执行,保存选项
    MOVE-CORRESPONDING MYTAB TO S_SCREEN.
    EXPORT S_SCREEN FROM S_SCREEN TO MEMORY ID 'S_SCREEN'  .
  ENDIF.

  IF MYTAB-ACTIVETAB = 'PUSH1' OR SY-BATCH = 'X'.
    PERFORM GET_DATA_1.

  ELSEIF MYTAB-ACTIVETAB = 'PUSH2'.
    PERFORM GET_DATA_2.
  ENDIF.


  CHECK GT_ALV IS NOT INITIAL.
*--------------------------------------------------------------------*

  SORT GT_ALV BY OBJKEY.
  PERFORM SET_ALL_SELECTED USING 'X'.


ENDFORM.                    "get_data


*&amp;---------------------------------------------------------------------*
*&amp;      Form  GET_DATA_1
*&amp;---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM GET_DATA_1 .

  DATA: LT_ALV TYPE TABLE OF TY_ALV,
        LS_ALV TYPE TY_ALV.
  DATA: LT_ALV_I TYPE TABLE OF TY_ALV_I,
        LS_ALV_I TYPE TY_ALV_I.
  DATA: LT_ZTSKFS TYPE TABLE OF ZTSKFS,
        LS_ZTSKFS TYPE ZTSKFS.

  SELECT *
    INTO TABLE LT_ZTSKFS
    FROM ZTSKFS
    WHERE ZRATE > 0.

  SELECT VBELN
         ZJYCK
         ZPAYID
         ZYWLX
         ZSKLX
         ZHHZF
         ZSKFS
         ZYSZK
         BUDAT
         ZFKDH
    INTO CORRESPONDING FIELDS OF TABLE GT_ALV_I
    FROM ZPLUSDAYS
    WHERE BUDAT EQ P_BUDAT
      AND BUKRS EQ '1000'.
    .
  DELETE GT_ALV_I WHERE NOT ZFKDH IS INITIAL.
  LOOP AT GT_ALV_I ASSIGNING <ALV_I>.
    <ALV_I>-ZFORM = 'ZPLUSDAYS'.
  ENDLOOP.
  SELECT VBELN
         ZJYCK
         ZPAYID
         ZYWLX
         ZSKLX
         ZHHZF
         ZSKFS
         ZYSZK
         BUDAT
         ZFKDH
    APPENDING CORRESPONDING FIELDS OF TABLE GT_ALV_I
    FROM ZEC_S_SALES_DAYS
    WHERE BUDAT EQ P_BUDAT
    .
  DELETE GT_ALV_I WHERE NOT ZFKDH IS INITIAL.

  LOOP AT GT_ALV_I ASSIGNING <ALV_I> WHERE ZFORM IS INITIAL.
    <ALV_I>-ZFORM = 'ZEC_S_SALES'.
  ENDLOOP.


  CHECK GT_ALV_I IS NOT INITIAL.

  LOOP AT GT_ALV_I ASSIGNING <ALV_I>.
    READ TABLE LT_ZTSKFS INTO LS_ZTSKFS WITH KEY
                                        ZSKFS = <ALV_I>-ZSKFS
                                        BINARY SEARCH.
    IF SY-SUBRC <> 0.
      CONTINUE.
    ENDIF.

    CASE <ALV_I>-ZSKLX.
      WHEN '10' OR '52' OR '19' OR '11' OR '30'
          OR '18' OR '70' OR '39' OR '40' OR '68'.
        IF <ALV_I>-ZSKLX EQ '68' AND
           ( <ALV_I>-ZHHZF <> '2' OR <ALV_I>-ZHHZF <> '3').
          CONTINUE.
        ENDIF.
        IF <ALV_I>-ZSKFS EQ '17' OR
           <ALV_I>-ZSKFS EQ '33' OR
           <ALV_I>-ZSKFS EQ '34' OR
           LS_ALV_I-ZSKFS EQ '38'.
          CONTINUE.
        ENDIF.
*      自营
        IF <ALV_I>-ZYSZK > 0.
          LS_ALV-ZSKJE01 = LS_ALV-ZSKJE01 +
                <ALV_I>-ZYSZK * ( 100 - LS_ZTSKFS-ZRATE ) / 100.
        ELSE.
          LS_ALV-ZTKJE01 = LS_ALV-ZTKJE01 +
                <ALV_I>-ZYSZK * ( 100 - LS_ZTSKFS-ZRATE ) / 100.

        ENDIF.
        <ALV_I>-VALID = 'X'.
      WHEN '16' OR '22'.
        IF <ALV_I>-ZHHZF = '0'.
*      联营非银盈通
          IF <ALV_I>-ZYSZK > 0.
            LS_ALV-ZSKJE02 = LS_ALV-ZSKJE02 +
                  <ALV_I>-ZYSZK * ( 100 - LS_ZTSKFS-ZRATE ) / 100.
          ELSE.
            LS_ALV-ZTKJE02 = LS_ALV-ZTKJE02 +
                  <ALV_I>-ZYSZK * ( 100 - LS_ZTSKFS-ZRATE ) / 100.
          ENDIF.
          <ALV_I>-VALID = 'X'.
        ELSEIF <ALV_I>-ZHHZF = '1'.
*      联营银盈通
          IF <ALV_I>-ZYSZK > 0.
            LS_ALV-ZSKJE03 = LS_ALV-ZSKJE02 +
                  <ALV_I>-ZYSZK * ( 100 - LS_ZTSKFS-ZRATE ) / 100.
          ELSE.
            LS_ALV-ZTKJE03 = LS_ALV-ZTKJE02 +
                  <ALV_I>-ZYSZK * ( 100 - LS_ZTSKFS-ZRATE ) / 100.
          ENDIF.
          <ALV_I>-VALID = 'X'.
        ENDIF.

      WHEN OTHERS.
    ENDCASE.

  ENDLOOP.

  DELETE GT_ALV_I WHERE NOT VALID = 'X'.
*--------------------------------------------------------------------*
*  联营银盈通结算妥投金额

*--------------------------------------------------------------------*
  IF LS_ALV IS INITIAL.
    RETURN.
  ENDIF.
*--------------------------------------------------------------------*
*  付款金额=自营收款金额+自营退款金额
*    + 联营非银盈通结算收款金额+联营非银盈通结算退款金额
*    +联营银盈通结算妥投金额+联营银盈通结算退货金额
LS_ALV-ZFKJE = LS_ALV-ZSKJE01 + LS_ALV-ZTKJE01
        + LS_ALV-ZSKJE02 + LS_ALV-ZTKJE02
        + LS_ALV-ZSKJE04 + LS_ALV-ZTKJE04 .
LS_ALV-WAERK = 'CNY'.

*--------------------------------------------------------------------*
  LS_ALV-BUDAT = P_BUDAT.
  APPEND LS_ALV TO GT_ALV.

ENDFORM.                                                    "GET_DATA_1

*&amp;---------------------------------------------------------------------*
*&amp;      Form  GET_DATA_2
*&amp;---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM GET_DATA_2 .

  SELECT *
    INTO CORRESPONDING FIELDS OF TABLE GT_ALV
    FROM ZTFI_730
    WHERE ZFKDH IN S_ZFKDH
      AND BUDAT IN S_BUDAT
    .

  LOOP AT GT_ALV ASSIGNING <ALV>.
    IF <ALV>-ZSPZT = 'X'."已审核
      PERFORM SET_STYLE USING 'ZSEL' 'DISABLE'
               CHANGING <ALV>-CELLSTYLES.
    ENDIF.

  ENDLOOP.

ENDFORM.                                                    "GET_DATA_2

*&amp;---------------------------------------------------------------------*
*&amp;      Form  PF_PRO_SAVE
*&amp;---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM PF_PRO_SAVE .
  DATA: LS_ALV TYPE TY_ALV,
        LS_ALV_I TYPE TY_ALV_I,
        LT_ZTFI_730 TYPE TABLE OF ZTFI_730,
        LS_ZTFI_730 TYPE ZTFI_730.



  CHECK MYTAB-ACTIVETAB = 'PUSH1' .

  READ TABLE  GT_ALV ASSIGNING <ALV> INDEX 1.
  CHECK <ALV>-ZSEL EQ 'X' AND <ALV>-ZFKDH = ''.

  <ALV>-CDATE = SY-DATUM.
  <ALV>-CTIME = SY-UZEIT.
  <ALV>-CUSER = SY-UNAME.
  CALL FUNCTION 'NUMBER_GET_NEXT'
    EXPORTING
      NR_RANGE_NR             = '01'
      OBJECT                  = 'ZFKDH01'
    IMPORTING
      NUMBER                  = <ALV>-ZFKDH
    EXCEPTIONS
      INTERVAL_NOT_FOUND      = 1
      NUMBER_RANGE_NOT_INTERN = 2
      OBJECT_NOT_FOUND        = 3
      QUANTITY_IS_0           = 4
      QUANTITY_IS_NOT_1       = 5
      INTERVAL_OVERFLOW       = 6
      BUFFER_OVERFLOW         = 7
      OTHERS                  = 8.
  IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
       WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.

  MOVE-CORRESPONDING <ALV> TO LS_ZTFI_730.



  MODIFY ZTFI_730 FROM LS_ZTFI_730.
  IF SY-SUBRC = 0.
    LOOP AT GT_ALV_I INTO LS_ALV_I.
      IF LS_ALV_I-ZFORM = 'ZPLUSDAYS'.
        UPDATE ZPLUSDAYS
          SET ZFKDH = LS_ZTFI_730-ZFKDH
        WHERE VBELN   = LS_ALV_I-VBELN
          AND ZJYCK   = LS_ALV_I-ZJYCK
          AND ZPAYID  = LS_ALV_I-ZPAYID
          AND ZYWLX   = LS_ALV_I-ZYWLX.
      ELSEIF LS_ALV_I-ZFORM = 'ZEC_S_SALES'.
        UPDATE ZEC_S_SALES_DAYS
          SET ZFKDH = LS_ZTFI_730-ZFKDH
        WHERE VBELN   = LS_ALV_I-VBELN
          AND ZJYCK   = LS_ALV_I-ZJYCK
          AND ZPAYID  = LS_ALV_I-ZPAYID
          AND ZYWLX   = LS_ALV_I-ZYWLX.

        COMMIT WORK.
      ENDIF.
    ENDLOOP.
    COMMIT WORK.
    MESSAGE S100(ZDX_100) WITH '保存成功'.
  ELSE.
    ROLLBACK WORK.
    MESSAGE I100(ZDX_100) WITH '保存数据时出错,请重试'.
    LEAVE PROGRAM.

  ENDIF.


  PERFORM REFRESH_ALV.

ENDFORM.                    " PF_PRO_SAVE
*&amp;---------------------------------------------------------------------*
*&amp;  包括                ZSDR716_F02
*&amp;---------------------------------------------------------------------*

*&amp;---------------------------------------------------------------------*
*&amp;      Form  PF_PRP_data
*&amp;---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*
FORM PF_PRO_DATA.

  LOOP AT GT_ALV ASSIGNING <ALV> WHERE ZSEL EQ 'X' AND ZFKDH <> ''.
    UPDATE ZTFI_730
      SET ZSPZT = 'X'
    WHERE ZFKDH = <ALV>-ZFKDH.
    IF SY-SUBRC = 0.
      COMMIT WORK.
      <ALV>-ZSPZT = 'X'.
      <ALV>-STATU = ICON_GREEN_LIGHT.
      <ALV>-ZSEL  = ''.
      PERFORM SET_STYLE USING 'ZSEL' 'DISABLE'
                         CHANGING <ALV>-CELLSTYLES.
    ELSE.
      PERFORM PF_SET_ERROR_MESSAGE USING '审核失败,请重试'
                                         'EN'
                                   CHANGING <ALV>.
    ENDIF.


  ENDLOOP.


  PERFORM REFRESH_ALV.

ENDFORM.                    " PF_PRP_SEN
*&amp;---------------------------------------------------------------------*
*&amp;  包括                ZSHOW_JD
*&amp;---------------------------------------------------------------------*
*1.FROM schedule为显示处理进度,使用时
*	    DATA: i_percent TYPE I.
*        l_lines = LINES( P_DATA ).
*	  LOOP AT P_DATA INTO WA.
*         i_percent =  sy-tabix * 100 / l_lines .
*         perform schedule using '正在写入数据:' i_percent .
*        ENDLOOP.
*2.FORM window_of_log 为SAP标准的错误窗口显示错误信息。
*--------------------------------------------------------------------*


DATA:IL_BEF_PERCENT TYPE INT4.  " 上一次使用的点比,如是本次与上一次一样,则直接返回
DATA:LS_MSGNO TYPE MSGNO.

*&amp;---------------------------------------------------------------------*
*&amp;      Form  schedule
*&amp;---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->C_MESSAGE  text
*      -->I_PERCENT  text
*----------------------------------------------------------------------*
FORM SCHEDULE USING
C_MESSAGE TYPE C
I_PERCENT TYPE I.
  DATA: C_SCHE(204).

  IF SY-BATCH = 'X'."后台执行,不显示进度
    RETURN.
  ENDIF.
  IF I_PERCENT = IL_BEF_PERCENT.
    RETURN.
  ENDIF.

  IL_BEF_PERCENT = I_PERCENT .

  IF I_PERCENT <= 0 OR I_PERCENT > 100 .
    I_PERCENT = 1.
  ENDIF.

  DATA: C_PERCENT(4),
  C_BLOCK(6) TYPE C VALUE '■',
  I_BLOCKLEN TYPE I,
  I_COUNT TYPE I,
  I_COL TYPE I,
  I_LEN TYPE I,
  I_TEMP TYPE I VALUE 0,
  I_MOD TYPE I.
  I_BLOCKLEN = STRLEN( C_BLOCK ).
  C_PERCENT = I_PERCENT.
  CONDENSE C_PERCENT.
  C_PERCENT+3(1) = '%'.
*  c_sche = c_percent.
  I_COUNT = I_PERCENT / 4.
  DO I_COUNT TIMES.
*    i_col = ( i_temp * i_blocklen ) + 4.
    I_COL = ( I_TEMP * I_BLOCKLEN ).
    C_SCHE+I_COL(I_BLOCKLEN) = C_BLOCK.
    I_TEMP = I_TEMP + 1.
  ENDDO.
  I_LEN = STRLEN( C_MESSAGE ).
  I_MOD = I_LEN MOD 2.
  IF I_MOD = 1.
    I_LEN = I_LEN + 1.
  ENDIF.
*  if i_len > 0.
*    c_sche+4(i_len) = c_message.
*  endif.

  CONCATENATE C_PERCENT C_MESSAGE C_SCHE INTO C_SCHE.

  I_LEN = STRLEN( C_SCHE ).

  CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
    EXPORTING
      PERCENTAGE = 0
      TEXT       = C_SCHE
    EXCEPTIONS
      OTHERS     = 1.
ENDFORM. " SCHEDULE



3.二、创建TITLE

名称为:TITLE,值为:&1



4.三、创建状态条

名称:ZST,设置功能键,F02,F03,F10

ABAP代码模板1 - 第3张  | 优通SAP

5.四、屏幕窗口

名称:9001

此屏幕创建完成后,不用对屏幕格式做任何修改,不放任何控件在屏幕上,保持原样就行。

逻辑流如下:

PROCESS BEFORE OUTPUT.
  MODULE STATUS_9001.

PROCESS AFTER INPUT.
  MODULE USER_COMMAND_9001.

6.五、程序说明

程序创建完成后,一般需要做如下修改:

1. INCLUDE ZSDR0226_TOP ,对数据类型 TY_ALV 定义要显示及查询可能用到的字段(元素),此定义的不一定都显示;

2.修改查询屏幕 INCLUDE ZFIR730_SCR.

3.修改 INCLUDE ZFIR730_FRM.,主要是修改 FORM CREATE_STRU . 定义要在ALV中显示的字段及显示文字等。

4.修改 INCLUDE ZFIR730_F01. ,主要修改 FORM GET_DATA . 用于取数逻辑。

5.修改 INCLUDE ZFIR730_F02. ,如有操作功能定义,可以在此修改,比如,创建凭证,审核等。

                       

留下一个回复

你的email不会被公开。