238
SAP AG 2006 %&5HPRWH)XQFWLRQ&DOOVLQ$%$3 © SAP AG 2007 %& 5HPRWH)XQFWLRQ&DOOVLQ$%$3 System R/3 Collection 62 Materialnummer 50086522

BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

Embed Size (px)

Citation preview

Page 1: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

SAP AG 2006

%&����5HPRWH�)XQFWLRQ�&DOOV�LQ�$%$3

������������ ������������� ����������������������

© SAP AG 2007

%&���5HPRWH�)XQFWLRQ�&DOOV�LQ�$%$3

� System R/3

� Collection 62

� Materialnummer 50086522

Page 2: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP
Page 3: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

SAP AG 2006

&RS\ULJKW������6$3�$*��$OO�ULJKWV�UHVHUYHG�

1R�SDUW�RI�WKLV�SXEOLFDWLRQ�PD\�EH�UHSURGXFHG�RU�WUDQVPLWWHG�LQ�DQ\�IRUP�RU�IRU�DQ\�SXUSRVH�ZLWKRXW�!WKH�H[SUHVV�SHUPLVVLRQ�RI�6$3�$*��7KH�LQIRUPDWLRQ�FRQWDLQHG�KHUHLQ�PD\�EH�FKDQJHG�ZLWKRXW�SULRU�QRWLFH��

&RS\ULJKW

� Some software products marketed by SAP AG and its distributors may contain proprietary software

components of other software manufacturers. �

Microsoft, Windows, Outlook and PowerPoint are registered trademarks of Microsoft Corporation. �

IBM, DB2, DB2 Universal Database, OS/2, Parallel Sysplex, MVS/ESA, AIX, S/390, AS/400, OS/390, OS/400, iSeries, pSeries, xSeries, zSeries, z/OS, AFP, Intelligent Miner, WebSphere, Netfinity, Tivoli and Informix are trademarks or registered trademarks of IBM Corporation in the USA and/or in other countries.

� Oracle is a registered trademark of Oracle Corporation.

� UNIX, X/Open, OSF/1 and Motif are registered trademarks of the Open Group.

� Citrix, ICA, Program Neighborhood, MetaFrame, WinFrame, VideoFrame and MultiWin are trademarks or

registered trademarks of Citrix Systems, Inc.

Page 4: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

� HTML, XML, XHTML and W3C are trademarks or registered trademarks of W3C®, World Wide Web

Consortium, Massachusetts Institute of Technology. �

Java is a registered trademark of Sun Microsystems, Inc. �

JavaScript is a registered trademark of Sun Microsystems, Inc., used under license for technology invented and implemented by Netscape.

� MaxDB is a trademark of MySQL AB, Sweden.

� SAP, R/3, mySAP, mySAP.com, xApps, xApp and other SAP products and services mentioned

herein as well as their respective logos are trademarks or registered trademarks of SAP AG in Germany and in other countries around the world. All other product and service names are trademarks of their respective companies. The information provided herein is non-binding and is intended for information purposes only. Products may have country-specific variations.

� The information contained herein may be changed without prior notice. These materials are provided by SAP

AG and its affiliated companies ("SAP Group") for informational purposes only. The SAP Group does not assume any liability or provide guarantees for errors or incompleteness in this publication. The SAP Group is solely responsible for products and services according to requirements explicitly defined in the agreement regarding the respective products and services. No further liability is assumed as a result of the information contained in this publication.

Page 5: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

SAP AG 2002

3UHUHTXLVLWHV

z 6$37(& WUDLQLQJ�FRXUVH

z %&��� WUDLQLQJ�FRXUVHz %&��� WUDLQLQJ�FRXUVH �KLJKO\�UHFRPPHQGHG�DV�

SUHSDUDWLRQ�IRU�UHPRWH�GDWDEDVH�FKDQJHV�

Page 6: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

SAP AG 2002

7DUJHW�$XGLHQFH

z 3DUWLFLSDQWV� $%$3 GHYHORSHUV�LQYROYHG LQ FURVV�V\VWHPFRPPXQLFDWLRQ�WKURXJK 5)& IURP�WKH5���6\VWHP

z 'XUDWLRQ� ��GD\V

1RWHV�WR�WKH�SDUWLFLSDQW � The training materials are QRW�VHOI�WHDFK�SURJUDPV��They�FRPSOHPHQW�WKH�FRXUVH�LQVWUXFWRUV�

H[SODQDWLRQV��On the sheets, there is space for you to write down additional information.

Page 7: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 1-1

SAP AG 2002

z *HQHUDO�*RDOVz &RXUVH�2EMHFWLYHVz &RXUVH�&RQWHQW

&RXUVH *RDOV DQG�&RQWHQWV

Page 8: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 1-2

SAP AG 2002

7KLV�FRXUVH ZLOO SURYLGH�\RX�ZLWK�z .QRZOHGJH�RI�WKH�XVH�RI�WKH 5)& LQWHUIDFH�RQ�WKH

5�� V\VWHP�VLGH�IRU�GDWD�H[FKDQJH�EHWZHHQ�WKH 5���6\VWHP DQG�RWKHU�DSSOLFDWLRQ�V\VWHPV

z .QRZOHGJH�RI�WKH�EDVLFV�RI�XVLQJ�%$3,V

*HQHUDO�*RDOV

Page 9: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 1-3

SAP AG 2002

&RXUVH�2EMHFWLYHV

z 7KH�LPSOHPHQWDWLRQ�RI�5)&V LQ WKH 5���6\VWHP IRU�GDWD�H[FKDQJH�EHWZHHQ 5�� DQG�RWKHU�DSSOLFDWLRQ�V\VWHPV�

z 2YHUYLHZ�RI�WKH�FRQFHSW�DQG�XVH�RI�%$3,V�DV DQLQWHUIDFH WR�5�� GDWD

Page 10: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 1-4

SAP AG 2002

Unit 1 &RXUVH *RDOV DQG�&RQWHQWVUnit 2 ,QWURGXFWLRQUnit 3 5HPRWH�)XQFWLRQ�&DOOUnit 4 %$3,�� %XVLQHVV�$SSOLFDWLRQ�3URJUDPPLQJ ,QWHUIDFH

3UHIDFH

([HUFLVHV6ROXWLRQV$SSHQGL[

&RXUVH�&RQWHQW

Page 11: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 2-1

SAP AG 2002

,QWURGXFWLRQ

z %DVLF WHUPVz (QYLURQPHQW�DQG�DUFKLWHFWXUHz 7HFKQLFDO�EDFNJURXQG

&URVV�V\VWHP�GDWD�GLVWULEXWLRQ�

Page 12: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 2-2

SAP AG 2002

z <RX ZLOO OHDUQ�DERXW�WKH�EDVLF�FRQFHSWV� WKH�HQYLURQPHQW� DQG�WKH�DUFKLWHFWXUH�RI�FURVV�V\VWHP�GDWD�GLVWULEXWLRQ��

z <RX ZLOO UHFHLYH DQ RYHUYLHZ�RI�H[LVWLQJ�LQWHUIDFHV�WKDW�\RX�FDQ�XVH WR PDLQWDLQ�GDWD�FRQVLVWHQF\ LQGLVWULEXWHG�V\VWHPV�

z <RX ZLOO OHDUQ�ZKHUH WR JHW�VXSSRUW�ZKHQ�FKRRVLQJ�GHVLJQLQJ� DQG�LPSOHPHQWLQJ�LQWHUIDFHV�

z <RX ZLOO EHFRPH�IDPLOLDU�ZLWK�WKH�WHFKQLFDO�EDFNJURXQG�RI�FURVV�V\VWHP�FRPPXQLFDWLRQ�

8QLW�2EMHFWLYHV

Page 13: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 2-3

SAP AG 2002

'LVWULEXWHG 6\VWHPV

5��

5��5��

([WHUQDOV\VWHP

([WHUQDOV\VWHP

Page 14: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 2-4

SAP AG 2002

2/(

$/($/(,'RF 5)&

CPI-C

W5)&*8,

(',

$)(

%)$

%25

'&20 CORBA

+70/ -$9$-$9$

V5)&

:RUNIORZ

&KRRVLQJ�DQG�'HVLJQLQJ�WKH ,QWHUIDFH

,QWHUIDFH$GYLVHU

� Choosing a suitable interface technology is a central task in an integration project. The ,QWHUIDFH�$GYLVHU supports you when choosing the interface technology, and when designing your interface.

� 6$3�,QWHJUDWLRQ�7HFKQRORJLHV, a Knowledge Product, gives you detailed information on implementing the interfaces.

Page 15: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 2-5

SAP AG 2002

2YHUYLHZ�RI�,QWHUIDFHV�IRU�'DWD 'LVWULEXWLRQ

&3,�&

5)&

$/(� ,QWHUIDFHV�SURYLGHG�E\ 6$3 IRUFURVV�V\VWHP�GDWD�GLVWULEXWLRQ

� %DVHG �PRVWO\� RQ 5)& DQG�,'RF� 7UDLQLQJ FRXUVHV � %,7�����$/(��

%,7�����,'RF���%,7�����,'RF�

� RFC is based on CPI-C, which means an RFC call is always transmitted through CPI-C calls.�� CPI-C (Common Programming Interface - Communication) is a program-to-program communication

interface that allows communication between programs. It consists of socalled CPI-C calls that a program uses to set up a connection to another program, transmit or recieve data, and then disconnect the connection again.

� Since CPI-C is more complicated to use than RFC, it should only be used under the following conditions: - If RFC is not available (few platforms) - If older programs that communicate through CPI-C need to be maintained - If a more complex communication protocol is required (with RFC, only simple input/output handling is possible)

� In the appendix, you will find additional information about CPI-C with exercises and solutions.

Page 16: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 2-6

SAP AG 2002

$%$3

5'%06

$%$3

5�� $UFKLWHFWXUH

6$3*8,

6$3*8, 6$3

*8,3UHVHQWDWLRQ

$SSOLFDWLRQ

'DWDEDVH

6$3*8,

� The SAP R/3 System has a modular software architecture that follows the software-oriented client/server principle.

� The system distributes presentation, application logic, and data across hosts at different levels. This forms the basis for the high degree of scalability in the R/3 System.

� The lowest level is the GDWDEDVH�OHYHO. The data is managed at this level using a relational database management system (RDBMS). In addition to master and transaction data, the database also stores programs and metadata that describes the R/3 System and the structure of its data.

� The second level is the DSSOLFDWLRQ�OD\HU, which consists of ABAP programs. You can complement the existing SAP functions by writing your own programs using the ABAP Workbench.

� The third level is the SUHVHQWDWLRQ�OD\HU (SAPGUI), which contains the user interface through which end users access the application functions, enter data, and display the results of their work. You can also use alternative front ends (AFEs) or interfaces at this level instead of the SAPGUI.

Page 17: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 2-7

SAP AG 2002

&RPPXQLFDWLRQ�DQG�'DWD�,QWHUIDFHV

$SSOLFDWLRQVHUYHU

5'%06'DWDEDVHVHUYHU

$%$3�3URJUDP

&RPPXQLFDWLRQ�LQWHUIDFHV&3,�&��5)& )LOH�,�2

'DWD�LQWHUIDFHV� %DWFK�LQSXW��6$3�64/��DQG�VR�RQ

3URJUDP5HPRWH 6\VWHP�5����5��� ([WHUQDO

6\VWHP�

+773

,QWHUQHW�

������������ �� �������������������� ��! " #%$'&(" �)������*+���-,�� .+/10

� Communication interfaces and data interfaces are different. In addition to the file I/O, the communication interfaces are the gate to external communication, whereas the data interfaces are used for read and write access to the R/3 database.

� The data interfaces include Batch Input, Direct Input, CALL TRANSACTION USING, SAP-SQL (OpenSQL), Native SQL For more information on these interfaces, refer to the training courses BC420 and BC414.

� As of SAP R/3 Release 4.7 or SAP Web Application Server 6.20, it is possible to exchange data between ABAP programs and applications over the Internet using the HTTP protocol (instead of the RFC protocol). This topic is covered in training course BC416.

Page 18: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 2-8

SAP AG 2002

,QVWDQFH

�����

,QVWDQFH

�' 9 ( 6 0

,QVWDQFH

�����

'

,QVWDQFH

�����

''%*:

*:

*:

*DWHZD\'LVSDWFKHU

'LVSDWFKHU 'LVSDWFKHU

6$3�*DWHZD\

� An LQVWDQFH is an administrative unit in the R/3 System. It describes which services (dialog, update, enqueue, background, spool, gateway) are available on the corresponding application server.

� The GLVSDWFKHU process on an application server coordinates tasks within the respective instance. It FRPPXQLFDWHV�with other instances (application servers) in the same R/3 System through the message server and, through the gateway service, with external systems. As of Release 3.0, a gateway service (application server) belongs to each instance (application server). You can also install a gateway service on a non-R/3 host.

� When an application server (dispatcher) communicates with external systems, it usually uses its own gateway work process. However, it may be more useful to use a gateway that runs on a dedicated host, for communication with SNA, where a gateway with an add-on is required. The reason is to minimize the effort needed for configuration and maintenance (the gateway add-on is only on one host instead of each application server). You may have to use a remote gateway, for example, with remote Windows NT applications because the remote program can only be started using this gateway.

Page 19: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 2-9

SAP AG 2002

$UFKLWHFWXUH�DQG�8VH�RI�WKH 6$3 *DWHZD\

243 5243 56 7 8 9 : ; < = 9 > ? 9 >6 7 8 9 : ; < = 9 > ? 9 >@ A @ B < C@ A @ B < C

6 D6 D @ E@ EB =B =FHGFHGI =I =

E EE E

J KJ K

= L= L

B EB EB BB BM EM E

G IG I5��

([WHUQDO�V\VWHPV

6$36$3*DWHZD\*DWHZD\

7&3�,3

7&3�,3 2SWLRQDO�61$2SWLRQDO�61$)XQFWLRQV)XQFWLRQV 5����,%0�5����6LHPHQV�

/8���

2�3 5243 56 7 8 9 : ; < = 9 > ? 9 >6 7 8 9 : ; < = 9 > ? 9 >@ A @ B < C@ A @ B < C

6 D6 D @ E@ EB =B =FNGFHGI =I =

E EE E

J KJ K

= L= L

B EB EB BB BM EM E

G IG I5��

7&3�,3

([WHUQDO�V\VWHPV

�7&3�,3� �/8����

� R/3 communication always runs through the SAP gateway and is based on TCP/IP.

� For R/3 communication with an IBM R/2 System or other LU6.2 systems where the LU6.2 transport protocol is used, you need an SAP gateway with additional SNA functions. The optional SNA functions on the SAP gateway mainly consist of the protocol converter for the TCP/IP LU6.2 conversion (SAP) and LU6.2 functions (external software). An SAP gateway with SNA functions is also known as an (SAP) SNA gateway.

Page 20: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 2-10

SAP AG 2002

z 7KH�,QWHUIDFH $GYLVHU VXSSRUWV�\RX�ZKHQ�FKRRVLQJ�WKH�LQWHUIDFH�WHFKQRORJ\�DQG�ZKHQ�GHVLJQLQJ�\RXU�LQWHUIDFH�

z 6$3 RIIHUV� WRJHWKHU�ZLWK�WKH $/( FRPSRQHQW�SUHGHILQHG�LQWHUIDFHV�IRU�PDLQWDLQLQJ�GDWD�FRQVLVWHQF\ LQ GLVWULEXWHG�V\VWHPV�

z 5)& LV�EDVHG�RQ &3,�&� +RZHYHU��&3,�&�VKRXOG�EH�XVHG�RQO\�LI�DEVROXWHO\�QHFHVVDU\� GXH WR LWV�FRPSOLFDWHG�XVDJH�

z 7KHUH�LV D GLIIHUHQFH�EHWZHHQ�FRPPXQLFDWLRQ�LQWHUIDFHV�DQG�GDWD�LQWHUIDFHV�

z 5�� FRPPXQLFDWLRQ�DOZD\V�UXQV�WKURXJK D JDWHZD\�

7RSLF�6XPPDU\

Page 21: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 3-1

SAP AG 2002

5HPRWH�)XQFWLRQ�&DOO

z 2YHUYLHZz 5)& 'HVWLQDWLRQVz 6\QFKURQRXV 5)&z $V\QFKURQRXV 5)&z 7UDQVDFWLRQDO 5)&z 4XHXHG 5)&z 5)& ZLWK�([WHUQDO�3URJUDPVz 8VH�RI 5)& 7\SHV DQG 5)& $XWKRUL]DWLRQV

Page 22: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 3-2

SAP AG 2002

2YHUYLHZ

2YHUYLHZ2YHUYLHZ

5)& 'HVWLQDWLRQV5)& 'HVWLQDWLRQV

6\QFKURQRXV 5)&6\QFKURQRXV 5)&

$V\QFKURQRXV 5)&$V\QFKURQRXV 5)&

7UDQVDFWLRQDO 5)&7UDQVDFWLRQDO 5)&

4XHXHG 5)&4XHXHG 5)&

5)& ZLWK�([WHUQDO�3URJUDPV5)& ZLWK�([WHUQDO�3URJUDPV

8VH�RI 5)& 7\SHV DQG 5)& $XWKRUL]DWLRQV8VH�RI 5)& 7\SHV DQG 5)& $XWKRUL]DWLRQV

Page 23: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 3-3

SAP AG 2002

z 7KLV�WRSLF ZLOO SURYLGH�\RX�ZLWK DQ RYHUYLHZ�RI�WKH5)& HQYLURQPHQW�DQG�WKH�YDULRXV 5)& W\SHV�

5)&�2YHUYLHZ��7RSLF�2EMHFWLYHV

Page 24: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 3-4

SAP AG 2002

5)& IURP�:LWKLQ 6$3�5��

5�� $SSOLFDWLRQ 6HUYHU

:RUN�SURFHVV352*5$0����&$//�)81&7,21

���

��������� ��� �� �����

/RFDO )0

:RUN�SURFHVV352*5$0����&$//�)81&7,21����'(67,1$7,21����

5HPRWH 6\VWHP([WHUQDO�QRQ�6$3 V\VWHP5���6\VWHP$SSOLFDWLRQ�VHUYHU�IURPDQRWKHU 5���6\VWHP$QRWKHU�DSSOLFDWLRQ�VHUYHU�IURP�WKH�VDPH 5���6\VWHP

)0

�:RUN�SURFHVV�

UHPRWH� ������ �� �

������������ ���

� When you call a function module locally, it runs in the same work process as the calling program.

� If a function module is called remotely, it runs in its own work process (its own SAP LUW) if the remote system is an SAP R/3 System.

� The remote destination can be another application server in the same or a different SAP R/3 System, an SAP R/2 System, or an external non-SAP system.

� Note that the calling program is rolled out for each remote function call (RFC), which triggers an implicit database (DB) commit.

Page 25: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 3-5

SAP AG 2002

5)& 'HVWLQDWLRQV

5HPRWH 6\VWHPV5�� $SSOLFDWLRQ 6HUYHU�IRU�DQRWKHU�RU�WKH�VDPH5���6\VWHP�

5���6\VWHP

([WHUQDO�V\VWHP

352*5$0����&$//�)81&7,21����'(67,1$7,21 ���

5)&�6LGH�,QIR�7DEOH�5)&'(6

5���6\VWHP

0DLQWHQDQFH�WUDQV�DFWLRQ 60��

)0

& URXWLQH

)0

� Use transaction SM59 to maintain RFC destinations that must specify an ABAP program when calling remote function modules in the RFC side information table, RFCDES.

� For each partner system, you need to maintain one entry in this information table.

Page 26: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 3-6

SAP AG 2002

5�� )XQFWLRQ�0RGXOHV�7KDW�&DQ�%H�&DOOHG�5HPRWHO\

1RUPDO IXQFWLRQ�PRGXOH5HPRWH�HQDEOHG�PRGXOH8SGDWH PRGXOH

3URSHUWLHV3URFHVVLQJ�W\SH

LQWHUIDFH&+$1*,1* SDUDPHWHU QRW DOORZHG7\SH DVVLJQPHQW�IRU DOO LQWHUIDFH�SDUDPHWHUV�LV�UHTXLUHG��E\�VSHFLIL\LQJ D 'LFWLRQDU\�ILHOG�VWUXFWXUH�

� 3RVVLEOH�DV�RI 6$3�5���5HOHDVH ��� RU 6$3�:HE $SSOLFDWLRQ6HUYHU����� �

� As of SAP R/3 Release 4.6C, nested structures can be transferred even for remote-enabled function modules.

Page 27: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 3-7

SAP AG 2002

&DOOLQJ�([WHUQDO & 5RXWLQHV�8VLQJ 5)&

([WHUQDO 6\VWHP

352*5$0����

&$//�)81&7,21�$%&'(67,1$7,21�(;73*0(;3257,1*����,03257,1*�����7$%/(6����(;&(37,216����

5���6\VWHP

5)& OLEUDU\��5)&�6'.��

���

$%$3 SURJUDP

5)& VHUYHU�SURJUDP���

���

���

& URXWLQH $%&���

& URXWLQH ;<=���

� SAP delivers the RFC Library for all standard external platforms that contain RFC calls for C programs. After installing the RFC Library on your external platform, you can use the RFC client or RFC server programs with RFC calls.

Page 28: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 3-8

SAP AG 2006

3URFHVV�)ORZ��6\QFKURQRXV�5)&��V5)&�

352*5$0�������

&$//�)81&7,21�;<='(67,1$7,21�%(;3257,1*����,03257,1*��������

352*5$0�������

&$//�)81&7,21�;<='(67,1$7,21�%(;3257,1*����,03257,1*��������

)81&7,21�;<=�

(1')81&7,21�

'DWD�WUDQVIHU

'DWD�LV�UHWXUQHG

5HPRWH�IXQFWLRQ

���

� ������ �� �� ���������� �

'%�/8:

� With synchronous RFCs, processing is stalled in the calling program until the called remote function is processed and its output is returned. Then processing continues in the calling program after the call.

Page 29: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 3-9

SAP AG 2006

352*5$0�������

&$//�)81&7,21�;<='(67,1$7,21�%67$57,1*�1(:�7$6.�%�(;3257,1*�������

352*5$0�������

&$//�)81&7,21�;<='(67,1$7,21�%67$57,1*�1(:�7$6.�%�(;3257,1*�������

)81&7,21�;<=�

(1')81&7,21�

'DWD�WUDQVIHU

'DWD�LV�UHWXUQHG

5HPRWH�IXQFWLRQ

���

3URFHVV�)ORZ��$V\QFKURQRXV�5)&���D5)&��

� ������ �� �� �����!�"�# �

'%�/8:

� In an asynchronous Remote Function Call, the called remote function is started and processing continues immediately afterwards in the calling program. The remote function itself is processed separately from the calling program. The output of the function can be received later in the program.

� Asynchronous RFCs are intended for parallel processing of processes.

Page 30: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 3-10

SAP AG 2006

3URFHVV�)ORZ��7UDQVDFWLRQDO�5)&��W5)&��

352*5$0�������

&$//�)81&7,21�;�,1�%$&.*5281'�7$6.'(67,1$7,21�%���

&$//�)81&7,21�;�,1 %$&.*5281'�7$6.'(67,1$7,21�%���

&200,7 :25.�

352*5$0�������

&$//�)81&7,21�;�,1�%$&.*5281'�7$6.'(67,1$7,21�%���

&$//�)81&7,21�;�,1 %$&.*5281'�7$6.'(67,1$7,21�%���

&200,7 :25.�)81&7,21�;��

(1')81&7,21�

0DQDJHPHQW ��0RQLWRULQJRI�/8:V0DQDJHPHQW ��0RQLWRULQJRI�/8:V

��� )81&7,21�;��

(1')81&7,21�

GDWD�WUDQVIHU6WDUW

ZLWK

�QR�ZDLWLQJ�

/RJLFDO�XQLW�RI�ZRUN�/8:����

���

'%�/8:

$�%&���' �� ��(�)�*������ �+�

*XDUDQWHHGSURFHVVLQJ�FRQILUPDWLRQ �

� Whereas with synchronous and asynchronous RFCs each call makes up a single logical unit of work (LUW) in the remote system, for transactional RFCs you can group several remote functions in one LUW (with automatic rollback mechanism if there is an error).

Page 31: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 3-11

SAP AG 2002

3URFHVV�)ORZ� 4XHXHG 5)&���T5)&�

�� W5)&�/8:

,.-�/103254 6*/�786.9�-;: <8=

Q�WH W5)&�/8:,>-�/?0?2@4 6A/B7B6>9A-.: < C

,>-�/?0?2@4 6A/B7B6>9A-.: < D

,.-�/103254 6*/�786.9�-;: <FE

,>-�/?0?2@4 6A/B7B6>9A-.: <(G

�����

/8:LV�VHQW

/8:LV�JHQHUDWHG

/8:�4XHXH

6HULDOL]DWLRQ�RI�W5)&�/8:V

� LUWs generated using tRFC are processed independently of each other. This means the order in which they are processed is not always the order in which they are generated.

� To ensure that tRFC-LUWs are processed in the same order in which they were generated, use qRFC as an extension of tRFC�

� Queued RFC (qRFC) is available as of release 4.6A and can be used in SAP R/3-R/3 connections and in SAP R/3 external connections.

Page 32: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 3-12

SAP AG 2002

5)&�2YHUYLHZ� 7RSLF�6XPPDU\

z <RX�FDQ�XVH 5)&�WR FDOO $%$3 IXQFWLRQ�PRGXOHV LQ�6$3 V\VWHPV�DQG & URXWLQHV LQ H[WHUQDO�VHUYHU�SURJUDPV�

z 7R GR�WKLV� \RX�QHHG DQ�5)& GHVWLQDWLRQ�WKDW�\RX�PDLQWDLQ LQ WKH�VLGH�LQIRUPDWLRQ�WDEOH 5)&'(6�

z 7KHUH�DUH�IRXU�FDOO�YDULDQWV��V\QFKURQRXV�DV\QFKURQRXV� WUDQVDFWLRQDO� DQG�TXHXHG 5)&�6HOHFW�WKH�DSSURSULDWH 5)& W\SH�GHSHQGLQJ�RQ�WKH�SXUSRVH�DQG�UHTXLUHPHQWV�LQYROYHG�

Page 33: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 3-13

SAP AG 2002

5)& 'HVWLQDWLRQV

2YHUYLHZ2YHUYLHZ

5HPRWH�'HVWLQDWLRQV5HPRWH�'HVWLQDWLRQV

6\QFKURQRXV 5)&6\QFKURQRXV 5)&

$V\QFKURQRXV 5)&$V\QFKURQRXV 5)&

7UDQVDFWLRQDO 5)&7UDQVDFWLRQDO 5)&

4XHXHG 5)&4XHXHG 5)&

5)& ZLWK�([WHUQDO�3URJUDPV5)& ZLWK�([WHUQDO�3URJUDPV

6HFXULW\�$VSHFWV6HFXULW\�$VSHFWV

2YHUYLHZ2YHUYLHZ

5)& 'HVWLQDWLRQV5)& 'HVWLQDWLRQV

6\QFKURQRXV 5)&6\QFKURQRXV 5)&

$V\QFKURQRXV 5)&$V\QFKURQRXV 5)&

7UDQVDFWLRQDO 5)&7UDQVDFWLRQDO 5)&

4XHXHG 5)&4XHXHG 5)&

5)& ZLWK�([WHUQDO�3URJUDPV5)& ZLWK�([WHUQDO�3URJUDPV

8VH�RI 5)& 7\SHV DQG 5)& $XWKRUL]DWLRQV8VH�RI 5)& 7\SHV DQG 5)& $XWKRUL]DWLRQV

Page 34: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 3-14

SAP AG 2002

5)&�'HVWLQDWLRQV��7RSLF�2EMHFWLYHV

z <RX�DUH�DEOH WR PDLQWDLQ 5)& GHVWLQDWLRQV�IRU�FRPPXQLFDWLRQ�SURFHVVHV�VWHPPLQJ�IURP DQ�6$3�5���6\VWHP�

z <RX�DUH�IDPLOLDU�ZLWK�WKH�VWDQGDUG�GHVWLQDWLRQV63$&(���121(���DQG %$&.�

Page 35: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 3-15

SAP AG 2006

0DLQWHQDQFH�RI�5)&�'HVWLQDWLRQV

5���FRQQHFWLRQV

5)&�'HVWLQDWLRQV

7UDQVDFWLRQ�!60��

5���FRQQHFWLRQV���$%$3�FRQQHFWLRQV

,QWHUQDO�FRQQHFWLRQV/RJLFDO�FRQQHFWLRQV7&3�,3�FRQQHFWLRQV&RQQHFWLRQV�XVLQJ�$%$3�GULYHUV

+773�FRQQHFWLRQV�WR�H[W��VHUYHU+773�FRQQHFWLRQV�WR�5���V\VWHP�$%$3�V\VWHP

� 3RVVLEOH�DV�RI�6$3�5���5HOHDVH�����RU�6$3�:HE�$SSOLFDWLRQ�6HUYHU�����

� Using transaction SM59, you maintain the RFC destination in the RFC side information table RFCDES.

� You can maintain RFC destinations in the source system only.

� Depending on the remote system, maintain one destination for the corresponding type.

� As of SAP R/3 Release 4.7 or SAP Web Application Server 6.20, there are two new HTTP destination types. Using these, it is possible to exchange data between ABAP programs and application in the Internet on the basis of the HTTP protocol (instead of the RFC protocol). For further information, see training course BC416.

Page 36: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 3-16

SAP AG 2002

'HVWLQDWLRQ IRU 5���5�� &RQQHFWLRQ

5)& GHVWLQDWLRQ

��6\VWHP QXPEHU

$%&

5�� FRQQHFWLRQ

KV����

7\SH���'HVWLQDWLRQ

&RQQHFWLRQ�W\SH

/RDG�GLVWULEXWLRQ7DUJHW�KRVW'HVFULSWLRQ

<HV 1R

5)& FRQQHFWLRQ WR UHPRWH 5���6\VWHP�$%&

