sap abap log程序

news2024/12/25 23:43:08

1.成果:
在这里插入图片描述

1.数据库表设计:
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

2.报表

*&---------------------------------------------------------------------*
*& Report ZFUNC_LOG
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT zfunc_log.

*&---------------------------------------------------------------------*
* 数据定义部分
*
*&---------------------------------------------------------------------*
TABLES:  zfunc_log.
TYPE-POOLS: slis, vrm, abap,icon.

DATA: BEGIN OF gs_out,
        sel.
    INCLUDE TYPE zfunc_log.
DATA: stext TYPE tftit-stext,
      icon  TYPE icon-internal,
      icon2 TYPE icon-internal,
      icon3 TYPE icon-internal,
      icon4 TYPE icon-internal,
      END OF gs_out.
DATA: gt_out LIKE TABLE OF gs_out.
FIELD-SYMBOLS: <fs_out> LIKE gs_out.


DATA: gs_fieldcat TYPE lvc_s_fcat,              "字段工作区
      gt_fieldcat TYPE lvc_t_fcat.

DATA: gs_list TYPE lvc_s_drop.
DATA: gt_list TYPE lvc_t_drop.

DATA: gt_listheader TYPE slis_t_listheader,            "ALV 表头
      gs_setting    TYPE lvc_s_glay,
      gs_layout     TYPE lvc_s_layo.                  "ALV布局工作区

DATA: gs_sort TYPE lvc_s_sort,
      gt_sort TYPE lvc_t_sort.
DATA: gs_stbl TYPE lvc_s_stbl.
DATA: gcl_alv_grid TYPE REF TO cl_gui_alv_grid.
DATA: gs_events TYPE slis_alv_event,
      gt_events TYPE slis_t_event.
DATA: gv_msg TYPE string.

DATA: gv_new_id TYPE abap_bool.
DATA: gv_zz_log_id TYPE zfunc_log-id.

DATA: gcl_root TYPE REF TO cx_root.

SELECTION-SCREEN BEGIN OF BLOCK bk01 WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS: s_id    FOR zfunc_log-id,
                s_name FOR zfunc_log-func_name,
                s_erdat FOR zfunc_log-erdat,
                s_erzet FOR zfunc_log-erzet,
                s_ernam FOR zfunc_log-ernam,
                s_msgty FOR zfunc_log-msgty,
                s_msgtxt FOR zfunc_log-msgtxt,
                s_zd    FOR zfunc_log-xuterminal,
                s_ip    FOR zfunc_log-ip.
SELECTION-SCREEN END OF BLOCK bk01.

*&---------------------------------------------------------------------*
* 流程部分
*
*&---------------------------------------------------------------------*

INITIALIZATION.
  s_erdat[] = VALUE #( ( sign = 'I'
                       option = 'BT'
                          low = sy-datum - 15
                         high = sy-datum ) ).

START-OF-SELECTION.

END-OF-SELECTION.
  PERFORM frm_ready_report.
  PERFORM frm_pre_fieldcat.   "设置字段
  PERFORM frm_set_event.      "设置事件
  PERFORM frm_set_header.     "设置表头
  PERFORM frm_set_layout.     "设置布局
  PERFORM frm_show_alv.


*&---------------------------------------------------------------------*
* 逻辑实现部分
*
*&---------------------------------------------------------------------*

*&---------------------------------------------------------------------*
*&      Form  FRM_READY_REPORT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM frm_ready_report.
  PERFORM frm_get_data.           "获取数据
  PERFORM frm_deal_data.          "处理数据
ENDFORM.                    "FRM_READY_REPORT

*&---------------------------------------------------------------------*
*&      Form  FRM_PRE_FIELDCAT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM frm_pre_fieldcat .


  CLEAR gs_fieldcat.
  REFRESH gt_fieldcat.

  "动态字段名称赋值
  DATA: lo_tabdescr TYPE REF TO cl_abap_structdescr.
  DATA: ls_field_in TYPE dfies,
        lt_dfies    TYPE ddfields.

  lo_tabdescr ?= cl_abap_structdescr=>describe_by_data( gs_out ).
  CALL METHOD cl_salv_data_descr=>read_structdescr
    EXPORTING
      r_structdescr = lo_tabdescr
    RECEIVING
      t_dfies       = lt_dfies.

*  "===自动赋值fieldcat===
*  loop at lt_dfies into ls_field_in.
*    clear: gs_fieldcat.
*    move-corresponding ls_field_in to gs_fieldcat.
*    gs_fieldcat-ref_field = ls_field_in-fieldname. "参照类型字段
*    gs_fieldcat-ref_table = ls_field_in-tabname.   "参照类型的表,搜索帮助,域控制
*    if gs_fieldcat-coltext is initial.         "当COLTEXT不存在显示FILEDTEXT,如字段没域,只有手工描述的情况
*      gs_fieldcat-coltext = ls_field_in-fieldtext.
*    endif.
*    case ls_field_in-fieldname.
*      when 'MANDT' or 'SEL'.
*        continue.
*      when others.
*    endcase.
*    append gs_fieldcat to gt_fieldcat.
*  endloop.

  "===手动赋值fieldcat===
  DEFINE set_fieldcat.
    READ TABLE lt_dfies INTO ls_field_in WITH KEY fieldname = &1.
    IF sy-subrc = 0.
      CLEAR: gs_fieldcat.
      MOVE-CORRESPONDING ls_field_in TO gs_fieldcat.

      gs_fieldcat-coltext = &2.
      gs_fieldcat-edit = &3.
      gs_fieldcat-ref_table = &4.
      gs_fieldcat-ref_field = &5.
      gs_fieldcat-lowercase      = 'X'.

      IF gs_fieldcat-ref_field IS INITIAL.
        gs_fieldcat-ref_field = ls_field_in-fieldname. "参照类型字段
      ENDIF.
      IF gs_fieldcat-ref_table IS INITIAL.
        gs_fieldcat-ref_table = ls_field_in-tabname.   "参照类型的表,搜索帮助,域控制
      ENDIF.
      IF gs_fieldcat-coltext IS INITIAL.         "当coltext不存在显示filedtext,如字段没域,只有手工描述的情况
        gs_fieldcat-coltext = ls_field_in-fieldtext.
      ENDIF.
      IF gs_fieldcat-outputlen IS INITIAL.         "当coltext不存在显示filedtext,如字段没域,只有手工描述的情况
        gs_fieldcat-outputlen = 40.
      ENDIF.
      APPEND gs_fieldcat TO gt_fieldcat.
    ENDIF.
  END-OF-DEFINITION.

  set_fieldcat 'ID' '' '' '' ''."不赋值COLTEXT,带出数据元素的名称
  set_fieldcat 'FUNC_NAME' '函数名' '' '' ''. "
  set_fieldcat 'STEXT' '函数描述' '' '' ''. "
  set_fieldcat 'XUTERMINAL' '终端' '' '' ''. "
  set_fieldcat 'IP' 'IP' '' '' ''. "
  set_fieldcat 'ERDAT' '' '' '' ''. "
  set_fieldcat 'ERZET' '' '' '' ''. "
  set_fieldcat 'ERNAM' '' '' '' ''. "
  set_fieldcat 'MSGTY' '' '' '' ''. "
  set_fieldcat 'MSGTXT' '' '' '' ''. "
  set_fieldcat 'ICON'  '传入数据-转换展示' '' '' ''. "
  set_fieldcat 'ICON2' '传入数据-初始展示' '' '' ''. "
  set_fieldcat 'ICON3' '返回数据-转换展示' '' '' ''. "
  set_fieldcat 'ICON4' '返回数据-初始展示' '' '' ''. "
  set_fieldcat 'TZNTSTMPS_BEG' '开始时间戳' '' '' ''. "
  set_fieldcat 'TZNTSTMPS_END' '结束时间戳' '' '' ''. "
  set_fieldcat 'TZNTSTMPS' '时间差(秒)' '' '' ''. "

  "其他特殊处理
  LOOP AT gt_fieldcat INTO gs_fieldcat.
    IF  gs_fieldcat-fieldname CS 'ID' .
      gs_fieldcat-fix_column = 'X'.
    ENDIF.
    IF gs_fieldcat-fieldname CS 'ICON'.
      gs_fieldcat-icon = 'X'.
      gs_fieldcat-hotspot = 'X'.
    ENDIF.
    MODIFY gt_fieldcat FROM gs_fieldcat.
  ENDLOOP.


  DEFINE set_sort.  "定义排序宏
    CLEAR gs_sort.
    gs_sort-fieldname = &1.
    gs_sort-spos = 1.
    gs_sort-up = 'X'.
    gs_sort-subtot = 'X'.
    APPEND gs_sort TO gt_sort.
  END-OF-DEFINITION.
