process-mining
2021.10
true
重要 :
请注意此内容已使用机器翻译进行了部分本地化。 新发布内容的本地化可能需要 1-2 周的时间才能完成。
UiPath logo, featuring letters U and I in white

Process Mining

Automation CloudAutomation Cloud Public SectorAutomation SuiteStandalone
上次更新日期 2024年12月20日

在 SAP 系统上安装 Z_XTRACT_IS_TABLE 功能模块

简介

要使用 UiPath Process Mining中的原生 SAP 提取,您必须将 Z_XTRACT_IS_TABLE函数模块添加到 SAP 系统。
注意:设置本机 SAP 提取时,需要 SAP Z_XTRACT_IS_TABLE 函数模块。例如,如果在 SAP 系统中重命名了此函数模块,则可以在 SAP 连接字符串的 FunctionModule 参数(可选)中指定正确的名称。

先决条件

为了能够在 SAP 系统上安装自定义功能模块,您必须拥有 SAP 用户的凭据和开发密钥。

添加新功能组

注意: 建议添加新的功能组以添加功能模块。

请按照以下步骤添加新的函数组。

步骤

操作

1

打开 SAP GUI。

2

在左上角的命令字段中输入SE37

3

转到“ 转到 ”菜单,然后选择“ 函数组” ->“创建组”。

4

输入“函数”组的名称。

注意: 名称必须以Z开头,例如Z_PM_DATA_EXTRACTION

5

在“ 短文本 ” 字段中输入函数组的说明,例如 ProcessMining Data Extraction

6

单击“保存”

激活功能组

请按照以下步骤激活“函数”组。

步骤

操作

1

选择 “功能组”

2

搜索您创建的函数组,例如PM_DATA_EXTRACTION

3

右键单击“函数”组的顶部对象, 然后从上下文菜单中选择“激活 ”。

添加功能模块

创建函数组后,您可以从 SE37 GUI 窗口添加函数模块。

请按照以下步骤安装 Z_XTRACT_IS_TABLE 函数模块。

步骤

操作

1

在“ 函数模块 ” 字段中输入Z_XTRACT_IS_TABLE ,然后单击“ 创建”。

2

转到“ 属性 ” 选项卡,然后在“ 处理类型 ” 选项列表中选择“远程启用的模块” 选项。

3

转到“ 导入 ” 选项卡并定义导入参数,如下所示。

注意: 您可能会收到LIKE运算符已过时的警告。 您可以忽略警告并浏览列表。 单击“ENTER”以确认您仍要使用它。 浏览整个列表后,系统将接受该代码。

4

转到“ 表格 ” 选项卡并定义表格参数,如下所示。

注意: 您可能会收到LIKE运算符已过时的警告。 您可以忽略警告并浏览列表。 单击“ENTER”以确认您仍要使用它。 浏览整个列表后,系统将接受该代码。

5

转到“ 异常 ” 选项卡以定义异常,如下所示。

6

转到“ 源代码 ” 选项卡,然后输入Z_XTRACT_IS_TABLEABAP代码。
注意: 您可以复制并粘贴下面显示的代码。

7

保存“函数”模块并将其激活。

导入参数

有关要在“ 导入 ” 选项卡中定义的导入参数的概述,请参见下图。



表格参数

有关要在“表格”选项卡中定义的表格参数的概述,请参见下图。



异常

有关要在“异常” 选项卡中定义的 异常 的概述,请参见下图。



ABAP 代码

有关要粘贴到“ 源代码 ” 选项卡中的 ABAP 代码,请参见下面的代码文本。

