zoukankan      html  css  js  c++  java
  • SAP如何通过RFC连接.NET

     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
    SAPRFCProgram 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.TcodeSM59 創建RFC連接,選擇TCP/IP連接

    3Calling 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

  • 相关阅读:
    php1
    c# out参数
    c#冒泡算法
    c#方法 最大值我最小值
    方法
    OUT参数
    芮年
    PHP博客
    数组习题
    从郑和下西洋 到华人爱燕窝
  • 原文地址:https://www.cnblogs.com/godwar/p/895759.html
Copyright © 2011-2022 走看看