*  SET_SORT 'GJAHR'.
*  SET_SORT 'SEASON'.
ENDFORM.                    " FRM_PRE_FIELDCAT

*&---------------------------------------------------------------------*
*&      Form  FRM_SET_HEADER
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM frm_set_header .

ENDFORM.                    " FRM_SET_HEADER

*&---------------------------------------------------------------------*
*&      Form  FRM_GET_DATA
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM frm_get_data .
  SELECT *
    INTO CORRESPONDING FIELDS OF TABLE gt_out
    FROM zfunc_log
    WHERE id          IN s_id
      AND erdat       IN s_erdat
      AND erzet       IN s_erzet
      AND ernam       IN s_ernam
      AND msgtxt      IN s_msgtxt
      AND msgty       IN s_msgty
      AND xuterminal  IN s_zd
      AND func_name  IN s_name
      AND ip          IN s_ip    .
ENDFORM.                   " FRM_GET_DATA

*&---------------------------------------------------------------------*
*&      Form  FRM_DEAL_DATA
*----------------------------------------------------------------------*
FORM frm_deal_data.
  DATA: ls_tftit TYPE tftit,
        lt_tftit TYPE TABLE OF tftit.

*  CALL METHOD zcl_jt=>get_text_table
*    EXPORTING
*      table_name    = 'TFTIT'
*      intab_field   = 'FUNC_NAME'
*      outtab_field  = 'FUNCNAME'
*      langu_field   = 'SPRAS'
*      other_sql     = ''
*      object_struct = gs_out
*      object_table  = gt_out
*    IMPORTING
*      text_table    = lt_tftit.
  IF gt_out[] IS NOT INITIAL.
    SELECT
    * INTO TABLE lt_tftit
    FROM tftit
      FOR ALL ENTRIES IN gt_out
      WHERE funcname = gt_out-func_name
    .
  ENDIF.



  LOOP AT gt_out ASSIGNING <fs_out>.
    READ TABLE lt_tftit INTO ls_tftit WITH KEY funcname = <fs_out>-func_name BINARY SEARCH.
    IF sy-subrc = 0.
      <fs_out>-stext = ls_tftit-stext.
    ENDIF.
    <fs_out>-icon  = icon_parameter_import.
    <fs_out>-icon2 = icon_parameter_import.
    <fs_out>-icon3 = icon_parameter_result.
    <fs_out>-icon4 = icon_parameter_result.
  ENDLOOP.

  SORT gt_out BY id DESCENDING.
ENDFORM.                    "FRM_GET_DATA

*&---------------------------------------------------------------------*
*&      Form  FRM_SHOW_ALV
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM frm_show_alv .
  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
    EXPORTING
*     I_INTERFACE_CHECK        = ' '
*     I_BYPASSING_BUFFER       =
*     I_BUFFER_ACTIVE          =
      i_callback_program       = sy-cprog
      i_callback_pf_status_set = 'SUB_STATUS_SET'
      i_callback_user_command  = 'SUB_USER_COMMAND'
*     I_CALLBACK_TOP_OF_PAGE   = ' '
*     I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
*     I_CALLBACK_HTML_END_OF_LIST       = ' '
*     I_STRUCTURE_NAME         =
*     I_BACKGROUND_ID          = ' '
*     I_GRID_TITLE             =
*     I_GRID_SETTINGS          = GS_SETTING   "编辑回填数据时候打开
      is_layout_lvc            = gs_layout
      it_fieldcat_lvc          = gt_fieldcat
*     IT_EXCLUDING             =
*     IT_SPECIAL_GROUPS_LVC    =
      it_sort_lvc              = gt_sort
*     IT_FILTER_LVC            =
*     IT_HYPERLINK             =
*     IS_SEL_HIDE              =
*     I_DEFAULT                = 'X'
      i_save                   = 'A'
*     IS_VARIANT               =
      it_events                = gt_events
*     IT_EVENT_EXIT            =
*     IS_PRINT_LVC             =
*     IS_REPREP_ID_LVC         =
*     I_SCREEN_START_COLUMN    = 0
*     I_SCREEN_START_LINE      = 0
*     I_SCREEN_END_COLUMN      = 0
*     I_SCREEN_END_LINE        = 0
*     I_HTML_HEIGHT_TOP        =
*     I_HTML_HEIGHT_END        =
*     IT_ALV_GRAPHICS          =
*     IT_EXCEPT_QINFO_LVC      =
*     IR_SALV_FULLSCREEN_ADAPTER        =
*   IMPORTING
*     E_EXIT_CAUSED_BY_CALLER  =
*     ES_EXIT_CAUSED_BY_USER   =
    TABLES
      t_outtab                 = gt_out
    EXCEPTIONS
      program_error            = 1
      OTHERS                   = 2.
  IF sy-subrc <> 0.
* Implement suGT_OUTle error handling here
  ENDIF.

ENDFORM.                    " FRM_SHOW_ALV

*&---------------------------------------------------------------------*
*&      Form  SUB_TOP_OF_PAGE
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM sub_top_of_page.
  CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
    EXPORTING
      it_list_commentary = gt_listheader
*     I_LOGO             =
*     I_END_OF_LIST_GRID =
*     I_ALV_FORM         =
    .

ENDFORM.                    "SUB_TOP_OF_PAGE
*&---------------------------------------------------------------------*
*&      Form  FRM_SET_LAYOUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM frm_set_layout .
  gs_setting-edt_cll_cb = 'X'.
  gs_layout-cwidth_opt = 'X'.
  gs_layout-box_fname = 'SEL'.
ENDFORM.                    " FRM_SET_LAYOUT

*&---------------------------------------------------------------------*
*&      Form  SUB_STATUS_SET
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM sub_status_set USING rt_extab TYPE slis_t_extab.
  SET PF-STATUS 'STATUS01'.
  SET TITLEBAR 'TITLE'.
ENDFORM.                    "SUB_STATUS_SET


*  ----------------------------------------------------------------------*
*         CLASS lcl_event_receiver DEFINITION
*定义类
*  ----------------------------------------------------------------------*
CLASS lcl_event_receiver DEFINITION.
  PUBLIC SECTION.
    METHODS data_changed FOR EVENT data_changed OF cl_gui_alv_grid
      IMPORTING er_data_changed
                  e_onf4
                  e_onf4_before
                  e_onf4_after
                  e_ucomm.
    METHODS handle_modify
                  FOR EVENT data_changed_finished OF cl_gui_alv_grid
      IMPORTING e_modified et_good_cells.