FUNCTION Z_XTRACT_IS_TABLE.
*"
*"*"Lokale Schnittstelle:
*"  IMPORTING
*"     VALUE(QUERY_TABLE) LIKE  DD02L-TABNAME
*"     VALUE(DELIMITER) LIKE  SONV-FLAG DEFAULT SPACE
*"     VALUE(NO_DATA) LIKE  SONV-FLAG DEFAULT SPACE
*"    VALUE(ROWSKIPS) LIKE  SOID-ACCNT DEFAULT 0
*"     VALUE(ROWCOUNT) LIKE  SOID-ACCNT DEFAULT 0
*"  TABLES
*"      OPTIONS STRUCTURE  RFC_DB_OPT
*"      FIELDS STRUCTURE  RFC_DB_FLD
*"     DATA STRUCTURE  CHAR8000
*"  EXCEPTIONS
*"      TABLE_NOT_AVAILABLE
*"      TABLE_WITHOUT_DATA
*"     OPTION_NOT_VALID
*"     FIELD_NOT_VALID
*"     NOT_AUTHORIZED
*"      DATA_BUFFER_EXCEEDED
*"-------------------------------------------
"
CALL FUNCTION 'VIEW_AUTHORITY_CHECK'
     EXPORTING
          VIEW_ACTION                    = 'S'
          VIEW_NAME                      = QUERY_TABLE
     EXCEPTIONS
          NO_AUTHORITY                   = 2
          NO_CLIENTINDEPENDENT_AUTHORITY = 2
          NO_LINEDEPENDENT_AUTHORITY     = 2
          OTHERS                         = 1.
IF SY-SUBRC = 2.
  RAISE NOT_AUTHORIZED.
ELSEIF SY-SUBRC = 1.
  RAISE TABLE_NOT_AVAILABLE.
ENDIF.
* -------------------------------------------- 
*  find out about the structure of QUERY_TABLE
* --------------------------------------------
DATA BEGIN OF TABLE_STRUCTURE OCCURS 10.
        INCLUDE STRUCTURE DFIES.
DATA END OF TABLE_STRUCTURE.
"DATA TABLE_HEADER LIKE X030L.
DATA TABLE_TYPE TYPE DD02V-TABCLASS.
CALL FUNCTION 'DDIF_FIELDINFO_GET'
  EXPORTING
    TABNAME              = QUERY_TABLE
*   FIELDNAME            = ' '
*   LANGU                = SY-LANGU
*   LFIELDNAME           = ' '
*   ALL_TYPES            = ' '
*   GROUP_NAMES          = ' '
  IMPORTING
*   X030L_WA             =
    DDOBJTYPE            = TABLE_TYPE
*   DFIES_WA             =
*   LINES_DESCR          =
  TABLES
    DFIES_TAB            = TABLE_STRUCTURE
*   FIXED_VALUES         =
  EXCEPTIONS
    NOT_FOUND            = 1
    INTERNAL_ERROR       = 2
    OTHERS               = 3
          .
IF SY-SUBRC <> 0.
  RAISE TABLE_NOT_AVAILABLE.
ENDIF.
IF TABLE_TYPE = 'INTTAB'.
  RAISE TABLE_WITHOUT_DATA.
ENDIF.
* -------------------------------------------
*  isolate first field of DATA as output field
*  (i.e. allow for changes to structure DATA!)
* -------------------------------------------
DATA LINE_LENGTH TYPE I.
FIELD-SYMBOLS <D>.
ASSIGN COMPONENT 0 OF STRUCTURE DATA TO <D>.
* If this line leads to a syntax error
* please just delete the 'in character mode'
DESCRIBE FIELD <D> LENGTH LINE_LENGTH in character mode.
* -------------------------------------------
*  if FIELDS are not specified, read all available fields
* -------------------------------------------
DATA NUMBER_OF_FIELDS TYPE I.
DESCRIBE TABLE FIELDS LINES NUMBER_OF_FIELDS.
IF NUMBER_OF_FIELDS = 0.
  LOOP AT TABLE_STRUCTURE.
    MOVE TABLE_STRUCTURE-FIELDNAME TO FIELDS-FIELDNAME.
    APPEND FIELDS.
  ENDLOOP.
