ABAP Help Document(29):14 Data Interface and Comunication Interfaces

14.Data Interfaces and Conmunication Interfaces

          ABAP提供与其他系统交互的数据接口。

14.1Remote Function Call(RFC)

          ABAP提供的调用远程系统功能的接口。

语法:

1. CALL FUNCTION func DESTINATION dest parameter_list.

parameter_list:

[EXPORTING  p1 = a1 p2 = a2 ...]
[IMPORTING  p1 = a1 p2 = a2 ...]
[TABLES     t1 = itab1 t2 = itab2 ...]
[CHANGING   p1 = a1 p2 = a2 ...]
[EXCEPTIONS [exc1 = n1 exc2 = n2 ...]
 [system_failure = ns [MESSAGE smess]]
[communication_failure = nc [MESSAGE cmess]]
[OTHERS = n_others]].

Synchronous RFC,同步RFC。

2. CALL FUNCTION func STARTING NEW TASK task

                [DESTINATION {dest|{IN GROUP {group|DEFAULT}}}]

                [{PERFORMING subr}|{CALLING meth} ON END OF TASK]

                parameter_list.

parameter_list:

[EXPORTING  p1 = a1 p2 = a2 ...]
[TABLES     t1 = itab1 t2 = itab2 ...]
[CHANGING   p1 = a1 p2 = a2 ...]
[EXCEPTIONS [exc1 = n1 exc2 = n2 ...]
[system_failure = ns [MESSAGE smess]]
[communication_failure = nc [MESSAGE cmess]]
[resource_failure      = nr [MESSAGE rmess]]
[OTHERS = n_others]].

Asynchronous RFC,异步RFC。

异步调用的一下显示配置参数:

profile parameter:

rdisp/rfc_min_wait_dia_wp:Number of available dialog work processes: 1;

rdisp/rfc_max_own_used_wp:Percentage of user-specific dialog work processes: 75% ;

rdisp/rfc_max_queue: Percentage of waiting requests in dialog queue: 5%;

rdisp/rfc_max_login: Percentage of logons to the system: 90%;

rdisp/rfc_max_own_login: Percentage of own logons to system: 25%;

rdisp/rfc_max_comm_entries: Percentage of used communication entries: 90%;

语法:

RECEIVE RESULTS FROM FUNCTION func

                [KEEPING TASK]

                parameter_list.

parameter_list:

[IMPORTING  p1 = a1 p2 = a2 ...]
[TABLES     t1 = itab1 t2 = itab2 ...]
 [CHANGING   p1 = a1 p2 = a2 ...]
[EXCEPTIONS [exc1 = n1 exc2 = n2 ...]
[system_failure = ns [MESSAGE smess]]
[communication_failure = nc [MESSAGE cmess]]
[OTHERS = n_others]].

通过RECEIVE获取异步function返回的结果。

语法:

WAIT UNTIL log_exp [UP TO sec SECONDS].

等待一段时间,执行之后语句。

3. CALL FUNCTION func IN BACKGROUND UNIT parameter_list.

Background RFC,后台RFC。

语法:CALL FUNCTION func IN BACKGROUND UNIT oref  parameter_list.

parameter_list:

EXPORTING  p1 = a1 p2 = a2 ... ]
[TABLES     t1 = itab1 t2 = itab2 ...]

oref为实现了接口IF_BGRFC_UNIT的类实例;

4. CALL FUNCTION func IN BACKGROUND TASK

                     [AS SEPARATE UNIT]

                     [DESTINATION dest]

                     parameter_list.

Transactional RFC ,推荐使用Background RFC。

          ABAP使用Tcode:SM59管理RFC Destination;

       RFC Function Exception: SYSTEM_FAILURE、COMMUNICATION_FAILURE、RESOURCE_FAILURE;

          RFC权限检查:profile parameter:auth/rfc_authority_check,配置为1,自动检查RFC权限;

       RFC Trust Relationships,使用Tcode:SMT1,配置受信任系统;

示例:DEMO_PARALLEL_RFC。

14.2 ABAP and XML

          Transformation Editor:使用Tcode:STRANS,编辑transformation程序。

1.ST

Simple Transformations(ST):描述ABAP数据到XML格式转换;

ST Command命令:

ST Command

Meaning

<tt:apply ...>

Callss a subtemplate

<tt:assign ...>

Assigns a value to data

<tt:attribute ...>

Non-literal attribute

<tt:call ...>

Call an ST program

<tt:call-method ...>

Calls a static method or an instance method in ABAP Objects

<tt:cast ...>

Down casts reference variables

<tt:clear ...>

Initializes data

<tt:cond ...>

Conditional transformation

<tt:cond-var ...>

Condition for variables

<tt:context ...>

Context for local data roots in subtemplates