ENDCLASS.                    "LCL_EVENT_RECEIVER DEFINITION

*  ----------------------------------------------------------------------*
*         CLASS lcl_event_receiver IMPLEMENTATION
* 定义方法
*  ----------------------------------------------------------------------*
CLASS lcl_event_receiver IMPLEMENTATION.
  METHOD data_changed.
    PERFORM handle_data_changed USING er_data_changed.
  ENDMETHOD.
  METHOD handle_modify.
    PERFORM handle_data_finish USING e_modified et_good_cells.
  ENDMETHOD.                    "HANDLE_MODIFY
ENDCLASS.                    "LCL_EVENT_RECEIVER IMPLEMENTATION

FORM handle_data_finish USING e_modified TYPE char01
                               et_good_cells TYPE lvc_t_modi.
*在此处添加你自己的代码,改变传入ALV函数的那个内表的值,就能实现你的功能。
  DATA: eh_good_cells TYPE lvc_s_modi.
  DATA: lv_itab_trans_to_itab TYPE char01. "内表修改影响alv显示
  CLEAR: lv_itab_trans_to_itab.

  IF e_modified = 'X'.
    LOOP AT et_good_cells INTO eh_good_cells. "修改的行。
      READ TABLE gt_out ASSIGNING <fs_out> INDEX eh_good_cells-row_id.
      IF sy-subrc = 0.

      ENDIF.
    ENDLOOP.
*-------------------------------------------------
* 稳定刷新
    IF lv_itab_trans_to_itab IS NOT INITIAL. "假如每次修改数据都刷新ALV,非常影响速度
      gs_stbl-row = 'X'." 基于行的稳定刷新
      gs_stbl-col = 'X'." 基于列稳定刷新
      CALL METHOD gcl_alv_grid->refresh_table_display
        EXPORTING
          is_stable = gs_stbl.
    ENDIF.
  ENDIF.

ENDFORM.
FORM handle_data_changed  USING p_er_data_changed TYPE REF TO cl_alv_changed_data_protocol.
*如果更新的reason字段长度小于10为则提示用户填入字符数不能低于10
  DATA:mod_data        TYPE lvc_t_modi,
       gs_out_mod_data TYPE lvc_s_modi.

  mod_data = p_er_data_changed->mt_mod_cells.
  LOOP AT mod_data INTO gs_out_mod_data.
  ENDLOOP.
ENDFORM.                    "handle_data_changed

*&---------------------------------------------------------------------*
*&      Form  FRM_SET_EVENT
*定义事件
*&---------------------------------------------------------------------*
FORM frm_set_event .
  CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
    EXPORTING
      i_list_type     = 0
    IMPORTING
      et_events       = gt_events
    EXCEPTIONS
      list_type_wrong = 1
      OTHERS          = 2.
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
           WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.

  gs_events-name = 'CALLER_EXIT'.
  gs_events-form = 'FRM_CALLER_EXIT'.
  APPEND gs_events TO gt_events.

ENDFORM.                    " FRM_SET_EVENT

*&---------------------------------------------------------------------*
*&      Form  F_CALLER_EXIT
* 注册回车事件
*&---------------------------------------------------------------------*
FORM frm_caller_exit USING ls_data TYPE slis_data_caller_exit.

  CHECK sy-batch = ''. "后台执行获取对象失败

  DATA gt_event_receiver TYPE REF TO lcl_event_receiver.

  CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
    IMPORTING
      e_grid = gcl_alv_grid.


* 设置enter事件
  CALL METHOD gcl_alv_grid->register_edit_event
    EXPORTING
      i_event_id = cl_gui_alv_grid=>mc_evt_enter
    EXCEPTIONS
      error      = 1
      OTHERS     = 2.
  CALL METHOD gcl_alv_grid->register_edit_event
    EXPORTING
      i_event_id = cl_gui_alv_grid=>mc_evt_modified
    EXCEPTIONS
      error      = 1
      OTHERS     = 2.
  IF sy-subrc <> 0.
*   Implement suGT_OUTle error handling here
  ENDIF.
  CREATE OBJECT gt_event_receiver.
  SET HANDLER gt_event_receiver->handle_modify FOR gcl_alv_grid.
  SET HANDLER gt_event_receiver->data_changed FOR gcl_alv_grid.



ENDFORM.                   "F_CALLER_EXIT


*&---------------------------------------------------------------------*
*&      Form  SUB_USER_COMMAND
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM sub_user_command USING s_ucomm TYPE sy-ucomm
                            re_selfield TYPE slis_selfield.

  CALL METHOD gcl_alv_grid->check_changed_data. "触发数据变更
  CASE s_ucomm.
    WHEN '&IC1'.
      READ TABLE gt_out INTO gs_out INDEX re_selfield-tabindex.
      IF sy-subrc = 0.

        CASE re_selfield-fieldname.
          WHEN 'ICON'.
            PERFORM frm_display_json.
          WHEN 'ICON2'.
            PERFORM frm_display_json_old.
          WHEN 'ICON3'.
            PERFORM frm_display_return_json.
          WHEN 'ICON4'.
            PERFORM frm_display_return_json_old.
          WHEN OTHERS.
            SET PARAMETER ID 'LIB' FIELD gs_out-func_name.
            CALL TRANSACTION 'SE37' WITH AUTHORITY-CHECK AND SKIP FIRST SCREEN.
        ENDCASE.
      ENDIF.
    WHEN 'RESEND'.
      gv_new_id = ''.
      PERFORM frm_resend.
      CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
        EXPORTING
          percentage = 50
          text       = '等待2秒数据库刷新'.

      WAIT UP TO 1 SECONDS.
      PERFORM frm_ready_report.
      re_selfield-refresh = 'X'.
    WHEN 'RESEND2'.
      gv_new_id = 'X'.
      PERFORM frm_resend.
      CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
        EXPORTING
          percentage = 50
          text       = '等待2秒数据库刷新'.
      WAIT UP TO 1 SECONDS.
      PERFORM frm_ready_report.
      re_selfield-refresh = 'X'.
    WHEN 'LEAVE' OR 'EXIT' OR 'CANCEL'.
      LEAVE TO SCREEN 0.
  ENDCASE.

ENDFORM.                    "SUB_USER_COMMAND

FORM frm_display_json.
  DATA: ls_data TYPE zfunc_log_data,
        lt_data TYPE TABLE OF zfunc_log_data.
  FIELD-SYMBOLS: <ls_data> TYPE zfunc_log_data.
  DATA: lv_json_string TYPE string.

  SELECT *
    INTO CORRESPONDING FIELDS OF TABLE lt_data
    FROM zfunc_log_data
    WHERE id = gs_out-id.

  "为了合并数据,使用at end of
  SORT lt_data BY canum.
  LOOP AT lt_data INTO ls_data.
    CLEAR: ls_data-canum .
    MODIFY lt_data FROM ls_data.
  ENDLOOP.

  cl_demo_output=>next_section( `输入数据` ).
  LOOP AT lt_data INTO ls_data WHERE func_paramtype = 'I'.
    PERFORM frm_transdisplay_data USING ls_data ''.
  ENDLOOP.

  cl_demo_output=>next_section( `更改数据` ).
  LOOP AT lt_data INTO ls_data WHERE func_paramtype = 'C'.
    PERFORM frm_transdisplay_data USING ls_data ''.
  ENDLOOP.

  cl_demo_output=>next_section( `表数据` ).
  LOOP AT lt_data ASSIGNING <ls_data> WHERE func_paramtype = 'T'.

    lv_json_string = lv_json_string && <ls_data>-json_data.
    AT END OF func_parameter.
      PERFORM frm_transdisplay_data USING <ls_data> lv_json_string.
      CLEAR: lv_json_string.
    ENDAT.
  ENDLOOP.

  cl_demo_output=>end_section( ).
  cl_demo_output=>display( ).