ENDIF.
* -------------------------------------------
*  for each field which has to be read, copy structure information
*  into tables FIELDS_INT (internal use) and FIELDS (output)
* -------------------------------------------
DATA: BEGIN OF FIELDS_INT OCCURS 10,
        FIELDNAME  LIKE TABLE_STRUCTURE-FIELDNAME,
        TYPE       LIKE TABLE_STRUCTURE-INTTYPE,
        DECIMALS   LIKE TABLE_STRUCTURE-DECIMALS,
        LENGTH_SRC LIKE TABLE_STRUCTURE-INTLEN,
        LENGTH_DST LIKE TABLE_STRUCTURE-LENG,
        OFFSET_SRC LIKE TABLE_STRUCTURE-OFFSET,
        OFFSET_DST LIKE TABLE_STRUCTURE-OFFSET,
      END OF FIELDS_INT,
      LINE_CURSOR TYPE I.
LINE_CURSOR = 0.
*  for each field which has to be read ...
LOOP AT FIELDS.
  READ TABLE TABLE_STRUCTURE WITH KEY FIELDNAME = FIELDS-FIELDNAME.
  IF SY-SUBRC NE 0.
    RAISE FIELD_NOT_VALID.
  ENDIF.
* compute the place for field contents in DATA rows:
* if not first field in row, allow space for delimiter
  IF LINE_CURSOR <> 0.
    IF NO_DATA EQ SPACE AND DELIMITER NE SPACE.
      MOVE DELIMITER TO DATA+LINE_CURSOR.
    ENDIF.
    LINE_CURSOR = LINE_CURSOR + STRLEN( DELIMITER ).
  ENDIF.
* ... copy structure information into tables FIELDS_INT
* (which is used internally during SELECT) ...
  FIELDS_INT-FIELDNAME  = TABLE_STRUCTURE-FIELDNAME.
  FIELDS_INT-LENGTH_SRC = TABLE_STRUCTURE-INTLEN.
*  FIELDS_INT-LENGTH_DST = TABLE_STRUCTURE-LENG.
* modified by Theobald, 2007-11-20
  FIELDS_INT-LENGTH_DST = TABLE_STRUCTURE-OUTPUTLEN.
  FIELDS_INT-OFFSET_SRC = TABLE_STRUCTURE-OFFSET.
  FIELDS_INT-OFFSET_DST = LINE_CURSOR.
  FIELDS_INT-TYPE       = TABLE_STRUCTURE-INTTYPE.
  FIELDS_INT-DECIMALS   = TABLE_STRUCTURE-DECIMALS.
* compute the place for contents of next field in DATA rows
*  LINE_CURSOR = LINE_CURSOR + TABLE_STRUCTURE-LENG.
* modified by Theobald, 2007-11-20
LINE_CURSOR = LINE_CURSOR + TABLE_STRUCTURE-OUTPUTLEN.
  IF LINE_CURSOR > LINE_LENGTH AND NO_DATA EQ SPACE.
    RAISE DATA_BUFFER_EXCEEDED.
  ENDIF.
  APPEND FIELDS_INT.
* ... and into table FIELDS (which is output to the caller)
  FIELDS-FIELDTEXT = TABLE_STRUCTURE-FIELDTEXT.
  FIELDS-TYPE      = TABLE_STRUCTURE-INTTYPE.
  FIELDS-LENGTH    = FIELDS_INT-LENGTH_DST.
  FIELDS-OFFSET    = FIELDS_INT-OFFSET_DST.
  MODIFY FIELDS.
ENDLOOP.
* end of loop at FIELDS
* -------------------------------------------
*  read data from the database and copy relevant portions into DATA
* -------------------------------------------
* output data only if NO_DATA equals space (otherwise the structure
* information in FIELDS is the only result of the module)
IF NO_DATA EQ SPACE.
DATA: BEGIN OF WORK, BUFFER(30000), F TYPE F, END OF WORK.
FIELD-SYMBOLS: <WA> TYPE ANY, <COMP> TYPE ANY.
ASSIGN WORK TO <WA> CASTING TYPE (QUERY_TABLE).
IF ROWCOUNT > 0.
  ROWCOUNT = ROWCOUNT + ROWSKIPS.
