设为首页 收藏本站
查看: 1039|回复: 0

[经验分享] SAP如何通过RFC连接.NET

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2015-9-17 12:31:30 | 显示全部楼层 |阅读模式
http://abap4.itpub.net/


  The following steps need to create server side application.
1. Create a SAP Connector Class - Application ( Under Visual C# Projects ) and give the RFC name and build the application.
2. Inside this application, write your .net code as per your requirement.
3. After completed, this application will create an exe file ( Under the folder binrelease ).
4. You need to pass the command line parameters to execute this exe file. Command line parameters are
-a<registeration Name> -g<SAP Server Name/IP Address> -X<Sap Gateway>
For example:-aREG -gSAPSER1 -xSAPGW00
5. Create a RFC destination in SM59, Under TCP/IP.Technical Settings --> Activation Type --> Registered Server Program ( Need to be selected ).
Program ID must be your registeration name : TDS - SAP的RFC中Program ID 在.NET裡面的名稱是隨便命名的。
Gateway Options are
Gateway Host:SAPSER1(10.1.2.150)-SAP服務器的IP地址
Gateway Service:SAPGW00-SAP網關
  For the parameter Gateway Host, you should enter the hostname of your SAP application server. The value for the parameter Gateway Service is usually SAPGW<XX>, where the XX is the system number of your SAP system.
  6. Write an ABAP program to call the RFC with destination as created in 5th setp.
7. The exe file should run in the same domain/LAN of your SAP server. You can test the connection in SM59.It should be obvoius that the main option is "Registered Server Program" and not "Start...".
And "ProgramID" or "registration name" is an arbitrary string that just need to be equal in SM59 and at the command line of the RFC server.
  1.查看.NET註冊的Program ID是否運行
  It sounds like that another RFC server program with the same Program ID is running there and the SAP gateway is "balancing" the load between your RFC server and that one.
You can use SMGW->GoTo->Logged on Clients to check all registered RFC servers and their programIDs (TP name).
  2.Tcode:SM59 - 創建RFC連接,選擇TCP/IP連接
  3.Calling RFC .NET Server from SAP Programs
To execute our .NET server stub application from the SAP system we need to execute the ABAP command Call function X Destination Y. This report calls our proxy and writes the results to screen. Alternatively, you can use the SAP function module』s single test capability with the TRFC destination for your .NET server stub.

To create a TRFC destination for the SAP .NET server stub create a destination of type T (TRFC) in transaction code SM59. The program ID in your server stub is case sensitive.

Example

*&---------------------------------------------------------------------

*& Report ZRFCSERVERCALL

**&--------------------------------------------------------------------

*& This program can be used with the RFCServerConsole sample

*& Source is available in %RFCServerConsoleABAPProgram

*&---------------------------------------------------------------------

REPORT ZRFCSERVERCALL .

DATA: TBLCUST like BRFCKNA1 occurs 0 with header line.

PARAMETERS: P_CUSTNO like KNA1-KUNNR, P_CUSTNA like KNA1-NAME1,

P_DEST(15) TYPE C.

CALL FUNCTION 'RFC_CUSTOMER_GET' DESTINATION P_DEST

EXPORTING

KUNNR = P_CUSTNO

NAME1 = P_CUSTNA

TABLES

CUSTOMER_T = TBLCUST

EXCEPTIONS

NOTHING_SPECIFIED = 1

NO_RECORD_FOUND = 2

OTHERS = 3.

CASE SY-SUBRC.

WHEN 0.

LOOP AT TBLCUST.

WRITE: / SY-TABIX, TBLCUST-KUNNR, TBLCUST-NAME1, TBLCUST-ORT01.

ENDLOOP.

WHEN 1.

WRITE: / 'You need to specify a value ', SY-MSGV1.

WHEN 2.

WRITE: / '.NET component didnt find anything ', SY-MSGV1.

WHEN 3.

WRITE: / 'Some other error occurred ', SY-MSGV1.

WHEN OTHERS.

WRITE: / 'Something is wrong if we get here'.

ENDCASE.

The entry point in the C# method is the method with the function module name being called from the SAP system (for example, RFC_CUSTOMER_GET). In Microsoft Visual Studio, you can set a breakpoint here and examine the input values from the SAP system. This provides a similar idea to the ABAP_DEBUG functionality that is provided in the client proxy.



    RFCServerConsole - is an SAP RFC Server implemented in C#.
The SAP system calls out to this .net component.
This component implements, RFC_CUSTOMER_GET and will return 2 customers to SAP. Before calling this
component from inside of SAP, you'll need a TCP/IP destination (SM59) - (type registration). Set the
SAP connection in the Visual Studio project properties for RFCServerConsole (e.g. right click on it)
Properties > Configuration Properties > Debugging > Command line arguments.
(example -aSomeProgID -gLOCALHOST -xSAPGW00)
The program id (-a) parameter must match exactly in your component and in the TCP/IP destination (SM59)

All you have to do in sm59 is write RFC destination , Program ID , Description .
The Program ID is important ,because it is just the SomeProgID (example -aSomeProgID -gLOCALHOST -xSAPGW00)run RFCServerConsole.exe -aSomeProgID -gLOCALHOST -xSAPGW00 in commond.exe

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-114950-1-1.html 上篇帖子: SAP的BI产品线 下篇帖子: SAP Netweaver Gateway Add-on for Backend System Installation
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表