ENDFORM.


FORM frm_display_return_json.
  DATA: ls_data TYPE zfunc_log_data,
        lt_data TYPE TABLE OF zfunc_log_data.
  FIELD-SYMBOLS: <ls_data> TYPE zfunc_log_data.
  DATA: lv_json_string TYPE string.

  SELECT *
    INTO CORRESPONDING FIELDS OF TABLE lt_data
    FROM zfunc_log_data_e
    WHERE id = gs_out-id.


  "为了合并数据,使用at end of
  SORT lt_data BY canum.
  LOOP AT lt_data INTO ls_data.
    CLEAR: ls_data-canum .
    MODIFY lt_data FROM ls_data.
  ENDLOOP.


  cl_demo_output=>next_section( `输入数据` ).
  LOOP AT lt_data INTO ls_data WHERE func_paramtype = 'I'.
    PERFORM frm_transdisplay_data USING ls_data ''.
  ENDLOOP.

  cl_demo_output=>next_section( `输出数据` ).
  LOOP AT lt_data INTO ls_data WHERE func_paramtype = 'E'.
    PERFORM frm_transdisplay_data USING ls_data ''.
  ENDLOOP.

  cl_demo_output=>next_section( `更改数据` ).
  LOOP AT lt_data INTO ls_data WHERE func_paramtype = 'C'.
    PERFORM frm_transdisplay_data USING ls_data ''.
  ENDLOOP.

  cl_demo_output=>next_section( `表数据` ).
  LOOP AT lt_data ASSIGNING <ls_data> WHERE func_paramtype = 'T'.

    lv_json_string = lv_json_string && <ls_data>-json_data.
    AT END OF func_parameter.
      PERFORM frm_transdisplay_data USING <ls_data> lv_json_string.
      CLEAR: lv_json_string.
    ENDAT.

  ENDLOOP.

  cl_demo_output=>end_section( ).
  cl_demo_output=>display( ).


ENDFORM.

FORM frm_transdisplay_data USING im_data TYPE zfunc_log_data
                                  im_json_data TYPE string.
  DATA: lv_post_data TYPE string.

  "动态创建工作区、内表
  DATA           objekt     TYPE REF TO data.
  FIELD-SYMBOLS  <fs_aber>    TYPE any.



  IF im_data-func_type = 'X'.
    CREATE DATA objekt TYPE (im_data-func_structure).
    ASSIGN objekt->* TO <fs_aber>.
  ELSE.
    if im_data-func_paramtype = 'I' or im_data-func_paramtype = 'E'.
      CREATE DATA objekt TYPE (im_data-func_structure)."防止importing\exporting参数类型为like时dump
      ASSIGN objekt->* TO <fs_aber>.
    ELSE.
      CREATE DATA objekt TYPE TABLE OF (im_data-func_structure).
      ASSIGN objekt->* TO <fs_aber>.
    ENDIF.
  ENDIF.

  IF im_json_data IS NOT INITIAL.
    lv_post_data = im_json_data.
  ELSE.
    lv_post_data = im_data-json_data.
  ENDIF.
  /ui2/cl_json=>deserialize( EXPORTING json = lv_post_data
                                       pretty_name = /ui2/cl_json=>pretty_mode-camel_case
                             CHANGING data = <fs_aber> ).
  lv_post_data = im_data-func_parameter.
  cl_demo_output=>write_data( value = <fs_aber> name = lv_post_data ).
ENDFORM.

FORM frm_display_json_old.

  DATA: ls_data TYPE zfunc_log_data,
        lt_data TYPE TABLE OF zfunc_log_data.
  DATA: lv_post_data TYPE string.

  DATA: lv_json_string TYPE string.

  SELECT *
    INTO CORRESPONDING FIELDS OF TABLE lt_data
    FROM zfunc_log_data
    WHERE id = gs_out-id.

  "为了合并数据,使用at end of
  SORT lt_data BY canum.
  LOOP AT lt_data INTO ls_data.
    CLEAR: ls_data-canum .
    MODIFY lt_data FROM ls_data.
  ENDLOOP.

  cl_demo_output=>next_section( `输入数据` ).
  LOOP AT lt_data INTO ls_data WHERE func_paramtype = 'I'.
    lv_post_data = ls_data-func_parameter && `  参照类型(` && ls_data-func_structure && ')'.
    cl_demo_output=>write_data( value = ls_data-json_data name = lv_post_data ).
  ENDLOOP.

  cl_demo_output=>next_section( `更改数据` ).
  LOOP AT lt_data INTO ls_data WHERE func_paramtype = 'C'.
    lv_post_data = ls_data-func_parameter && `  参照类型(` && ls_data-func_structure && ')'.
    cl_demo_output=>write_data( value = ls_data-json_data name = lv_post_data ).
  ENDLOOP.

  cl_demo_output=>next_section( `表数据` ).
  LOOP AT lt_data INTO ls_data WHERE func_paramtype = 'T'.

    lv_post_data = ls_data-func_parameter && `  参照类型(` && ls_data-func_structure && ')'.
    lv_json_string = lv_json_string && ls_data-json_data.
    AT END OF func_parameter.
      cl_demo_output=>write_data( value = lv_json_string name = lv_post_data ).
      CLEAR: lv_json_string.
    ENDAT.
  ENDLOOP.

  cl_demo_output=>end_section( ).
  cl_demo_output=>display( ).
ENDFORM.


FORM frm_display_return_json_old.

  DATA: ls_data TYPE zfunc_log_data,
        lt_data TYPE TABLE OF zfunc_log_data.
  DATA: lv_post_data TYPE string.

  DATA: lv_json_string TYPE string.

  SELECT *
    INTO CORRESPONDING FIELDS OF TABLE lt_data
    FROM zfunc_log_data_e
    WHERE id = gs_out-id.


  "为了合并数据,使用at end of
  SORT lt_data BY canum.
  LOOP AT lt_data INTO ls_data.
    CLEAR: ls_data-canum .
    MODIFY lt_data FROM ls_data.
  ENDLOOP.



  cl_demo_output=>next_section( `输入数据` ).
  LOOP AT lt_data INTO ls_data WHERE func_paramtype = 'I'.
    lv_post_data = ls_data-func_parameter && `  参照类型(` && ls_data-func_structure && ')'.
    cl_demo_output=>write_data( value = ls_data-json_data name = lv_post_data ).
  ENDLOOP.

  cl_demo_output=>next_section( `输出数据` ).
  LOOP AT lt_data INTO ls_data WHERE func_paramtype = 'E'.
    lv_post_data = ls_data-func_parameter && `  参照类型(` && ls_data-func_structure && ')'.
    cl_demo_output=>write_data( value = ls_data-json_data name = lv_post_data ).
  ENDLOOP.

  cl_demo_output=>next_section( `更改数据` ).
  LOOP AT lt_data INTO ls_data WHERE func_paramtype = 'C'.
    lv_post_data = ls_data-func_parameter && `  参照类型(` && ls_data-func_structure && ')'.
    cl_demo_output=>write_data( value = ls_data-json_data name = lv_post_data ).
  ENDLOOP.

  cl_demo_output=>next_section( `表数据` ).
  LOOP AT lt_data INTO ls_data WHERE func_paramtype = 'T'.

    lv_post_data = ls_data-func_parameter && `  参照类型(` && ls_data-func_structure && ')'.
    lv_json_string = lv_json_string && ls_data-json_data.
    AT END OF func_parameter.
      cl_demo_output=>write_data( value = lv_json_string name = lv_post_data ).
      CLEAR: lv_json_string.
    ENDAT.

  ENDLOOP.

  cl_demo_output=>end_section( ).
  cl_demo_output=>display( ).