(1/DQJXDJH���&OLHQW60,7+8VHU 3DVVZRUG

*DWHZD\�RSWLRQV*DWHZD\�KRVW*DWHZD\�VHUYLFH

HIHIHHIHIH

� If you want to connect to another SAP R/3 System, you need a destination with type 3. Note that the name of a type 3 destination is case sensitive, that is, a distinction is made between lowercase and uppercase letters.

� If you want to ensure that a particular R/3 application server is addressed, set the /RDG�GLVWULEXWLRQ option to 1R. In this case, you must specify the R/3 application server using the 7DUJHW�KRVW and 6\VWHP�QXPEHU parameters. However, if you do want to use load distribution when you log on, set the /RDG�GLVWULEXWLRQ option to <HV. In this case, you must specify the V\VWHP ,', the PHVVDJH�VHUYHU, and the required ORJRQ�JURXS. You can find out this information from transactions SM51 (overview of R/3 servers) and SMLG (overview of logon groups) in the SAP R/3 target system. You determine the message server of an SAP R/3 System using the profile parameter UGLVS�PVKRVRX. You can display this using transaction RZ11 or report RSPFPAR.

� In the destination system, you can specify the logon data of a user in the target system. This must be a user of the type GLDORJ or &3,& (or of the type "communication" in more recent releases). When the destination is used, the logon to the target system occurs automatically. If you do not enter the logon language in an RFC destination, the logon language of the current caller is used. If the logon data is not complete or is faulty, a logon screen from the target system appears at runtime.

Page 37: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 3-17

SAP AG 2002

*DWHZD\�RSWLRQV*DWHZD\�KRVW*DWHZD\�VHUYLFH

'HVWLQDWLRQ IRU 5���5�� &RQQHFWLRQ

5)& GHVWLQDWLRQ

.��

5�� FRQQHFWLRQ

7\SH�� GHVWLQDWLRQ

&RQQHFWLRQ�W\SH

'HVFULSWLRQ5)& FRQQHFWLRQ WR UHPRWH 5���6\VWHP�.��

(1/DQJXDJH���&OLHQW60,7+8VHU 3DVVZRUG

HIHIHHIHIH

� If you want to connect to an SAP R/2 system, you need a destination with type 2. In the destination, you need to specify the logon data of an R/2 user with the type CPIC. You must also specify the SNA gateway (for IBM R/2) or the host gateway (for Siemens R/2) through which the connection is to be made.

� Note that the destination name (in the figure, it is K50) for a type 2 destination cannot be chosen at random. It must match the name of the corresponding destination in the gateway side information table (for more information, see the online documentation on maintaining gateways).

Page 38: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 3-18

SAP AG 2002

*DWHZD\�RSWLRQV*DWHZD\�KRVW*DWHZD\�VHUYLFH

'HVWLQDWLRQ IRU 5�� ([WHUQDO�&RQQHFWLRQ

7\SH�7 GHVWLQDWLRQ

5)& GHVWLQDWLRQ&RQQHFWLRQ�W\SH 7

$FWLYDWLRQ�W\SH

3URJUDP7DUJHW�KRVW

'HVFULSWLRQ

6WDUW 5HJLVWUDWLRQ

$SSOLFDWLRQ�VHUYHU ([SOLFLW�KRVW )URQW�HQG ZRUNVWDWLRQ

5)&(;(&

7&3�,3 FRQQHFWLRQ

&� ? [\] ? UIFH[HFLZGI����

6WDUW RQ

([SOLFLW�KRVW

5)& FRQQHFWLRQ WR H[WHUQDO�VHUYHU�SURJUDP�UIFH[HF

HIHIHHIHIH

� For connections to external RFC server programs, you need a destination with the type T. There are two variations of type T: 1. 6WDUW: The external program is started when the actual communication is being established. a)�2Q�WKH�DSSOLFDWLRQ�VHUYHU: The external program is started on the current SAP R/3 application server. You must give the complete program path including the program names. b) 2Q�WKH�F[SOLFLW�KRVW: The external program is started on the specified host. You must specify the following: - Host name --> Name of the machine where the external program is located - Path --> Complete path including program names on an external host c) )URQW�HQG�ZRUNVWDWLRQ: The external program is started on the current front end at runtime through the SAPGUI. You must enter the compete (absolute) path of the program including program names. 2. 5HJLVWUDWLRQ: These destination variations let you access a program that has already started and has registered itself on a gateway. This program must be started manually beforehand and registers itself using an RFC call with a program ID on a gateway (see the online documentation). With this variant, the start time is not required. It is suited for starting a program frequently. You must specify the following: - Program-ID --> ID under which the external server program has registered on the SAP gateway - Gateway --> Host and TCP/IP service of the gateway where the external program has registered (If the gateway is the one for the current application server, this information is not required.)

Page 39: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 3-19

SAP AG 2002

$XWKRUL]DWLRQ�DQG�8VH�RI 5)& 'HVWLQDWLRQV

6HFXULW\�RSWLRQV$XWKRUL]DWLRQ� ;<=

5)& GHVWLQDWLRQ $%&���

�DV�RI 6$3�5�� UHOHDVH ��� RU 6$3�:HE $SSOLFDWLRQ6HUYHU������

8VH�RI�WKLV�GHVWLQDWLRQ�UHTXLUHV�DXWKRUL]DWLRQ�IRU�WKH�DXWKRUL]DWLRQ�REMHFW 6B,&)

)LHOG ,&)B),(/'��� ��'(67 )LHOG ,&)B9$/8(�� ��;<=

� As of SAP R/3 Release 4.7 or SAP Web Application Server 6.20, it is possible to have an automatic check of the required authorization for destination use. It can be implemented for all destination types.

Page 40: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 3-20

SAP AG 2002

'HVWLQDWLRQV 63$&(���121(� DQG %$&.

5���6\VWHP�$

&$//�)81&7,21�$%&'(67,1$7,21�63$&(���

/RFDO )0

&$//�)81&7,21�$%&'(67,1$7,21�121(���

6HPL�UHPRWH

)0*DWH�ZD\

)0

5���6\VWHP %&$//�)81&7,21�$%&

'(67,1$7,21�%���

UHPRWH )81&7,21�$%&�

&$//�)81&7,21�;<='(67,1$7,21�%$&.���

���

(1')81&7,21�

� The destinations listed above are predefined standard destinations and have the following meanings: - SPACE: Local call of a function module - NONE: Also a local call, but the call request is sent to the default gateway of the current application server and is handled there like an external call request. This destination is suited to the RFC test if you only have one system to test. - BACK: You can use this destination if you want to start a function module from the called function module in the current system. (This functions with synchronous RFC only.)

� You cannot use these standard destinations from R/2 systems. Destination BACK cannot be used for R/3-R/2 connections.

Page 41: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 3-21

SAP AG 2002

5)&�'HVWLQDWLRQV� 7RSLF�6XPPDU\

z 7R PDNH D UHPRWH�FDOO WR�D IXQFWLRQ�PRGXOH� \RX�UHTXLUH DQ�5)& GHVWLQDWLRQ LQ WKH�VRXUFH�V\VWHP� 7KLV�LV DQ HQWU\ LQ WKH 5)& VLGH�LQIRUPDWLRQ�WDEOH 5)&'(6�ZKLFK�\RX�FDQ�PDLQWDLQ�XVLQJ�WUDQVDFWLRQ 60���

z 7KLV�W\SH�RI 5)& GHVWLQDWLRQ�FRQWDLQV�FRPPXQLFDWLRQ�SDUDPHWHUV�DQG� LI�UHTXLUHG� WKH�ORJRQ�GDWD�QHFHVVDU\�IRU�VHWWLQJ XS WKH�FRQQHFWLRQ�RU�WKH�ORJRQ LQ WKH�UHPRWH�V\VWHP��

z 'HSHQGLQJ�RQ�WKH�UHPRWH�SDUWQHU�V\VWHP� \RX�QHHG WRGHILQH DQ�5)& GHVWLQDWLRQ�RI�WKH�DSSURSULDWH�W\SH�

z 63$&(��121(� DQG %$&. DUH�SUHGHILQHG� VWDQGDUG�GHVWLQDWLRQV�ZLWK�VSHFLDO�PHDQLQJV��

Page 42: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 3-22

SAP AG 2002

6\QFKURQRXV 5)&

2YHUYLHZ2YHUYLHZ

5HPRWH�'HVWLQDWLRQV5HPRWH�'HVWLQDWLRQV

6\QFKURQRXV 5)&6\QFKURQRXV 5)&

$V\QFKURQRXV 5)&$V\QFKURQRXV 5)&

7UDQVDFWLRQDO 5)&7UDQVDFWLRQDO 5)&

4XHXHG 5)&4XHXHG 5)&

5)& ZLWK�([WHUQDO�3URJUDPV5)& ZLWK�([WHUQDO�3URJUDPV

6HFXULW\�$VSHFWV6HFXULW\�$VSHFWV

2YHUYLHZ2YHUYLHZ

5)& 'HVWLQDWLRQV5)& 'HVWLQDWLRQV

6\QFKURQRXV 5)&6\QFKURQRXV 5)&

$V\QFKURQRXV 5)&$V\QFKURQRXV 5)&

7UDQVDFWLRQDO 5)&7UDQVDFWLRQDO 5)&

4XHXHG 5)&4XHXHG 5)&

5)& ZLWK�([WHUQDO�3URJUDPV5)& ZLWK�([WHUQDO�3URJUDPV

8VH�RI 5)& 7\SHV ��5)& $XWKRUL]DWLRQV8VH�RI 5)& 7\SHV ��5)& $XWKRUL]DWLRQV

Page 43: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 3-23

SAP AG 2002

6\QFKURQRXV�5)&�'HVWLQDWLRQV��7RSLF�2EMHFWLYHV

z ,Q WKLV�WRSLF�\RX ZLOO OHDUQ�WKH�WHFKQLTXHV�RI�V\QFKURQRXV 5)&�

Page 44: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 3-24

SAP AG 2002

6\QFKURQRXV 5)&���3URFHVV�)ORZ�

352*5$0�������

&$//�)81&7,21�;<='(67,1$7,21�%(;3257,1*����,03257,1*����

���

352*5$0�������

&$//�)81&7,21�;<='(67,1$7,21�%(;3257,1*����,03257,1*����

���

'DWD�LV�SDVVHG

'DWD�LV�UHWXUQHG� ������ �� �

�����>�!�"�J �K�

)81&7,21�;<=�

(1')81&7,21�

5HPRWH�IXQFWLRQ

���'%�/8:

� With synchronous RFCs, processing is stalled in the calling program until the called remote function is processed and its output is returned. Processing in the calling program continues after the call.

Page 45: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 3-25

SAP AG 2002

6\QFKURQRXV 5)&���6\QWD[�

&$//�)81&7,21�$%&'(67,1$7,21�;<=(;3257,1*��I�� �D�,03257,1*��I�� �D�7$%/(6�����W�� �LWDE(;&(37,216&20081,&$7,21B)$,/85(� ��6<67(0B)$,/85(�������� �����

$%$3 SURJUDP)81&7,21�$%&�

(1')81&7,21�

5�� $SSOLFDWLRQ 6HUYHU 5HPRWH 6$3�6\VWHP

([WHUQDO�SURJUDP& URXWLQH $%&

$%$3 IXQFWLRQ�PRGXOH��� ���

���

���

� You can call the remote ABAP function modules or even C routines in external server programs using the command CALL FUNCTION ... DESTINATION .

� When you call a function in this way, always include handling for the standard exceptions COMMUNICATION_FAILURE�and SYSTEM_FAILURE.

� The exception COMMUNICATION_FAILURE is triggered by the system if the specified destination in the side information table RFCDES is not maintained, or if the connection to the remote system cannot be established.

� The exception SYSTEM_FAILURE is triggered if the function module or C routine that you want to start in the remote system is not available.

Page 46: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 3-26

SAP AG 2002

/RJLFDO�8QLWV DQG�5HPRWH�3URJUDP�&RQWH[W

)XQFWLRQ�JURXS�

352*5$0��������

&$//�)81&7,21�$%&'(67,1$7,21�%

&$//�)81&7,21�;<='(67,1$7,21�%

*OREDO GDWD

���

���

���

���

$%$3 SURJUDP

)81&7,21�$%&�

(1')81&7,21�

)81&7,21�;<=�

(1')81&7,21�

5�� DSSOLFDWLRQ�VHUYHU5�� DSSOLFDWLRQ�VHUYHU 5HPRWH 5�� DSSOLFDWLRQ�VHUYHU5HPRWH 5�� DSSOLFDWLRQ�VHUYHU

� ������ �� �� �����!���� �K�

'%�/8:��

'%�/8:��� ������ �� �

� �����!���� �K�

� The connection to a remote destination remains intact for as long as the context of the calling program remains active. The function groups addressed in the remote destination remain active for as long as the calling program itself remains active (this is the same as with local calls). This means that if you call two function modules from the same function group one after the other, they can both access the same global data of the function group.

� Each function module called using synchronous RFC forms its own logical unit of work (LUW).

Page 47: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 3-27

SAP AG 2002

5HPRWH�'HEXJJLQJ

&$//�)81&7,21�$%&'(67,1$7,21�%

$%$3 SURJUDP LQ WKH�GHEXJJHU

)81&7,21�$%&�

(1')81&7,21�

5�� DSSOLFDWLRQ�VHUYHU 5HPRWH 5�� DSSOLFDWLRQ�VHUYHU

)XQFWLRQ�PRGXOHLQ WKH�GHEXJJHU���

���

���

� You can debug function modules called remotely in R/3 - R/3 connections.

� In this way, you can easily access, step by step, the remote function module for processing through the debugger of your calling prgram

� Also, you can have a breakpoint set automatically before each RFC statement in the debugger of your calling program. From the Debugger menu, choose: %UHDNSRLQWV�→�%UHDNSRLQW�IRU�VWDWHPHQW�→�(QWHU�5)&�

� During remote debugging of a synchronous RFC, the remote logon user must be type GLDORJ and must have debug authorization. If this is not the case, the remote function module is executed in one step (background processing).

Page 48: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 3-28

SAP AG 2002

5)&�'LDORJ

)81&7,21�$%&�

&$//�6&5((1�����

(1')81&7,21�

352*5$0����

&$//�)81&7,21�$%&'(67,1$7,21�%

6FUHHQ ��� 6FUHHQ ���

���

���

���

���

5�� DSSOLFDWLRQ�VHUYHU 5HPRWH 5�� DSSOLFDWLRQ�VHUYHU

'LVSOD\ UHPRWH�VFUHHQIRU�LQSXW

8VHU�HQWULHV

6FUHHQ ���

&DOOLQJ�VHVVLRQ

� If a remotely-called function module uses dialogs (for example, CALL SCREEN, CALL TRANSACTION, or list display), the screens concerned are displayed with all the functions in the session of the caller.

� Here, the remote logon must be type GLDORJ. Otherwise, the RFC exception SYSTEM_FAILURE will be triggered.

� Remember that these RFC dialogs in background processing cause program termination with the exception SYSTEM_FAILURE.

Page 49: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 3-29

SAP AG 2002

6\QFKURQRXV�5)&� 7RSLF�6XPPDU\

z :LWK�V\QFKURQRXV 5)&� WKH�FDOOLQJ�SURJUDP�ZDLWV�XQWLO�WKH�FDOOHG�IXQFWLRQ�PRGXOH�KDV�EHHQ�SURFHVVHG�

z ,Q�D�UHPRWH�IXQFWLRQ�FDOO�EHWZHHQ�WZR 5���6\VWHPV� \RX�FDQ�GHEXJ�IXQFWLRQ�PRGXOHV�WKDW�DUH�UXQQLQJ�UHPRWHO\�

z ,Q�DQ�5)& EHWZHHQ 5���6\VWHPV��DOO UHPRWH�GLDORJV�DUH�GLVSOD\HG�RQ�WKH�FDOOLQJ�SURJUDP�VLGH�

Page 50: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 3-30

SAP AG 2002

$V\QFKURQRXV 5)&

2YHUYLHZ2YHUYLHZ

5HPRWH�'HVWLQDWLRQV5HPRWH�'HVWLQDWLRQV

6\QFKURQRXV 5)&6\QFKURQRXV 5)&

$V\QFKURQRXV 5)&$V\QFKURQRXV 5)&

7UDQVDFWLRQDO 5)&7UDQVDFWLRQDO 5)&

4XHXHG 5)&4XHXHG 5)&

5)& ZLWK�([WHUQDO�3URJUDPV5)& ZLWK�([WHUQDO�3URJUDPV

6HFXULW\�$VSHFWV6HFXULW\�$VSHFWV

2YHUYLHZ2YHUYLHZ

5)& 'HVWLQDWLRQV5)& 'HVWLQDWLRQV

6\QFKURQRXV 5)&6\QFKURQRXV 5)&

$V\QFKURQRXV 5)&$V\QFKURQRXV 5)&

7UDQVDFWLRQDO 5)&7UDQVDFWLRQDO 5)&

4XHXHG 5)&4XHXHG 5)&

5)& ZLWK�([WHUQDO�3URJUDPV5)& ZLWK�([WHUQDO�3URJUDPV

8VH�RI 5)& 7\SHV DQG 5)& $XWKRUL]DWLRQV8VH�RI 5)& 7\SHV DQG 5)& $XWKRUL]DWLRQV

Page 51: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 3-31

SAP AG 2002

$V\QFKURQRXV�5)&��7RSLF�2EMHFWLYHV

z <RX ZLOO OHDUQ�KRZ WR FDOO�IXQFWLRQ�PRGXOHV�DV\QFKURQRXVO\ LQ RUGHU WR LPSOHPHQW SDUDOOHOSURFHVVLQJ�

z <RX ZLOO EH�DEOH WR H[SODLQ�WKH�LQWHUQDO�UHVRXUFH�PDQDJHPHQW�WHFKQLTXHV�XVHG LQ WKLV�FRQWH[W�

Page 52: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 3-32

SAP AG 2002

$V\QFKURQRXV 5)&���3URFHVV�)ORZ�

352*5$0�������

&$//�)81&7,21�;<='(67,1$7,21�%67$57,1*�1(:�7$6.�%�(;3257,1*����

���

352*5$0�������

&$//�)81&7,21�;<='(67,1$7,21�%67$57,1*�1(:�7$6.�%�(;3257,1*����

���

'DWD�LV�SDVVHG

'DWD�LV�UHWXUQHG

)81&7,21�;<=�

(1')81&7,21�

5HPRWH�IXQFWLRQ

���L M#N�O'P Q�P R

S(T)Q�U!M"MJP RKV

'%�/8:

� In an asynchronous remote function call, the called remote function is started and processing continues immedately afterwards in the calling program. Remote function processing itself is separate from the calling program. The output of the function can be received later in the program.

� Asynchronous RFCs are intended for parallel processing of processes.

Page 53: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 3-33

SAP AG 2002

$V\QFKURQRXV 5)&���%DVLF�6\QWD[�

)81&7,21�;<=�

(1')81&7,21�

352*5$0����

&$//�)81&7,21�;<='(67,1$7,21�%67$57,1*�1(:�7$6. 7�(;3257,1*�����7$%/(6����(;&(37,216&20081,&$7,21B)$,/85(� ��6<67(0B)$,/85(�������� ����

352*5$0����

&$//�)81&7,21�;<='(67,1$7,21�%67$57,1*�1(:�7$6. 7�(;3257,1*�����7$%/(6����(;&(37,216&20081,&$7,21B)$,/85(� ��6<67(0B)$,/85(�������� ����

���

���

���

$V\QFKURQRXVFDOO

,Q WKH�D5)&�FDOO�� 1R ,03257,1* DGGLWLRQ� 1R�FDWFKLQJ�RI )0 H[FHSWLRQV

� With the STARTING NEW TASK <task name> addition, you can call a remote function module asynchronously. You can use any task name.

� The function module that you call is executed in its own work process.

� You can also use aRFC in background processing. Note, however, that in this context, too, the RFC calls are each executed in a work process.

� In the side information table RFCDES, you can set the number of aRFC calls for each destination using the aRFC options. After these aRFC calls, an automatic load check is performed on the target server. If resource bottlenecks are detected, the system waits for a short time for the next aRFC call meant for the same remote system, and the client program is rolled out of its work process. The client program can then receive results from previous aRFC calls.

� During the call, you may not specify an IMPORTING addition since the call does not wait for the end of the function module. Here, for the same reason, you can handle only the two system exceptions COMMUNICATION_FAILURE and SYSTEM_FAILURE. The function module output must be received and the function module-specific exceptions must be handled later on in a different place.

� Receiving the function module output and handling the function module-specific exceptions are optional tasks, however.

Page 54: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 3-34

SAP AG 2006

D5)&�ZLWK�&RQILUPDWLRQ����

)81&7,21�;<=�

(1')81&7,21�

352*5$0�������

&$//�)81&7,21�;<='(67,1$7,21�%67$57,1*�1(:�7$6. 7�3(5)250,1*�83��21�(1'�2)�7$6.(;3257,1*����7$%/(6����(;&(37,216&20081,&$7,21B)$,/85(� ��6<67(0B)$,/85(�������� ���

���)250�83��86,1*�7�

5(&(,9(�5(68/76�)520�)81&7,21�;<=

,03257,1*�����7$%/(6��������(;&(37,216&20081,&$7,21B)$,/85(� ��6<67(0B)$,/85(�������� ��)/,*+7B127B)281'������ ���

���(1')250��

352*5$0�������&$//�)81&7,21�;<='(67,1$7,21�%67$57,1*�1(:�7$6. 7�3(5)250,1*�83��21�(1'�2)�7$6.(;3257,1*����7$%/(6����(;&(37,216&20081,&$7,21B)$,/85(� ��6<67(0B)$,/85(�������� ���

���)250�83��86,1*�7�5(&(,9(�5(68/76�)520�)81&7,21�

;<=,03257,1*�����7$%/(6��������(;&(37,216&20081,&$7,21B)$,/85(� ��6<67(0B)$,/85(�������� ��)/,*+7B127B)281'������ ���

���(1')250��

���

7��� 7�

� A program can receive output (parameters and exceptions) from a function module that is running asynchronously.

� To implement this, use the addition "3(5)250,1*��subprogram!�21�(1'�2)�7$6." for the call. The subprogram you specify must exist in your program and the output of the function module should be received through the command "5(&(,9(�5(68/76�)520�)81&7,21��IEQDPH!������". When the function module ends, the subprogram is called automatically.

� The subprogram must also have a formal parameter with any name you choose. When the subroutine is called, it receives the accompanying task name. This parameter lets you see which aRFC call just ended, and you can receive the relevant output using the "RECEIVE RESULTS FROM FUNCTION" command.

� The subroutine cannot contain any statements that interrupt the program execution (such as CALL SCREEN, SUBMIT, COMMIT WORK, WAIT, RFCs, W or I messages). WRITE statements in this subroutine, which is specially defined for aRFC, do not work.

� The subroutine can only be executed automatically if the calling program is in rollout status. -> "WAIT UNTIL" statements (see next slide).

� The addition KEEPING TASK with the RECEIVE statement causes the function group context that was loaded remotely to wait until the calling program has ended. This lets you use the old remote context with later aRFC calls under the same task name.

Page 55: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 3-35

SAP AG 2006

D5)&�ZLWK�&RQILUPDWLRQ����

)81&7,21�;<=�

(1')81&7,21�

352*5$0���������

&$//�)81&7,21�;<='(67,1$7,21�%67$57,1*�1(:�7$6.�7�3(5)250,1*�83��21�(1'�2)�7$6.���

:$,7�817,/��ORJH[S! �

)250�83��86,1*�7�5(&(,9(�5(68/76�)520�)81&7,21�;<=,03257,1* � 7$%/(6 � (;&(37,216����

(1')250�

352*5$0���������

&$//�)81&7,21�;<='(67,1$7,21�%67$57,1*�1(:�7$6.�7�3(5)250,1*�83��21�(1'�2)�7$6.���

:$,7�817,/��ORJH[S! �

)250�83��86,1*�7�5(&(,9(�5(68/76�)520�)81&7,21�;<=,03257,1* � 7$%/(6 � (;&(37,216����

(1')250�

Program waitsin rollout status

(implicit DB commit)

Evaluate SY-SUBRC immediately or store

������

(QG�RI�PDLQ�SURJUDP

Set WAIT condition

���

7��� 7�

� The language element WAIT UNTIL with the addition PERFORMING is only useful with aRFC, and otherwise has no effects.

� At the execution of the "WAIT UNTIL" statement, the specified condition is checked. If the condition is met, the program continues directly after the "WAIT UNTIL" statement. Otherwise, the program waits in rollout status for the output delivery of the aRFC.??? If an aRFC now returns its output, the form routine specified when it was called is executed and then it branches back to the "WAIT UNTIL" statement. This check/wait process repeats until the "WAIT UNTIL" condition is met or until no more open aRFC calls are left.

� Note that the "WAIT UNTIL" statement sets the SY-SUBRC. Therefore, store the SY-SUBRC value (set in the form routine by exceptions-handling in RECEIVE RESULTS) in its own global variable before leaving the form routine if you need this value again later (after WAIT UNTIL).

Page 56: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 3-36

SAP AG 2006

([DPSOH���:DLWLQJ�IRU�PXOWLSOH�D5)&V

352*5$0�������

&$//�)81&7,21�;�'(67,1$7,21�%67$57,1*�1(:�7$6.�7��������3(5)250,1*�83��21�(1'�2)�7$6.

���&$//�)81&7,21�;�

'(67,1$7,21�%67$57,1*�1(:�7$6.�7��3(5)250,1*�83��21�(1'�2)�7$6.

���

:$,7�817,/��127�IODJ��,6�,1,7,$/ $1' 127�IODJ��,6�,1,7,$/�

)250�83��86,1*�7�&$6(�7�:+(1 7��� �5(&(,9( 5(68/76 � Output processing of ;�!������IODJ� ;�:+(1 7��� �5(&(,9( 5(68/76 � Output processing of ;�!������IODJ� ;��

(1'&$6(����(1')250�

352*5$0�������

&$//�)81&7,21�;�'(67,1$7,21�%67$57,1*�1(:�7$6.�7��������3(5)250,1*�83��21�(1'�2)�7$6.

���&$//�)81&7,21�;�

'(67,1$7,21�%67$57,1*�1(:�7$6.�7��3(5)250,1*�83��21�(1'�2)�7$6.

���

:$,7�817,/��127�IODJ��,6�,1,7,$/ $1' 127�IODJ��,6�,1,7,$/�

)250�83��86,1*�7�&$6(�7�:+(1 7��� �5(&(,9( 5(68/76 � Output processing of ;�!������IODJ� ;�:+(1 7��� �5(&(,9( 5(68/76 � Output processing of ;�!������IODJ� ;��

(1'&$6(����(1')250�

������

� In this program example, there are two aRFCs and, when the aRFCs are confirmed, the subroutine UP1 is always executed.

� This subroutine uses parameter T (which is automatically transferred by the system at the call) to separately decide which function module just returned its output. Then the corresponding RECEIVE RESULTS statement is used to receive (and process) the output.???

� After processing an aRFC output, you must adjust the WAIT UNTIL condition accordingly. (here: set flag1 or flag2)

Page 57: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 3-37

SAP AG 2002

D5)&�%HWZHHQ 'LIIHUHQW�5���6\VWHPV

352*5$0����&$//�)81&7,21 ���'(67,1$7,21�%67$57,1*�1(:�7$6. ���

5�� DSSOLFDWLRQ�VHUYHU

:RUN�SURFHVV

5HPRWH�

5���6\VWHP�$

5�� DSSOLFDWLRQ�VHUYHU

:RUN�SURFHVV

5���6\VWHP�%

)XQFWLRQ�JURXS�

)XQFWLRQPRGXOH)XQFWLRQPRGXOH

� aRFC is particularly suited for implementing parallel processing in several R/3 Systems.

Page 58: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 3-38

SAP AG 2002

D5)&�:LWKLQ�WKH 6DPH�5���6\VWHP

352*5$0����&$//�)81&7,21 ���'(67,1$7,21�$�67$57,1*�1(:�7$6. ���

5�� DSSOLFDWLRQ�VHUYHU $�

:RUN�SURFHVV

UHPRWH�

5���6\VWHP

5�� DSSOLFDWLRQ�VHUYHU $���

:RUN�SURFHVV)XQFWLRQ�JURXS�

)XQFWLRQ�PRGXOH)XQFWLRQ�PRGXOH

,QWHUQDO

� You can also use aRFC within the same SAP R/3 System, for example, to move some of the processing load to an application server specially used for this.

� Enter the RFC destination that refers to the corresponding application server. (You can find this under ,QWHUQDO�FRQQHFWLRQV in transaction SM59.)

Page 59: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 3-39

SAP AG 2006

5���6\VWHP�

D5)&�LQ�WKH�6DPH�5���6\VWHP�ZLWK�/RDG�'LVWULEXWLRQ

352*5$0���������

&$//�)81&7,21�;<=67$57,1*�1(:�7$6.�7�'(67,1$7,21�,1�*5283�*�

�'(67,1$7,21�,1�*5283�'()$8/7W�W�W

(;&(37,216W�W�W5(6285&(B)$,/85( ����

352*5$0���������

&$//�)81&7,21�;<=67$57,1*�1(:�7$6.�7�'(67,1$7,21�,1�*5283�*�

�'(67,1$7,21�,1�*5283�'()$8/7W�W�W

(;&(37,216W�W�W5(6285&(B)$,/85( ����

$SSO�6HUYHU$�

$SSO�6HUYHU$�

5)&�JURXS�*�

���

$SSO�6HUYHU$�

$SSO�6HUYHU$�

5)&�JURXS�*�

5)&�JURXS�'()$8/7

� You can use transaction SM59 to divide the application servers for an SAP R/3 system into different RFC groups.

� At a function module call in this R/3 system you can use the addition DESTINATION IN GROUP <RFC group> to specify one of the defined RFC groups. The server in this group that has the lowest load is then selected to execute the function module. You can also specify the ’DEFAULT’ RFC group. The server is then selected from amongst all the application servers of the R/3 system.

� When assigning an application server to an RFC group, you can specify conditions under which the application server is to be considered as "available for aRFCs within the same R/3 system". If none of the servers belonging to the specified RFC group are available for this aRFC, the system triggers the exception 5(6285&(B)$,/85(��

� Notes about the addition �'(67,1$7,21�,1�*5283�� - It is generally to be considered different from the previous addition DESTINATION, -�In contrast to the previous addition DESTINATION you must specify it �DIWHU��67$57,1*�1(:�7$6.���and - FDQ�RQO\�EH�XVHG�LQ�WKH�VDPH�5���V\VWHP, that is, it cannot be used together with the previous addition DESTINATION.

Page 60: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 3-40

SAP AG 2002

D5)&�:LWKLQ�WKH 6DPH $SSOLFDWLRQ 6HUYHU

5�� $SSOLFDWLRQ 6HUYHU

/RFDO

5���6\VWHP

:RUN�SURFHVV �)XQFWLRQ�JURXS�

)XQFWLRQ�PRGXOH

352*5$0����&$//�)81&7,21 ���67$57,1*�1(:�7$6. ���

:RUN�SURFHVV �

� You can also use aRFC locally within the VDPH�DSSOLFDWLRQ�VHUYHU to implement parallel processing in several work processes.

� Here you do not need to specify a destination.

� Note, however, that several work processes will be occupied by your program at the same time.

Page 61: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 3-41

SAP AG 2002

D5)&�ZLWK 'LDORJ

)81&7,21�$%&�

&$//�6&5((1�����

(1')81&7,21�

352*5$0����

&$//�)81&7,21�$%&'(67,1$7,21�%67$57,1*�1(:�7$6.�7�

6FUHHQ ���

���

������

���

5�� DSSOLFDWLRQ�VHUYHU 5HPRWH 5�� DSSOLFDWLRQ�VHUYHU

S�P X�N�O Y�Z\[5]*M�U�R@]IXAQ�[@]*]�^_ U&[�P�^!N�`>R

8VHU�HQWULHV

6FUHHQ ���6FUHHQ ���&DOOLQJ�VHVVLRQ

0DLQ VHVVLRQ ([WHUQDO�VHVVLRQ

� If you have called a function module asynchronously and it contains dialogs, the relevant screens are displayed in an additional (new external session) window on the calling side.

� Here, the remote logon use must be type GLDORJ� Otherwise, the RFC exception SYSTEM_FAILURE will be triggered.

� As with synchronous RFC, remote debugging is also possible for asynchronous calls. The debugger screen then appears as a new external mode. Here, too, the remote logon use must be type GLDORJ�and must also have debugging authorization.

� When you write the program, limit the number of external sessions for each dialog user to six. If the calling dialog user already has six external sessions open, the exception SYSTEM_FAILURE is triggered.

� Remember, too, that the aRFC dialog described here will not function if you have an SAP router set in between. The reason is that, for each aRFC dialog, a return link to the source system is specially set up, but this is not possible if an SAP router is implemented.

Page 62: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 3-42

SAP AG 2002

$V\QFKURQRXV�5)&� 7RSLF�6XPPDU\

z D5)&�HQDEOHV�\RX WR LPSOHPHQW SDUDOOHO SURFHVVLQJ�z <RX�FDQ�XVH�D5)&�V\VWHP�ZLGH� IRU PXOWLSOH DSSOLFDWLRQ�

VHUYHUV� RU�ORFDOO\�RQ�WKH�VDPH�DSSOLFDWLRQ�VHUYHU��z )XQFWLRQ�PRGXOHV�UXQQLQJ�DV\QFKURQRXVO\�FDQ�UHWXUQ�

GDWD WR WKH�FDOOLQJ�SURJUDP� 7R GR�WKLV� WKH�FDOOLQJ�SURJUDP�PXVW�UHPDLQ�DFWLYH�XQWLO�WKH�IXQFWLRQ�PRGXOH�RXWSXW�KDV�EHHQ�UHWXUQHG�

Page 63: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 3-43

SAP AG 2002

7UDQVDFWLRQDO 5)&

2YHUYLHZ2YHUYLHZ

5HPRWH�'HVWLQDWLRQV5HPRWH�'HVWLQDWLRQV

6\QFKURQRXV 5)&6\QFKURQRXV 5)&

$V\QFKURQRXV 5)&$V\QFKURQRXV 5)&

7UDQVDFWLRQDO 5)&7UDQVDFWLRQDO 5)&

4XHXHG 5)&4XHXHG 5)&

5)& ZLWK�([WHUQDO�3URJUDPV5)& ZLWK�([WHUQDO�3URJUDPV

6HFXULW\�$VSHFWV6HFXULW\�$VSHFWV

2YHUYLHZ2YHUYLHZ

5)& 'HVWLQDWLRQV5)& 'HVWLQDWLRQV

6\QFKURQRXV 5)&6\QFKURQRXV 5)&

$V\QFKURQRXV 5)&$V\QFKURQRXV 5)&

7UDQVDFWLRQDO 5)&7UDQVDFWLRQDO 5)&

4XHXHG 5)&4XHXHG 5)&

5)& ZLWK�([WHUQDO�3URJUDPV5)& ZLWK�([WHUQDO�3URJUDPV

8VH�RI 5)& 7\SHV DQG 5)& $XWKRUL]DWLRQV8VH�RI 5)& 7\SHV DQG 5)& $XWKRUL]DWLRQV

Page 64: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 3-44

SAP AG 2002

7UDQVDFWLRQDO�5)&��7RSLF�2EMHFWLYHV

z +RZ WR FRPELQH�VHYHUDO�UHPRWH�IXQFWLRQ�PRGXOHV�IRU�HDFK�GHVWLQDWLRQ� LQWR D GDWDEDVH /8: ZLWK�DXWRPDWLF�UROOEDFN�DQG�FRPPLW�PHFKDQLVPV�XVLQJ�W5)&�

z +RZ WR SURJUDP�W5)& LQ�$%$3�z 7R EH�DZDUH�WKDW�W5)&�JXDUDQWHHV�UHWXUQ�FRQILUPDWLRQ�RI�WKH�UHPRWH�SURFHVVLQJ�VWDWXV�DQG WREH�DEOH WR�PDQDJH W5)&�/8:V�XVLQJ�WUDQVDFWLRQ60���

Page 65: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 3-45

SAP AG 2006

7UDQVDFWLRQDO�5)&����3XUSRVH��3URFHVV��DQG�6\QWD[

352*5$0�������

&$//�)81&7,21�;�,1�%$&.*5281'�7$6.'(67,1$7,21�%���

&$//�)81&7,21�;�,1 %$&.*5281'�7$6.'(67,1$7,21�%���

&200,7 :25.�

352*5$0�������

&$//�)81&7,21�;�,1�%$&.*5281'�7$6.'(67,1$7,21�%���

&$//�)81&7,21�;�,1 %$&.*5281'�7$6.'(67,1$7,21�%���

&200,7 :25.����

6WDUW�ZLWK�GDWD�WUDQVIHU

�QR�ZDLWLQJ�

1R�IXQFWLRQ�PRGXOHRXWSXWV�UHFHLYHG

*XDUDQWHHGSURFHVVLQJ�FRQILUPDWLRQ

)81&7,21�;��

(1')81&7,21�

0DQDJHPHQW���PRQLWRULQJ�RI�W5)&�/8:V�XVLQJ�60��

0DQDJHPHQW���PRQLWRULQJ�RI�W5)&�/8:V�XVLQJ�60��

)81&7,21�;��

(1')81&7,21�

/RJLFDO�XQLW�RI�ZRUN�/8:����

���

'%�/8:

a�b&N�O'P Q�P RS(T�Q�U!M"MJP R+V

� Whereas with synchronous and asynchronous RFCs each call makes up a single logical unit of work (LUW) in the remote system, for transactional RFCs you can group several remote functions in one LUW (with automatic rollback mechanism if there is an error).

� You can implement a tRFC with the addition ",1�%$&.*5281'�7$6.", which you must place EHIRUH the DESTINATION entry. You can use "&200,7�:25." to bundle all the previously executed ??? RFCs in one LUW.

� tRFCs are also called asynchronously. Unlike aRFC, the output from the called function module cannot be received. -> No IMPORTING . . . / PERFORMING . . . ON END OF TASK when called; -> No RECEIVE RESULTS FROM FUNCTION . . .

� In the source system, you can use the administration transaction SM58 to display and modify tRFC LUWs.

Page 66: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 3-46

SAP AG 2002

([HFXWLRQ�0HFKDQLVPV

)XQFWLRQ �)XQFWLRQ �

6HUYHU

/8:([HFXWLRQ�VWDWXV

W5)&�FDOO �W5)&�FDOO �

&OLHQW

/8:

-RE

&200,7�:25.�

$5)&667$7($5)&6'$7$

60��

W5)&�FDOO�

ced�f>fhg.i.j!c*kAl;m�jn+o k?d�p�krq!mAgrq&s;d!c>t�u.p>mAi�jAv�k1d o t nw>x�y m�p�k�lzj&u <date/time> {

2SWLRQDO��

� tRFC calls are first stored in the local tRFC tables ARFCSSTATE and ARFCSDATA. The execution status of the LUWs is logged in table ARFCSSTATE, while ARFCSDATA contains the input data for the tRFCs.

� If you do not want to execute a remote LUW immediately, but rather trigger it at a later time, call the function module START_OF_BACKGROUNDTASK EHIRUH the COMMIT WORK�statement locally. Here, you must enter the date and time of execution.

� The COMMIT WORK statement automatically schedules an immediate job or a job set for a later start time to remotely call the LUW. During job execution, the relevant data is read from the tRFC tables, and the corresponding tRFCs are transmitted. If the remote LUW is executed successfully, the accompanying entries are deleted from the tRFC tables. If an error occurs, an automatic repeat mechanism or rollback mechanism is activated.

� If the update is also triggered locally by the COMMIT WORK statement, the tRFCs are executed only when the local update is successfully completed.

Page 67: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 3-47

SAP AG 2002

$XWRPDWLF�0HFKDQLVPV� 6XFFHVVIXO RU�(UURU

)XQFWLRQ �)XQFWLRQ �

6HUYHU

/8:([HFXWLRQ�VWDWXV

&OLHQW

-RE$5)&667$7($5)&6'$7$

60��

W5)&�FDOO�

,I�VXFFHVVIXO� 5HOHYDQW HQWULHV�GHOHWHG�IURP�W5)&�WDEOHV�,I�SDUWQHU QRW UHDFKDEOH� $XWRPDWLF�MRE�UHVFKHGXOLQJ�<RX�FDQ�VHW�WKH�QXPEHU�RI�UHSHDW�DWWHPSWV�DQG�LQWHUYDO�OHQJWK LQ WKH�GHVWLQDWLRQ

W5)&�RSWLRQV�

$XWRPDWLF�UROOEDFN LQ WKH�WDUJHW�V\VWHP � HUURU�QRWH LQ�$5)&667$7(

$ PHVVDJH ��5$,6(��H[FHSWLRQ!�1R�GHOHWLRQ � QR�DXWRPDWLF�MRE�UHVFKHGXOLQJ LQ VRXUFH�V\VWHP�

,I�HUURU�ZLWK�WHUPLQDWLRQ LQ RQH�RI�UHPRWH�IXQFWLRQV�PRGXOHV�|~}

|�}

� If no connection can be made to the partner, this is logged in the tRFC status table ARFCSSTATE (viewable by calling transaction SM58), and the job is rescheduled. In the destination, you can set the number of times the system repeats the effort to connect, and the time intervals, using the tRFC options. The default setting is 30 times maximum, with a 15-minute interval.

� If the program terminates with an A/X-message (MESSAGE A/X...) or triggers an exception (RAISE...) after a tRFC-LUW has been sucessfully executed in the partner system in one of the function modules, the following will happen: - All the changes executed in the remote system in the current LUW are rolled back. - These changes are logged in the source system of the remote program termination in the tRFC status table ARFCSSTATE (can be viewed using SM58). The entries relevant to the LUW remain in the tRFC tables, and the execution job is not rescheduled. In this case, you can find the remote error using transaction SM58, and you have to correct the problem in the remote system. Afterwards, you must trigger the remote execution again in transaction SM58 (function ([HFXWH�/8:).

� If you want to cancel and roll back this remote execution from a remote function module of a tRFC LUW, but at the same time reschedule the job in the source system (for example, because a master record that is to be processed is locked and the LUW must be executed again), call the function module RESTART_OF_BACKGROUNDTASK in the remote function module instead of MESSAGE A... or RAISE...

Page 68: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 3-48

SAP AG 2002

/8: %XQGOLQJ

;�

'HVWLQDWLRQ�%/8:�

352*5$0�������

&$//�)81&7,21�;��,1�%$&.*5281'�7$6.�'(67,1$7,21

&$//�)81&7,21�;��,1�%$&.*5281'�7$6.�'(67,1$7,21��

&$//�)81&7,21�;��,1�%$&.*5281'�7$6.�'(67,1$7,21

&$//�)81&7,21�;��,1�%$&.*5281'�7$6.�'(67,1$7,21

���&200,7�:25.�

352*5$0�������

&$//�)81&7,21�;��,1�%$&.*5281'�7$6.�'(67,1$7,21

&$//�)81&7,21�;��,1�%$&.*5281'�7$6.�'(67,1$7,21��

&$//�)81&7,21�;��,1�%$&.*5281'�7$6.�'(67,1$7,21

&$//�)81&7,21�;��,1�%$&.*5281'�7$6.�'(67,1$7,21

���&200,7�:25.�

&OLHQW SURJUDP

���I�

���I�

�����

�����

;�

;�

'HVWLQDWLRQ�&/8:�;�

� If tRFCs are transmitted with different destinations before the COMMIT WORK, they are grouped into different LUWs according to their destination.

� A tRFC call with the AS SEPARATE UNIT addition is always processed as a separate LUW independently of the other tRFCs.

� Each tRFC-LUW is assigned a unique transaction ID (viewable using transaction SM58). The function module ID_OF_BACKGROUNDTASK (called before the COMMIT WORK) returns this ID. You can determine the LUW execution status using the function module STATUS_OF_BACKGROUNDTASK under the transaction ID (which is called after the COMMIT WORK).

� If you also called the update function modules locally before the COMMIT WORK, tRFC calls will be processed only after the local update function modules have been processed successfully.

� You can also call transactional C functions. However, you must use the rollback mechanism in the external server program (see RFC-SDK documentation and example programs).

Page 69: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 3-49

SAP AG 2002

7UDQVDFWLRQDO�5)&� 7RSLF�6XPPDU\

z <RX�FDQ�XVH�W5)& WR SURFHVV�VHYHUDO�IXQFWLRQ�PRGXOHV�UHPRWHO\ LQ WKH�VDPH /8: ZLWK�WKH�DXWRPDWLF�UROOEDFN�PHFKDQLVP�

z W5)&�DOORZV�\RX WR HQVXUH�WKDW�WKH�IXQFWLRQ�PRGXOHV�\RX�FDOO�DUH�H[HFXWHG�HYHQ�LI�WKH�WDUJHW�V\VWHP�LV�XQDYDLODEOH�ZKHQ�WKH�FDOO�LV�PDGH�

z :LWK�W5)&V� \RX�DUH�JXDUDQWHHG D FRQILUPDWLRQ�RI�WKH�UHPRWH�SURFHVVLQJ�VWDWXV�

z <RX�FDQ�XVH�WUDQVDFWLRQ 60���WR GLVSOD\�DQG�SURFHVV�GHOHWH�DQG�H[HFXWH� LQFRUUHFW�RU�QRQ�H[HFXWHG�W5)&�/8:V�

Page 70: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 3-50

SAP AG 2002

4XHXHG 5)&

2YHUYLHZ2YHUYLHZ

5HPRWH�'HVWLQDWLRQV5HPRWH�'HVWLQDWLRQV

6\QFKURQRXV 5)&6\QFKURQRXV 5)&

$V\QFKURQRXV 5)&$V\QFKURQRXV 5)&

7UDQVDFWLRQDO 5)&7UDQVDFWLRQDO 5)&

4XHXHG 5)&4XHXHG 5)&

5)& ZLWK�([WHUQDO�3URJUDPV5)& ZLWK�([WHUQDO�3URJUDPV

6HFXULW\�$VSHFWV6HFXULW\�$VSHFWV

2YHUYLHZ2YHUYLHZ

5)& 'HVWLQDWLRQV5)& 'HVWLQDWLRQV

6\QFKURQRXV 5)&6\QFKURQRXV 5)&

$V\QFKURQRXV 5)&$V\QFKURQRXV 5)&

7UDQVDFWLRQDO 5)&7UDQVDFWLRQDO 5)&

4XHXHG 5)&4XHXHG 5)&

5)& ZLWK�([WHUQDO�3URJUDPV5)& ZLWK�([WHUQDO�3URJUDPV

8VH�RI 5)& 7\SHV DQG 5)& $XWKRUL]DWLRQV8VH�RI 5)& 7\SHV DQG 5)& $XWKRUL]DWLRQV

Page 71: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 3-51

SAP AG 2002

4XHXHG�5)&��7RSLF�2EMHFWLYHV

z <RX�NQRZ�WKDW�\RX�FDQ�VHULDOL]H�W5)&�/8:V LQ�DTXHXH�XVLQJ�TXHXHG 5)&�

z <RX�FDQ�H[SODLQ�WKH�DUFKLWHFWXUH�DQG�SURJUDPPLQJ�RI�TXHXHG 5)&�

z <RX�NQRZ�KRZ WR�PDQDJH�5)& TXHXHV�XVLQJ�WUDQVDFWLRQ 604��

Page 72: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 3-52

SAP AG 2002

3XUSRVH�RI�4XHXHG 5)&��T5)&�

�VW��W5)& /8:�.���1�3�5� �*���8�.���;� �F�

�.���1�3�5� �*���8�.���;� �8�

Q�WK W5)&�/8:�>���?�?�@� �A�B�B�>�A�.� � �

�>���?�?�@� �A�B�B�>�A�.� � �

�>���?�?�@� �A�B�B�>�A�.� �(�

�����

/8:LV�VHQW

/8:LV�JHQHUDWHG

/8:�4XHXH

6HULDOL]DWLRQ�RI�W5)&�/8:V

� LUWs generated using tRFC are processed independently of each other. This means the order in which they are processed is not always the order in which they are generated.

� To ensure that tRFC-LUWs are processed in the same order as they were generated, use qRFC as an extension of tRFC.

� Queued RFC (qRFC) is available as of Release 4.6A, and can be used in SAP R/3-R/3 connections and in SAP R/3 external connections.

Page 73: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 3-53

SAP AG 2002

6\QWD[

�>�������A�����!�&���*�����A�����.  ¡�¢&�� �£��!¢A�!¢. &����¤�¢¥�¦¢�§�¨����&�!�;�ª© «�¬!­>®�¯±°²�+£�³B� W�>�������A�����!�&���*��� � �

�;�´������µ�©���������¶·�.�K¡�µ¶�¢ª¡A���;���K�&���*�¸�¹§!º�»8� W�WAW

¨A�!��©�����¤ W�W�WW�W�W

�>�������A�����!�&���*�����A�����.  ¡�¢&�� �£��!¢A�!¢. &����¤�¢¥�¦¢�§�¨����&�!�;�ª© «�¬!­>®�¯±°²�+£�³B� W�>�������A�����!�&���*��� � �

�;�´������µ�©���������¶·�.�K¡�µ¶�¢ª¡A���;���K�&���*�¸�¹§!º�»8� W�WAW

����¤�¤(�*�½¼�����µ W�>�������A�����!�&���*�����A�����.  ¡�¢&�� �£��!¢A�!¢. &����¤�¢¥�¦¢�§�¨����&�!�;�ª© «�¬!­>®�¯±°²�+£�³B� W�>�������A�����!�&���*��� � �

�;�´������µ�©���������¶·�.�K¡�µ¶�¢ª¡A���;���K�&���*�¸�¹§!º�»8� W�WAW

�>�������A�����!�&���*�����A�����.  ¡�¢&�� �£��!¢A�!¢. &����¤�¢¥�¦¢�§�¨����&�!�;�ª© «�¬!­>®�¯±°²�+£�³B� W�>�������A�����!�&���*��� ¶ �

�;�´������µ�©���������¶·�.�K¡�µ¶�¢ª¡A���;���K�&���*�¸�¹§!º�»8� W�WAW

����¤�¤(�*�½¼�����µ W

¾1¿�ÀÂÁ�à Ä*Å>ÆÀ¹Ç�È*ÉBÊ1Ë�Ì�ÍÏÎÑÐÒ&Ó Æ Ó ÆÕÔI¾

Ö�ÐA×ØÁ�à Ä*Å.ÆÀ¹Ç�È*ÉBÊ1Ë�Ì�ÍÏÎÑÐÒ&Ó Æ Ó ÆÕÔI¾

W�W�W

� To place tRFC-LUWs in a first-in-first-out (FIFO) queue, you must specify the queue you want to use through the function module TRFC_SET_QUEUE_NAME EHIRUH�HYHU\�VLQJOH�W5)&�FDOO.

� You can choose the queue name you need to specify, and it can have up to 24 characters The queue name may QRW start with an empty character or the percent (%) symbol, and may not contain an asterisk (*).

Page 74: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 3-54

SAP AG 2002

'DWD�6WRUDJH�DQG 4XHXH�0DQDJHPHQW

75)&4287 $5)&667$7( $5)&6'$7$

W5)&�GDWD4XHXH GDWD

0DLQWDLQ�XVLQJ�7UDQVDFWLRQ 604�

'R QRW PDLQWDLQ�XVLQJ 60���

� The tRFC LUWs belonging to a queue are stored in the tRFC tables,ARFCSSTATE and ARFCSDATA. However, you cannot maintain or display these LUWs using Transaction SM58. You PXVW use the queue administration transaction SMQ1.

� The queue data (queue attributes + pointers to the relevant tRFC-LUWs in the tRFC tables) is stored in the TRFCQOUT table, which you can maintain using transaction SMQ1. The following functions are available: - List queues - Display queues with a list of accompanying LUWs and function modules including input data - Start or stop transmission of queues - Delete queues

� If an LUW error occurs in the remote system, the queue is rolled back there. The relevant LUW and all of the other LUWs in the queue remain in the queue and in the tRFC tables. After correcting the error, you can use transaction SMQ1 to transmit the queue again.

Page 75: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 3-55

SAP AG 2002

4XHXHG�5)&� 7RSLF�6XPPDU\

z :LWK�T5)&� \RX�FDQ�HQVXUH�WKDW�W5)&�/8:V�DUH�SURFHVVHG LQ WKH�RUGHU�WKH\�ZHUH�JHQHUDWHG�VHULDOL]DWLRQ��

z 7KLV�LV�LPSOHPHQWHG�XVLQJ D TXHXH�IRU�W5)&�/8:V�z 7KH�TXHXH�DWWULEXWHV�DUH�VWRUHG LQ WKH�TXHXH�WDEOH75)&4287 DQG�WKH�W5)&�LQSXW�GDWD LQ WKH�W5)&�WDEOHV $5)&667$7(�DQG $5)&6'$7$� <RX�FDQ�PDLQWDLQ�DQG�GLVSOD\�WKLV�LQIRUPDWLRQ�XVLQJ�WUDQVDFWLRQ 604��

Page 76: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 3-56

SAP AG 2002

5)& ZLWK�([WHUQDO�3URJUDPV

2YHUYLHZ2YHUYLHZ

5HPRWH�'HVWLQDWLRQV5HPRWH�'HVWLQDWLRQV

6\QFKURQRXV 5)&6\QFKURQRXV 5)&

$V\QFKURQRXV 5)&$V\QFKURQRXV 5)&

7UDQVDFWLRQDO 5)&7UDQVDFWLRQDO 5)&

4XHXHG 5)&4XHXHG 5)&

5)& ZLWK�([WHUQDO�3URJUDPV5)& ZLWK�([WHUQDO�3URJUDPV

6HFXULW\�$VSHFWV6HFXULW\�$VSHFWV

2YHUYLHZ2YHUYLHZ

5)& 'HVWLQDWLRQV5)& 'HVWLQDWLRQV

6\QFKURQRXV 5)&6\QFKURQRXV 5)&

$V\QFKURQRXV 5)&$V\QFKURQRXV 5)&

7UDQVDFWLRQDO 5)&7UDQVDFWLRQDO 5)&

4XHXHG 5)&4XHXHG 5)&

5)& ZLWK�([WHUQDO�3URJUDPV5)& ZLWK�([WHUQDO�3URJUDPV

8VH�RI 5)& 7\SHV DQG 5)& $XWKRUL]DWLRQV8VH�RI 5)& 7\SHV DQG 5)& $XWKRUL]DWLRQV

Page 77: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 3-57

SAP AG 2002

5)&�ZLWK�([WHUQDO�3URJUDPV��7RSLF�2EMHFWLYHV

z <RX ZLOO OHDUQ�KRZ�H[WHUQDO 5)& FOLHQWV�DQG 5)&VHUYHUV�DUH�VWUXFWXUHG LQ�&�

Page 78: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 3-58

SAP AG 2002

([WHUQDO 5)&�&OLHQW DQG 6HUYHU([WHUQDO 6\VWHP

352*5$0����

&$//�)81&7,21�$%&'(67,1$7,21 (;73*0���

5���6\VWHP

5)& OLEUDU\�5)&�6'.�

$%$3 SURJUDP

5)& VHUYHU�SURJUDP���

���

���&�5RXWLQH�$%&

���&�5RXWLQH�;<=

5)& FOLHQW�SURJUDP���

)XQFWLRQ�PRGXOH)81&7,21�)81&��

(1')81&7,21�

���

� SAP delivers the RFC Library for all standard external platforms that contain RFC calls for C programs. After installing the RFC Library on your external platform, you can use the RFC client or RFC server programs with RFC calls.

� In addition to the RFC Library, you also have several sample programs in C source together with documentation supplied with your system.

Page 79: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 3-59

SAP AG 2002

5)& 'HVWLQDWLRQV�IRU & 3URJUDPV �VDSUIF�LQL�

VDSUIF�LQL���WH[W�ILOH�

'(67 7��B/%7<3( %5�1$0( 7��06+267 LZGI����*5283 63$&(

'(67 7��B$6�7<3( $$6+267 LZGI����6<615 ��

'(67 (;73*07<3( (*:+267 KV����*:6(59 VDSJZ��73+267 KV����731$0( '�?DEF?VUIFVHUY

���

� You maintain RFC destinations for C programs in the text file saprfc.ini .

� In addition to the RFC Library, there is also an saprfc.ini with sample entries and documentation for maintaining the different RFC destination types supplied with your system.

� For details, refer to the online documentation.

Page 80: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 3-60

SAP AG 2002

([WHUQDO 5)&�&OLHQW

5IF2SHQ���������

5IF&DOO���������

5IF5HFHLYH���������

5IF&DOO����������

5IF5HFHLYH����������

5IF&ORVH���������

5IF&DOO5HFHLYH������

� This slide shows you the structure of an external RFC client.

� The connection to the SAP R/3 System is made using the RFC call 5IF2SHQ with the destination and logon data.

� 5IF&DOO calls an R/3 function module. 5IF5HFHLYH receives the output of the function module. This enables you to use an asynchronous call. If you want to use a synchronous call, use 5IF&DOO5HFHLYH�instead of these two RFC calls.

� To close the RFC connection to the SAP R/3 System, use 5IF&ORVH� � You will find the semantics and syntax for the RFC calls listed in the RFC library in the online

documentation.

� The VDSLQIR program provides an example of an RFC client in C source that is delivered with the RFC Library. This program calls the function module RFC_SYSTEM_INFO in a remote R/3 System to get R/3 system data from it.

Page 81: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 3-61

SAP AG 2002

([WHUQDO 5)&�6HUYHUPDLQ�����^������5IF$FFHSW�����5IF,QVWDOO)XQFWLRQ�DEF�����5IF,QVWDOO)XQFWLRQ�[\]�����5IF'LVSDWFK�����5IF&ORVH�����`VWDWLF 5)&B5& DEF�����^�����5IF*HW'DWD�����

5IF6HQG'DWD�����`VWDWLF 5)&B5& [\]�����^�������`

'DWD�SURFHVVLQJ

� This slide shows you the structure of an external RFC server.

� The call 5IF$FFHSW accepts the incoming RFC connection.

� All C routines for the RFC server program that should be called remotely must be registered as being remote-enabled using the call 5IF,QVWDOO)XQFWLRQ.

� The call 5IF'LVSDWFK sends the incoming call to the corresponding C rontine.

� The call 5IF*HW'DWD enables the C routine to receive the input sent from the calling program.

� The call 5IF6HQG'DWD, returns the result to the calling program.

� The call 5IF&ORVH ends the RFC connection.

� You will find the semantics and syntax for the RFC calls listed in the RFC Library in the online documentation.

� The VDSLQIR program provides an example of an RFC client in C source that is delivered with the RFC library. This program contains various, interesting remote-enabled routines and can, for example, be called in the standard system with the supplied ABAP program RSRFCDOC through a corresponding RFC destination.

Page 82: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 3-62

SAP AG 2002

5)&�ZLWK�([WHUQDO�SURJUDPV� 7RSLF�6XPPDU\

z 7KH 5)&�6'. PXVW�EH�LQVWDOOHG�IRU 5)& RQ�WKH�H[WHUQDO�SODWIRUP�

z 7KH�WH[W�ILOH�VDSUIF�LQL�FRQWDLQV 5)& GHVWLQDWLRQV�IRU &FOLHQWV�

z <RX�FDQ�FDOO 5�� IXQFWLRQ�PRGXOHV�XVLQJ DQ H[WHUQDO5)& FOLHQW�SURJUDP�

z $OO UHPRWH�HQDEOHG� UHJLVWHUHG & URXWLQHV�RI DQ�5)&VHUYHU�SURJUDP�FDQ�EH�FDOOHG�IURP�ZLWKLQ $%$3SURJUDPV��

Page 83: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 3-63

SAP AG 2002

8VH�RI 5)& 7\SHV ��5)& $XWKRUL]DWLRQV

2YHUYLHZ2YHUYLHZ

5HPRWH�'HVWLQDWLRQV5HPRWH�'HVWLQDWLRQV

6\QFKURQRXV 5)&6\QFKURQRXV 5)&

$V\QFKURQRXV 5)&$V\QFKURQRXV 5)&

7UDQVDFWLRQDO 5)&7UDQVDFWLRQDO 5)&

4XHXHG 5)&4XHXHG 5)&

5)& ZLWK�([WHUQDO�3URJUDPV5)& ZLWK�([WHUQDO�3URJUDPV

6HFXULW\�$VSHFWV6HFXULW\�$VSHFWV

2YHUYLHZ2YHUYLHZ

5)& 'HVWLQDWLRQV5)& 'HVWLQDWLRQV

6\QFKURQRXV 5)&6\QFKURQRXV 5)&

$V\QFKURQRXV 5)&$V\QFKURQRXV 5)&

7UDQVDFWLRQDO 5)&7UDQVDFWLRQDO 5)&

4XHXHG 5)&4XHXHG 5)&

5)& ZLWK�([WHUQDO�3URJUDPV5)& ZLWK�([WHUQDO�3URJUDPV

8VH�RI 5)& 7\SHV DQG 5)& $XWKRUL]DWLRQV8VH�RI 5)& 7\SHV DQG 5)& $XWKRUL]DWLRQV

Page 84: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 3-64

SAP AG 2002

5)&�7\SHV�DQG�$XWKRUL]DWLRQV� 7RSLF�2EMHFWLYHV

z <RX ZLOO OHDUQ�ZKLFK 5)& W\SHV�DUH WR EH�XVHG�IRU�ZKLFK�SXUSRVH�

z <RX�FDQ�H[SODLQ�ZKLFK�DXWKRUL]DWLRQ�FKHFNV�H[LVW�IRU5)&�

z <RX�NQRZ�ZKLFK�DXWKRUL]DWLRQV�WKH�UHPRWH�XVHU�QHHGV�IRU�WKH 5)& ORJRQ WR FDOO�WKH�UHPRWH�IXQFWLRQ�PRGXOH�VXFFHVVIXOO\�

z <RX�FDQ�GHILQH�WUXVW�UHODWLRQVKLSV�EHWZHHQ 6$3�5����6\VWHPV� DQG DOVR H[SODLQ � IRU�H[LVWLQJ�WUXVW�UHODWLRQVKLSV � KRZ�XVHUV LQ WKH�VRXUFH�V\VWHP�FDQ�XVH�WKH�UHOHDVHG�XVHU�,'V LQ WKH�WDUJHW�V\VWHP�ZLWKRXW�QHHGLQJ D SDVVZRUG�IRU 5)& ORJRQ�

z <RX�NQRZ�KRZ WR UHOHDVH�XVHU�,'V LQ WKH�WDUJHW�V\VWHP�IRU�VSHFLILF�XVHU�,'V LQ WKH�VRXUFH�V\VWHP�ZLWK DQH[LVWLQJ�WUXVW�UHODWLRQVKLS�

z <RX�NQRZ�WKH�5)&�XWLOLWLHV�WKDW�DUH�XVHIXO��

Page 85: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 3-65

SAP AG 2002

3URFHVVLQJ 6WDWXV IRU�&RPPXQLFDWLRQ�(UURUV

V5)&� D5)&

6RXUFH�V\VWHP 7DUJHW�V\VWHP

3URJUDP5)& HUURU

3URJUDP

5HPRWHSURFHVVLQJ

5HPRWHSURFHVVLQJ

W5)&� T5)&

*XDUDQWHHG�FRQILUPDWLRQ�RI�UHPRWH�SURFHVVLQJ�

VWDWXV

5HPRWHSURFHVVLQJ�VWDWXV"

� If a communication error occurs during synchronous or asynchronous RFC, the remote processing status is unknown. Therefore, these two RFC types are suitable for remote data retrieval where knowledge of the remote processing status is not of primary importance, even if a communication error occurs.

� Transaction or queued RFCs, on the other hand, always guarantee confirmation of the remote processing status (continued confirmation attempts until confirmation is successful) Therefore, these two RFC types are paraticularly suitable for remote data changes where knowledge of the remote processing status is important.

Page 86: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 3-66

SAP AG 2002

8VH�RI 'LIIHUHQW�5)& 7\SHV

5HPRWH�'DWD�5HWULHYDO�

5HPRWH�'DWD�&KDQJHV�

� 6\QFKURQRXV 5)&� $V\QFKURQRXV 5)&