<tt:copy ...>

Transformation to and from asXML

<tt:create-object ...>

Creates objects in ABAP Objects

<tt:d-cond ...>

Conditional transformation for deserializations

<tt:deserialize ...>

Defines the transformation direction

<tt:empty ...>

Empty pattern

<... tt:extensible="..."...>

Extensibility of literal XML elements

<tt:front ...>

Initial part of a structured type

<tt:group ...>

Groups conditional transformations

<tt:include ...>

Includes an ST program

<... tt:lax="..." ...>

Compares names of literal XML elements

<tt:loop ...>

Loops across internal tables

<tt:namespace ...>

Defines a namespace

<tt:node ...>

Component of a type

<tt:parameter ...>

Declares parameters

<tt:read ...>

Reads a variable from XML

<tt:ref ...>

Sets the current node

<... tt:ref="..."...>

Sets the current node for a literal XML element

<tt:root ...>

Declares a data root

<tt:serialize ...>

Defines the transformation direction

<tt:s-cond ...>

Conditional transformation for serializations

<tt:skip ...>

SkipsXML elements in deserializations

<tt:switch ...>

Defines a case distinction between conditional transformations.

<tt:switch-var ...>

Case distinctions for variables

<tt:template ...>

Main template or subtemplates

<tt:text ...>

Literal Text

<tt:transform ...>

Root element of an ST program

<tt:type ...>

Type definition

<tt:value ...>

Transforms elementary data objects and structures

<... tt:value-ref ="..." ...>

Short form of the transformation of elementary data objects

<tt:variable ...>

Declares a variable

<tt:with-parameter ...>

Passes a value to ST programs, subtemplates, and ABAP methods

<tt:with-root ...>

Passes data to ST programs and subtemplates

<tt:write ...>

Writes a variable to XML

Namespaces:

1.http://www.sap.com/abapxml/types/dictionary describes the ABAP Dictionary.

2.http://www.sap.com/abapxml/types/type-pool/name describes the type group name.

3.http://www.sap.com/abapxml/types/class-pool/class describes the global class class.

4.http://www.sap.com/abapxml/types/defined/name describes the type that is defined in the current ST program using tt:type.

定义Root节点

<tt:transform [template="tmpl"]>
</tt:transform>

定义Type节点

<tt:type name="..." [[line-]type="..." [length="..."] [decimals="..."]]
  [extensible=extensible_flag]>

</tt:type>

ABAP数据类型:C, D, F, I, N, P, STRING, T, X or XSTRING;

定义数据

1.tt:root defines data roots for ABAP data interfaces.

2.tt:parameter defines parameters as formal parameters.

3.tt:variable defines variables as local data.

语法:

<tt:root name="..." [[line-]type="..." [length="..."] [decimals="..."]]  [...] />

<tt:parameter name="..." [ref-type="..."] [kind="..."] [[s-val="..."][d-val="..."]]|[val="..."] />

kind:in输入参数;out输出参数;in/out输入输出参数;

s-val,在串行化时有效;d-val,反串行化时有效;val,串行化反串行化都生效;

<tt:variable name="..." [ref-type="..."] [[s-val="..."][d-val="..."]]|[val="..."] />

定义模板

<tt:template [name="tmpl"]>  </tt:template>

定义引用

<tt:... ref="node">   ...  </tt:...>

14.3 ABAP and OLE

语法:

CREATE OBJECT ole class [NO FLUSH] [QUEUE-ONLY].

type group: OLE2;

权限检查Function: AUTHORITY_CHECK_OLE;

语法:

CALL METHOD OF ole meth [= rc]
               [EXPORTING p1 = f1 p2 = f2 ...]
               [NO FLUSH] [QUEUE-ONLY].

语法:

GET PROPERTY OF ole attr = dobj [NO FLUSH] [QUEUE-ONLY]   [EXPORTING p1 = f1 p2 = f2 ...].

语法:

SET PROPERTY OF ole attr = dobj [NO FLUSH]  [EXPORTING p1 = f1 p2 = f2 ...].

语法:

FREE OBJECT ole [NO FLUSH].

可以使用ole2方式生成excel。

14.4 UUIDS

       使用类CL_SYSTEM_UUID获取UUID。

示例:

FORM f_get_uuid.
  DATA:lo_system_uuid TYPE REF TO if_system_uuid.
  DATA:lv_uuid TYPE sysuuid_c32.
  "创建类对象
  lo_system_uuid = cl_uuid_factory=>create_system_uuid( ).
  TRY.
      lv_uuid = lo_system_uuid->create_uuid_c32( ).
      WRITE:/ lv_uuid.
  CATCH cx_uuid_error.
  ENDTRY.
ENDFORM.
原文地址:https://www.cnblogs.com/tangToms/p/14697297.html