ENDFORM.

FORM frm_resend.
  DATA: ls_data TYPE zfunc_log_data,
        lt_data TYPE TABLE OF zfunc_log_data.
  FIELD-SYMBOLS: <ls_data> TYPE zfunc_log_data.

  DATA: ls_ptab TYPE abap_func_parmbind,
        lt_ptab TYPE abap_func_parmbind_tab.
  DATA: lt_etab TYPE abap_func_excpbind_tab.
  DATA: BEGIN OF ls_id,
          sel,
          id        TYPE zfunc_log-id,
          func_name TYPE zfunc_log-func_name,
        END OF ls_id,
        lt_id LIKE TABLE OF ls_id.
  DATA: lv_post_data TYPE string.
  DATA: lv_json_string TYPE string.

  DATA           objekt     TYPE REF TO data.
  FIELD-SYMBOLS  <fs_aber>    TYPE any.

  CLEAR: lt_ptab[],
         lt_data[].

  lt_id = CORRESPONDING #( gt_out[] ).
  DELETE lt_id WHERE sel = ''.

  IF lt_id[] IS NOT INITIAL.
    SELECT *
      INTO CORRESPONDING FIELDS OF TABLE lt_data
      FROM zfunc_log_data
      FOR ALL ENTRIES IN lt_id
      WHERE id = lt_id-id.


    "为了合并数据,使用at end of
    SORT lt_data BY id canum.
    LOOP AT lt_data INTO ls_data.
      CLEAR: ls_data-canum .
      MODIFY lt_data FROM ls_data.
    ENDLOOP.
  ENDIF.


  LOOP AT lt_id INTO ls_id.
    CLEAR: lt_ptab[],
           lt_etab[]. " ADD BY HEZZ AT 20190105

    gv_zz_log_id = ls_id-id. "赋值当前ID
    LOOP AT lt_data ASSIGNING <ls_data> WHERE id = ls_id-id .
      "动态创建工作区、内表
      IF <ls_data>-func_type = 'X'.
        CREATE DATA objekt TYPE (<ls_data>-func_structure).
        ASSIGN objekt->* TO <fs_aber>.
      ELSE.
        CREATE DATA objekt TYPE TABLE OF (<ls_data>-func_structure).
        ASSIGN objekt->* TO <fs_aber>.
      ENDIF.

      lv_json_string = lv_json_string && <ls_data>-json_data.

      AT END OF func_parameter.

        /ui2/cl_json=>deserialize( EXPORTING json = lv_json_string
                                             pretty_name = /ui2/cl_json=>pretty_mode-camel_case
                                   CHANGING data = <fs_aber> ).

        ls_ptab-value = objekt.
*      ls_ptab-tables_wa = ''.
        ls_ptab-name      = <ls_data>-func_parameter.
        CASE <ls_data>-func_paramtype.
          WHEN 'I'.
            ls_ptab-kind      = abap_func_exporting.
          WHEN 'C'.
            ls_ptab-kind      = abap_func_changing.
          WHEN 'T'.
            ls_ptab-kind      = abap_func_tables.
          WHEN OTHERS.
        ENDCASE.

        INSERT ls_ptab INTO TABLE lt_ptab.
        CLEAR: ls_ptab.
        CLEAR: lv_json_string.
      ENDAT.
    ENDLOOP.

    "调用函数
    TRY .
        CALL FUNCTION ls_id-func_name
          PARAMETER-TABLE lt_ptab
          EXCEPTION-TABLE lt_etab.
      CATCH cx_root INTO gcl_root .
        DATA(lv_text) = gcl_root->if_message~get_longtext( ).
        MESSAGE i001(00) WITH '函数' ls_id-func_name '异常,' lv_text.
    ENDTRY.
  ENDLOOP.
ENDFORM.

2.接口
接口:ZFUNC_SAVE

FUNCTION ZFUNC_SAVE.
*"----------------------------------------------------------------------
*"*"本地接口:
*"  IMPORTING
*"     VALUE(HEAD) TYPE  ZFUNC_LOG
*"  TABLES
*"      DATA STRUCTURE  ZFUNC_LOG_DATA
*"      DATA_E STRUCTURE  ZFUNC_LOG_DATA_E
*"----------------------------------------------------------------------


IF head IS NOT INITIAL.
    MODIFY zfunc_log FROM head.
  ENDIF.
  IF data[] IS NOT INITIAL.
    MODIFY zfunc_log_data FROM TABLE data.
    COMMIT WORK AND WAIT.
  ENDIF.

  IF data_e[] IS NOT INITIAL.

    MODIFY zfunc_log_data_e FROM TABLE data_e.
    COMMIT WORK AND WAIT.
  ENDIF.
ENDFUNCTION.

接口:ZFUNC_UPDATE_STATU

FUNCTION ZFUNC_UPDATE_STATU.
*"----------------------------------------------------------------------
*"*"本地接口:
*"  IMPORTING
*"     VALUE(I_ID) TYPE  ZFUNC_LOG_ID
*"     VALUE(I_MSGTY) TYPE  MSGTY
*"     VALUE(I_MSGTXT) TYPE  MSGTXT
*"----------------------------------------------------------------------

DATA: ls_log TYPE zfunc_log.
  DATA: lv_d_beg   TYPE dats,
        lv_t_beg   TYPE tims,
        lv_d_end   TYPE dats,
        lv_t_end   TYPE tims,
        lv_seconds TYPE int4.

  CLEAR: ls_log,lv_d_beg,lv_t_beg,lv_d_end,lv_t_end,lv_seconds.

  DO 3 TIMES.
    SELECT SINGLE  *
       INTO CORRESPONDING FIELDS OF ls_log
       FROM zfunc_log
       WHERE id = i_id.
    IF ls_log IS INITIAL.
      WAIT UP TO 1 SECONDS.
    ELSE.
      EXIT.
    ENDIF.
  ENDDO.


  GET TIME STAMP FIELD ls_log-tzntstmps_end ."结束时间戳

  IF ls_log-tzntstmps_beg IS INITIAL.
    ls_log-tzntstmps_beg = ls_log-tzntstmps_end.
  ENDIF.

  CONVERT TIME STAMP ls_log-tzntstmps_beg TIME ZONE 'UTC+8' INTO DATE lv_d_beg TIME lv_t_beg.
  CONVERT TIME STAMP ls_log-tzntstmps_end TIME ZONE 'UTC+8' INTO DATE lv_d_end TIME lv_t_end.

  "开始结束差值
  CALL FUNCTION 'SALP_SM_CALC_TIME_DIFFERENCE'
    EXPORTING
      date_1  = lv_d_end
      time_1  = lv_t_end
      date_2  = lv_d_beg
      time_2  = lv_t_beg
    IMPORTING
      seconds = lv_seconds.

  ls_log-tzntstmps = lv_seconds.
  ls_log-msgty = i_msgty.
  ls_log-msgtxt = i_msgtxt.
  UPDATE zfunc_log SET tzntstmps = ls_log-tzntstmps
                   tzntstmps_end = ls_log-tzntstmps_end
                           msgty = ls_log-msgty
                          msgtxt = ls_log-msgtxt
                          WHERE id = i_id.
  COMMIT WORK AND WAIT.