� 7UDQVDFWLRQDO 5)&� 4XHXHG 5)&

Page 87: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 3-67

SAP AG 2002

$XWKRUL]DWLRQ &KHFN IRU 5)&

6RXUFH 6\VWHP 7DUJHW 6$3�5���6\VWHP

5)&8VHU 60,7+

5)& ORJRQ�ZLWKUHPRWH�XVHU

60,7+

3URJUDP � $XWKRUL]DWLRQ�IRU 5)& VWDUW�RI�GHVLUHG�IXQFWLRQ�PRGXOH

� $XWKRUL]DWLRQV�IRU�DFWLRQVRQ�WKH�IXQFWLRQ�PRGXOH

)XQFWLRQ�PRGXOH

�5����5��� H[WHUQDO�

� The authorization object S_RFC lets you define, for each RFC logon user, in which function groups the user is authorized to start RFC. This user can only start function modules in these function groups with RFC.

� This authorization check is active by default. However, you can deactivate this default setting using a profile parameter.

� Authorization checks for actions that call a function module remotely (for example, transaction authorization for CALL TRANSACTION) are compared against the user master record of the corresponding RFC logon user.

Page 88: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 3-68

SAP AG 2006

7KH�$XWKRUL]DWLRQ�2EMHFW�6B5)&

$XWKRUL]DWLRQ�$%&'�5)&B1$0(��������$%&'$&797������������������

2EMHFW�6B5)&5)&B1$0(� �)XQFWLRQ�JURXS�

$&797������������$FWLYLW\�

$XWKRUL]DWLRQ�$//5)&B1$0(��������� $&797�������������������

5)&B7<3(�����5)&�REMHFW�W\SH�

5)&B7<3(����������)8*5

5)&B7<3(���������)8*5

$XWKRUL]DWLRQ�IRU�5)&�ORJRQ�XVHUWR�VWDUW�D�IXQFWLRQ�PRGXOH

� The authorization object S_RFC contains three fields: - 5)&B1$0(�: Can currently contain only names of function groups - $&797�: Can currently accept only the value 16 (execute) - 5)&B7<3(�: Can currently accept only the value FUGR (function group)

� The above examples show authorizations for the object S_RFC : - If you use an RFC logon user with authorization "ALL", you can call all function modules. . - However, if you use an RFC logon user that only has authorization "ABCD", you can only call function modules of function group ABCD.

Page 89: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 3-69

SAP AG 2002

7UXVW 5HODWLRQVKLSV �2QO\ 5���5�� �

5���6\VWHP�$

7UXVWHG 6\VWHP

5���6\VWHP�%

7UXVWLQJ 6\VWHP

'HFODUDWLRQ�RI D WUXVW�UHODWLRQVKLS�XVLQJ 607��LQ WKH�V\VWHP�WKDW�LV WREHFRPH�WKH�WUXVWLQJ�V\VWHP�

607�

� You can declare a trust relationship between two SAP R/3 Systems so that you can perform certain RFC logons in the trusting system without requiring a password for released users.

� You always declare a trust relationship in the system that is to become the trusting system, which means, it is in the RFC target system.

� You use transaction SMT1 to define a trust relationship.

� You can use transaction SMT2�in the trusted system to display which trusting systems are declared for the local system.

Page 90: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 3-70

SAP AG 2002

5)& /RJRQ�:LWKRXW D 3DVVZRUG

5���6\VWHP�$7UXVWHG 6\VWHP7UXVW GHVWLQDWLRQ �60���Remote system BRemote client 002Remote user SMITHNo password !

'LDORJ�XVHU5\DQ

$%$3SURJUDP

5)&

5���6\VWHP�%7UXVWLQJ 6\VWHP

8VHU 60,7+5)& ORJRQ5HPRWH�XVHU60,7+ XVHG�ZLWKRXW�SDVVZRUG

Logon language EN

- Released for user Ryan in trusted system A

)XQFWLRQ�PRGXOH

- Authorization for RFC start of desired function module

- Authorizations for actionson the function module

� A dialog user in the trusted system (RFC source system) can use a specially released, defined user ID for the RFC logon in the trusting system (RFC target system) without a password. To do this, the user requires a trust destination, created using transaction SM59�(7UXVWHG�V\VWHP = ’<HV’), in which only the name of the remote user is entered, not the accompanying password. 1RWH: You can also use regular destinations (with a password) with an existing trust relationship.

� To be able to use RFC logon without a password for a specific user ID in the trusted system, you need to release a user in the trusting system. You do this by giving an authorization for the authorization object S_RFCACL to the user you want to release in the trusting system.

� For a detailed description of the definition and usage of trust relationships, refer to note number 128447.

Page 91: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 3-71

SAP AG 2006

7KH�$XWKRUL]DWLRQ�2EMHFW�6B5)&$&/

2EMHFW��6B5)&$&/

5HOHDVH�D�XVHU�LQ�WKH�7UXVWLQJ�6\VWHP E\�DVVLJQLQJ�DXWKRUL]DWLRQ

5)&B6<6,'5)&B&/,(175)&B86(55)&B(486(55)&B7&2'(5)&B,1)2$&797

$XWKRUL]DWLRQ��$���B5<$1�5)&B6<6,'����������$5)&B&/,(17����������5)&B86(5����������5<$15)&B(486(5������<5)&B7&2'(��������� 5)&B,1)2������������� $&797��������������������

� The authorization object 6B5)&$&/ contains seven fields : - 5)&B6<6,'�: Calling RFC source system (trusted system) - 5)&B&/,(17�: Calling client - 5)&B86(5�: Calling user - 5)&B(486(5�: Indicator that shows if the user that has this authorization is released for the user of the same name in the RFC source system. - 5)&B7&2'(�: Calling transaction - 5)&B,1)2: Additional information about the RFC source system (not currently used) - $&797�: Can only have the value 16 (execute)

� Example: If user SMITH in the trusting system has the authorization "A400_RYAN", he is released for the user RYAN in the trusted system A. RYAN is allowed to use remote user SMITH for RFC logon without a password using any transaction from system A, client 400. 5)&B(486(5� � means that user SMITH is released for the user of the same name in trusted system A.

Page 92: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 3-72

SAP AG 2002

L

5)&�8WLOLWLHV

z 6KRUW�GXPSV�FDXVHG�E\�UHPRWH�IXQFWLRQ�PRGXOHV�67�� LQ WKH�UHPRWH�V\VWHP

z *DWHZD\�PRQLWRU �GLVSOD\V DOO UXQQLQJ�UHPRWH�FRQQHFWLRQV�WKDW�UXQ�RQ�WKH�FXUUHQW 5�� JDWHZD\�� 60*:

z 7UDFHV �� 8VHU�UHODWHG 5)& WUDFH � 67��� 'HVWLQDWLRQ�UHODWHG 5)& WUDFH � 60��� *DWHZD\�WUDFH � 60*:

z ,Q WKH�GHEXJJHU� KDYH D EUHDNSRLQW�VHW LQ�IURQW RI�HDFK 5)&��%UHDNSRLQW�PHQX LQ WKH�GHEXJJHU

z *HQHUDO WLSV�IRU 5)&� �NH\ LQ�$%$3 HGLWRU(QWHU $%$3 WHUP 5)&

� You can analyze dumps caused by RFC function modules in the remote system using transaction ST22.

� The gateway monitor (transaction SMGW) shows all the remote connections that run through the gateway of the current application server.

� Using transaction ST05, you can switch on/off and display a user-related RFC trace for the current user.

� To display a destination-related trace, proceed as follows: - Set WUDFH�flag in der definition (SM59) of the required destination Display trace using SM59 then choose RFC → Display trace

� To display the gateway trace, use transaction SMGW or choose from the menu as follows: *RWR�→�7UDFH�→�*DWHZD\�→�'LVSOD\�ILOH.

� To have a breakpoint set automatically before each RFC statement in the debugger of your calling program, from the Debugger menu, choose: %UHDNSRLQWV�→�%UHDNSRLQW�IRU�VWDWHPHQW�→�(QWHU�5)&�

� Through the i key (information key) in your ABAP editor, you can specify the ABAP term RFC and call up useful information on the RFC topic.

Page 93: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 3-73

SAP AG 2002

5)&�7\SHV�DQG�$XWKRUL]DWLRQV� 7RSLF�6XPPDU\

z 6\QFKURQRXV�DQG�DV\QFKURQRXV�5)&V�DUH�VXLWDEOH�IRU�UHPRWH�GDWD�UHWULHYDO� )RU�UHPRWH�GDWD�FKDQJHV�WUDQVDFWLRQDO�RU�TXHXHG 5)& LV�PRUH�VXLWDEOH�GHSHQGLQJ�RQ�UHTXLUHPHQWV� EHFDXVH�RI�JXDUDQWHHG�UHPRWH�SURFHVVLQJ�FRQILUPDWLRQ�

z 7R VWDUW D IXQFWLRQ�PRGXOH�XVLQJ 5)&� WKH 5)& ORJRQ�XVHU LQ WKH�WDUJHW�V\VWHP�QHHGV D FRUUHVSRQGLQJ�DXWKRUL]DWLRQ�IRU�WKH�DXWKRUL]DWLRQ�REMHFW 6B5)&�

z )RU DQ H[LVWLQJ�WUXVW�UHODWLRQVKLS�EHWZHHQ�WZR 6$3�5���6\VWHPV� VSHFLILF�XVHUV LQ WKH�VRXUFH�V\VWHP�FDQ�XVH�WKH�XVHU�UHOHDVHG�IRU�WKHP LQ WKH�WDUJHW�V\VWHP�IRU 5)&ORJRQV�ZLWKRXW D SDVVZRUG�

z 7R UHOHDVH D XVHU LQ WKH�WDUJHW�V\VWHP� \RX�QHHG WR JLYHDQ DXWKRUL]DWLRQ�IRU�WKH�DXWKRUL]DWLRQ�REMHFW 6B5)&$&/�

Page 94: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 3-74

Page 95: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 3-75

([HUFLVHV�

8QLW��5HPRWH�)XQFWLRQ�&DOO�7RSLF��5HPRWH�'HVWLQDWLRQV�

• Creating a logical destination for RFC communication with another R/3 System.

RFC destination name: DEST##

User in source system: BC415-##

Remote user for RFC logon: BC415-## ( ## = your group number)

1-1 Create and maintain logical destinations for Remote Function Call using transaction SM59. Create a destination in R/3 System A through which it can communicate with R/3 System B using RFC. (The names of systems A and B will be given to you by your instructor.) You can find out the information you need using transaction SM51 in the target system.

1-2 Test your destination.

7LSV��7ULFNV�

When maintaining the destination, you can press ENTER after entering the connection type to refresh the screen where fields relating to the connection type appear for maintenance.

Page 96: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 3-76

Page 97: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 3-77

Exercises

8QLW��5HPRWH�)XQFWLRQ�&DOO�7RSLF��6\QFKURQRXV�5)&�

• Calling a remote function module synchronously and passing data.

Template: SAPBC415_RFCSYNC_T1

Name of your solution program: ZBC415_##_RFCSYNC

Name of the function module to be called: BC415_RFC_READ_SPFLI

2-1 In system B, learn to use the functions of the�%&���B5)&B5($'B63)/, function module (interface and source text). The function module reads an entry from table SPFLI. In the function call, you pass the relevant key values required for the read access using the interface parameters. If no table entry was found during the read access, an exception is triggered in the function module. If the function module reads an entry successfully, it passes the table entry and system ID back to the caller through the interface parameters.

2-2 In system A, create a program by first copying the sample program listed above. From your program, call the function module BC415_RFC_READ_SPFLI in destination system B. Check the exceptions defined in the function module. If an error occurs, display the relevant error message. If the program is successful, output the data returned by the function module.

Page 98: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 3-78

Page 99: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 3-79

Exercises

8QLW��5HPRWH�)XQFWLRQ�&DOO�7RSLF��$V\QFKURQRXV�5)&�

• Calling an RFC function module synchronously and passing data.

Template: ZBC415_##_RFCSYNC (or SAPBC415_RFCSYNC_S1)

Name of your solution program: ZBC415_##_RFCASYNC

3-1 Calling a function module remotely and asynchronously Copy your solution from the Synchronous RFC exercise or the model solution SAPBC415_RFCSYNC_S1, and convert the function call, data transfer, and exception handling to asynchronous processing.

Page 100: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 3-80

Page 101: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 3-81

([HUFLVHV�

8QLW��5HPRWH�)XQFWLRQ�&DOO�7RSLF��7UDQVDFWLRQDO�5)&�

• Making identical changes to a customer’s telephone number in two R/3 Systems using transactional RFC.

Template: SAPBC415_RFCTRANS_T1

Name of your dialog program : SAPMZ_BC415_##_RFCTRANS

Name of your transaction : ZBC415_##

4-1 Making the same changes to customer data in two R/3 Systems.

4-1-1 Copy the program SAPBC415_RFCTRANS_T1 to your program. This program is a module pool, with screens and user interfaces. Ensure that you copy all of the program components! You need to define a transaction code for your dialog program (see name above).

4-1-2 Go to the module USER_COMMAND_0200. There you will find a CASE statement for the field OKCODE. Enter the processing step you want to supplement under :+(1�µ6$9(¶.

4-1-3 The function module BC415_TRFC_CHANGE_SCUSTOM_ENTR allows you to change the telephone number of a customer (table SCUSTOM ). This function module contains two import parameters: CUSTOMER_ID Æ customer number I_TELEPHONE Æ telephone number Call the function module locally (-> local change) and then call it again remotely using transactional RFC (-> identical remote change).

4-1-4 In the remote system, use the Data Browser (transaction SE16) to check that the changes have been made correctly. If not, use transaction SM58 (tRFC monitor) to find out why.

4-1-5 Set the processing of the tRFC LUW for a future time. To do this, use the START_OF_BACKGROUNDTASK function module. In screen 200, you see the entry field for the time of execution that you pass along when you call the function module.

4-1-6 In the source system, use transaction SM58 to check that the tRFC LUW has been correctly scheduled and executed.

Page 102: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 3-82

Page 103: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 3-83

6ROXWLRQV��

8QLW��5HPRWH�)XQFWLRQ�&DOO�7RSLF���5HPRWH�'HVWLQDWLRQ�

• Creating a logical destination for RFC communication with another R/3 system.

1. Call transaction 60��.

2. Choose &UHDWH. A screen appears, on which you should enter the name of the new destination. In the "Connection Type” field, enter � as the connection type (Æ the target system is an R/3 system). Enter a description. Choose (QWHU to continue.

3. In the next step, you must specify an R/3 application server for the target system by entering the relevant host name and the R/3 system number. You can get the required information by running transaction SM51 in the target system. There you will see a list of all the instances in the target system. The instance ID consists of the: - Name of the host on which the instance is running (for example, hs0330) - System ID (for example, ABC) - System number for the instance (for example, 17) This example would therefore be displayed as follows: hs0330_ABC_17.

4. Choose "Unicode Test" to check if the target system is a Unicode system, and make the appropriate settings according to the result.

5. You must now enter the RFC logon data ( language, client, user, password), and save the destination.

6. Test your RFC destination by choosing "Connection Test” or “Remote Logon”.

Page 104: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 3-84

8QLW��5HPRWH�)XQFWLRQ�&DOO�7RSLF��6\QFKURQRXV�5)&��

• Calling an RFC function module synchronously, with data transfer.

6RXUFH�WH[W�RI�WKH�VROXWLRQ�SURJUDP�

REPORT sapbc415_rfcsync_s1 MESSAGE-ID bc415.

PARAMETERS:

icarr TYPE sflight-carrid DEFAULT ’LH’,

iconn TYPE sflight-connid DEFAULT ’0400’,

dest TYPE rfcdes-rfcdest DEFAULT ’NONE’.

DATA: wa_spfli TYPE spfli,

sysid LIKE sy-sysid,

mess(80).

START-OF-SELECTION.

CALL FUNCTION ’BC415_RFC_READ_SPFLI’

DESTINATION dest

EXPORTING

carrid = icarr

connid = iconn

IMPORTING

ex_spfli = wa_spfli

sys = sysid

EXCEPTIONS

invalid_data = 1

communication_failure = 2 MESSAGE mess

system_failure = 3 MESSAGE mess.

CASE sy-subrc.

WHEN 0.

WRITE: / text-004, sysid COLOR 5.

SKIP.

Page 105: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 3-85

WRITE: wa_spfli-carrid, wa_spfli-connid,

wa_spfli-cityfrom, wa_spfli-cityto.

WHEN 1.

WRITE / text-001.

WHEN 2.

WRITE / mess.

WHEN 3.

WRITE / mess.

ENDCASE.

Page 106: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 3-86

Page 107: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 3-87

8QLW��5HPRWH�)XQFWLRQ�&DOO�7RSLF��$V\QFKURQRXV�5)&�

• Calling an RFC function module asynchronously with data transfer.

6RXUFH�WH[W�RI�WKH�VROXWLRQ�SURJUDP�

REPORT sapbc415_rfcasync_s1 MESSAGE-ID bc415.

PARAMETERS:

icarr TYPE sflight-carrid DEFAULT ’LH’,

iconn TYPE sflight-connid DEFAULT ’0400’,

dest TYPE rfcdes-rfcdest DEFAULT ’NONE’.

DATA: wa_spfli TYPE spfli,

sysid LIKE sy-sysid,

mess(80),

flag,

retcode LIKE sy-subrc.

START-OF-SELECTION.

CALL FUNCTION ’BC415_RFC_READ_SPFLI’

DESTINATION dest

STARTING NEW TASK ’T1’

PERFORMING back ON END OF TASK

EXPORTING

carrid = icarr

connid = iconn

EXCEPTIONS

communication_failure = 2 MESSAGE mess

system_failure = 3 MESSAGE mess.

CASE sy-subrc.

Page 108: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 3-88

WHEN 2.

WRITE: / mess.

EXIT.

WHEN 3.

WRITE: / mess.

EXIT.

ENDCASE.

WAIT UNTIL flag IS NOT INITIAL.

CASE retcode.

WHEN 0.

WRITE: / text-004, sysid COLOR 5.

SKIP.

WRITE: wa_spfli-carrid, wa_spfli-connid,

wa_spfli-cityfrom, wa_spfli-cityto.

WHEN 1.

WRITE: / text-001, / text-002.

WHEN 2 OR 3.

WRITE mess.

ENDCASE.

Page 109: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 3-89

*---------------------------------------------------------------------*

* FORM BACK *

*---------------------------------------------------------------------*

* --> T *

*---------------------------------------------------------------------*

FORM back USING t.

RECEIVE RESULTS FROM FUNCTION ’BC415_RFC_READ_SPFLI’

IMPORTING

ex_spfli = wa_spfli

sys = sysid

EXCEPTIONS

invalid_data = 1

communication_failure = 2 message mess

system_failure = 3 message mess.

retcode = sy-subrc.

flag = ’X’.

ENDFORM. "BACK

Page 110: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 3-90

Page 111: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 3-91

8QLW��5HPRWH�)XQFWLRQ�&DOO��7RSLF��7UDQVDFWLRQDO�5)&��

• Making identical changes to a customer’s telephone number in two R/3 systems using transactional RFC.

6FUHHQ������)ORZ�/RJLF��

PROCESS BEFORE OUTPUT. MODULE status_0200. MODULE set_values.

PROCESS AFTER INPUT. MODULE user_command_0200.

0RGXO�XVHUBFRPPDQGB�����

MODULE user_command_0200 INPUT.

CASE okcode.

WHEN ’SAVE’.

CALL FUNCTION ’BC415_TRFC_CHANGE_SCUSTOM_ENTR’

EXPORTING

customer_id = scustom-id

i_telephone = scustom-telephone

EXCEPTIONS

no_data_found = 1.

IF sy-subrc <> 0.

MESSAGE a514 WITH scustom-id.

ELSE.

MESSAGE i515.

ENDIF.

CALL FUNCTION ’BC415_TRFC_CHANGE_SCUSTOM_ENTR’

IN BACKGROUND TASK

DESTINATION destination

EXPORTING

customer_id = scustom-id

i_telephone = scustom-telephone.

Page 112: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 3-92

CALL FUNCTION ’START_OF_BACKGROUNDTASK’

EXPORTING

startdate = sy-datum

starttime..= time.

COMMIT WORK.

MESSAGE i517 WITH time.

WHEN ’SM58’.

CALL TRANSACTION ’SM58’.

WHEN ’BACK’.

LEAVE TO SCREEN 100.

WHEN ’END’.

LEAVE PROGRAM.

WHEN ’CANC’.

LEAVE TO SCREEN 100.

ENDCASE.

ENDMODULE. " user_command_0200 INPUT

Page 113: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 4-1

SAP AG 2002

%$3,�� %XVLQHVV�$SSOLFDWLRQ�3URJUDPPLQJ ,QWHUIDFH