ENDIF.
  SELECT * FROM (QUERY_TABLE) INTO <WA> WHERE (OPTIONS).
    IF SY-DBCNT GT ROWSKIPS.
*   copy all relevant fields into DATA (output) table
      LOOP AT FIELDS_INT.
        IF FIELDS_INT-TYPE = 'P'.
        ASSIGN COMPONENT FIELDS_INT-FIELDNAME
            OF STRUCTURE <WA> TO <COMP>
            TYPE     FIELDS_INT-TYPE
            DECIMALS FIELDS_INT-DECIMALS.
        ELSE.
        ASSIGN COMPONENT FIELDS_INT-FIELDNAME
            OF STRUCTURE <WA> TO <COMP>
            TYPE     FIELDS_INT-TYPE.
        ENDIF.
        MOVE <COMP> TO
            <D>+FIELDS_INT-OFFSET_DST(FIELDS_INT-LENGTH_DST).
      ENDLOOP.
*   end of loop at FIELDS_INT
      APPEND DATA.
      IF ROWCOUNT > 0 AND SY-DBCNT GE ROWCOUNT. EXIT. ENDIF.
    ENDIF.
  ENDSELECT.
ENDIF.
ENDFUNCTION.FUNCTION Z_XTRACT_IS_TABLE.
*"
*"*"Lokale Schnittstelle:
*"  IMPORTING
*"     VALUE(QUERY_TABLE) LIKE  DD02L-TABNAME
*"     VALUE(DELIMITER) LIKE  SONV-FLAG DEFAULT SPACE
*"     VALUE(NO_DATA) LIKE  SONV-FLAG DEFAULT SPACE
*"    VALUE(ROWSKIPS) LIKE  SOID-ACCNT DEFAULT 0
*"     VALUE(ROWCOUNT) LIKE  SOID-ACCNT DEFAULT 0
*"  TABLES
*"      OPTIONS STRUCTURE  RFC_DB_OPT
*"      FIELDS STRUCTURE  RFC_DB_FLD
*"     DATA STRUCTURE  CHAR8000
*"  EXCEPTIONS
*"      TABLE_NOT_AVAILABLE
*"      TABLE_WITHOUT_DATA
*"     OPTION_NOT_VALID
*"     FIELD_NOT_VALID
*"     NOT_AUTHORIZED
*"      DATA_BUFFER_EXCEEDED
*"-------------------------------------------
"
CALL FUNCTION 'VIEW_AUTHORITY_CHECK'
     EXPORTING
          VIEW_ACTION                    = 'S'
          VIEW_NAME                      = QUERY_TABLE
     EXCEPTIONS
          NO_AUTHORITY                   = 2
          NO_CLIENTINDEPENDENT_AUTHORITY = 2
          NO_LINEDEPENDENT_AUTHORITY     = 2
          OTHERS                         = 1.
IF SY-SUBRC = 2.
  RAISE NOT_AUTHORIZED.
ELSEIF SY-SUBRC = 1.
  RAISE TABLE_NOT_AVAILABLE.
ENDIF.
* -------------------------------------------- 
*  find out about the structure of QUERY_TABLE
* --------------------------------------------
DATA BEGIN OF TABLE_STRUCTURE OCCURS 10.
        INCLUDE STRUCTURE DFIES.
DATA END OF TABLE_STRUCTURE.
"DATA TABLE_HEADER LIKE X030L.
DATA TABLE_TYPE TYPE DD02V-TABCLASS.
CALL FUNCTION 'DDIF_FIELDINFO_GET'
  EXPORTING
    TABNAME              = QUERY_TABLE
*   FIELDNAME            = ' '
*   LANGU                = SY-LANGU
*   LFIELDNAME           = ' '
*   ALL_TYPES            = ' '
*   GROUP_NAMES          = ' '
  IMPORTING
*   X030L_WA             =
    DDOBJTYPE            = TABLE_TYPE
*   DFIES_WA             =
*   LINES_DESCR          =
  TABLES
    DFIES_TAB            = TABLE_STRUCTURE