ENDFUNCTION.

4.调用方式
包含文件:ZFUNC_TOP

*&---------------------------------------------------------------------*
*& Include ZFUNC_TOP
*&---------------------------------------------------------------------*
"因为通用名称,所以变量必须特殊
DATA: ls_zz_log_callstack TYPE sys_calls,
      lt_zz_log_callstack TYPE sys_callst.

DATA: ls_zz_log_save TYPE zfunc_log.

DATA: ls_zz_log_data_save TYPE zfunc_log_data,
      lt_zz_log_data_save TYPE TABLE OF zfunc_log_data.

DATA: ls_zz_log_fupararef TYPE fupararef,
      lt_zz_log_fupararef TYPE TABLE OF fupararef.

DATA: lv_zz_log_table_name TYPE string.

DATA: lv_zz_log_id TYPE zfunc_log_data-id.

DATA: lv_zz_log_opcode_usr_attr(1) TYPE x VALUE 5,
      lv_zz_log_terminal           TYPE usr41-terminal.
DATA: lv_zz_log_ip TYPE string.

"判断是否产生new id
DATA: lv_zz_log_is_run TYPE abap_bool.


FIELD-SYMBOLS: <fs_zz_log_variable> TYPE any.
FIELD-SYMBOLS: <fs_zz_log_variable_tab> TYPE ANY TABLE.

DATA: lv_zz_log_string TYPE string.

DATA:lv_zz_code TYPE msgty,
      lv_zz_message TYPE msgtxt.

包含文件:ZFUNC_BEGIN

*&---------------------------------------------------------------------*
*& Include ZFUNC_BEGIN
*&---------------------------------------------------------------------*

lv_zz_log_is_run = 'X'.

"读取重运行程序的运行ID
ASSIGN ('(ZFUNC_LOG)GV_ZZ_LOG_ID')  TO FIELD-SYMBOL(<fs_zz_log_id>).
IF <fs_zz_log_id> IS ASSIGNED.
  lv_zz_log_id = <fs_zz_log_id>.
ENDIF.

"读取重运行程序的命令
ASSIGN ('(ZFUNC_LOG)GV_NEW_ID') TO FIELD-SYMBOL(<fs_new_id>).
IF <fs_new_id> IS ASSIGNED .
  lv_zz_log_is_run = <fs_new_id>.
  IF <fs_new_id> IS NOT INITIAL.
    CLEAR: lv_zz_log_id.
  ENDIF.
ENDIF.


IF lv_zz_log_is_run IS NOT INITIAL. "运行标志

  CLEAR: lt_zz_log_data_save[].

  CALL FUNCTION 'SYSTEM_CALLSTACK'
    IMPORTING
*     callstack    = callstack
      et_callstack = lt_zz_log_callstack.

  "read first function name
  CLEAR: ls_zz_log_callstack.
  READ TABLE lt_zz_log_callstack INTO ls_zz_log_callstack WITH KEY eventtype = 'FUNC'.
  IF lt_zz_log_callstack IS INITIAL.
    EXIT.
  ENDIF.

  SELECT *
    INTO CORRESPONDING FIELDS OF TABLE lt_zz_log_fupararef
    FROM fupararef
   WHERE funcname = ls_zz_log_callstack-eventname.

  LOOP AT lt_zz_log_fupararef INTO ls_zz_log_fupararef WHERE paramtype NE 'E'.
    CLEAR: ls_zz_log_data_save.
    ls_zz_log_data_save-func_name       = ls_zz_log_callstack-eventname. "函数名称
    ls_zz_log_data_save-func_paramtype  = ls_zz_log_fupararef-paramtype.
    ls_zz_log_data_save-func_parameter  = ls_zz_log_fupararef-parameter.
    ls_zz_log_data_save-func_structure  = ls_zz_log_fupararef-structure.
    ls_zz_log_data_save-func_defaultval = ls_zz_log_fupararef-defaultval.
    ls_zz_log_data_save-func_type       = ls_zz_log_fupararef-type.
    ls_zz_log_data_save-func_class      = ls_zz_log_fupararef-class.
    ls_zz_log_data_save-func_ref_class  = ls_zz_log_fupararef-ref_class.

    IF ls_zz_log_fupararef-paramtype NE 'T'.
      ASSIGN (ls_zz_log_fupararef-parameter) TO <fs_zz_log_variable>.
      IF <fs_zz_log_variable> IS ASSIGNED.
        IF <fs_zz_log_variable> IS NOT INITIAL OR ls_zz_log_fupararef-defaultval IS NOT INITIAL.
          lv_zz_log_string = /ui2/cl_json=>serialize( data = <fs_zz_log_variable>
                                          compress = abap_true pretty_name = abap_true ).
        ENDIF.
      ENDIF.
    ELSE.
      lv_zz_log_table_name = ls_zz_log_fupararef-parameter && '[]'.
      ASSIGN (lv_zz_log_table_name) TO <fs_zz_log_variable_tab>.
      IF <fs_zz_log_variable_tab> IS ASSIGNED.
        IF <fs_zz_log_variable_tab> IS NOT INITIAL.
          lv_zz_log_string = /ui2/cl_json=>serialize( data = <fs_zz_log_variable_tab> compress = abap_true pretty_name = abap_true ).
        ENDIF.
      ENDIF.
    ENDIF.

    WHILE strlen( lv_zz_log_string ) > 0.
      IF strlen( lv_zz_log_string ) >= 1024 .
        ls_zz_log_data_save-json_data = lv_zz_log_string.
        APPEND ls_zz_log_data_save TO lt_zz_log_data_save.
        SHIFT lv_zz_log_string BY 1024 PLACES.
      ELSE.
        ls_zz_log_data_save-json_data = lv_zz_log_string.
        APPEND ls_zz_log_data_save TO lt_zz_log_data_save.
        CLEAR: lv_zz_log_string.
      ENDIF.
    ENDWHILE.
  ENDLOOP.

  "生成一个log id.
  IF lv_zz_log_id IS INITIAL.
    CALL FUNCTION 'NUMBER_GET_NEXT'
      EXPORTING
        nr_range_nr             = '01'
        object                  = 'ZFUNC_LOG'
      IMPORTING
        number                  = lv_zz_log_id
      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.
  ENDIF.


  "网页计算机名称就是IP地址
  CALL 'ThUsrInfo' ID 'OPCODE'  FIELD lv_zz_log_opcode_usr_attr
                   ID'TERMINAL' FIELD lv_zz_log_terminal.

  DATA: lv_zz_log_regex TYPE string.
  lv_zz_log_regex = '((?:(?:25[0-5]|2[0-4]\d|((1\d{2})|([1-9]?\d)))\.){3}(?:25[0-5]|2[0-4]\d|((1\d{2})|([1-9]?\d))))'.
  IF NOT contains( val = lv_zz_log_terminal regex = lv_zz_log_regex ).
    CALL METHOD cl_gui_frontend_services=>get_ip_address
      RECEIVING
        ip_address           = lv_zz_log_ip
      EXCEPTIONS
        cntl_error           = 1
        error_no_gui         = 2
        not_supported_by_gui = 3
        OTHERS               = 4.
    IF sy-subrc <> 0.
      CLEAR: lv_zz_log_ip.
    ENDIF.

  ELSE.
    lv_zz_log_ip = lv_zz_log_terminal.
  ENDIF.

  "赋值抬头
  ls_zz_log_save-id         = lv_zz_log_id.
  ls_zz_log_save-func_name  = ls_zz_log_callstack-eventname.
  ls_zz_log_save-erdat      = sy-datum.
  ls_zz_log_save-erzet      = sy-uzeit.
  ls_zz_log_save-ernam      = sy-uname.
  ls_zz_log_save-xuterminal = lv_zz_log_terminal.
  ls_zz_log_save-ip         = lv_zz_log_ip.
  ls_zz_log_save-msgty      = 'I'.
  ls_zz_log_save-msgtxt     = '开始调用'.
  GET TIME STAMP FIELD ls_zz_log_save-tzntstmps_beg."开始时间戳


  "赋值行项目
  LOOP AT lt_zz_log_data_save INTO ls_zz_log_data_save.
    ls_zz_log_data_save-id = lv_zz_log_id.
    ls_zz_log_data_save-canum = sy-tabix.
    MODIFY lt_zz_log_data_save FROM ls_zz_log_data_save.
  ENDLOOP.

  "把数据弄成异步提交模式保存,避免事务提交。
  CALL FUNCTION 'ZFUNC_SAVE' STARTING NEW TASK 'ZFUNC_BEGIN'
    EXPORTING
      head = ls_zz_log_save
    TABLES
      data = lt_zz_log_data_save.