z %$3, 2YHUYLHZz 8VLQJ�WKH %$3,�([SORUHU�WR�6HDUFK�)RU�DQG�'LVSOD\�%$3,V�z &DOOLQJ�%$3,V LQ�2WKHU 5���6\VWHPV

Page 114: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 4-2

SAP AG 2006

/HDUQLQJ�2EMHFWLYHV

z 2YHUYLHZ�RI�EXVLQHVV�REMHFWV��EXVLQHVV�REMHFW�UHSRVLWRU\��%25���DQG�WKH�DUFKLWHFWXUH�RI�%$3,V

z 8VLQJ�WKH�%$3,�([SORUHU�WR�VHDUFK�IRU�DQG�GLVSOD\�%$3,V

z &DOOLQJ�%$3,V�LQ�RWKHU�5���V\VWHPV

Page 115: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 4-3

SAP AG 2006

%XVLQHVV�2EMHFW5HSRVLWRU\

5��$SSOLFDWLRQ�GDWD

��������� �

%XVLQHVV�2EMHFWV�LQ�WKH�%25

%XVLQHVV�2EMHFWV

2EMHFW�RULHQWHG�YLHZ�RI�5���DSSOLFDWLRQ�GDWD0HWKRGV�IRU�GLVSOD\LQJ�FKDQJLQJ�DSSOLFDWLRQ�GDWD$GPLQLVWUDWLRQ�LQ�WKH�%XVLQHVV�2EMHFW�5HSRVLWRU\��%25�

�� �� ����������

�������� ���������� ��� ��� � �

!� � � ����

"$#�# � � ���%� & ' # � ��(����

) ������� ' ��

� SAP business objects provide an object-oriented view of business data and processes in the R/3 System.

� The Business Object Repository (BOR) manages business objects, organizational objects, and technical objects in a hierarchical display corresponding to the component hierarchy in the R/3 system.

Page 116: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 4-4

SAP AG 2006

6DOHV�2UGHU(PSOR\HHVz &XVWRPHUz 'DWH

z ,WHP�OLVW

$WWULEXWHV�

0HWKRGV� z &KDQJH�DGGUHVV

z ,QFUHDVH�VDODU\

z &UHDWH

z 'LVSOD\

z /RFN

z 1DPHz $GGUHVV

z 6DODU\

([DPSOHV�RI�%XVLQHVV�2EMHFWV

� You can use the methods of a business object to display or change its attributes.

Page 117: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 4-5

SAP AG 2002

3URJUDP

$%$3 FRGH

)XQFWLRQ�PRGXOH

5HSRUW

7UDQVDFWLRQ0HWKRGV

$WWULEXWHV

(YHQWV

,QWHUIDFHV

2EMHFW�W\SH

6\QFKURQRXV

9LUWXDO�DWWULEXWHV

2EMHFW�UHIHUHQFHV

)LHOG�UHIHUHQFHV,QWHUIDFHV

%DVLF GDWD

$V\QFKURQRXV

$3, PHWKRGV

5HODWLRQVKLS�DWWULEXWH

&RPSRQHQWV�RI DQ 2EMHFW 7\SH

.H\�ILHOGV

� Components of an object type in the BOR - %DVLF�GDWD: Technical details such as an internal ID, release level, transport data, and so on. - ,QWHUIDFHV: List of interfaces from which the object type adopts attributes, methods, and events. - .H\�ILHOGV� Attributes that uniquely identify an object of this type. Usually the key fields of the underlying database tables. - $WWULEXWHV: Object type attributes. These are either values from database fields (field references), values that are calculated at runtime (virtual attributes), or pointers to other objects (object references). Object references are particularly useful in Workflow definitions, allowing you to navigate easily between objects that belong together in a particular business context. - 0HWKRGV: Calls to R/3 transactions, function modules, or other ABAP code. BAPIs are known as API methods. - (YHQWV: To be used in workflow definitions. The events are only defined in the BOR. To trigger an event, use the following links (for details, see the online documentation on workflow definition): - Links to change documents for the underlying database fields - Links to the status administration - Links to message control - Calling the function module SWE_EVENT_CREATE

Page 118: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 4-6

SAP AG 2002

z :HOO�GHILQHG LQWHUIDFH�IRU�5�� GDWD�DQG�SURFHVVHVz ,PSOHPHQWHG�DV D�VSHFLDO�UHPRWH�HQDEOHG�PHWKRG�RI

EXVLQHVV�REMHFWV LQ WKH�%XVLQHVV�2EMHFW�5HSRVLWRU\

:KDW�LV D�%$3,"�

%XVLQHVV�$SSOLFDWLRQ�3URJUDPPLQJ�,QWHUIDFH

%$3,

� BAPIs are special, remote-enabled methods of a business object; they are implemented as RFC-enabled function modules.

� BAPIs can perform various functions such as: - Creating an object - Querying the attributes of an object - Changing the attributes of an object

� BAPIs are interfaces to R/3 data.

Page 119: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 4-7

SAP AG 2002

%XVLQHVV�:RUNIORZ

%$3,V � 8VHV

,QWHUQHW��,QWUDQHW

9LVXDO%DVLF�-$9$���

5�� &RPSRQHQWVHWXS

5�� VDWHOOLWH�V\VWHPV �GLVWULEXWHG�VFHQDULRV �$/(�

6SHFLDO�GHYHORSPHQWVE\�FXVWRPHUV�RU�SDUWQHUV

*,+.-0/ 102�-3-4,576�805 102.1:9

*;+:-</ 102�-3-4=5>6�8.5 1.2.109

*;+:-0/ 102?-�-4;5>6 8.5 1.2.1.9

� You can use BAPIs for different applications. For example:

- Internet application components: Where individual R/3 functions are implemented on the Internet or intranet for users with no R/3 experience.

- Building R/3 components: Communication between the business objects from different R/3 components (applications).

- VisualBasic / JAVA / C++ : External clients (for example, alternative GUIs) access R/3 data and processes through BAPIs.

Page 120: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 4-8

SAP AG 2002

%$3,�$WWULEXWHV

z 2EMHFW�RULHQWHG@ ,PSOHPHQWHG�DV�REMHFW�PHWKRGV�IURP�WKH %25

z 6WDEOH�LQWHUIDFH@ 7KH�LQWHUIDFH�RI D�%$3, FDQQRW�EH�FKDQJHG

z &DQ�EH�XVHG�LQWHUQDOO\�DQG�H[WHUQDOO\@ %$3,V�FDQ�EH�XVHG�ERWK�ZLWKLQ�WKH 6$3�5���6\VWHP DQG�

H[WHUQDOO\z 'R QRW KDYH D SUHVHQWDWLRQ�OD\HU

@ 7KH�FDOOHU�LV�UHVSRQVLEOH�IRU�WKH�H[WHUQDO�YLVXDOL]DWLRQ�RI�WKH�UHVXOWV

z 6XFFHVV�DQG�HUURU�FRQILUPDWLRQ�WKURXJKH[SRUW�SDUDPHWHU 5(7851@ 6WUXFWXUH�RU�WDEOH �DFFRUGLQJ WR HDFK %$3,�

� You can access BAPIs from external clients like methods access objects, which are themselves an instance in the client.

� SAP guarantees that no incompatible changes will be made to the interfaces of BAPIs.

� You can also use BAPIs within the R/3 System to access business data. This makes it easier for customers and partners to add to the functions offered by the R/3 System.

� Displaying data that is transmitted to a BAPI or that is returned from a BAPI must be done from the calling program.

� The return parameter RETURN contains success or error messages for the BAPI, and, depending on the SAP R/3 release, has one of these dictionary structures: BAPIRETURN, BAPIRETURN1, BAPIRET1, BAPIRET2 or BAPIRET2_FIX. These structures commonly comprise the following relevant fields: TYPE (message type: S(uccess), E(rror), W(arning), I(nformation) ) ; ID (message class) ; NUMBER (message number) ; MESSAGE (message text) ; MESSAGE_V1, MESSAGE_V2, MESSAGE_V3, MESSAGE_V4 (message variables)

� If the transmission is successful, RETURN is either completely empty (all the fields have their initial fields for their types), or only the TYPE field has the value 6. Refer to the online documentation to find out which applies to the BAPI you are using.

Page 121: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 4-9

SAP AG 2002

'DWDEDVH 8SGDWHV 7KURXJK�%$3,V

%$3, FDOO

6HUYLFH REMHFW���%DSL6HUYLFH

%$3,���7UDQVDFWLRQ&RPPLW

%$3,���7UDQVDFWLRQ5ROOEDFN

z 'DWDEDVH�XSGDWHV LQ�%$3, DOZD\V�WKURXJK�XSGDWH�WDVN

z 1R�&200,7 :25. RU 52//%$&. :25. LQ WKH %$3,

z %$3,�/8: LV�FORVHG�RU�UHMHFWHG�E\�FRUUHVSRQGLQJ

� Database updates in BAPIs are always performed by an update task. The update type (synchronous or asynchronous) is specified when you call the commit BAPIs.

� In BAPIs containing database updates, a COMMIT WORK or ROLLBACK WORK is not used. Closing or rejecting a BAPI LUW occurs by calling a special BAPI from the service object BapiService (object type SAP0001). BAPI��7UDQVDFWLRQ&RPPLW�� (relevant function module BAPI_TRANSACTION_COMMIT) BAPI��7UDQVDFWLRQ5ROOEDFN�� (relevant function module BAPI_TRANSACTION_ROLLBACK)

Page 122: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 4-10

SAP AG 2002

6WDQGDUG�%$3,V DQG %$3,�([SORUHU

z *HW/LVW@ 5HWXUQV�WKH�FRQWHQWV�RI�WKH�REMHFWV�NH\�ILHOGV

z *HW'HWDLO@ 5HWXUQV�LQIRUPDWLRQ �DWWULEXWHV� RQ�WKH�REMHFW�FRQFHUQHG

z &UHDWH)URP'DWD@ *HQHUDWHV D QHZ�REMHFW LQ WKH 5���6\VWHP DQG�UHWXUQV�

LQIRUPDWLRQ�DERXW�LW

6WDQGDUG %$3,V

%$3,�([SORUHUz 'LVSOD\ RI DOO EXVLQHVV�REMHFWV�ZLWK�%$3,V�JURXSHG�E\�

DSSOLFDWLRQ

�7UDQVDFWLRQ %$3,�

� The above BAPIs exist for many business objects.

� Depending on the object, you can use additional BAPIs (for example, CheckPassword for the business object &XVWRPHU��

� The BAPI Explorer (transaction BAPI) displays all business objects with BAPIs, grouped by application. �

� There is an example of how to create your own BAPIs in the appendix.

� For more detailed information and guidelines on BAPI programming, refer to the BAPI Explorer in the "Project” tab page.��

Page 123: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 4-11

SAP AG 2002

%XVLQHVV�REMHFWUHSRVLWRU\

%XVLQHVV�REMHFW ;<=%$3,V � 0���0�

5��

)XQFWLRQ�PRGXOHV�

%$3,B;<=B0�

%$3, OD\HU

%$3,GHILQLWLRQV

�5)&�

$SSOLFDWLRQ�GHYHORSPHQW

5XQ WLPH

%$3, OD\HU

$FFHVVLQJ�%$3,V�IURP�([WHUQDO 6\VWHPV

%$3, FDOO

([WHUQDO�V\VWHP9LVXDO %DVLF&��-$9$

%$3,B;<=B0�/LEUDU\

� The programmer needs to know which business objects are available with which BAPIs, and what the interface looks like.

� The BAPI Browser is a logical view of the BOR in which only those objects that have BAPIs are displayed. The complete interface of each BAPI is displayed.

� SAP delivers libraries for BAPI calls for various development environments (Visual Basic, C++, Java). These libraries include the technical details of the communication, enabling developers to call a BAPI from outside the system without having to worry about how BAPIs are actually implemented in the system.

� You can get more information on using BAPIs with Visual Basic, C++, and Java from the training courses CA925, CA926, and CA927.

Page 124: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 4-12

SAP AG 2002

352*5$0������'$7$��0<B5(7851�/,.(����&$//�)81&7,21�%$3,B;<=B0�'(67,1$7,21�$%&(;3257,1*����,03257,1*

���5(7851� �0<B5(7851

(;&(37,216����

$%$3 SURJUDP

5)&

$FFHVVLQJ�%$3,V�IURP $%$3

%XVLQHVV�REMHFWUHSRVLWRU\

%XVLQHVV�REMHFW ;<=%$3,V � 0���0�

5��

)XQFWLRQ�PRGXOHV�

%$3,B;<=B0�

%$3,B;<=B0�'LUHFW

� Currently, you can only access BAPIs from an ABAP program using the relevant direct function call (local or remote). SAP is planning a later release where all BOR business objects will be integrated in the class library of ABAP so that you will be able to access BAPIs object-oriented from ABAP using ABAP-OO.

� The naming convention for BAPI function modules is: BAPI_<business_object>_<method>

� There are no exceptions for BAPI function modules. Success or error messages are returned by the RETURN export parameter, which, depending on the SAP R/3 release, has one of these dictionary structures: BAPIRETURN, BAPIRETURN1, BAPIRET1, BAPIRET2 or BAPIRET2_FIX. These structures commonly comprise the following relevant fields: TYPE (message type: S(uccess), E(rror), W(arning), I(nformation) ) ; ID (message class); NUMBER (message number); MESSAGE (message text) ; MESSAGE_V1, MESSAGE_V2, MESSAGE_V3, MESSAGE_V4 (message variables)

� If the transmission is successful, RETURN is either completely empty (all the fields have their initial fields for their types), or only the TYPE field has the value 6. Refer to the documentation to find out which applies to the BAPI you are using.

Page 125: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 4-13

SAP AG 2002

8QLW�6XPPDU\

z %$3,V�DUH�UHPRWH�HQDEOHG�PHWKRGV�IRU�REMHFWV LQ WKH%25 ZLWK DQ LQWHUIDFH�WKDW�FDQQRW�EH�FKDQJHG�

z <RX�FDQ�FXUUHQWO\�DFFHVV�%$3,V�ZLWK�REMHFW�RULHQWHG�SURJUDPPLQJ�RQO\�IURP�H[WHUQDO�V\VWHPV �9LVXDO%DVLF��&����-DYD��7KH %$3, FDOO�FDQ�EH�XVHG�IURP $%$3 DV D GLUHFW�UHPRWH� IXQFWLRQ�FDOO�RQO\�

z %$3,V�DOZD\V�UXQ�GDWDEDVH�XSGDWHV�WKURXJK�XSGDWH�WDVNV�6LQFH�%$3,V�GR QRW FRQWDLQ &200,7�:25. RU52//%$&.�:25.� \RX�FDQ�FORVH�RU�UHMHFW DQ�/8:�RQO\�E\�FDOOLQJ�VSHFLILF�%$3,V�

z 8VLQJ�WKH %$3,�([SORUHU� \RX�FDQ�GLVSOD\�%$3,V�JURXSHG�E\�DSSOLFDWLRQ�

Page 126: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 4-14

Page 127: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 4-15

([HUFLVHV��

8QLW��%$3,���%XVLQHVV�$SSOLFDWLRQ�3URJUDPPLQJ�,QWHUIDFH�7RSLF��)LQGLQJ��'LVSOD\LQJ��7HVWLQJ��DQG�&DOOLQJ�%$3,V�

• Searching for a BAPI in the BAPI Explorer

• Displaying and tesing a BAPI

• Calling a BAPI from ABAP

You want to find existing BAPIs for a specific R/3 component, display them, test them locally, and call them from a remote R/3 System.

�%$3,V����)LQGLQJ��'LVSOD\LQJ��7HVWLQJ��&DOOLQJ�1-1 Find the business object )OLJKW&RQQHFWLRQ in V\VWHP�%.

1-1-1 Which BAPIs does the business object contain?

1-1-2 Which BAPI do you use to get a list of flights?

1-1-3 Which function module is behind this BAPI?

1-1-4 Test the BAPI in the test environment.

1-2 Call the BAPI from V\VWHP�$.

1-2-1 To create the coding for the function module call, create in V\VWHP�% a dummy program with any name, and use the editor function WHPSODWH for &$//�)81&7,21 with the corresponding function module. Copy the coding you created to the Clipboard so you can enter it in the ABAP Editor of system A.

1-2-2 In V\VWHP�$� create a QHZ =%&���B��B%$3, program. Insert the function module call from the Clipboard and supplement it with additions and the necessary parameter values for an sRFC in system B. Get all the flights from FRANKFURT (DE) to NEW YORK (US) from the remote BAPI.

After a successful call (SY-SUBRC = 0)the field TYPE of the RETURN structure has the value “S”. In this case, output the contents of the internal table (required flights) returned by the BAPI.

If an RFC communication error (6<�68%5&�1(��) or a BAPI error (5(7851�7<3(�1(�6) has occurred, output the relevant error message.

Page 128: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 4-16

Page 129: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 4-17

�6ROXWLRQV

Unit: BAPI - Business Application Programming Interface

Topic: Find, Display, Test, and Call BAPIs

• Searching for a BAPI in the BAPI Explorer

• Displaying and testing a BAPI

• Calling a BAPI from ABAP

BAPI you searched for to list flights:� *HW/LVW

Function module belonging to BAPI:� %$3,B6)/,*+7B*(7/,67

ABAP program with remote BAPI call: see following pages

Page 130: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 4-18

REPORT sapbc415_bapi_s1

PARAMETERS:

fromcoun TYPE bapisfdeta-countryfr OBLIGATORY DEFAULT ’DE’,

fromcity TYPE bapisfdeta-cityfrom OBLIGATORY DEFAULT ’FRANKFURT’,

tocoun TYPE bapisfdeta-countryto OBLIGATORY DEFAULT ’US’,

tocity TYPE bapisfdeta-cityto OBLIGATORY DEFAULT ’NEW YORK’,

carrier TYPE bapisfdeta-carrid DEFAULT ’LH’,

afternon TYPE bapi_aux-afternoon,

maxread TYPE bapi_aux-maxread,

dest TYPE rfcdes-rfcdest DEFAULT ’NONE’.

DATA:

flightlist TYPE TABLE OF bapisflist,

flight LIKE LINE OF flightlist,

return TYPE bapiret2,

msg(80).

START-OF-SELECTION.

CALL FUNCTION ’BAPI_SFLIGHT_GETLIST’

DESTINATION dest

EXPORTING

fromcountrykey = fromcoun

fromcity = fromcity

tocountrykey = tocoun

tocity = tocity

airlinecarrier = carrier

afternoon = afternon

maxread = maxread

IMPORTING

return = return

TABLES

flightlist = flightlist

EXCEPTIONS

system_failure = 1 MESSAGE msg

communication_failure = 2 MESSAGE msg

OTHERS = 3.

CASE sy-subrc.

WHEN 0.

IF return-type <> ’S’.

Page 131: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 4-19

WRITE: / text-001, return-message.

ELSE.

PERFORM print_list.

ENDIF.

WHEN 1 OR 2.

WRITE: / text-002, msg.

WHEN OTHERS.

WRITE: / text-003.

ENDCASE.

*&---------------------------------------------------------------------*

*& Form PRINT_LIST

*&---------------------------------------------------------------------*

FORM print_list.

LOOP AT flightlist INTO flight.

WRITE: / flight-carrid, flight-connid, flight-fldate,

flight-airpfrom, flight-deptime,

flight-seatsmax, flight-seatsocc.

ENDLOOP.

ENDFORM. " PRINT_LIST

Page 132: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 4-20

Page 133: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 5-1

SAP AG 2002

$SSHQGL[

7KLV�DSSHQGL[�FRQWDLQV�DGGLWLRQDO�LQIRUPDWLRQ� ZKLFK�LV QRW�D GHILQLWH�SDUW�RI�WKH�VWDQGDUG�FRXUVH� <RXU�LQVWUXFWRU�PLJKW QRW KDYH�HQRXJK�WLPH WR�FRYHU WKLV�LQIRUPDWLRQ�GXULQJ�UHJXODU�FODVV�WLPH�

Page 134: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 5-2

SAP AG 2002

0DLQWDLQLQJ DQ�5)&�'HVWLQDWLRQ�LQ�5��

0DLQWDLQLQJ DQ�5)&�'HVWLQDWLRQ�LQ�5��0DLQWDLQLQJ DQ�5)&�'HVWLQDWLRQ�LQ�5��

:HE�5)&:HE�5)&

7KH &3,�& &RPPXQLFDWLRQ ,QWHUIDFH7KH &3,�& &RPPXQLFDWLRQ ,QWHUIDFH

$V\QFKURQRXV�'DWD 7UDQVIHU WKURXJK 4XHXH$SSOLFDWLRQ�3URJUDPPLQJ ,QWHUIDFH��4$3,�$V\QFKURQRXV�'DWD 7UDQVIHU WKURXJK 4XHXH$SSOLFDWLRQ�3URJUDPPLQJ ,QWHUIDFH��4$3,�

([HUFLVHV�DQG�6ROXWLRQV�IRU &3,�& DQG 4�$3,�%$3,�:RUNVKRS([HUFLVHV�DQG�6ROXWLRQV�IRU &3,�& DQG 4�$3,�%$3,�:RUNVKRS

Page 135: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 5-3

SAP AG 2002

0DLQWDLQLQJ 5)& 6LGHLQIR� 5����,%0��� 5��

5���6\VWHP7������������� �����������61$ VXEV\VWHP

'HVW /8 73�������

'(67 ��7��/8 ��KV����73 ��VDSGS��*:+267 ��KV����*:6(59 ��VDSJZ��3URWRFRO �� I

6$3�61$�JDWHZD\

������������� �!� "

KV����KV����

# $&%('�)+* �

7&3�,3

/8���

&3,�& VLGHLQIR��WDEOH;&20���.���

7��B5� /8�� 7��

,-./

6LGHLQIR�WDEOHRI��JZKRVW

JZKRVW0�13254 4 276�4 8:97;�<�85=>�? @� A&B5� �

5���6\VWHP.��

'HVW 5�� ORJRQ ;&20GDWD���������HQWU\

5)& VLGHLQIR�WDEOH 5)&'���.���

7��B�����������������������������7��B5�C�D E FHGJI KMLMNJFMOPRQ NSNST7U�O VRKJD Q GMW X

� The architecture of an RFC connection originating from an IBM R/2 System is identical to that of a CPI-C connection.

� For this type of communication, you must create an RFC destination in the RFC side information table RFCD within the IBM R/2 System using transaction TM31. You can choose any destination name you like. You must specify the R/3 logon data and the name of an existing XCOM entry as the communication parameters. The specified XCOM entry is used to build the connection when using this RFCdestination.

Page 136: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 5-4

SAP AG 2002

0DLQWDLQLQJ 5)& 6LGHLQIR� 5����6LHPHQV��� 5��6LHPHQV KRVW

6$3�*DWHZD\5���6\VWHP�

.��

6LGHLQIR WDEOH�RI�JZKRVW'(67 7��/8 KV����73 VDSGS��*:+267 KV����*:6(59 VDSJZ��3URWRFRO� I&3,�& VLGHLQIR�WDEOH

;&20���.���'HVW /8 73 &RPP�7\SH7��B5� 7�� +

5���6\VWHP7���Y��������Z[�\���]�����

6$3�*DWHZD\

KV����

7&3�,37&3�,3JZKRVW

'HVW 5�� ORJRQ�GDWD ;&20 HQWU\5)& VLGHLQIR�WDEOH 5)&'���.���

7��B�������������������������������������������7��B5�^�_ ` �]a ��b+c * �]de � *f* � ) d�g�b3_ �]aih�j

� The architecture of an RFC connection originating from a Siemens R/2 System is identical to that of a CPI-C connection.

� For this type of communication, you must create an RFC destination in the RFC side information table RFCD in the Siemens R/2 System using transaction TM31. You can choose any destination name. You must specify the R/3 logon data and the name of an existing XCOM entry as the communication parameters. The specified XCOM entry is used to build the connection when using this RFC destination.

Page 137: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 5-5

SAP AG 2002

:HE�5)&

0DLQWDLQLQJ DQ�5)&�'HVWLQDWLRQ�LQ�5��0DLQWDLQLQJ DQ�5)&�'HVWLQDWLRQ�LQ�5��

:HE�5)&:HE�5)&

7KH &3,�& &RPPXQLFDWLRQ ,QWHUIDFH7KH &3,�& &RPPXQLFDWLRQ ,QWHUIDFH

$V\QFKURQRXV�'DWD 7UDQVIHU WKURXJK 4$3,$V\QFKURQRXV�'DWD 7UDQVIHU WKURXJK 4$3,

([HUFLVHV � 6ROXWLRQV�IRU &3,�& DQG 4�$3,��%$3,�:RUNVKRS([HUFLVHV � 6ROXWLRQV�IRU &3,�& DQG 4�$3,��%$3,�:RUNVKRS

Page 138: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 5-6

SAP AG 2002

6FHQDULR� %XVLQHVV LQ WKH :RUOG :LGH :HE

,17(51(7,17(51(7:::::::HE

%URZVHU

:HE XVHU

5��:HE�VLGH�DFFHVV WR�5�� IXQFWLRQV

)XQFWLRQPRGXOH

7UDQVDFWLRQ

5HSRUW

Page 139: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 5-7

SAP AG 2002

)LYH�7LHUHG &OLHQW�6HUYHU $UFKLWHFWXUH

5��5��$SSO$SSO��6HUYHU6HUYHU

5��5��'DWDEDVH'DWDEDVH6HUYHU6HUYHU

,QWHUQHW,QWHUQHW7UDQVDFWLRQ7UDQVDFWLRQ

6HUYHU6HUYHU+773+7736HUYHU6HUYHU

,QWHUQHW,QWHUQHW%URZVHU%URZVHU

5HTXHVW

5HVSRQVH

� The Internet Transaction Server connects the three-tiered client/server architecture of R/3 with the two-tiered HTTP client/server architecture.

� From the R/3 point of view, the ITS and HTTP servers form an intermediate layer between the application and presentation layers.

� From the Internet user’s point of view, the ITS takes care of the interactive HTML pages (generated at runtime).

Page 140: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 5-8

SAP AG 2002

:HE�5)& $UFKLWHFWXUH

5��

)XQF

WLRQ�P

RGXOH

:::B

',63

$7&+

B5(4

8(67

:HE5

)&�

IXQFWL

RQ�PRG

XOH

,QWHUQHW,QWHUQHW%URZVHU%URZVHU ,76,76+773+773

6HUYHU6HUYHU

k\AZAml

6HUYLFH�)LOH6HUYLFH�)LOH�85/��85/�

+70/�

85/ nporq

nso:qk\A�A�l

tsu n

tsu n6HLWH

,QSXW

� WebRFC is the term used when you call special function modules in R/3 using the ITS. The service function module WWW_DISPATCH_REQUEST is always called as the agent that executes the call.

� Attributes of WebRFC-enabled function modules include:

- Returns an HTML page or a MIME object as the output

- Permits read or write access to the R/3 database

- Allows business objects to be called from WebRFC-enabled function modules

- Cannot be used by Internet users

� SAP delivers important, essential functions as WebRFC-enabled function modules.

� For more information, refer to training course BC440.

Page 141: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 5-9

SAP AG 2002

5)& 8VLQJ ;0/�)LOHV 7KURXJK�WKH�%XVLQHVV�&RQQHFWRU

5��

5)&�HQDEOHG�IXQFWLRQ�PRGXOH

6HUYLFH�)LOH6HUYLFH�)LOH�85/��85/�

5)&

5)&t\���wv7� > ���

;0/

5)&n ?�xyx

;0/

6$3%XVLQHVV�&RQQHFWRU

+773

5)&+773

� Use the SAP Business Connector to call an arbitrary RFC-enabled function module from the intranet or the Internet.

� On the SAP BC, you can set up a service that points to an RFC-enabled function module. If you call the service from the Internet using the corresponding URL, and an XML file is passed to the service, the application data will be transmitted through the SAP BC from the file to the function module interface in the SAP System. The response of the function module is converted by the SAP BC into an XML file, which is then returned to the caller.

� You will find examples of such XML files used for calling a function in the SAP Interface Repository, which is a collection of interfaces that can be viewed publicly (http://ifr.sap.com).

� The SAP BC is a middleware technology developed by SAP and can be used by SAP customers free of charge. For information on the SAP BC, refer to the service marketplace (http://service.sap.com/connectors).

� More details are available in the training course BIT530 ,QWURGXFWLRQ�WR�WKH�6$3�%XVLQHVV�&RQQHFWRU.

Page 142: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 5-10

SAP AG 2002

7KH &3,�& &RPPXQLFDWLRQ ,QWHUIDFH

0DLQWDLQLQJ DQ�5)&�'HVWLQDWLRQ�LQ�5��0DLQWDLQLQJ DQ�5)&�'HVWLQDWLRQ�LQ�5��

:HE�5)&:HE�5)&

7KH &3,�& &RPPXQLFDWLRQ ,QWHUIDFH7KH &3,�& &RPPXQLFDWLRQ ,QWHUIDFH

$V\QFKURQRXV�'DWD 7UDQVIHU WKURXJK 4�$3,$V\QFKURQRXV�'DWD 7UDQVIHU WKURXJK 4�$3,

([HUFLVHV � 6ROXWLRQV�IRU &3,�& DQG 4�$3,��%$3,�:RUNVKRS([HUFLVHV � 6ROXWLRQV�IRU &3,�& DQG 4�$3,��%$3,�:RUNVKRS

Page 143: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 5-11

SAP AG 2002

7KH�&3,�&�&RPPXQLFDWLRQ�,QWHUIDFH�7RSLF�2EMHFWLYHV

z ,Q WKLV�FKDSWHU�\RX ZLOO OHDUQ�KRZ WR UXQ�SURJUDP�WR�SURJUDP�FRPPXQLFDWLRQ�XVLQJ�WKH &3,�& LQWHUIDFH�

z 7KLV�LQFOXGHV�� 'HILQLQJ�UHPRWH�GHVWLQDWLRQV� 8VLQJ�WKH &3,�& FDOOV�IRU�FRPPXQLFDWLRQ� 8QGHUVWDQGLQJ�SDUWLFXODU�DVSHFWV�RI�UHPRWHO\�FDOOLQJ DQ�$%$3 SURJUDP

z <RX ZLOO�DOVR EHFRPH�IDPLOLDU�ZLWK�WKH &3,�& WHVW�HQYLURQPHQW�

Page 144: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 5-12

SAP AG 2002

7RSLF�2YHUYLHZ

z ,QWURGXFWLRQz 5HPRWH�'HVWLQDWLRQVz 8VLQJ &3,�&�LQ &RPPXQLFDWLRQVz &DOOLQJ DQ�$%$3 3URJUDP�5HPRWHO\z 'HYHORSPHQW�DQG 7HVW (QYLURQPHQW

Page 145: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 5-13

SAP AG 2002

,QWURGXFWLRQ

,QWURGXFWLRQ,QWURGXFWLRQ

5HPRWH�'HVWLQDWLRQV5HPRWH�'HVWLQDWLRQV

8VLQJ &3,�&�LQ &RPPXQLFDWLRQV8VLQJ &3,�&�LQ &RPPXQLFDWLRQV

&DOOLQJ DQ�$%$3 3URJUDP�5HPRWHO\&DOOLQJ DQ�$%$3 3URJUDP�5HPRWHO\

'HYHORSPHQW�DQG 7HVW (QYLURQPHQW'HYHORSPHQW�DQG 7HVW (QYLURQPHQW

Page 146: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 5-14

SAP AG 2002

,QWURGXFWLRQ�WR�&3,�&��7RSLF�2EMHFWLYHV

z ,Q WKLV�WRSLF�\RX ZLOO OHDUQ�DERXW�WKH�JHQHUDO�IXQFWLRQV�RI &3,�& DQG�WKH�FRQQHFWLRQ�W\SHV�

Page 147: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 5-15

SAP AG 2002

5��

5�� 5��([WHUQDO6\VWHP

$YDLODEOH�&RQQHFWLRQ�7\SHV�

&�3�,�� &

� The SAP CPI-C interface allows ABAP programs in an R/3 or an R/2 System and external C programs to communicate with each other and exchange data.

� Communication using CPI-C is an interesting option whenever RFC is not available.

Page 148: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 5-16

SAP AG 2002

Start connection

Send data

Receive confirmation

Close connection

Accept connection

Receive and processdata

Send confirmation

Recognize end of

6\VWHP�$ 6\VWHP�%$FWLYH�SURJUDP 3DVVLYH SURJUDP

connection and close

'LUHFW�&RPPXQLFDWLRQ�8VLQJ &3,�&

3URJUDP�WR�SURJUDP�FRPPXQLFDWLRQ �&3,�&�

� CPI-C (Common Programming Interface for Communications) is a standardized program-to-program communication interface that was originally developed at IBM. It consists of a set of calls with which two programs can communicate with each other.

� SAP supports the CPI-C interface for ABAP and C programs.

Page 149: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 5-17

SAP AG 2002

5HPRWH�'HVWLQDWLRQV

,QWURGXFWLRQ,QWURGXFWLRQ

5HPRWH�'HVWLQDWLRQV5HPRWH�'HVWLQDWLRQV

8VLQJ &3,�&�LQ &RPPXQLFDWLRQV8VLQJ &3,�&�LQ &RPPXQLFDWLRQV

&DOOLQJ DQ�$%$3 3URJUDP�5HPRWHO\&DOOLQJ DQ�$%$3 3URJUDP�5HPRWHO\

'HYHORSPHQW�DQG 7HVW (QYLURQPHQW'HYHORSPHQW�DQG 7HVW (QYLURQPHQW

Page 150: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 5-18

SAP AG 2002

8QLW�2EMHFWLYHV

z ,Q WKLV�WRSLF� \RX ZLOO OHDUQ�KRZ WR�'HILQH�WKH &3,�& GHVWLQDWLRQ �DOVR NQRZQ�DV DV\PEROLF�GHVWLQDWLRQ�RU�VLGH�LQIRUPDWLRQ�HQWU\� WKDW�LV�UHTXLUHG WR FRQQHFW WR WKH�SDUWQHU�V\VWHP�

Page 151: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 5-19

SAP AG 2002

6LGHLQIR�7DEOH6LGHLQIR�7DEOH LQLQ WKH�6RXUFHWKH�6RXUFH6\VWHP6\VWHP

6\PEROLF�GHVWLQDWLRQ &RPPXQLFDWLRQ�SDUDPHWHU7��.��

����������

���

(;73*0 �����

6\PEROLF�'HVWLQDWLRQV �6LGH ,QIRUPDWLRQ (QWULHV�

� To start communication with a partner using CPI-C, the active program has to have an entry in the side information table (sideinfo entry). This entry contains all of the necessary communication parameters.

� For each remote partner you want to call, you must have a corresponding sideinfo entry. These sideinfo entries are also known as V\PEROLF�GHVWLQDWLRQV.

� The sideinfo table in the R/3 System is called 7;&20. You maintain it using transaction SM54.

Page 152: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 5-20

SAP AG 2002

'HVW /8 73 3URW *: +RVW *:�6HUYLFH

6$3�*DWHZD\

6LGHLQIR�WDEOH 7;&20���6\VWHP�7���

5���6\VWHP�7��

7��B$ KV���� VDSGS�� I KV���� VDSJZ��7��B% KV���� VDSGS�� I KV���� VDSJZ��7��B& KV���� VDSGS�� I

KV����

z�{�|�}�~��Z���!�&�������

6$3�'LVSDWFKHU

5���6\VWHP�7��KV����

z�{�|�}�~��� �!�&���3���

6$3�*DWHZD\

5���5��

60��

� To start communication between two R/3 Systems, you need an entry in the sideinfo table TXCOM in the active (source) system.

� Specifications in the sideinfo entry: 'HVW�: Any logical name (name of the sideinfo entry) 3URW: ’ I ’ (protocol type for R/3-R/3 connection) *:�KRVW: Host on which the requisite gateway is running *:�6HUYLFH : TCP/IP service for gateway to be used (If the two fields�*:�KRVt and *:�VHUYLFH are not set with values, the default gateway of the current application server is used when the connection is set up.) /8 : Application server of the appropriate R/3 system (target system) 73�: TCP/IP service of the dispatcher of the passive R/3 System (target system)

Page 153: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 5-21

SAP AG 2002

5���5����,%0�

5���6\VWHP

'(67 ��.��/8 ��/8��73 ��;�6$

+RVW � KV����+RVW � KV����6$3�61$� �DWHZD\�7&3�,3����������/8����

� �w�(�i�+�i�

7&3�,37&3�,3 ����

��{�

5���6\VWHP�.��

7��/8���

'HVW /8 73 3URW *: +RVW *:�6HUYLFH6LGHLQIR�7DEOH 7;&20���6\VWHP�7���

.�� & KV���� VDSJZ��

6LGHLQIR�7DEOH�IRU�*DWHZD\

� To communicate between an R/3 System and an IBM R/2 System, you need an 61$�JDWHZD\ (SAP Gateway with SNA functions) on which, in addition to TCP/IP, a suitable LU6.2 product is installed and configured. We recommend installing the SNA gateway as a dedicated standalone gateway that can be used by various R/3 application servers to communicate with SNA LU6.2 systems.

� To connect from an R/3 System to an IBM R/2 System, you need an entry in the sideinfo table 7;&20�LQ�WKH�5���6\VWHP, and an entry in the VLGHLQIR�WDEOH�RI�WKH�61$�*DWHZD\.� 7;&20�HQWU\: 'HVW�: Name of sideinfo entry (must match name of corresponding gateway sideinfo entry) 3URW : C’ (Protocol type for R/3-R/2 connection) *:�KRVW���*:�VHUYLFH�: Host and TCP/IP service of the SNA gateway /8 / 73: Not important 6LGHLQIR�HQWU\�RI�JDWHZD\�(see graphic) : Sideinfo on the gateway (see diagram): Contains the entry name (must match the corresponding TXCOM entry), SNA entries about the Logical Unit (LU) for the R/2 host (remotely called), and the R/2 Taskhandler (TP = X1SA). (See online documentation for maintenance of gateway sideinfo table)

� You can also install the SNA gateway on the host side. The advantage of running the SNA gateway on the IBM host is that you can use existing TCP/IP and LU6.2 software for the gateway on the host side.

Page 154: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 5-22

SAP AG 2002

5���5�����6LHPHQV�

6LHPHQV KRVW

6$3*DWHZD\

��{�

5���6\VWHP�.��

{!� �5�w���7���~����w� �

zY�¡ �~J� ���7�Z� �

7&3�,37&3�,3

6LGHLQIR�WDEOH 7;&20���6\VWHP�7���'HVW /8 73 3URW *: +RVW *:�6HUYLFH.�� & EV�KRVW� VDSJZ��

5�� V\VWHP+RVW � KV����

7��

� To communicate between an R/3 System and a Siemens R/2 System, you need an SAP gateway running on the Siemens host that can be addressed using TCP/IP. (TCP/IP functions on the host side are available starting with BS2000 version 10, DCAM version 11.)

� You can operate the host gateway with or without VLGHLQIR. (Setting in host file SAPGW.RSPARAM, parameter EV��XVHBVLGHLQIR [0,1] ) You may have to maintain a corresponding sideinfo entry for the host gateway. Refer to the documentation for maintaining the gateway sideinfo table.

� To connect from an R/3 System to a Siemens R/2 System, you need an entry in the sideinfo table TXCOM in the R/3 System. 7;&20�HQWU\: 'HVW�: Name of the DCAM or UTM application (SAP System) to be called by the gateway or name of the gateway side info entry. 3URW: C (Protocol type for R/3-R/2 connection) *:�KRVW���*:�VHUYLFH: Host name / TCP/IP service of the host gateway /8 / 73: Not important

Page 155: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 5-23

SAP AG 2002

5����,%0��5��

5���6\VWHP7��z�{�|�}�~��� �����������61$�6XEV\VWHP

'HVW /8 73������� '(67 7��/8 KV����73 VDSGS��*:+267 KV����*:6(59 VDSJZ��3URWRFRO � I

6$3�61$�*DWHZD\

6$3�*DWHZD\

KV����KV����� �&�(���+���

7&3�,3/8���

6LGHLQIR�WDEOH;&20 �.���

7��B5� /8�� 7��

���¢

6LGHLQIR�WDEOHRI��JZKRVW

JZKRVW£�¤3¥5¦ ¦ ¥7§�¦ ¨:©7ª�«�¨5¬���5�@� ­&�5� �

5���6\VWHP.��

� To start a connection from an IBM R/2 System to an R/3 System, you need an entry in WKH�5���VLGHLQIR�WDEOH�;&20 and an entry in the VLGHLQIR�WDEOH�RI�WKH�SURJUDP�JZKRVW on the gateway. Sideinfo entry in R/2 (table TXCOM) 'HVW�: Any logical name (name of the sideinfo entry) /8�: Logical unit of the SNA gateway 73 : Name under which the program JZKRVW�can be called on the SNA gateway through the specified logical unit 6LGHLQIR�HQWU\�IRU�JZKRVW�RQ�61$�JDWHZD\: '(67 : Name of the sideinfo entry (must match TP value in XCOM) 3URWRFRO : I *:+267���*:6(59�: Host and TCP/IP service of the required SAP gateway /8 : Application server of the R/3 System 73�: TCP/IP service of the R/3 dispatcher

� You can also operate the SNA gateway on the host side. The advantage of running the SNA gateway on the IBM host is that you can use existing TCP/IP and LU6.2 software for the gateway on the host side.

Page 156: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 5-24

SAP AG 2002

5����6LHPHQV��5��

6LHPHQV KRVW

6$3�*DWHZD\5���6\VWHP�

.��

6LGHLQIR WDEOH�RI�JZKRVW'(67 7��/8 KV����73 VDSGS��*:+267 KV����*:6(59 VDSJZ��3URWRFRO I6LGHLQIR�WDEOH

;&20 �.���'HVW /8 73 &RPP�7\SH7��B5� 7�� +

5���6\VWHP7��zY{�|�}�~�Z�[�\���]�����

6$3�*DWHZD\

KV����

7&3�,3JZKRVW

� For communication between Siemens R/2 and R/3, you need the host gateway that runs on the Siemens host.

� To start a connection from a Siemens R/2 System to an R/3 System, you use the program JZKRVW�on the host gateway. For this, you need an entry in the sideinfo table of the R/2 System and one in the sideinfo table of gwhost. 6LGHLQIR�HQWU\�LQ�5����WDEOH�7;&20) 'HVW�: Any logical name (name of the sideinfo entry) /8�: Not important 73�: Name of the corresponding gwhost sideinfo entry &RPP�7\SH�: H�� 6LGHLQIR�HQWU\�IRU�JZKRVW�RQ�KRVW�JDWHZD\: '(67 : Name of the sideinfo entry (must match TP value in XCOM) 3URWRFRO : I *:+267���*:6(59�: Host and TCP/IP service of the required SAP gateway /8 : Application server of the R/3 System 73�: TCP/IP service of the R/3 dispatcher

Page 157: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 5-25

SAP AG 2002

5���� ([WHUQDO�6\VWHP

+RVW � KV����

5�� 6\VWHP7��

�6\VWHP 1R�����

6$3*DWHZD\

+RVW � KV����([WHUQDO�V\VWHP

& SURJUDP

&XUUHQW IURQW�HQG

& SURJUDP

{�®¯ �°

'HVW /8 73 3URW *: +RVW *:�6HUYLFH6LGHLQIR�WDEOH 7;&20���6\VWHP�7���

3*0B$ KV���� �3DWK�QDPH! (3*0B% KV���� �3DWK�QDPH! ( KV���� VDSJZ��3*0B) �3DWK�QDPH! )

� 81,;�� You call an external program over the SAP gateway using the user that started the gateway (for example, t79adm). This user must have the correct start authorization. If the SAP gateway does not run on the same host as the external program, it is started by UHPRWH�VKHOO from the gateway. The user who started the SAP gateway must also exist on the host of the external program. (The program is called using its name). The �UKRVW (remote shell authorization) on the remote machine must also have a corresponding entry.

� 26���� As with UNIX, but without user ID

� 17�� As with OS/2, the SAP gateway must run on the same host as the external program because of the Windows NT remote shell function.

� /8����6\VWHPV��You can also reach external LU6.2 systems using the SAP SNA gateway. For example, you can call a Cobol program running in CICS using CPI-C from an R/3 System. The corresponding sideinfo table is maintained in the same way as the R/3 -> R/2 (IBM) communication scenario that you see in the online documentation.

� :LQGRZV��������:I:��� - No CPI-C - R C only at current front end

Page 158: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 5-26

SAP AG 2002

8VLQJ &3,�&�LQ &RPPXQLFDWLRQV

,QWURGXFWLRQ,QWURGXFWLRQ

5HPRWH�'HVWLQDWLRQV5HPRWH�'HVWLQDWLRQV

8VLQJ &3,�&�LQ &RPPXQLFDWLRQV8VLQJ &3,�&�LQ &RPPXQLFDWLRQV

&DOOLQJ DQ�$%$3 3URJUDP�5HPRWHO\&DOOLQJ DQ�$%$3 3URJUDP�5HPRWHO\

'HYHORSPHQW�DQG 7HVW (QYLURQPHQW'HYHORSPHQW�DQG 7HVW (QYLURQPHQW

Page 159: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 5-27

SAP AG 2002

8VLQJ�&3,�&�LQ�&RPPXQLFDWLRQV��7RSLF�2EMHFWLYHV

$W�WKH�FRQFOXVLRQ�RI�WKLV�WRSLF��\RX�ZLOO�EH�DEOH�WR��z /HDUQ�WKH�H[DFW�SURFHVV�IORZ�RI D�&3,�&FRPPXQLFDWLRQ

z ,GHQWLI\�WKH�FRPPXQLFDWLRQ�PHWKRGV�\RX�FDQ�XVH�DQG�WKHLU�DGYDQWDJHV�DQG�GLVDGYDQWDJHV

z ,PSOHPHQW�FRPPXQLFDWLRQV LQ�$%$3 XVLQJ &3,�&z 8VH�WKH�FRPPDQGV�IRU�FRQYHUWLQJ $6&,,�WR�(%&',&�

Page 160: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 5-28

SAP AG 2002

6LGHLQIRWDEOH

6LGHLQIRWDEOH

6\VWHP�$

$FWLYH�SURJUDP �&OLHQW�

6\VWHP�%

3DVVLYH SURJUDP �6HUYHU�,QLWLDOL]H�FRPPXQLFDWLRQ6WDUW FRQQHFWLRQ6HQG�GDWD5HFHLYH�GDWD&ORVH�FRQQHFWLRQ

$FFHSW�FRQQHFWLRQ5HFHLYH�GDWD6HQG�GDWD5HFHLYH�GDWD

3URFHVV�)ORZ�RI &3,�& &RPPXQLFDWLRQ

� The program that initiates the connection is called the active program or client. The program that is called is known as the passive program or server.

� To start a CPI-C connection, the active program must initialize it, that is, use a CPI-C call to read the necessary communication parameters from the corresponding sideinfo entry. These parameters are then stored under a conversation ID (output of the CPI-C call) and are used when the connection is made. After being accepted by the target program, the connection is available for data exchange.

� CPI-C is a semi-duplex communication method, that is, only one side may send data at a time. Once the passive program has accepted the communication, the active program may send data first, whereas the passive program must wait for data using a receive call.

� CPI-C transmission is asynchronous. In other words, the transmitting buffer is physically transmitted along with permission to send (!) only when the sending side submits its next receive command.

� The connection may only be closed by the program that is currently permitted to send data (otherwise data may be lost). The partner program waiting with the receive command then receives the corresponding return code (18).

Page 161: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 5-29

SAP AG 2002

6\VWHP�$3URJUDP ;

6HQG�GDWD5HFHLYH�FRQILUPDWLRQ6HQG�GDWD5HFHLYH�FRQILUPDWLRQ6HQG�GDWD5HFHLYH�FRQILUPDWLRQ

������

������

6\VWHP�%3URJUDP <

5HFHLYH�GDWD6HQG�FRQILUPDWLRQ5HFHLYH�GDWD6HQG�FRQILUPDWLRQ5HFHLYH�GDWD6HQG�FRQILUPDWLRQ

������

������

�3LQJ�3RQJ� &RPPXQLFDWLRQ�0HWKRG

� The term SLQJ�SRQJ describes the communication method illustrated above. With this method, a confirmation message is sent after each data record.

Page 162: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 5-30

SAP AG 2002

6\VWHP�$3URJUDP ;

6HQG�GDWD6HQG�GDWD6HQG�GDWD5HFHLYH�FRQILUPDWLRQ

������

������

6\VWHP�%3URJUDP <

5HFHLYH�GDWD5HFHLYH�GDWD5HFHLYH�GDWD6HQG�FRQILUPDWLRQ

������

������

�0XOWLVHQG� &RPPXQLFDWLRQ�0HWKRG

� In contrast to the SLQJ�SRQJ�method, PXOWLVHQG sends a series of data records before receiving a single confirmation at the end.

� &RPSDULVRQ�RI�WKH�WZR�FRPPXQLFDWLRQ�PHWKRGV� The SLQJ�SRQJ method involves more work because you are dealing with single records and individual confirmations, whereas PXOWLVHQG uses a single asynchronous transmission, and only has to wait for one overall confirmation. However, SLQJ�SRQJ provides you with better control of your data. If the communication is interrupted (communication error, or the receiving program crashes -> yielding return code 17), you always know, if you are using SLQJ�SRQJ� which records have arrived in the target system, which have been processed, and where you need to resume processing. The PXOWLVHQG�method, on the other hand, also returns code 17, but does not know which records have been received, and whether they have been fully or partially processed, or not processed at all. You should, therefore, use the ping pong method where each data record contains the data for one transaction.

Page 163: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 5-31

SAP AG 2002

&20081,&$7,21��,1,7&20081,&$7,21��$//2&$7(&20081,&$7,21��$&&(37&20081,&$7,21��6(1'&20081,&$7,21��5(&(,9(&20081,&$7,21��'($//2&$7(

$YDLODEOH &3,�& &DOOV LQ�$%$3

� You can execute the steps explained for CPI-C using the CPI-C calls specified previously: &20081,&$7,21��,1,7� Initialize connection &20081,&$7,21��$//2&$7(� Make (allocate) connection &20081,&$7,21��$&&(37� Accept connection &20081,&$7,21��6(1'� Send data &20081,&$7,21��5(&(,9(� Receive data &20081,&$7,21��'($//2&$7(� Close connection

� External C programs use the same calls to communicate with ABAP programs using CPI-C. Although the syntax of the calls is different in C (CMINIT, CMALLC, CMACCP, CMSEND, CMRCV, CMDEAL), their functions are the same as the corresponding ABAP calls.

Page 164: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 5-32

SAP AG 2002

$%$3 LQFOXGH 56&3,&')

���

* return_code'$7$�� &0B2. /,.(��,17����9$/8(�������

'$7$� ,17������7<3(��;��

&0B'($//2&$7('B$%(1' /,.(��,17����9$/8(�������&0B'($//2&$7('B1250$/ /,.(��,17����9$/8(�������&0B3$5$0(7(5B(5525 /,.(��,17����9$/8(�������&0B352'8&7B63(&,),&B(5525 /,.(��,17����9$/8(�������

&0B352*5$0B67$7(B&+(&. /,.(��,17����9$/8(�������

���

���

���

&3,�& 5HWXUQ &RGHV

� The return code of a CPI-C call in ABAP is always placed in the SY-SUBRC field. However, it can also be placed in the RETURNCODE parameter of the CPI-C call itself.

� In addition to the return code, some CPI-C calls also return special parameters containing extra information about data transfer and which side is entitled to send data.

� The return codes and return parameters of CPI-C calls are stored as hexadecimal code. When you query the codes, you should use meaningful constants instead of hexadecimal codes. For example, instead of IF RC = 18 use IF RC = CM_DEALLOCATED_NORMAL to close the connection from the partner side. These CPI-C constants are contained in the standard ABAP include 56&3,&').

� The most important return codes are: 0000 ( CM_OK ) Connection OK 0011 ( CM_DEALLOCATED_ABEND ) Connection terminated 0012 ( CM_DEALLOCATED_NORMAL ) Connection from partner terminated normally 0013 ( CM_PARAMETER_ERROR ) Invalid conversation ID in CPI-C call 0014 ( CM_PRODUCT_SPECIFIC_ERROR ) Invalid sideinfo entry in CMINIT call 0019 ( CM_PROGRAM_STATE_CHECK ) Send command rejected due to missing transmission permission

Page 165: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 5-33

SAP AG 2002

���

&20081,&$7,21�,1,7

���

'(67,1$7,21 GHVW,' FRQYLG

> 5(7851&2'( UF @��

,QLWLDOL]LQJ D�&3,�& &RQQHFWLRQ

� &20081,&$7,21��,1,7��is used to initialize the CPI-C connection. (Preparing the connection) Entry: '(67,1$7,21 Name of a sideinfo entry Output: ,'�� Conversation ID: This indicates the communication partners for the specified sideinfo entry. It is used until the next connection is made and is, at the same time, the name of the connection. 5(7851&2'(� Return code of the call is always stored in SY-SUBRC; it can be used in additional fields. This parameter is optional.

� The fields listed in the INIT call must have the following types: dest C8 convid C8 rc X2

� Legend: Lowercase plus italics indicates ABAP field. Underlined indicates entry variable. [ ... ] indicates optional specification

Page 166: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 5-34

SAP AG 2002

���

&20081,&$7,21��$//2&$7(

���

,' FRQYLG> 5(7851&2'( UF @��

6WDUWLQJ D�&3,�& &RQQHFWLRQ

� &20081,&$7,21��$//2&$7( builds the CPI-C connection and the corresponding partner program is started. You must specify the conversation ID returned by the INIT call.

Page 167: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 5-35

SAP AG 2002

&20081,&$7,21��$&&(37

���

,' FRQYLG> 5(7851&2'( UF @��

$FFHSWLQJ D�&3,�& &RQQHFWLRQ

� For a valid connection to be established, the called program must accept the connection using the &20081,&$7,21�$&&(37 statement. The ACCEPT call returns the conversation ID of the connection and a return code. This must be the first statement in the passive program.

� After the ACCEPT call from the side that was called, the active program has the required transmission permission. The passive program must first receive data.

Page 168: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 5-36

SAP AG 2002

���

&20081,&$7,21�6(1'

���

,' FRQYLG

> /(1*7+ VHQGOHQ @%8))(5 VHQGEXI

> 5(7851&2'( UF @��

6HQGLQJ�'DWD

� In the SEND command, you can transmit a data packet of up to 30000 bytes. Parameters: ,'�� Conversation ID %8))(5 Transmission buffer (max 30000 bytes) /(1*7+�� Length of the buffer you want to send (Optional: If entries are missing, the entire transmission buffer is sent.). The field must be type P. Output: RETURNCODE

� If a program sends data without having permission, the return code issued is 25 (hex 19).

Page 169: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 5-37

SAP AG 2002

&20081,&$7,21��5(&(,9(,' FRQYLG

> /(1*7+ UFYOHQ @%8))(5 UFYEXI

> 5(7851&2'( UF @��

> 5(&(,9(' UFYGOHQ @'$7$,1)2 GDWDLQIR67$786,1)2 VWDWXVLQIR

> +2/'��@

5HFHLYLQJ�'DWD

���

���

� Your own previous SEND packages that are still in the buffer due to the asynchronous SEND, together with the transmission permission, are physically transmitted through the connection by the COMMUNICATION RECEIVE statement. The statement then waits for the data. Parameters: ,'� Conversation ID /HQJWK Use this parameter to specify which part of the specified receive buffer should be used. (Optional; if you do not specify a length, the system uses the whole receive buffer.) The field must be type P. +2/'� This addition (without a field) causes the work process to be stopped (no rollout/rollin) while it waits from the RECEIVE. You would use this when using RECEIVE within a SELECT loop. Output: %8))(5� Receiving buffer (contains data received) 5(&(,9('�Number of character received. This field must be type X4. '$7$,1)2�Information on whether the receive buffer was large enough for the incoming SEND packet. This field must be type X4. 67$786,1)2 Information on the transmission permission. This field must be type X4. 5(7851&2'(�

Page 170: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 5-38

SAP AG 2002

$%$3 LQFOXGH 56&3,&')

���

* data_received

'$7$�� &0B12B'$7$B5(&(,9(' /,.(��,17����9$/8(�����������

'$7$� ,17������7<3(��;��

&0B&203/(7(B'$7$B5(&(,9(' /,.(��,17����9$/8(�����������

��� &0B,1&203/(7(B'$7$B5(&(,9(' /,.(��,17����9$/8(�����������

* status_received

'$7$�� &0B12B67$786B5(&(,9(' /,.(��,17����9$/8(�����������&0B6(1'B5(&(,9(' /,.(��,17����9$/8(�����������

���

9DOXHV�RI '$7$,1)2 DQG 67$786,1)2

� The return parameter '$7$,1)2 specifies whether data has been received and whether the receive buffer (or section of the buffer) used was large enough to receive the entire SEND packet. DATAINFO can have the following values: CM_NO_DATA_RECEIVED --> No data received CM_COMPLETE_DATA_RECEIVED --> Data received and RECEIVE buffer is large enough CM_INCOMPLETE_DATA_RECEIVED --> Data received but RECEIVE buffer too small to receive entire SEND packet. (In this case, the remaining segments must be transmitted as long as there are other RECEIVEs to be received, until DATAINFO has the value CM_COMPLETE_DATA_RECEIVED.)

� The return parameter 67$786,1)2 indicates whether transmission permission has also been received. STATUSINFO May have the following values: CM_NO_STATUS_RECEIVED --> No transmission permission received CM_SEND_RECEIVED --> Transmission permission received

Page 171: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 5-39

SAP AG 2002

���

&20081,&$7,21�'($//2&$7(

���

,' FRQYLG> 5(7851&2'( UF @��

&ORVLQJ D�&3,�& &RQQHFWLRQ

� You use this call to close the CPI-C connection. Any data in the local buffer that has not yet been sent is transmitted first and then the connection is closed.

� The connection should always be closed by the program that has transmission permission; otherwise, any data that has not yet been received is lost.

Page 172: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 5-40

SAP AG 2002

&RQYHUWLQJ�'DWD

5��5��

%6����%6����

96(96(096096

5��5��

81,;81,;

(%&',&$6&,,

1717

����������

75$16/$7( ILHOG )520 &2'(�3$*(������72 &2'(�3$*(�������

&RQYHUVLRQ�FRPPDQG LQ�$%$3�

� Data conversion is necessary when two systems that use different character sets communicate with each other.

� To convert the character sets, you use the following ABAP command 75$16/$7(���ILHOG!���)520�&2'(�3$*(���������72�&2'(�3$*(��������This command lets you convert character strings between different code pages. The contents of the field you specify is converted from the source code page representation to the target code representation.

� You can display and/or maintain the codepages in R/3 using transaction 63$'.

Page 173: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 5-41

SAP AG 2002

&DOOLQJ DQ�$%$3 3URJUDP�5HPRWHO\

,QWURGXFWLRQ,QWURGXFWLRQ

5HPRWH�'HVWLQDWLRQV5HPRWH�'HVWLQDWLRQV

8VLQJ &3,�&�LQ &RPPXQLFDWLRQV8VLQJ &3,�&�LQ &RPPXQLFDWLRQV

&DOOLQJ DQ�$%$3 3URJUDP�5HPRWHO\&DOOLQJ DQ�$%$3 3URJUDP�5HPRWHO\

'HYHORSPHQW�DQG 7HVW (QYLURQPHQW'HYHORSPHQW�DQG 7HVW (QYLURQPHQW

Page 174: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 5-42

SAP AG 2002

&DOOLQJ�DQ�$%$3�3URJUDP�5HPRWHO\��7RSLF�2EMHFWLYHV

z $W�WKH�FRQFOXVWLRQ�RI�WKLV�WRSLF� \RX ZLOO EH�DEOH WR�FDOO D�SDVVLYH�$%$3 SURJUDP�UHPRWHO\�

Page 175: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 5-43

SAP AG 2002

$FWLYH&3,�& SURJUDP�$%$3��&�

5����5����H[WHUQDO�V\VWHP

3DVVLYH&3,�& SURJUDP�$%$3 URXWLQH�

5����5��6$3�6$3�%DVLV%DVLV V\VWHPV\VWHP

&DOOLQJ DQ�$%$3 3URJUDP�8VLQJ &3,�&

� You can call ABAP programs (or more precisely, ABAP form routines) in an R/2 or an R/3 System remotely using CPI-C. You cannot communicate with them directly, however. The connection must be made through the SAP Basis System of the passive program.

� In the R/2 System, the SAP Basis System is the task handler, called using X1SA. In the SAP R/3 System, you address the dispatcher using sapdp##.

Page 176: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 5-44

SAP AG 2002

���� ,QLWLDOL]H�FRQQHFWLRQ�ZLWK�UHPRWH�V\VWHP,QLWLDOL]H�FRQQHFWLRQ�ZLWK�UHPRWH�V\VWHP �,1,7��,1,7����� (VWDEOLVK�FRQQHFWLRQ�ZLWK�UHPRWH�V\VWHP�(VWDEOLVK�FRQQHFWLRQ�ZLWK�UHPRWH�V\VWHP��$//2&$7(� �$//2&$7(�

���� :DLW�IRU�UHVSRQVH�IURP�UHPRWH�V\VWHP:DLW�IRU�UHVSRQVH�IURP�UHPRWH�V\VWHP �5(&(,9(��5(&(,9(����� :LWK:LWK DIILUPDWLYHDIILUPDWLYH DQVZHUDQVZHU�� FRPPXQLFDWH�ZLWK�UHPRWHFRPPXQLFDWH�ZLWK�UHPRWH

$%$3�$%$3�URXWLQHURXWLQH �VHQG�VHQG SHUPLVVLRQ�RQ�DFWLYH�VLGHSHUPLVVLRQ�RQ�DFWLYH�VLGH��

���� 6HQG�FRQQHFW�VWULQJ6HQG�FRQQHFW�VWULQJ WR�WR�UHPRWH�V\VWHPUHPRWH�V\VWHP �6(1'��6(1'�

� � �� &RQWDLQV&RQWDLQV 6$36$3 ORJRQ�GDWD�IRU�WKH�UHPRWH�V\VWHPORJRQ�GDWD�IRU�WKH�UHPRWH�V\VWHP�� DQG�DQG�WKH�QDPH�RI�WKH�UHPRWHWKH�QDPH�RI�WKH�UHPRWH $%$3$%$3 URXWLQHURXWLQH

�� 0XVW�DOZD\V�EH�VHQW0XVW�DOZD\V�EH�VHQW LQ�(%&',&LQ�(%&',&

3URFHGXUH LQ WKH�$FWLYH�3URJUDP

� The above procedure for calling a remote ABAP routine is the same, regardless of whether the active program is an ABAP program in an R/2 or an R/3 System, or a C program in an external system.

Page 177: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 5-45

SAP AG 2002

'LFWLRQDU\�VWUXFWXUH&3,&&211)LHOG� 7\SH /HQJWK��������

5(4,' & �5(47<3( & �$02'( & �,02'( & �),//� & �0$1' & �1$0( & ��&2'( & �/$1* & �&255 & �352* & �02'1 & ��

9DOXH

&3,&�

����FKDUDFWHU�FOLHQW !��6$3XVHU !� 3DVVZRUG !� /RJRQ�ODQJXDJH !

��$%$3SURJUDP !��)RUP URXWLQH !

&211

��1RW LPSRUWDQW !��1RW LPSRUWDQW !

��1RW LPSRUWDQW !

7KH�&RQQHFW 6WULQJ

� The valid format for a connect string is contained in the ABAP Dictionary structure CPICCONN. By defining a structure using the latter and setting the fields with suitable values, you create your own connect string. If you are programming in C, use the call SAP_CMLOGON to create a connect string in EBCDIC.

� All of the values in a connect string must be entered in uppercase.

� In the 1$0( field, enter a XVHU�ZLWK�W\SH�&3,�& that is already defined in the relevant client of the remote system.

� The one-character language key is converted into the corresponding two-character key by the remote Basis system. This must be made known to the remote system.

� In the 352* field, enter the main program of the remote routine. The syntax must be correct. The name of this main program can have a maximum of 8 characters.

� The form routine that you enter in the 02'1 field must exist within the specified main program.

Page 178: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 5-46

SAP AG 2002

3RVLWLYH &RQILUPDWLRQ 0HVVDJH

$33& &3,& �5HWXUQ�FRGH ��� 7UDQVPLVVLRQ

SHUPLVVLRQ� �

1HJDWLYH &RQILUPDWLRQ 0HVVDJH

)5(( &3,& � 8VHU QRW SHUPLWWHG5HWXUQ�FRGH �����

&RQILUPDWLRQ 0HVVDJHV IURP�WKH�5HPRWH %DVLV�6\VWHP

� If the remote Basis system’s check on the connect string is positive (valid logon data, main program and form routine are syntactically correct and exist in the target system), the active program receives the 12-byte EBCDIC string APPCCPIC1 with return code 0 and the transmission permission. As of this point, the system can communicate directly with the called ABAP routine. The data format is completely open.

� If the checks fail, the remote Basis system sends a corresponding error message with the 12-byte header FREECPIC1 in EBCDIC and terminates the connection.

Page 179: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 5-47

SAP AG 2002

5(3257��;<=��,1&/8'(��56&3,&')�7$%/(6��&3,&&211�

&20081,&$7,21��,1,7�������&20081,&$7,21��$//2&$7(�������&20081,&$7,21��6(1'����%8))(5��&3,&&211�������

&3,&&211�5(4,' ��&211��&3,&&211�352* ��===��

���

&3,&&211�02'1 ��$%&��75$16/$7(��&3,&&211���)520�&2'(�3$*(������

72������ &2'(�3$*(������ ��

&20081,&$7,21��5(&(,9( %8))(5��5&9%8)�������

&20081,&$7,21��6(1'��� ��� � 6HQG�DSSOLFDWLRQ�GDWD,)��5(7851&2'(��1(��&0B2.�������(;,7������(1',)�

&20081,&$7,21��5(&(,9(��� ��� � 5HFHLYH�DSSOLFDWLRQ�GDWD

���

$FWLYH $%$3 3URJUDP

� The above coding example shows an active ABAP program that calls an ABAP form routine remotely in another SAP system (R/2 or R/3) using CPI-C.

Page 180: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 5-48

SAP AG 2002

5(3257��===��,1&/8'(�56&3,&')�

&20081,&$7,21��$&&(37�������)250��$%&��

&20081,&$7,21��6(1'��� ��� � 6HQG�DSSOLFDWLRQ�GDWD&20081,&$7,21��5(&(,9(��� ��� � 5HFHLYH�DSSOLFDWLRQ�GDWD

���

(1')250�����

$%$3 3URJUDP�:LWK D�3DVVLYH�5RXWLQH

� This coding example shows an ABAP program containing an ABAP routine that can be called remotely.

� The main program may contain more than one subroutine that can be called remotely. However, only the subroutine specified in the connect string is executed.

Page 181: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 5-49

SAP AG 2002

'HYHORSPHQW�DQG 7HVW (QYLURQPHQW

,QWURGXFWLRQ,QWURGXFWLRQ

5HPRWH�'HVWLQDWLRQV5HPRWH�'HVWLQDWLRQV

8VLQJ &3,�&�LQ &RPPXQLFDWLRQV8VLQJ &3,�&�LQ &RPPXQLFDWLRQV

&DOOLQJ DQ�$%$3 3URJUDP�5HPRWHO\&DOOLQJ DQ�$%$3 3URJUDP�5HPRWHO\

'HYHORSPHQW�DQG 7HVW (QYLURQPHQW'HYHORSPHQW�DQG 7HVW (QYLURQPHQW

Page 182: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 5-50

SAP AG 2002

'HYHORSPHQW�DQG�7HVW�(QYLURQPHQW�7RSLF�2EMHFWLYHV

$W�WKH�FRQFOXVLRQ�RI�WKLV�WRSLF� \RX ZLOO EH�DEOH WR�z 8VH�WKH &3,�& WHVW�SURJUDPV�VXSSOLHG�E\ 6$3�LQWKH�VWDQGDUG 5���6\VWHP

z $QDO\]H &3,�& SURJUDPV�DQG�FRQQHFWLRQV�XVLQJ�WKH�WRROV�SURYLGHG

Page 183: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 5-51

SAP AG 2002

7KH 6$3�&3,�&�6RIWZDUH 'HYHORSPHQW�.LW �6'.�

5��$%$3�ODQJXDJH�VFRSH

&20081,&$7,21�,1,7����&20081,&$7,21�$//2&$7(����

([WHUQDOV\VWHP

&3,�&�6'.&0,1,7�����&0$//&�����&0$&&3�����&06(1'�����&05&9�����&0'($/�����

&20081,&$7,21�$&&(37����&20081,&$7,21�6(1'����&20081,&$7,21�5(&(,9(����&20081,&$7,21�'($//2&$7(����

���

6DPSOHSURJUDPV

� In R/3, the CPI-C calls are contained in the language scope of ABAP.

� However, on external platforms you must install the CPI-C library (CPI-C-SDK). For information on how to use the CPI-C calls, refer to the text files and sample programs delivered with the SDK.

Page 184: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 5-52

SAP AG 2002

5�����5��$%$3 SURJUDPV

$&3,&7��DFWLYH�

$&3,&7��SDVVLYH�

([WHUQDO�V\VWHP& SURJUDPV

FFSLFW�W�DFWLYH�

FFSLFW�W�SDVVLYH�

&3,�&�7HVW 3URJUDPV

� The standard system contains the CPI-C test programs $&3,&7� and $&3,&7� (in R/2 as of release 5.0G). $&3,&7� is an active CPI-C program, $&3,&7� is a passive CPI-C program. You can use them to test R/3-R/3 and R/3-R/2 CPI-C connections.

� SAP also supplies the SAP CPI-C SDK (Software Development Kit) with every SAP R/3 System. You can use this kit to develop CPI-C programs in C. The SDK contains the C programs FFSLFW�W (active) and FFSLFW�W (passive). You can use these programs to test connections between two external systems, but, above all, to test connections between external systems and an R/3 System. ccpict1 can call not only FFSLFW�W remotely, but also the passive ABAP program $&3,&7�. Likewise, the active ABAP program $&3,&7� can call the passive C program FFSLFW�W.

� When you run $&3,&7�, you must specify: - If $&3,&7��or FFSLFW�W��should be called remotely (parameter ’ABAP’) , - If test data should be converted from ASCII to EBCDIC (parameter &219(57). If you call $&3,&7�, you must also enter the logon data for the connect string on the selection screen of $&3,&7�.

Page 185: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 5-53

SAP AG 2002

$QDO\VLV 7RROV

$%$3�'HEXJJHU$%$3�'HEXJJHU

*DWHZD\ 0RQLWRU���60*:�*DWHZD\ 0RQLWRU���60*:�

6\VWHP�/RJ���60���6\VWHP�/RJ���60���

� You can use the Debugger to analyze an active ABAP CPIC-C program in R/3. This does not apply in R/2 since screen changes are not allowed in R/2 during a CPI-C connection (Debugging involves screen changes). You cannot analyze passive programs in the Debugger.

� You can use the Gateway monitor (transaction SMGW) to monitor SAP Gateway activity (existing CPI-C connections) and generate and display Gateway traces.

� One of the tasks of the system log is to record failed CPI-C logons that have been sent from remote systems to the current system. You can display the system log using transaction SM21.

Page 186: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 5-54

SAP AG 2002

7KH�&3,�&�&RPPXQLFDWLRQ�,QWHUIDFH�7RSLF�6XPPDU\

z 7KH &3,�& LQWHUIDFH�DOORZV�SURJUDPV LQ�5����5����DQG�H[WHUQDO�V\VWHPV WR FRPPXQLFDWH�DQG�H[FKDQJH�GDWD�ZLWK�RQH�DQRWKHU�

z 7KH�FRPPXQLFDWLRQ�DOZD\V�UXQV�XVLQJ DQ�6$3*DWHZD\�

z 7R VWDUW D FRQQHFWLRQ� WKH�DFWLYH�SURJUDP�UHTXLUHVD GHVWLQDWLRQ �HQWU\ LQ WKH�VLGH�LQIRUPDWLRQ�WDEOH��

z ,I�WKH�WDUJHW�V\VWHP�LV DQ�6$3 V\VWHP� WKH�DFWLYH�SURJUDP�PXVW VHQG WKH�UHTXLUHG�ORJRQ�GDWD�DQG�WKH�QDPH�RI�WKH�IRUP�URXWLQH�LW�ZDQWV WR FDOO�DV DFRQQHFW�VWULQJ�

z 7KHUH�DUH�PDQ\ &3,�& WHVW�SURJUDPV�DQG�DQDO\VLV�WRROV�DYDLODEOH�

Page 187: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 5-55

SAP AG 2002

$V\QFKURQRXV�'DWD 7UDQVIHU WKURXJK 4XHXH$SSOLFDWLRQ�3URJUDPPLQJ ,QWHUIDFH��4$3,�

0DLQWDLQLQJ DQ�5)&�'HVWLQDWLRQ�LQ�5��0DLQWDLQLQJ DQ�5)&�'HVWLQDWLRQ�LQ�5��

:HE�5)&:HE�5)&

7KH &3,�& &RPPXQLFDWLRQ ,QWHUIDFH7KH &3,�& &RPPXQLFDWLRQ ,QWHUIDFH

$V\QFKURQRXV�'DWD 7UDQVIHU WKURXJK 4�$3,�$V\QFKURQRXV�'DWD 7UDQVIHU WKURXJK 4�$3,�

([HUFLVHV � 6ROXWLRQV�IRU &3,�& DQG 4�$3,��%$3,�:RUNVKRS([HUFLVHV � 6ROXWLRQV�IRU &3,�& DQG 4�$3,��%$3,�:RUNVKRS

Page 188: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 5-56

SAP AG 2002

$V\QFKURQRXV�'DWD�7UDQVIHU�7KURXJK�4$3,�7RSLF�2EMHFWLYHV

z 7UDQVPLW��EXIIHUHG� GDWD�DV\QFKURQRXVO\z *HQHUDWH D�TXHXH��ORFDOO\�GHSRVLWHG�GDWD�WKDW�LV WREH�VHQW�DV\QFKURQRXVO\�

z 0DQDJH�TXHXHV

$W�WKH�FRQFOXVLRQ�RI�WKLV�XQLW��\RX ZLOO�EH�DEOH WR

Page 189: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 5-57

SAP AG 2002

Accept connection

Receive data record& process

Send confirmation

Close connection and end program

5�� 5HPRWH 6\VWHP

3DVVLYH UHFLSLHQW�SURJUDP&3,�&5��

GDWDEDVH

±y² ³±�² ³´ µ ¶ · ¸ ¹ º » · ¼ ½ · ¼´ µ ¶ · ¸ ¹ º » · ¼ ½ · ¼¾ ¿ ¾ À¾ ¿ ¾ À´´ÁÁ ¾ ¾ ÂÀ »À »ÃÅÄÃYÄÆ »Æ »

 Â ÂÇ ÈÇ È» É» ÉÀ ÂÀ ÂÀ ÀÀ ÀÊ ÂÊ Â

Ä ÆÄ Æ

Ë�Ì7Ë�Í:Î]Ï�Ð]Ñ5Ï�Ò+Ó

4XHXH SRROQueue X Queue Y

� � �

Job X

Data selection

Data storage

(driver prog.)

Job Y(driver prog.)

���in queue

QAPI

$UFKLWHFWXUH

� One of the prerequisites of CPI-C communication is that the recipient system be available. Asynchronous data transmission (or buffered data transmission) is useful for cases where the recipient system is unavailable or overloaded (and so unable to receive and process data).

� The data that is to be sent is first placed in a queue. Then a job is automatically scheduled that starts an active CPI-C send program (driver program) at the set time to read and send the queue data. You specify the recipient passive program in the queue attributes, which is then called at the appropriate time to receive and process the data.

Page 190: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 5-58

SAP AG 2002

5��4XHXH SRRO

-RE�;

4XHXH DWWULEXWHV6WDUW PRGH $

6HQG GDWH ��������

4XHXH�;

�����

$XWRPDWLF�VFKHGXOLQJRI�WKH�GULYHU�SURJUDP

ZKHQ D TXHXH�LV�FUHDWHG

6WDUW WLPH � ��������6WDUW�GDWH�� ��������6WHS � 564$3,��

6HQG�WLPH ������

'ULYHU�SURJ� 564$3,��

$XWRPDWLF�6FKHGXOLQJ�RI D 'ULYHU�3URJUDP

� The system only schedules the transmission job for queues with the value A (automatic transmission) in the�6WDUW�PRGH attribute. The job has the same name as the queue, and is scheduled for the time and date specified in the ’Transmission date/time’ attribute. The only step in the job is to call the active CPI-C program specified in the 'ULYHU�SURJUDP attribute of the queue.

Page 191: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 5-59

SAP AG 2002

5��4XHXH SRRO

4XHXH�;

�����

6FKHGXOHG

RI�WKH�GULYHU�SURJUDP5HPRWH 6\VWHP

3DVVLYHUHFLSLHQWSURJUDP

&3,�&Ô:Õ�ÖZÕ5ÖØ×wÙ�ÚÙ

H[HFXWLRQ�RI

-RE�;6WDUW WLPH � ��������6WDUW�GDWH�� ��������6WHS � 564$3,��

Û Ö7Ù7×@Ü�Õ�ÖwÕ7ÖÝ×�Ù�Ú�Ù

4XHXH DWWULEXWHV

3DVVLYH SURJUDP'HVWLQDWLRQ

)RUP URXWLQH

ÞÞÞß à¡áYâ�ã:ä�åÅâçæ+è]æ]å�â7ãêé æìë7íî&ï!ð æ]è]æ3åÅâ7ã

Û Ö�Ù7×@ñçò�ó ôYñõ×ZÖ�Ú�ÙZö�÷ ø��

��

$XWRPDWLF�'DWD�7UDQVPLVVLRQ

� The specified driver program is started automatically at the chosen start time. This active CPI-C program calls the relevant recipient program and sends the queue to it. The driver program reads the relevant parameters for the CPI-C communication from the corresponding queue attributes.

� The SAP standard driver program 564$3,�� has the following properties: - If the connection to the remote system cannot be established, the driver program schedules itself again (-> new job). You can set the interval between attempts using the constant DELAYTIME in the driver program (300 sec.) . If the CLIENT attribute (client in remote SAP system) is set; the corresponding CPI-C connect string is constructed and sent automatically after establishing the connection with the remote system. The queue records are then read and sent in SLQJ�SRQJ�mode. LUWs that have been sent successfully are deleted from the queue (LUW = records that belong together). - If the connection is terminated when the data is transmitted, the current LUW in the queue is rolled back, the queue status is set to E, and an express e-mail is sent to the queue creator. (In this error case, the recipient program must roll back the current LUW in the remote system itself.). If required, you can adapt the driver program to your own needs, or write your own driver program for use in queue transmission.

� You must create a passive recipient program in the remote system that can receive and process the queue data.

Page 192: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 5-60

SAP AG 2002

�� 2SHQ�TXHXH �JHQHUDWH�TXHXH�KHDGHU�

� 3ODFH�UHFRUGV�RI�ILUVW /8: LQWR�TXHXH�RQH�E\�RQH��&200,7�:25.����IL[HV�/8:�LQ TXHXH�

3ODFH�UHFRUGV�RI�VHFRQG /8: LQWR�TXHXH�RQH�E\�RQH��&200,7�:25.����IL[HV�/8:�LQ TXHXH����

� &ORVH�TXHXH�IROORZHG�E\ &200,7�:25.��IL[HV TXHXH�

&UHDWLQJ D�4XHXH

� The above is the procedure for creating a queue.

Page 193: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 5-61

SAP AG 2002

)XQFWLRQ�PRGXOH)XQFWLRQ�PRGXOH

,PSRUW SDUDPHWHUV1$0(23(102'((5$6(7<3(67$57'$7(7,0(

48(8(B23(148(8(B23(19DOXHV��4XHXH QDPH !�:�������5��;������63$&(�$�������8��$�������0�������(������� VWDUW�PRGH �� 6HQG GDWH�!� 6HQG�WLPH !�����

2SHQLQJ D�4XHXH��,�

� When you open a queue using the function module QUEUE_OPEN, you must supply the following parameters: NAME Name of queue to be opened This parameter is not specified when opening a new queue.The queue, therefore, receives the current time stamp as its name, which you receive from the export parameter NAME of the function module. OPENMODE W Write ; R: Read ERASE X Deletes the queue shell when the queue is empty TYPE U : Unique (queue can only be filled with data once; it cannot be extended subsequently) Appendable (queue may be extended, even during transmission) START A Automatic (queue data is automatically sent through an internally scheduled job at the specified send time (DATE / TIME). M Manual (queue must be sent manually using transaction SM38) -> internal scheduling of an immediate job) E Event-controlled (used to start transmission immediately once the queue has been created.) To do this, you must manually create an appendable queue first from start mode E using transaction SM38. When the queue is activated, a job is created internally that is executed at the event SAP- QEVENT / parameter <queue name>. If you place data from this program into this queue, the accompanying event is triggered automatically at QUEUE_CLOSE. The scheduled job for sending data commences. DATE/TIME Transmission start time and date (only applies to start type A).

Page 194: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 5-62

SAP AG 2002

)XQFWLRQ�PRGXOH)XQFWLRQ�PRGXOH

,PSRUW SDUDPHWHUV

'$7$7<3('5,9(5'(67,1$7,21&/,(1786(5,'3$66:25'352*5$0

48(8(B23(148(8(B23(19DOXHV

63$&(������&3,&�������52'&�� 'ULYHU�SURJUDP !� 6LGH�LQIR�HQWU\�IRU�WDUJHW�V\VWHP !��&OLHQW�LQ WDUJHW�V\VWHP !� 8VHU LQ WDUJHW�V\VWHP !� 3DVVZRUG�RI�UHPRWH�XVHU !��3DVVLYH UHFLSLHQW�SURJUDP !

)250 ��)RUP URXWLQH LQ UHFLSLHQW�SURJUDP!

�����

2SHQLQJ D�4XHXH��,,�

� Further import parameters of function module QUEUE_OPEN: DATATYPE: This queue attribute is interpreted by the driver program RSQAPI20. SPACE : Queue data is transmitted unconverted. CPIC: If the sending system uses ASCII, the queue data is converted from ASCII to EBCDIC before it is sent. RODC: Queue data is sent by CPI-C using RODC protocol (only when sending to R/2). DRIVER Name of driver program (for example RSQAPI20) DESTINATION TXCOM entry (for making connection to receiving ssystem by driver) Only enter the following parameters if the receiving system is an SAP System: CLIENT Client in receiving system (with CLIENT values, the driver RSQAPI20 automatically sends a connect string.) USERID / PASSWORD Logon data for the receiving system PROGRAM / FORM Receiving program or form routine called remotely from the driver program

� The input parameters of the function module QUEUE_OPEN are stored in the queue header as queue attributes.

� The parameters of the QUEUE_* function modules are all defined with reference to ABAP Dictionary fields. Therefore, the corresponding actual parameters must all have the same types.

Page 195: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 5-63

SAP AG 2002

)XQFWLRQ�PRGXOH)XQFWLRQ�PRGXOH

,PSRUW SDUDPHWHUV1$0(67$7(

%8))(5/(1*7+

48(8(B38748(8(B3879DOXHV��4XHXH QDPH !�6� � VLQJOH�UHFRUG�RI /8:��) ��)LUVW UHFRUG�RI /8:��63$&(� � 0LGGOH�UHFRUG�RI /8:��/ ��/DVW UHFRUG�RI /8:��� 5HFRUG�FRQWHQWV!� 5HFRUG�OHQJWK !

6WRULQJ D 5HFRUG�RI DQ�/8:�LQ WKH 4XHXH

� The function module QUEUE_PUT requires the following input parameters: NAME Name of the queue into which you want to place the record. SATE Position of the current record within its LUW: S: Current record is the only record in the LUW F Current record is the first (but not only) record in the LUW SAPCE Current record is neither the first nor the last record in the LUW L Current record is the last of several records in the LUW BUFFER Current record LENGTH Length of current record

Page 196: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 5-64

SAP AG 2002

)XQFWLRQ�PRGXOH)XQFWLRQ�PRGXOH

,PSRUW SDUDPHWHUV1$0(23(102'(

48(8(B&/26(48(8(B&/26(9DOXHV��4XHXH QDPH !� 2SHQ�PRGH�XVHG WRRSHQ�WKH�TXHXH ��:���5���!

&ORVLQJ�WKH 4XHXH

� The function module QUEUE_CLOSE requires the following input parameters: NAME Name queue to be closed OPENMODE Open mode used when queue was opened

� If you created the queue with start mode A (automatic transmission), the corresponding job is scheduled automatically when you call QUEUE_CLOSE. The job name is the same as the queue name.

Page 197: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 5-65

SAP AG 2002

)XQFWLRQ�PRGXOHV)XQFWLRQ�PRGXOHV

48(8(B*(748(8(B*(7

48(8(B'(/(7(48(8(B'(/(7(

48(8(B(5$6(48(8(B(5$6(

)XQFWLRQ5HDGV D UHFRUG�IURP DTXHXH'HOHWHV DQ�/8: IURP�WKH�TXHXH'HOHWH�TXHXH�DQG�DQ\�GDWD LQ LW�

5HDGLQJ�DQG�'HOHWLQJ D�4XHXH

� If you modify driver program RSQAPI20 or write your own driver program, you can use the above function modules to read or delete queues. For further information about their use, refer to their documentation in the Function Builder.

Page 198: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 5-66

SAP AG 2002

5��4XHXH SRRO

4XHXH�;

�����4XHXH�<

z /LVW TXHXHVz 'LVSOD\�FKDQJH�TXHXH�DWWULEXWHVz 'LVSOD\ TXHXH�GDWDz 6WDUW TXHXH�WUDQVPLVVLRQz 'LVSOD\ WUDQVPLVVLRQ ORJz 'HOHWH�TXHXHz &UHDWH�TXHXHV�ZLWK�QR�GDWD

4XHXH�$GPLQLVWUDWLRQ��7UDQVDFWLRQ 60���

60��

� You can manage queues in the queue pool using transaction SM38. � The standard R/3 System contains the following demonstration programs, which show how to create

a queue and send and received data: Creating a queue: SAPBC415D_CREATE_QUEUE or RSQAPI10� Data transmission: RSQAPI20 (Standard driver program) Data transmission: RCVQDATP (Passive recipient program in the remote system)

� You can also use asynchronous (buffered) data transmission from an R/2 System. For further information, refer to the online documentation for &3,�&���$V\QFKURQRXV�'DWD�7UDQVPLVVLRQ.

Page 199: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 5-67

SAP AG 2002

$V\QFKURQRXV�'DWD�7UDQVIHU�7KURXJK�4$3,�7RSLF�6XPPDU\

ù $V\QFKURQRXV�GDWD�WUDQVPLVVLRQ�DOORZV�\RX WR SUHSDUH�DQG VHQG GDWD�VHSDUDWHO\�

ù 7KH�GDWD�LV�ILUVW�SODFHG LQ�D TXHXH�WKDW�LV�VHQW�E\ D GULYHU�SURJUDP WR WKH�DSSURSULDWH�UHFLSLHQW�SURJUDP�DW�WKH�VFKHGXOHG�WLPH�

ù <RX�XVH�WKH�IXQFWLRQ�PRGXOHV 48(8(B23(1��48(8(B387� DQG 48(8(B&/26(�WR FUHDWH D TXHXH�

ù 7KH�VWDQGDUG�V\VWHP�FRQWDLQV GULYHU�SURJUDP564$3,��� 7KLV�SURJUDP�FRQWDLQV�PDQ\�XVHIXO�IXQFWLRQV� DQG�FDQ�VHUYH�DV D WHPSODWH�IRU�\RXU�RZQ�GULYHU�SURJUDPV�

ù <RX�PXVW�FUHDWH D�SDVVLYH UHFLSLHQW�SURJUDP LQ WKH�UHPRWH�V\VWHP WR FRUUHVSRQG WR \RXU�GULYHU�SURJUDP�

ù 7UDQVDFWLRQ 60�� FRQWDLQV�IXQFWLRQV�WKDW�DOORZ�\RX WR�PDQDJH�\RXU�TXHXHV�

Page 200: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 5-68

SAP AG 2002

([HUFLVHV DQG�6ROXWLRQV�IRU &3,�& DQG 4�$3,�%$3,�:RUNVKRS

0DLQWDLQLQJ DQ�5)&�'HVWLQDWLRQ�LQ�5��0DLQWDLQLQJ DQ�5)&�'HVWLQDWLRQ�LQ�5��

:HE�5)&:HE�5)&

7KH &3,�& &RPPXQLFDWLRQ ,QWHUIDFH7KH &3,�& &RPPXQLFDWLRQ ,QWHUIDFH

$V\QFKURQRXV�'DWD 7UDQVIHU WKURXJK 4�$3,$V\QFKURQRXV�'DWD 7UDQVIHU WKURXJK 4�$3,

([HUFLVHV DQG�6ROXWLRQV�IRU &3,�& DQG 4�$3,�%$3,�:RUNVKRS([HUFLVHV DQG�6ROXWLRQV�IRU &3,�& DQG 4�$3,�%$3,�:RUNVKRS

Page 201: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 5-69

([HUFLVHV�

8QLW���7KH�&3,�&�&RPPXQLFDWLRQ�,QWHUIDFH�7RSLF��&3,�&�&RPPXQLFDWLRQ�%HWZHHQ�7ZR�$%$3�3URJUDPV�

• Creating a remote destination in the active system

• Developing active and passive ABAP programs

You have two R/3 Systems and want to use CPI-C communication to transmit data from one to the other.

1-1 Use CPI-C to link two R/3 Systems and transfer data from the passive system to the active system. (Your instructor will tell you the names of the active and passive systems).

1-1-1 In the active system, create a remote destination using transaction SM54. Destination name: '(67�� ( where ## is your group number).

1-1-2 In the active system, copy the main program 6$3%&���7B$&7,9(B&3,&B3*0�to program name =���B$���( where ## is your group number), and convert it into an active CPI-C program that:

• Prompts the user to enter a destination (DEST##) and an airline code (such as ‘AA’)

• Calls the SEND form routine of program Z415_P## remotely (## = group number. You must create the program in the passive system yourself)

• Sends the airline code to the partner program

• Receives the relevant SPFLI entries in SLQJ�SRQJ mode, stores them, and then displays them.

1-3 In the passive system, copy the main program 6$3%&���7B3$66,9(B&3,&B3*0�to your program =���B3���(where ## is your group number), and extend the form routine SEND so that it is a passive CPI-C partner. When it is called, the routine should:

• Receive an airline code

• Read the corresponding SPFLI entries

• Send the SPFLI entries to the caller in SLQJ�SRQJ mode

Page 202: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 5-70

• Terminate the CPI-C connection when finished.

��������7LSV��7ULFNV�

To find out the information required to create the sideinfo entry in the active system, use transaction SM51 (in the passive system).

Page 203: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 5-71

6ROXWLRQV�

8QLW��7KH�&3,�&�&RPPXQLFDWLRQ�,QWHUIDFH�7RSLF��&3,�&�&RPPXQLFDWLRQ�%HWZHHQ�7ZR�$%$3�3URJUDPV�

• Creating a remote destination in the active system

• Developing active and passive ABAP programs

You have two R/3 Systems and want to use CPI-C communication to transmit data from one to the other.

************************************************************************

* *

* Unit: The CPI-C Communication Interface *

* *

* Model solution for exercise 1 *

* ( Active program ) *

* *

************************************************************************

REPORT SAPBC415S_ACTIVE_CPIC_PGM.

TABLES SPFLI. " Receive buffer for an SPFLI record

TABLES CPICCONN. " Connect string

INCLUDE RSCPICDF. " CPI-C constants

* User details (CPI-C destination, required SPFLI records)

PARAMETERS: DEST(8) DEFAULT ’DEST00’,

CARRID LIKE SPFLI-CARRID DEFAULT ’LH’.

* CPI-C variables

DATA: CONVID(8), " Conversation ID

Page 204: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 5-72

RECEIPT(40), " Receipt: Record received

RBUFFER(255), " Receive buffer for logon response

RL(4) TYPE X, " Length of data received

DI(4) TYPE X, " Is the received data complete

SI(4) TYPE X, " Info about send permission

CPIC_RC LIKE SY-SUBRC, " Return code for CPI-C calls

COUNTER(2) TYPE P. " Counter for SPFLI records received

* Internal table for storing SPFLI records received

DATA: ITAB LIKE SPFLI OCCURS 0.

* Fill the connect string

CPICCONN-REQID = ’CONN’. " Request ID

CPICCONN-REQTYPE = ’CPIC’. " Connection type

CPICCONN-AMODE = ’1’. " Mode

CPICCONN-IMODE = ’ ’. " Unused

CPICCONN-FILL1 = ’ ’. " Unused

CPICCONN-MAND = ’401’. " Client

CPICCONN-NAME = ’SAPCPIC’. " CPI-C user in remote system

CPICCONN-CODE = ’ADMIN’. " Password of CPI-C user

CPICCONN-LANG = SY-LANGU. " Logon language

CPICCONN-KORR = ’ ’. " Unused

CPICCONN-PROG = ’CPICS33P’. " Partner ABAP program

CPICCONN-MODN = ’SEND’. " FORM routine

* Initialize communication

SKIP. FORMAT COLOR 1.

WRITE: / ’COMMUNICATION INIT : SYMDEST =’, DEST.

COMMUNICATION INIT

DESTINATION DEST

ID CONVID

RETURNCODE CPIC_RC.

FORMAT COLOR 2.

WRITE: / ’RC =’, CPIC_RC.

IF CPIC_RC NE CM_OK. EXIT. ENDIF. " Simple error handling

WRITE: / ’ ==> CONVID =’, CONVID.

Page 205: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 5-73

* Start communication

SKIP. FORMAT COLOR 1.

WRITE: / ’COMMUNICATION ALLOCATE : CONVID =’, CONVID.

COMMUNICATION ALLOCATE

ID CONVID

RETURNCODE CPIC_RC.

FORMAT COLOR 2.

WRITE: / ’RC =’, CPIC_RC.

IF CPIC_RC NE CM_OK. EXIT. ENDIF. " Simple error handling

* Send logon data

SKIP. FORMAT COLOR 1.

WRITE: / ’COMMUNICATION SEND (Logon-Data) : ’.

FORMAT COLOR 2. WRITE CPICCONN.

TRANSLATE CPICCONN FROM CODE PAGE ’1100’

TO CODE PAGE ’0100’.

COMMUNICATION SEND

ID CONVID

BUFFER CPICCONN

RETURNCODE CPIC_RC.

WRITE: / ’RC =’, CPIC_RC.

IF CPIC_RC NE CM_OK. EXIT. ENDIF. " Simple error handling

* Logon response received

SKIP. FORMAT COLOR 1.

WRITE: / ’COMMUNICATION RECEIVE (Logon response) :’.

COMMUNICATION RECEIVE

ID CONVID

BUFFER RBUFFER

RECEIVED RL

DATAINFO DI

STATUSINFO SI

RETURNCODE CPIC_RC.

Page 206: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 5-74

TRANSLATE RBUFFER FROM CODE PAGE ’0100’

TO CODE PAGE ’1100’.

FORMAT COLOR 2.

WRITE: / RBUFFER,

/2 ’RL =’, RL,

/2 ’SI =’, SI,

/2 ’DI =’, DI,

/2 ’RC =’, CPIC_RC.

IF CPIC_RC NE CM_OK. EXIT. ENDIF. " Simple error handling

* Send CARRID

SKIP. FORMAT COLOR 1.

WRITE: / ’COMMUNICATION SEND (CARRID) :’.

COMMUNICATION SEND

ID CONVID

BUFFER CARRID

RETURNCODE CPIC_RC.

FORMAT COLOR 2.

WRITE: / CARRID,

/2 ’RC =’, CPIC_RC.

IF CPIC_RC NE CM_OK. EXIT. ENDIF. " Simple error handling

* Loop for receiving and processing data and sending acknowledgement

* in ping pong mode:

* In each loop pass

* - One SPFLI record is received

* - appended to ITAB (processing) and

* - a receipt is sent to the sender.

DO.

* Receive SPFLI record

SKIP. FORMAT COLOR 1.

WRITE: / ’COMMUNICATION RECEIVE (SPFLI-Entry) : ...’.

COMMUNICATION RECEIVE

Page 207: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 5-75

ID CONVID

BUFFER SPFLI

RECEIVED RL

DATAINFO DI

STATUSINFO SI

RETURNCODE CPIC_RC.

IF CPIC_RC NE CM_OK. " If connection is

FORMAT COLOR 2. " terminated by

WRITE / ’-> CPI-C connection deallocated.’. " partner exit from

EXIT. " DO loop

ENDIF. " Loop

* Append SPFLI record to itab

APPEND SPFLI TO ITAB.

ADD 1 TO COUNTER.

FORMAT COLOR 2.

WRITE: / ’->’,

3 COUNTER,

6 ’. SPFLI-entry received and processed.’,

/2 ’RL =’, RL,

/2 ’SI =’, SI,

/2 ’DI =’, DI,

/2 ’RC =’, CPIC_RC.

* Send receipt

SKIP. FORMAT COLOR 1.

WRITE: / ’COMMUNICATION SEND (Receipt)’.

RECEIPT = ’ . entry received and processed.’.

MOVE COUNTER TO RECEIPT(4).

COMMUNICATION SEND

ID CONVID

BUFFER RECEIPT

RETURNCODE CPIC_RC.

FORMAT COLOR 2.

WRITE: /2 ’RC =’, CPIC_RC.

IF CPIC_RC NE CM_OK. EXIT. ENDIF. " Simple error handling

Page 208: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 5-76

ENDDO.

* Display itab

SKIP 2. FORMAT COLOR 3.

WRITE / ’Received SPFLI entries :’.

FORMAT COLOR 5.

LOOP AT ITAB INTO SPFLI.

WRITE: /3 SPFLI-CARRID, SPFLI-CONNID, SPFLI-CITYFROM, SPFLI-CITYTO.

ENDLOOP.

************************************************************************

* *

* Unit: The CPI-C Communication Interface *

* *

* Model solution for exercise 1 *

* ( Passive program ) *

* *

************************************************************************

REPORT CPICS33P .

TABLES SPFLI.

INCLUDE RSCPICDF.

DATA: CONVID(8), " Conversation ID

RL(4) TYPE X, " Length of data received

DI(4) TYPE X, " Is the received data complete

SI(4) TYPE X, " Info about send permission

CPIC_RC LIKE SY-SUBRC, " Return code for CPI-C calls

CARRID LIKE SPFLI-CARRID, " Receive field for SPFLI-CARRID

RECEIPT(40). " Receive field for receipt

DATA: ITAB LIKE SPFLI OCCURS 0.

FORM SEND.

Page 209: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 5-77

COMMUNICATION ACCEPT

ID CONVID

RETURNCODE CPIC_RC.

IF CPIC_RC NE CM_OK. EXIT. ENDIF. " Simple error handling

* Receive SPFLI-CARRID from active program

COMMUNICATION RECEIVE

ID CONVID

BUFFER CARRID

RECEIVED RL

DATAINFO DI

STATUSINFO SI

RETURNCODE CPIC_RC.

IF CPIC_RC NE CM_OK. EXIT. ENDIF. " Simple error handling

* Read SPFLI records into itab using array fetch

SELECT * FROM SPFLI

INTO TABLE ITAB

WHERE CARRID = CARRID.

* send contents of itab record by record in ping pong mode

LOOP AT ITAB INTO SPFLI.

COMMUNICATION SEND

ID CONVID

BUFFER SPFLI

RETURNCODE CPIC_RC.

IF CPIC_RC NE CM_OK. EXIT. ENDIF. " Simple error handling

COMMUNICATION RECEIVE

ID CONVID

BUFFER RECEIPT

Page 210: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 5-78

RECEIVED RL

DATAINFO DI

STATUSINFO SI

RETURNCODE CPIC_RC.

IF CPIC_RC NE CM_OK. EXIT. ENDIF. " Simple error handling

ENDLOOP.

* Close connection

COMMUNICATION DEALLOCATE

ID CONVID

RETURNCODE CPIC_RC.

ENDFORM.

Page 211: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 5-79

([HUFLVHV�

8QLW��$V\QFKURQRXV�'DWD�7UDQVIHU��4�$3,��7RSLF��$V\QFKURQRXV�'DWD�7UDQVIHU�EHWZHHQ�5���6\VWHPV�

• Creating a queue for automatic transmission in the source system

• Queue administration

• Checking the processing results

You want to send data from one system to another system, but asynchronously, because the target system is currently not available or overloaded.

1-1 In this exercise, you will pass data between two R/3 Systems using a buffer in the source system that is then transmitted to the target system. (Your instructor will tell you the names of the source and target systems).

1-1-1 In the source system, copy the main program 6$3%&���7B&5($7(B48(8(�to your program =%&���B��B&5($7(B48(8(�(## = your group number), and convert it into a program that generates a queue. The queue should have the following attributes:

• Name 4�� (## = group number)

• Extendable

• Automatic transmission at your chosen time using the driver program 564$3,�� (a slightly modified version of RSQAPI20, with the same functions as the original version).

• Recipient program and form routine 5&94'$73���5(&(,9( (already exist in target system).

• CPI-C destination and remote logon data as in the CPI-C exercise

• Data: two LUWs, each with three records. Record contents: ‘GR##_LUW1_REC1’ , ‘GR##_LUW1_REC2’ , ‘GR##_LUW1_REC3’ , ‘GR##_LUW2_REC1’ , ‘GR##_LUW2_REC2’ , ‘GR##_LUW2_REC3’ (## = your group number)

Page 212: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 5-80

1RWHV :

1 You can ignore the parameters for the function modules you are calling that are not documented in the exercises.

2 You can use OTHERS for the exceptions to the function modules you want to call. Refer to the relevant function module documentation for their meanings.

1-2 Use transaction 60����4XHXH�$GPLQLVWUDWLRQ� to ensure that your queue has been created successfully. Display its attributes. You can display the corresponding job using transaction 60����-RE�$GPLQLVWUDWLRQ�.

1-3 Log onto the target system and look at the coding of receiving program 5&94'$73. This program receives the queue data in ping-pong mode and stores it in table 4'$7 (data processing). Use transaction 6(����'DWD�%URZVHU� to ensure that your queue data has been successfully received and processed (stored in table QDAT).

��������7LSV��7ULFNV�

If you specify a WUDQVPLVVLRQ�WLPH�LQ�WKH�SDVW when you create your queue, the system will be able to create the queue successfully, but the corresponding job generated when you use QUEUE_CLOSE will be scheduled ZLWKRXW�D�VWDUW�WLPH.

Page 213: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 5-81

6ROXWLRQV�

8QLW��$V\QFKURQRXV�'DWD�7UDQVIHU��4�$3,��7RSLF��$V\QFKURQRXV�'DWD�7UDQVIHU�EHWZHHQ�5���6\VWHPV�

• Creating a queue for automatic transmission in the source system

• Queue administration

• Checking the processing results

You want to send data asynchronously from one system to another system because the target system is currently not available or overloaded.

REPORT SAPBC415S_CREATE_QUEUE MESSAGE-ID BC415.

INCLUDE RSQAPIDF.

PARAMETERS:

QID LIKE APQI-QID DEFAULT ’Q00’,

QTYPE LIKE APQI-QATTRIB DEFAULT ’A’, " unique/appendable

STRTMODE LIKE APQI-STARTMODE DEFAULT ’A’, " manual/automatic

STRTDATE LIKE APQI-STARTDATE DEFAULT SY-DATUM,

STRTTIME LIKE APQI-STARTTIME DEFAULT SY-UZEIT,

DRIVER LIKE APQI-STARTPGID DEFAULT ’RSQAPI21’, " data sending pgm

DEST LIKE APQI-DESTSYS DEFAULT ’DEST00’, " Sideinfo-entry

CLIENT LIKE APQI-MANDANT DEFAULT ’000’, " logon-data

USERID LIKE APQI-USERID DEFAULT ’SAPCPIC’, " for

PASSWD LIKE APQI-PASSWD DEFAULT ’ADMIN’, " remote system

PROG LIKE APQI-PROGID DEFAULT ’RCVQDATP’, " data receiving

FORM LIKE APQI-FORMID DEFAULT ’RECEIVE’, " program

LUWS TYPE N DEFAULT ’2’.

DATA:

RCDPOS, " record position in LUW

BUFFER LIKE APQD-VARDATA, " input data for queue

LENGTH TYPE I, " input length

LUWCOUNTER TYPE N. " counter for LUWs

Page 214: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 5-82

*----------------------------------------------------------------------*

* Open queue *

*----------------------------------------------------------------------*

CALL FUNCTION ’QUEUE_OPEN’

EXPORTING

NAME = QID

OPENMODE = ’W’

ERASE = ’X’ " automatically erased when empty

TYPE = QTYPE " unique/appendable

START = STRTMODE " manual/automatic start

DATE = STRTDATE

TIME = STRTTIME

DATATYPE = ’ ’ " no data conversion ASC_TO_EBC

DRIVER = DRIVER " active data sending program

DESTINATION = DEST " Sideinfo-entry

CLIENT = CLIENT " logon-data

USERID = USERID " for

PASSWORD = PASSWD " remote system

PROGRAM = PROG " passive data receiving program

FORM = FORM " and subroutine

EXCEPTIONS

INVALID_PARAMETER = 1 " invalid value in parameter

OTHERS = 2.

CASE SY-SUBRC.

WHEN 1.

MESSAGE E184 WITH ’Invalid value in QUEUE_OPEN-parameter !’.

WHEN 2.

MESSAGE E184 WITH ’Other error in QUEUE_OPEN !’.

ENDCASE.

*----------------------------------------------------------------------*

* Fill queue *

*----------------------------------------------------------------------*

DO LUWS TIMES.

RCDPOS = Q_FIRST. " first record of LUW

BUFFER = ’GR00_LUW _REC1’.

BUFFER+8(1) = LUWCOUNTER = SY-INDEX.

LENGTH = STRLEN( BUFFER ).

PERFORM INSERT_RECORD_TO_QUEUE.

Page 215: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 5-83

RCDPOS = Q_MIDDLE. " second record of LUW

BUFFER = ’GR00_LUW _REC2’.

BUFFER+8(1) = LUWCOUNTER = SY-INDEX.

LENGTH = STRLEN( BUFFER ).

PERFORM INSERT_RECORD_TO_QUEUE.

RCDPOS = Q_LAST. " third (last) record of LUW

BUFFER = ’GR00_LUW _REC3’.

BUFFER+8(1) = LUWCOUNTER = SY-INDEX.

LENGTH = STRLEN( BUFFER ).

PERFORM INSERT_RECORD_TO_QUEUE.

ENDDO.

*----------------------------------------------------------------------*

* Close queue *

*----------------------------------------------------------------------*

CALL FUNCTION ’QUEUE_CLOSE’

EXPORTING

NAME = QID

OPENMODE = ’W’ " openmode used in QUEUE_OPEN

EXCEPTIONS

INVALID_PARAMETER = 1

OTHERS = 2.

CASE SY-SUBRC.

WHEN 0. " queue sucessfully closed

COMMIT WORK.

SKIP 2.

WRITE: 6 ’Created queue sucessfully !’.

SKIP.

WRITE: 6 ’Queue-Id : ’, QID.

WHEN 1.

MESSAGE E184 WITH ’Invalid value in QUEUE_CLOSE-parameters !’.

WHEN 2.

MESSAGE E184 WITH ’Other error in QUEUE_CLOSE !’.

ENDCASE.

*----------------------------------------------------------------------*

Page 216: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 5-84

* FORM insert_record_to_queue *

*----------------------------------------------------------------------*

FORM INSERT_RECORD_TO_QUEUE.

CALL FUNCTION ’QUEUE_PUT’

EXPORTING

NAME = QID

STATE = RCDPOS " record position in LUW

BUFFER = BUFFER " record data

LENGTH = LENGTH " record length

EXCEPTIONS

INVALID_PARAMETER = 1 " invalid value in parameter

OTHERS = 2.

CASE SY-SUBRC.

WHEN 1. " invalid value in QUEUE_PUT-parameters

" -> message + LUW-rollback

MESSAGE E184

WITH ’Invalid value in QUEUE_PUT-parameters -> LUW-rollback’.

WHEN 2. " other error in QUEUE_PUT !

" -> message + LUW-rollback

MESSAGE E184

WITH ’Other error in QUEUE_PUT -> LUW-rollback’.

ENDCASE.

IF RCDPOS = Q_LAST. " complete LUW in queue

COMMIT WORK.

ENDIF.

ENDFORM.

Page 217: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 5-85

%$3,�:RUNVKRS��'HVFULSWLRQ��The following pages provide guidelines for creating BAPIs. We will start with the business object )OLJKW&XVWRPHU (object type 6&86720). This business object is available in all SAP training systems, but not in the standard delivery. If you want to reconstruct the example described in the guide in your own system, you must first import the 4.6 training add-on. This add-on contains all the objects used in ABAP training courses and can be downloaded from the SAP service homepage:

KWWS���VHUYLFH�VDS�FRP�RFV�GRZQORDG� Æ Logon with OSS user or User "walldorf" (Password "training")

,Q�WKH�QDYLJDWLRQ�DUHD�� Æ Download support packages

Æ Add-on support packages / CRTs

Æ Further add-on components

Æ Training

Æ Training 46C

,Q�WKH�FRQWHQWV�DUHD�� Æ All objects (full task)

Æ Download

���1RWH�� Data for flight tables can be generated automatically by calling the report SAPBC_DATA_GENERATOR.

Page 218: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 5-86

6FHQDULR��

In the scenario to be implemented here, you require a BAPI to read data about a flight customer. First, you need to display a list of flight customers. From this list you can select a flight customer, and then, using another BAPI, display specific details about this customer.

The relevant 6$3�%XVLQHVV�2EMHFW for this scenario is )OLJKW&XVWRPHU.

To read a flight customer’s details as described in the above scenario, two BAPIs are required: One to display a list of flight customers (*HW/LVW) and another to display details of a specific flight customer (*HW'HWDLO). The interdependency of these two BAPIs is evident because, first of all, the list of flight customers is displayed to obtain the ID of the specific flight customer sought. From this ID, you can display details of the flight customer.

However, the two BAPIs remain functionally independent of each other because, if the flight customer ID is known, the BAPI to display the details of a specific flight customer can be used without calling the *HW/LVW BAPI.

In this workshop, you will create the two above-mentioned BAPIs.

You will create the *HW/LVW BAPI first. It requires that you create a structure, a function module, and a form routine. To save time, the ABAP code is attached to the end of this workshop. After creating the ABAP programs, you will then use the BOR/BAPI Wizard to create the BAPI and attach it to the )OLJKW&XVWRPHU object.

The second BAPI you will create is the *HW'HWDLO BAPI. You will have to create a function module to get the detail about a flight customer and then create the BAPI using the BOR/BAPI wizard. To save time, the ABAP code is attached to the end of this workshop.

Page 219: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 5-87

6HFWLRQ��� 3URJUDPPLQJ�WKH�*HW/LVW�%$3,��%DFNJURXQG�The *HW/LVW BAPI requires a structure to hold the return data for the BAPI method call. The BAPI will return the &XVWRPHU�,' and the�&XVWRPHU�1DPH fields in a structure. The structure we will create is based upon the SCUSTOM table.

��� Go to the�'DWD�'LFWLRQDU\ and define a structure for the BAPI.

Use the Menu Path 7RROV��$%$3�:25.%(1&+ and select the 'LFWLRQDU\ command button in the toolbar or use transaction SE11 to get into the 'DWD�'LFWLRQDU\.

2 Select the VWUXFWXUHV option button and enter the name as ZBAPICUSTxx (xx is your group number). Press the (QWHU key to display the detailed structure screen.

3 In the 6KRUW�7H[W field, enter the structure for the *HW/LVW BAPI.

4 Complete the remaining entries for the two fields in the structure as follows:

Field Name: ID

Type Name: S_CUSTOMER

Press the (QWHU key, and the remaining entries for ID will be filled in from the S_CUSTOMER definition.

Field Name: NAME

Type Name: S_CUSTNAME

Press the (QWHU key, and the remaining entries for NAME will be filled in from the S_CUSTNAME definition.

5 Save and activate the structure.��

6HFWLRQ����%XLOGLQJ�WKH�)XQFWLRQ�0RGXOH�IRU�WKH�������������������*HW/LVW�%$3,�

1 Go to the )XQFWLRQ�%XLOGHU and create a function group. Use the menu path 7RROV��$%$3�:RUNEHQFK��)XQFWLRQ�%XLOGHU.

2 Name the function group ZGxx (xx is your group number).

Page 220: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 5-88

3 Create a function module. Name the module ZBAPI_GET_CUSTOMER_LISTxx (xx is your group number).

4 Define the interface for your function module.

On the $GPLQ tab :

• Enter the short text (your choice).

• Select 5HPRWH�)XQFWLRQ�&DOO supported in the processing type

On the ([SRUW tab:

• Enter 5HWXUQ for the export parameters and BAPIRETURN for the 5HI�ILHOG���VWUXFWXUH�

On the 7DEOHV tab:

• Enter SCUST_LIST for the table parameters and ZBAPICUSTxx for the 5HI�6WUXFWXUH ([[ is your group number).

On the 'RFXPHQWDWLRQ tab: Entries are made for you.

On the ,PSRUW, &KDQJLQJ and ([FHSWLRQV tabs: No entries required.

5 You will need to add global data for the function group. Specifically, you will need to add declarations for the table work area VFXVWRP, the internal table, and a message structure. See the attached program code for the function group global declarations at the end of this workshop. Since these are global for your function group, you will not need to repeat these declarations for the *HW'HWDLO BAPI. To access the *OREDO�'DWD area from the source code editor, use the menu path *R7R��*OREDO�'DWD.

6 Code the function module. The code for your function module is attached at the end of this workshop. PLEASE NOTE: YOU NEED TO CHANGE ANY REFERENCES TO TABLES AND PROGRAMS BASED UPON THE NAMES YOU HAVE BEEN ASSIGNED. THE SAMPLE CODE USES A STRUCTURE AND FUNCTION NAME DIFFERENT FROM YOURS.

7 You will need to create a form routine that handles messages. You can find the ABAP code at the end of this workshop. It should not be changed from the printed copy. You can just enter it as is.

Page 221: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 5-89

To access the form routine (subroutine) area, double click the name of the form routine being called. For our workshop, the form routine is set_return_message. This routine handles the messaging return structure (of type BAPIRETURN), which is used to inform the external program calling the BAPI whether the BAPI was successful or not.

Page 222: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 5-90

Page 223: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 5-91

6HFWLRQ������'HILQLQJ�0HWKRGV�LQ�WKH�%25�XVLQJ�WKH���������������������%25���%$3,�ZL]DUG��1 Go to the %XVLQHVV�2EMHFW�%XLOGHU. You can use the path from the main menu

7RROV��%XVLQHVV�)UDPHZRUN��%$3,�GHYHORSPHQW��%XVLQHVV�2EMHFW�%XLOGHU. Or you can use transaction SWO1 (alpha O).

2 In the %XVLQHVV�2EMHFW�%XLOGHU initial screen, enter SCUSTOMER as the object type. Then select the &KDQJH command button. Note: If you are prompted for a change request, enter one through the dialogs using a local change request path.

3 Once you have displayed the &KDQJH�2EMHFW�7\SH screen, go to the menu path 8WLOLWLHV��$3,�PHWKRGV��$GG�PHWKRG. This will display a dialog to enter the function module name you created in the previous steps (for example, ZBAPI_GET_CUSTOMER_LIST). Select the green checkmark, and the &UHDWH�$3, PHWKRG���0HWKRG�IHDWXUHV dialog will be displayed.

4 Enter the method name. Use the name *HW&XVWRPHU/LVW[[ ([[ is your group number). In the text boxes, type an appropriate name and description for documentation purposes. In the &KDUDFWHULVWLFV section, make sure 6\QFKURQRXV and ,QVWDQFH�LQGHSHQGHQW are checked.

5 Select the next button, which is the second button of three in the lower left corner of the dialog box. This will take you to the next step in the BOR/BAPI wizard. The next step is the &UHDWH�SDUDPHWHU dialog. In the &UHDWH�SDUDPHWHU step, a list of parameters and default names is displayed. You may need to edit this, as required. Modify the parameter names as follows:

• Each new word in the parameter name must start with a capital letter, for example, ScustList or CustDetail.

• Make sure that the parameter names of the method in the BOR are identical to the parameter names in the function module, except for the upper/lower case letters.

• Specify whether the individual table parameters are used for data import or data export. Table parameters are marked with a check in column 0OLQH (multiple lines).

Page 224: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 5-92

NOTE: You do not need to make any changes in this step for our workshop. Select the next button to bring you to the next step in the BOR/BAPI wizard.

6 The next step is the ([WHQG�3URJUDP step. The dialog warns you that the BAPI is not yet implemented. Select <HV to generate the template that will add the BAPI as a method of the SCUSTOMER object type. This step adds “wrapper object-oriented” code to your function module, converting it to a method of an SAP Business Object.

7 The next step is to generate the BAPI entry. You should now be back on the &KDQJH�2EMHFW�7\SH screen. Select the plus sign next to the 0HWKRGV to expand and display all the methods of SCUSTOMER. Your BAPI should now be listed with a green circle icon (green light). Select your BAPI once and then select the *HQHUDWH icon in the toolbar (fourth icon from the left).

8 Test your BAPI by selecting your BAPI once and then select the test tool in the toolbar (the sixth button from the left) or you can press the F8 key.

Page 225: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 5-93

6HFWLRQ����3URJUDPPLQJ�WKH�*HW'HWDLO�%$3,��%DFNJURXQG�The *HW'HWDLO BAPI requires several fields to hold the return data for the BAPI method call. The BAPI will return the following fields :

Customer ID

Customer Name

Postal Code

City

Customer Type

Discount

This BAPI will be instance-dependent and therefore require that a keyfield be passed to create the object.

What is the key field for the business object )OLJKW&XVWRPHU ?

Page 226: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 5-94

Page 227: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 5-95

6HFWLRQ����%XLOGLQJ�WKH�)XQFWLRQ�0RGXOH�IRU�WKH�������������������*HW'HWDLO�%$3,�

1 Create a function module in your Function Group ZGxx. Name the module ZBAPI_GET_CUSTOMER_DETAILxx ([[ is your group number). The global data for this function module was already created in the function group in the previous steps.

2 Define the interface for your function module.

On the $GPLQ tab :

• Enter the short text (your choice).

• Select 5HPRWH�)XQFWLRQ�&DOO supported in the processing type.

On the ,PSRUW tab:

• Enter ,' as the import parameter and ZBAPICUSTxx-ID as the 5HI�ILHOG���VWUXFWXUH.

On the ([SRUW tab, enter the following:

Export Parameters Ref.field / structure

SCUST_ID SCUSTOM-ID

SCUST_NAME SCUSTOM-NAME

SCUST_POSTCODE SCUSTOM-POSTCODE

SCUST_CITY SCUSTOM-CITY

SCUST_CUSTTYPE SCUSTOM-CUSTTYPE

SCUST_DISCOUNT SCUSTOM-DISCOUNT

RETURN BAPIRETURN

On the &KDQJLQJ��7DEOHV�DQG�([FHSWLRQV tab: no entries.

On the 'RFXPHQWDWLRQ tab: Entries are made for you.

3 The code for your function module is attached to the end of this workshop.

PLEASE NOTE: YOU NEED TO CHANGE ANY REFERENCES TO TABLES AND PROGRAMS BASED UPON THE NAMES YOU HAVE BEEN ASSIGNED. THE SAMPLE CODE USES A STRUCTURE AND FUNCTION NAME DIFFERENT FROM YOURS.

Page 228: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 5-96

4 The form routine your function module needs to handle messages was already created in the function group ZGxx in one of the last sections, so there is no need to create it again.

Page 229: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 5-97

6(&7,21����'HILQLQJ�0HWKRGV�LQ�WKH�%25�XVLQJ�WKH����������������������%25���%$3,�ZL]DUG��1 Go to the %XVLQHVV�2EMHFW�%XLOGHU. You can use the path from the main menu

7RROV�Æ�%XVLQHVV�)UDPHZRUN�Æ%$3,�GHYHORSPHQW�Æ%XVLQHVV�2EMHFW�%XLOGHU. Or you can use transaction SWO1 (alpha O).

2 In the %XVLQHVV�2EMHFW�%XLOGHU initial screen, enter SCUSTOMER as the object type. Then select the &KDQJH�FRPPDQG button. Note: If you are prompted for a change request, enter one through the dialogs using a local change request path.

3 Once you have displayed the &KDQJH�2EMHFW�7\SH screen, go to the menu path 8WLOLWLHV��$3,�PHWKRGV��$GG�PHWKRG. This will display a dialog to enter the function module name you created in the previous steps (for example, ZBAPI_GET_CUSTOMER_DETAILxx). Select the green checkmark, and WKH�&UHDWH�$3,�PHWKRG����0HWKRG�IHDWXUHV dialog will be displayed.

4 Enter the 0HWKRG name. Use the name *HW&XVWRPHU'HWDLO[[ ([[ is your group number). In the text boxes, type an appropriate name and description for documentation purposes. In the &KDUDFWHULVWLFV section, make sure 6\QFKURQRXV is checked. ,QVWDQFH�LQGHSHQGHQW will also be checked, but you will change this in a later step.

5 Select the next button, which is the second button of three in the lower left corner of the dialog box. This will take you to the next step in the BOR/BAPI wizard. The next step is the &UHDWH�SDUDPHWHU dialog. In the &UHDWH�SDUDPHWHU step, a list of parameters and default names is displayed. You may need to edit this, as required. Modify the parameter names as follows:

• Each new word in the parameter name must start with a capital letter, for example, ScustList or CustDetail.

• Make sure that the parameter names of the method in the BOR are identical to the parameter names in the function module, except for the upper/lower case letters.

• Specify whether the individual table parameters are used for data import or data export. Table parameters are marked with a check in the column 0OLQH (multiple lines).

Page 230: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 5-98

NOTE: You do not need to make any changes in this step for our workshop. Select the next button to bring you to the next step in the BOR/BAPI wizard.

6 The next step is the ([WHQG�3URJUDP step. The dialog warns you that the BAPI is not yet implemented. Select <HV to generate the template, which will add the BAPI as a method of the SCUSTOMER object type.

7 The next step is to generate the BAPI entry. You should now be back on the &KDQJH�2EMHFW�7\SH screen. Select the plus sign next to the 0HWKRGV to expand and display all the methods of SCUSTOMER. Your BAPI should now be listed with a green circle icon (green light). Select your BAPI once and then select the *HQHUDWH icon in the toolbar (fourth icon from the left).

8 After generating the BAPI, double click the *HW&XVWRPHU'HWDLO[[ BAPI. This will display the 0HWKRG attributes dialog with 3 tabs. On the *HQHUDO tab, deselect the ,QVWDQFH�LQGHSHQGHQW checkbox. Why do you deselect this checkbox? If you are not sure, have a look at the BAPI Programming Guide. It is very important to BAPI development that you know the difference between instance-dependent and instance-independent BAPIs.

9 Test your BAPI by selecting your BAPI once and then select the test tool in the toolbar (the sixth button from the left), or press the F8 key.

Page 231: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 5-99

$%$3�&RGHV� *OREDO�)XQFWLRQ�*URXS�'DWD�'HFODUDWLRQ�

FUNCTION-POOL ZG00. "MESSAGE-ID ..

TABLES SCUSTOM.

DATA: ITAB LIKE ZBAPICUST00 OCCURS 0 WITH HEADER LINE.

DATA: BEGIN OF MESSAGE,

MSGTY LIKE SY-MSGTY,

MSGID LIKE SY-MSGID,

MSGNO LIKE SY-MSGNO,

MSGV1 LIKE SY-MSGV1,

MSGV2 LIKE SY-MSGV2,

MSGV3 LIKE SY-MSGV3,

MSGV4 LIKE SY-MSGV4,

END OF MESSAGE.

Page 232: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 5-100

%$3,�)XQFWLRQ�0RGXOH�=%$3,B*(7B&86720(5B/,67���

FUNCTION ZBAPI_GET_CUSTOMER_LIST00.

*"-----------------------------------------------------

*"*"Local interface:

*" EXPORTING

*" VALUE(RETURN) LIKE BAPIRETURN STRUCTURE BAPIRETURN

*" TABLES

*" SCUST_LIST STRUCTURE ZBAPICUST00

*"-----------------------------------------------------

CLEAR SCUST_LIST.

REFRESH SCUST_LIST.

CLEAR ITAB.

REFRESH ITAB.

CLEAR RETURN.

CLEAR SCUSTOM.

SELECT * FROM SCUSTOM INTO CORRESPONDING FIELDS OF TABLE ITAB.

IF SY-SUBRC NE 0.

CLEAR MESSAGE.

MESSAGE-MSGTY = ’E’.

MESSAGE-MSGID = ’FN’.

MESSAGE-MSGNO = 022.

PERFORM SET_RETURN_MESSAGE

USING MESSAGE

Page 233: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 5-101

CHANGING RETURN.

ENDIF.

CHECK RETURN IS INITIAL.

SCUST_LIST[] = ITAB[].

ENDFUNCTION.

Page 234: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 5-102

Page 235: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 5-103

%$3,�)XQFWLRQ�0RGXOH�=%$3,B*(7B&86720(5B'(7$,/���

FUNCTION ZBAPI_GET_CUSTOMER_DETAIL00.

*"-----------------------------------------------------

*"*"Local interface:

*" IMPORTING

*" VALUE(ID) LIKE ZBAPICUST-ID

*" EXPORTING

*" VALUE(SCUST_ID) LIKE SCUSTOM-ID

*" VALUE(SCUST_NAME) LIKE SCUSTOM-NAME

*" VALUE(SCUST_POSTCODE) LIKE SCUSTOM-POSTCODE

*" VALUE(SCUST_CITY) LIKE SCUSTOM-CITY

*" VALUE(SCUST_CUSTTYPE) LIKE SCUSTOM-CUSTTYPE

*" VALUE(SCUST_DISCOUNT) LIKE SCUSTOM-DISCOUNT

*" VALUE(RETURN) LIKE BAPIRETURN STRUCTURE BAPIRETURN

*"-----------------------------------------------------

CLEAR: SCUST_ID, SCUST_NAME, SCUST_POSTCODE,

SCUST_CITY, SCUST_CUSTTYPE, SCUST_DISCOUNT.

CLEAR: SCUSTOM, RETURN.

SELECT SINGLE * FROM SCUSTOM WHERE ID = ID.

IF SY-SUBRC NE 0

CLEAR MESSAGE.

MESSAGE-MSGTY = ’E’.

MESSAGE-MSGID = ’FN’.

MESSAGE-MSGNO = 020.

MESSAGE-MSGV1 = ID.

Page 236: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 5-104

PERFORM SET_RETURN_MESSAGE

USING MESSAGE

CHANGING RETURN.

ENDIF.

CHECK RETURN IS INITIAL.

SCUST_ID = SCUSTOM-ID.

SCUST_NAME = SCUSTOM-NAME.

SCUST_POSTCODE = SCUSTOM-POSTCODE.

SCUST_CITY = SCUSTOM-CITY.

SCUST_CUSTTYPE = SCUSTOM-CUSTTYPE.

SCUST_DISCOUNT = SCUSTOM-DISCOUNT.

ENDFUNCTION.

Page 237: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 5-105

)XQFWLRQ�*URXS�)RUP�5RXWLQH�6(7B5(7851B0(66$*(�

*-----------------------------------------------------*

***INCLUDE LZG00F01 .

*-----------------------------------------------------*

*&----------------------------------------------------*

*& Form SET_RETURN_MESSAGE

*&----------------------------------------------------*

* text

*-----------------------------------------------------*

* -->P_MESSAGE text *

* <--P_RETURN text *

*-----------------------------------------------------*

FORM SET_RETURN_MESSAGE

USING P_MESSAGE LIKE MESSAGE

CHANGING P_RETURN LIKE BAPIRETURN.

CHECK NOT MESSAGE IS INITIAL.

CALL FUNCTION ’BALW_BAPIRETURN_GET’

EXPORTING

TYPE = P_MESSAGE-MSGTY

CL = P_MESSAGE-MSGID

NUMBER = P_MESSAGE-MSGNO

PAR1 = P_MESSAGE-MSGV1

PAR2 = P_MESSAGE-MSGV2

Page 238: BC415_EN_Col62_FV_301108[1] - Remote Function Calls in ABAP

© SAP AG BC415 5-106

PAR3 = P_MESSAGE-MSGV3

PAR4 = P_MESSAGE-MSGV4

IMPORTING

BAPIRETURN = P_RETURN

EXCEPTIONS

OTHERS = 1.

ENDFORM. " SET_RETURN_MESSAGE