*   FIXED_VALUES         =
  EXCEPTIONS
    NOT_FOUND            = 1
    INTERNAL_ERROR       = 2
    OTHERS               = 3
          .
IF SY-SUBRC <> 0.
  RAISE TABLE_NOT_AVAILABLE.
ENDIF.
IF TABLE_TYPE = 'INTTAB'.
  RAISE TABLE_WITHOUT_DATA.
ENDIF.
* -------------------------------------------
*  isolate first field of DATA as output field
*  (i.e. allow for changes to structure DATA!)
* -------------------------------------------
DATA LINE_LENGTH TYPE I.
FIELD-SYMBOLS <D>.
ASSIGN COMPONENT 0 OF STRUCTURE DATA TO <D>.
* If this line leads to a syntax error
* please just delete the 'in character mode'
DESCRIBE FIELD <D> LENGTH LINE_LENGTH in character mode.
* -------------------------------------------
*  if FIELDS are not specified, read all available fields
* -------------------------------------------
DATA NUMBER_OF_FIELDS TYPE I.
DESCRIBE TABLE FIELDS LINES NUMBER_OF_FIELDS.
IF NUMBER_OF_FIELDS = 0.
  LOOP AT TABLE_STRUCTURE.
    MOVE TABLE_STRUCTURE-FIELDNAME TO FIELDS-FIELDNAME.
    APPEND FIELDS.
  ENDLOOP.
ENDIF.
* -------------------------------------------
*  for each field which has to be read, copy structure information
*  into tables FIELDS_INT (internal use) and FIELDS (output)
* -------------------------------------------
DATA: BEGIN OF FIELDS_INT OCCURS 10,
        FIELDNAME  LIKE TABLE_STRUCTURE-FIELDNAME,
        TYPE       LIKE TABLE_STRUCTURE-INTTYPE,
        DECIMALS   LIKE TABLE_STRUCTURE-DECIMALS,
        LENGTH_SRC LIKE TABLE_STRUCTURE-INTLEN,
        LENGTH_DST LIKE TABLE_STRUCTURE-LENG,
        OFFSET_SRC LIKE TABLE_STRUCTURE-OFFSET,
        OFFSET_DST LIKE TABLE_STRUCTURE-OFFSET,
      END OF FIELDS_INT,
      LINE_CURSOR TYPE I.
LINE_CURSOR = 0.
*  for each field which has to be read ...
LOOP AT FIELDS.
  READ TABLE TABLE_STRUCTURE WITH KEY FIELDNAME = FIELDS-FIELDNAME.
  IF SY-SUBRC NE 0.
    RAISE FIELD_NOT_VALID.
  ENDIF.
* compute the place for field contents in DATA rows:
* if not first field in row, allow space for delimiter
  IF LINE_CURSOR <> 0.
    IF NO_DATA EQ SPACE AND DELIMITER NE SPACE.
      MOVE DELIMITER TO DATA+LINE_CURSOR.
    ENDIF.
    LINE_CURSOR = LINE_CURSOR + STRLEN( DELIMITER ).
  ENDIF.
* ... copy structure information into tables FIELDS_INT
* (which is used internally during SELECT) ...
  FIELDS_INT-FIELDNAME  = TABLE_STRUCTURE-FIELDNAME.
  FIELDS_INT-LENGTH_SRC = TABLE_STRUCTURE-INTLEN.
*  FIELDS_INT-LENGTH_DST = TABLE_STRUCTURE-LENG.
* modified by Theobald, 2007-11-20
  FIELDS_INT-LENGTH_DST = TABLE_STRUCTURE-OUTPUTLEN.
  FIELDS_INT-OFFSET_SRC = TABLE_STRUCTURE-OFFSET.
  FIELDS_INT-OFFSET_DST = LINE_CURSOR.
  FIELDS_INT-TYPE       = TABLE_STRUCTURE-INTTYPE.
  FIELDS_INT-DECIMALS   = TABLE_STRUCTURE-DECIMALS.