ENDIF.

包含文件:

*&---------------------------------------------------------------------*
*& Include ZFUNC_END
*&---------------------------------------------------------------------*


IF lv_zz_log_id IS NOT INITIAL. "运行标志

  CLEAR: lt_zz_log_data_save[].

  CALL FUNCTION 'SYSTEM_CALLSTACK'
    IMPORTING
*     callstack    = callstack
      et_callstack = lt_zz_log_callstack.

  "read first function name
  CLEAR: ls_zz_log_callstack.
  READ TABLE lt_zz_log_callstack INTO ls_zz_log_callstack WITH KEY eventtype = 'FUNC'.
  IF lt_zz_log_callstack IS INITIAL.
    EXIT.
  ENDIF.

  SELECT *
    INTO CORRESPONDING FIELDS OF TABLE lt_zz_log_fupararef
    FROM fupararef
   WHERE funcname = ls_zz_log_callstack-eventname.

  LOOP AT lt_zz_log_fupararef INTO ls_zz_log_fupararef.
    CLEAR: ls_zz_log_data_save.
    ls_zz_log_data_save-func_name       = ls_zz_log_callstack-eventname. "函数名称
    ls_zz_log_data_save-func_paramtype  = ls_zz_log_fupararef-paramtype.
    ls_zz_log_data_save-func_parameter  = ls_zz_log_fupararef-parameter.
    ls_zz_log_data_save-func_structure  = ls_zz_log_fupararef-structure.
    ls_zz_log_data_save-func_defaultval = ls_zz_log_fupararef-defaultval.
    ls_zz_log_data_save-func_type       = ls_zz_log_fupararef-type.
    ls_zz_log_data_save-func_class      = ls_zz_log_fupararef-class.
    ls_zz_log_data_save-func_ref_class  = ls_zz_log_fupararef-ref_class.

    IF ls_zz_log_fupararef-paramtype NE 'T'.
      ASSIGN (ls_zz_log_fupararef-parameter) TO <fs_zz_log_variable>.
      IF <fs_zz_log_variable> IS ASSIGNED.
        IF <fs_zz_log_variable> IS NOT INITIAL OR ls_zz_log_fupararef-defaultval IS NOT INITIAL.
          lv_zz_log_string = /ui2/cl_json=>serialize( data = <fs_zz_log_variable> compress = abap_true pretty_name = abap_true ).
        ENDIF.
      ENDIF.
    ELSE.
      lv_zz_log_table_name = ls_zz_log_fupararef-parameter && '[]'.
      ASSIGN (lv_zz_log_table_name) TO <fs_zz_log_variable_tab>.
      IF <fs_zz_log_variable_tab> IS ASSIGNED.
        IF <fs_zz_log_variable_tab> IS NOT INITIAL.
          lv_zz_log_string = /ui2/cl_json=>serialize( data = <fs_zz_log_variable_tab> compress = abap_true pretty_name = abap_true ).
        ENDIF.
      ENDIF.
    ENDIF.

    WHILE strlen( lv_zz_log_string ) > 0.
      IF strlen( lv_zz_log_string ) >= 1024 .
        ls_zz_log_data_save-json_data = lv_zz_log_string.
        APPEND ls_zz_log_data_save TO lt_zz_log_data_save.
        SHIFT lv_zz_log_string BY 1024 PLACES.
      ELSE.
        ls_zz_log_data_save-json_data = lv_zz_log_string.
        APPEND ls_zz_log_data_save TO lt_zz_log_data_save.
        CLEAR: lv_zz_log_string.
      ENDIF.
    ENDWHILE.
  ENDLOOP.



  "赋值行项目
  LOOP AT lt_zz_log_data_save INTO ls_zz_log_data_save.
    ls_zz_log_data_save-id = lv_zz_log_id.
    ls_zz_log_data_save-canum = sy-tabix.
    MODIFY lt_zz_log_data_save FROM ls_zz_log_data_save.
  ENDLOOP.

  "把数据弄成异步提交模式保存,避免事务提交。
  CALL FUNCTION 'ZFUNC_SAVE' STARTING NEW TASK 'ZFUNC_END'
    TABLES
      data_e = lt_zz_log_data_save.


ENDIF.

模块池:ZFUNC

*&---------------------------------------------------------------------*
*& Modulpool ZFUNC
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
PROGRAM ZFUNC.

FORM update_status USING im_log_id TYPE zfunc_log_data-id
                         im_code TYPE msgty
                         im_txt TYPE msgtxt.
  IF im_log_id IS NOT INITIAL.

    "必须要调用 zfunc_begin 后才能调用该函数
    CALL FUNCTION 'ZFUNC_UPDATE_STATU' STARTING NEW TASK 'ZFUNC_LOG'
      EXPORTING
        i_id     = im_log_id
        i_msgty  = im_code
        i_msgtxt = im_txt.
  ENDIF.

ENDFORM.

接口测试方法:

FUNCTION ZFUC_TEST01.
*"----------------------------------------------------------------------
*"*"本地接口:
*"  IMPORTING
*"     REFERENCE(IV_01) TYPE  MATNR
*"     REFERENCE(I_BEDAT) TYPE  EKKO-BEDAT
*"     REFERENCE(I_DAT) TYPE  DATUM
*"     REFERENCE(I_LIKE) LIKE  EKKO-BEDAT
*"     REFERENCE(I_MARA) LIKE  MARA STRUCTURE  MARA
*"     REFERENCE(R_AKTIO) TYPE  RANGE_AKTIO_TAB
*"  TABLES
*"      IT_OUT STRUCTURE  MARA OPTIONAL
*"----------------------------------------------------------------------
INCLUDE zfunc_top.
INCLUDE zfunc_begin.



select
  * INTO TABLE IT_OUT
  FROM mara
  WHERE matnr = IV_01.


PERFORM update_status(ZFUNC) USING lv_zz_log_id 'S' '成功'.
INCLUDE zfunc_end.

ENDFUNCTION.

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/807070.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

手把手教你从0入门线段树~

1. 什么是线段树? 1.1 初探线段树 定义&#xff1a;线段树是一种用于解决区间查询问题的数据结构&#xff0c;是一种广义上的二叉搜索树。 原理&#xff1a;它将一个区间划分为多个较小的子区间&#xff0c;并为每个子区间存储一些有用的信息&#xff0c;例如最大值、最小值…

YOLOv5改进系列(16)——添加EMA注意力机制(ICASSP2023|实测涨点)

【YOLOv5改进系列】前期回顾: YOLOv5改进系列(0)——重要性能指标与训练结果评价及分析 YOLOv5改进系列(1)——添加SE注意力机制 YOLOv5改进系列(2)——添加

android stduio 打开工程后直接报Connection refused解决

报错如下:Connection refused 解决方案: 打开gradle-wrapper.properties修改distributionUrl 将: distributionUrlhttp\://localhost/gradle/distributions/gradle-6.5-bin.zip 替换为: distributionUrlhttps\://services.gradle.org/distributions/gradle-6.5-bin.zip 错…

<C语言> 文件操作

1 文件指针 缓冲文件系统中&#xff0c;关键的概念是“文件类型指针”&#xff0c;简称“文件指针”。 每个被使用的文件都在内存中开辟了一个相应的文件信息区&#xff0c;用来存放文件的相关信息&#xff08;如文件的名 字&#xff0c;文件状态及文件当前的位置等&#xff…

windows系统之WSL 安装 Ubuntu

WSL windows10 以上才有这个wsl功能 WSL&#xff1a; windows Subsystem for Linux 是应用于Windows系统之上的Linux子系统 作用很简单&#xff0c;可以在Windows系统中获取Linux系统环境&#xff0c;并完全直连计算机硬件&#xff0c;无需要通过虚拟机虚拟硬件 Windows10的W…

MD-MTSP:斑马优化算法ZOA求解多仓库多旅行商问题MATLAB(可更改数据集,旅行商的数量和起点)

一、斑马优化算法ZOA 斑马优化算法&#xff08;Zebra Optimization Algorithm&#xff0c;ZOA&#xff09;Eva Trojovsk等人于2022年提出&#xff0c;其模拟斑马的觅食和对捕食者攻击的防御行为。斑马优化算法&#xff08;Zebra Optimization Algorithm&#xff0c;ZOA&#x…

海外ASO优化之应用商店本地化

大多数应用可供世界任何地方的用户使用&#xff0c;所以需要以多种不同语言来展示我们的应用。它能够包含在跨地理区域的搜索结果中&#xff0c;从而提高全球可见性和转化率。 1、关键词的研究&#xff0c;对于确定流行的本地关键词至关重要。 在本地化Google Play的应用页面时…

RTPS规范v2.5(中文版)

实时发布订阅协议 DDS互操作性有线协议 &#xff08;DDSI-RTPS&#xff09; 技术规范 V2.5 &#xff08;2022-04-01正式发布&#xff09; https://www.omg.org/spec/DDSI-RTPS/2.5/PDF   目 录 1 范围 8 2 一致性 8 3 规范性参考文献 8 4 术语和定义 9 5 标识 …

HTML5前端开发工程师的岗位职责说明(合集)

HTML5前端开发工程师的岗位职责说明1 职责 1、根据产品设计文档和视觉文件&#xff0c;利用HTML5相关技术开发移动平台的web前端页面; 2、基于HTML5.0标准进行页面制作&#xff0c;编写可复用的用户界面组件; 3、持续的优化前端体验和页面响应速度&#xff0c;并保证兼容性和…

Godot 4 插件 - Utility AI 研究

今天看到一个视频教学 Godot4 | 实现简单AI | Utility AI 插件_哔哩哔哩_bilibili 就看了一下。吸引我的不是插件&#xff0c;是AI这两个字母。这AI与Godot怎么结合&#xff1f;感觉还是离线使用&#xff0c;值得一看。 视频时间不长&#xff0c;15分钟左右&#xff0c;看得…

无涯教程-jQuery - Highlight方法函数

Highlight 效果可以与effect()方法一起使用。这将以特定的颜色突出显示元素的背景&#xff0c;默认为黄色(yellow)。 Highlight - 语法 selector.effect( "highlight", {arguments}, speed ); 这是所有参数的描述- color - 高亮显示颜色。默认值为"#fff…

比memcpy还要快的内存拷贝,了解一下

前言 朋友们有想过居然还有比memcpy更快的内存拷贝吗&#xff1f; 讲道理&#xff0c;在这之前我没想到过&#xff0c;我也一直觉得memcpy就是最快的内存拷贝方法了。 也不知道老板最近是咋了&#xff0c;天天开会都强调&#xff1a;“我们最近的目标就一个字&#xff0c;性能优…

CompletableFuture生产中使用问题

CompletableFuture生产中使用问题 1 背景2 测试3 原因4. 总结 1 背景 接到一个任务,需要优化下单接口,查看完业务逻辑后发现有一些可以并行或异步查询的地方,于是采用CompletableFuture来做异步优化,提高接口响应速度,伪代码如下 //查询用户信息CompletableFuture<JSONObj…

认识 springboot 并了解它的创建过程 - 1

前言 本篇介绍什么是SpringBoot, SpringBoot项目如何创建&#xff0c;认识创建SpringBoot项目的目录&#xff0c;了解SpringBoo特点如有错误&#xff0c;请在评论区指正&#xff0c;让我们一起交流&#xff0c;共同进步&#xff01; 文章目录 前言1.什么是springboot?2.为什么…

投影仪离线语音识别芯片ic方案,高识别率识别IC,WTK6900H-B-24SS

随着智能科技的不断演进&#xff0c;人工智能已经深入到我们的生活中的方方面面。投影仪作为现代影音娱乐与商务展示的得力工具&#xff0c;为了进一步提升用户与产品的交互体验&#xff0c;深圳唯创知音最新推出WTK6900H-B-24SS离线语音识别芯片IC方案。这项创新技术使得投影仪…

入侵检测——恶意软件、病毒、防病毒、反病毒技术

目录 1. 什么是恶意软件&#xff1f; 2. 恶意软件有哪些特征&#xff1f; 3. 恶意软件的可分为那几类&#xff1f; 3.1.1按照传播方式分类&#xff1a; 3.1.2按照功能分类&#xff1a; 4. 恶意软件的免杀技术有哪些&#xff1f; 5. 反病毒技术有哪些&#xff1f; 5…

左神算法之中级提升(6)

目录 【案例1】 【题目描述】 【思路解析】 【代码实现】 【案例2】 【题目描述】 【思路解析】 【代码实现】 【案例3】 【题目描述】 【思路解析】 【代码实现】 【案例4】 【题目描述】 2018年美团面试题 【思路解析】 【代码实现】 【案例5】 【题目描述】 …

Service Mesh之Istio部署bookinfo

给istio部署插件 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 rootk8s-master01:/usr/local# cd istio rootk8s-master01:/usr/local/istio# ls samples/addons/ extras grafana.yaml jaeger.yaml kiali.yaml prometheus.yaml RE…

AMD技术泄露?CPU加密技术面临新的危机

许多AMD CPU中的破解加密、泄露密码的漏洞可能需要几个月才能修复。 “Zenbleed”漏洞影响了所有基于Zen 2架构的Ryzen、Threadripper和EPYC处理器。 技术泄露情况 谷歌零项目安全团队成员Tavis Ormandy称&#xff0c;许多AMD新一代消费级、工作站和服务器处理器最近被曝出漏…

招商银行秋招攻略和考试内容详解

招商银行秋招简介 招商银行是一家股份制商业银行&#xff0c;银行的服务理念已经深入人心&#xff0c;在社会竞争愈来愈烈的今天&#xff0c;招商银行的招牌无疑是个香饽饽&#xff0c;很多人也慕名而至&#xff0c;纷纷向招商银行投出了简历。那么秋招银行的秋招开始时间是多…