* compute the place for contents of next field in DATA rows
*  LINE_CURSOR = LINE_CURSOR + TABLE_STRUCTURE-LENG.
* modified by Theobald, 2007-11-20
LINE_CURSOR = LINE_CURSOR + TABLE_STRUCTURE-OUTPUTLEN.
  IF LINE_CURSOR > LINE_LENGTH AND NO_DATA EQ SPACE.
    RAISE DATA_BUFFER_EXCEEDED.
  ENDIF.
  APPEND FIELDS_INT.
* ... and into table FIELDS (which is output to the caller)
  FIELDS-FIELDTEXT = TABLE_STRUCTURE-FIELDTEXT.
  FIELDS-TYPE      = TABLE_STRUCTURE-INTTYPE.
  FIELDS-LENGTH    = FIELDS_INT-LENGTH_DST.
  FIELDS-OFFSET    = FIELDS_INT-OFFSET_DST.
  MODIFY FIELDS.
ENDLOOP.
* end of loop at FIELDS
* -------------------------------------------
*  read data from the database and copy relevant portions into DATA
* -------------------------------------------
* output data only if NO_DATA equals space (otherwise the structure
* information in FIELDS is the only result of the module)
IF NO_DATA EQ SPACE.
DATA: BEGIN OF WORK, BUFFER(30000), F TYPE F, END OF WORK.
FIELD-SYMBOLS: <WA> TYPE ANY, <COMP> TYPE ANY.
ASSIGN WORK TO <WA> CASTING TYPE (QUERY_TABLE).
IF ROWCOUNT > 0.
  ROWCOUNT = ROWCOUNT + ROWSKIPS.
ENDIF.
  SELECT * FROM (QUERY_TABLE) INTO <WA> WHERE (OPTIONS).
    IF SY-DBCNT GT ROWSKIPS.
*   copy all relevant fields into DATA (output) table
      LOOP AT FIELDS_INT.
        IF FIELDS_INT-TYPE = 'P'.
        ASSIGN COMPONENT FIELDS_INT-FIELDNAME
            OF STRUCTURE <WA> TO <COMP>
            TYPE     FIELDS_INT-TYPE
            DECIMALS FIELDS_INT-DECIMALS.
        ELSE.
        ASSIGN COMPONENT FIELDS_INT-FIELDNAME
            OF STRUCTURE <WA> TO <COMP>
            TYPE     FIELDS_INT-TYPE.
        ENDIF.
        MOVE <COMP> TO
            <D>+FIELDS_INT-OFFSET_DST(FIELDS_INT-LENGTH_DST).
      ENDLOOP.
*   end of loop at FIELDS_INT
      APPEND DATA.
      IF ROWCOUNT > 0 AND SY-DBCNT GE ROWCOUNT. EXIT. ENDIF.
    ENDIF.
  ENDSELECT.
ENDIF.
ENDFUNCTION.

检查并激活功能模块

粘贴 ABAP 代码后,建议在激活函数模块之前检查代码是否存在语法错误。

检查功能模块

请按照此步骤检查 ABAP 代码。

步骤

操作

1

在“SAP 源代码 ” 选项卡中按CTRL+F2

如果没有错误,则可以激活功能模块。

激活功能模块

请按照以下步骤激活功能模块。

步骤

操作

1

在左上角的命令字段中输入SE80

2

选择 “功能模块”

3

搜索Z_XTRACT_IS_TABLE

4

右键单击 Z_XTRACT_IS_TABLE 的顶部对象,然后从上下文菜单中选择“激活”。

从 UiPath Process Mining 连接到 SAP 数据源

此时,可以使用原生 SAP 连接从 SAP 系统提取数据。 您可以使用 SAP 连接字符串表创建新的输入表并定义查询以提取数据,从而连接到 SAP 数据源。 请参见下图。



此页面有帮助吗?

获取您需要的帮助
了解 RPA - 自动化课程
UiPath Community 论坛
Uipath Logo White
信任与安全
© 2005-2024 UiPath。保留所有权利。