Jco - SAP-Java -outbound-Fall

Rund um Java und SAP®.

Jco - SAP-Java -outbound-Fall

Postby Kuzey5389 » Fri Oct 10, 2003 9:57 am

Hallo Leute !! :D

.. seit kurzem beschäftige ich mich mit Jco. Mein Problem ist der outbound-Fall, d.h. SAP ruft Java-Application auf. Leider in der Dokumentation ist nur eine Richtung beschrieben, nämlich Java ruft BAPIs, und so wie ich das verstanden habe, soll auch andersrum funktionieren !?

Ich würde mich sehr freuen, wenn mir jemand ein paar tips geben würde, ob es grundsätzlich möglich ist und ob es irgendwo eine Dok. gibt.

Danke .. und Alles Gute !! :lol:
Kuzey5389
.
.
 
Posts: 1
Joined: Fri Oct 10, 2003 9:57 am

Postby de Dieter » Fri Oct 10, 2003 3:13 pm

Hi Igel,

du meinst so ungefähr wie wenn du einen C Call auf eine funktion in einer DLL?
Das wäre natürlich denkbar und auch extrems interessant.
Sollte sich aber was finden lassen :wink:

MfG
de Dieter
 

Postby Christian4831 » Mon Oct 13, 2003 10:05 am

Hi Igel,

für dein Problem musst du einen JCO Server implementieren. Hier ein Beispiel für einen JCO Server (aus der JCO Doku):

Code: [Select all] [Expand/Collapse] [Download] (Untitled.txt)
  1. /**
  2.  * Example7.java
  3.  */
  4. import com.sap.mw.jco.*;
  5.  
  6. /**
  7.  * Example of a JCo server with transaction processing
  8.  * This is an example of the simplest implementation
  9.  * of a JCo dual server. It uses dynamic repositories
  10.  * for each of the servers.
  11.  *
  12.  * Property of SAP AG, Walldorf
  13.  * (c) Copyright SAP AG, Walldorf, 2000.
  14.  * All rights reserved.
  15.  *
  16.  * @version  1.1
  17.  * @author   SAP AG, Walldorf (C) 2001
  18.  */
  19.  
  20. //******************************************************************************
  21. public class Example7 implements JCO.ServerExceptionListener, JCO.ServerErrorListener {
  22. //******************************************************************************
  23.  
  24.     /**
  25.      *  This is the actual Server (Listener) object
  26.      */
  27.     static public class Server extends JCO.Server {
  28.  
  29.         /**
  30.          *  Simple constructor. Just call superclass to initialize everything
  31.          *  properly.
  32.          */
  33.         public Server(String gwhost, String gwserv, String program_id, IRepository repos)
  34.         {
  35.             super(gwhost, gwserv, program_id, repos);
  36.         }
  37.  
  38.         /**
  39.          *  This function will be invoked when a transactional RFC is being called from a
  40.          *  SAP R/3 system. The function has to store the TID in permanent storage and return <code>true</code>.
  41.          *  The method has to return <code>false</code> if the a transaction with this ID has already
  42.          *  been process. Throw an exception if anything goes wrong. The transaction processing will be
  43.          *  aborted thereafter.<b>
  44.          *  Derived servers must override this method to actually implement the transaction ID management.
  45.          *  @param tid the transaction ID
  46.          *  @return <code>true</code> if the ID is valid and not in use otherwise, <code>false</code> otherwise
  47.          */
  48.         protected boolean onCheckTID&#40;String tid&#41;
  49.         &#123;
  50.             return true;
  51.         &#125;
  52.  
  53.         /**
  54.          *  This function will be called after the <em>local</em> transaction has been completed.
  55.          *  All resources assiciated with this TID can be released.<b>
  56.          *  Derived servers must override this method to actually implement the transaction ID management.
  57.          *  @param tid the transaction ID
  58.          */
  59.         protected void onConfirmTID&#40;String tid&#41;
  60.         &#123;
  61.         &#125;
  62.  
  63.         /**
  64.          *  This function will be called after <em>all</em> RFC functions belonging to a certain transaction
  65.          *  have been successfully completed. <b>
  66.          *  Derived servers can override this method to locally commit the transaction.
  67.          *  @param tid the transaction ID
  68.          */
  69.         protected void onCommit&#40;String tid&#41;
  70.         &#123;
  71.         &#125;
  72.  
  73.         /**
  74.          *  This function will be called if an error in one of the RFC functions belonging to
  75.          *  a certain transaction has occurred.<b>
  76.          *  Derived servers can override this method to locally rollback the transaction.
  77.          *  @param tid the transaction ID
  78.          */
  79.         protected void onRollback&#40;String tid&#41;
  80.         &#123;
  81.         &#125;
  82.  
  83.         /**
  84.          *  Called upon an incoming requests
  85.          */
  86.         protected void handleRequest&#40;JCO.Function function&#41;
  87.         &#123;
  88.             // Process incoming requests
  89.             if &#40;function.getName&#40;&#41;.equals&#40;"STFC_CONNECTION"&#41;&#41; &#123;
  90.                 // Do your processing here
  91.                
  92.                 // For now we just dump the function to a HTML file
  93.                 // which can be viewed nicely in a browser
  94.                 function.writeHTML&#40;function.getName&#40;&#41; + ".html"&#41;;
  95.             &#125;
  96.  
  97.             // This will cause a short-dump in R/3 that indicates that we cannot
  98.             // handle the request.
  99.             else &#123;
  100.                 // Otherwise
  101.                 throw new JCO.AbapException&#40;"NOT_SUPPORTED","This service is not implemented by the external server"&#41;;
  102.             &#125;
  103.         &#125;
  104.     &#125;
  105.    
  106.     /**
  107.      *  Called if an exception was thrown anywhere in our server
  108.      */
  109.     public void serverExceptionOccurred&#40;JCO.Server srv, Exception ex&#41;
  110.     &#123;
  111.         System.out.println&#40;"Exception in Server " + srv.getProgID&#40;&#41; + ":\n" + ex&#41;;
  112.         ex.printStackTrace&#40;&#41;;
  113.     &#125;
  114.  
  115.     /**
  116.      *  Called if an error was thrown anywhere in our server
  117.      */
  118.     public void serverErrorOccurred&#40;JCO.Server srv, Error err&#41;
  119.     &#123;
  120.         System.out.println&#40;"Error in Server " + srv.getProgID&#40;&#41; + ":\n" + err&#41;;
  121.         err.printStackTrace&#40;&#41;;
  122.     &#125;
  123.  
  124.     // System IDs of the system that we gonna using be for dictionary calls
  125.     String POOL_A = "SYSTEM_A";
  126.     String POOL_B = "SYSTEM_B";
  127.  
  128.     // The server objects that actually handles the request
  129.     int MAX_SERVERS = 2;
  130.     Server servers[] = new Server[MAX_SERVERS];
  131.  
  132.     /**
  133.      *  Constructor. Creates a client pool, the repository and a server.
  134.      */
  135.     public Example7&#40;&#41;
  136.     &#123;
  137.  
  138.         IRepository repository;
  139.  
  140.         // Add a connection pool to a remote R/3 system A.
  141.         // We will use this connected to dynamically
  142.         // request dictionary information for incoming function calls.
  143.         // !!! Please, fill in the necessary login and system parameters !!!
  144.         JCO.addClientPool&#40;POOL_A,3,"000","user","password","EN","system_a","01"&#41;;
  145.  
  146.         // Create repository for System A
  147.         repository = JCO.createRepository&#40;"SYSTEM_A", POOL_A &#41;;
  148.  
  149.         // Create a new server and register it with system A
  150.         servers[0] = new Server&#40;"SystemA", "sapgw01", "SERVER_A", repository&#41;;
  151.  
  152.         // Add a connection pool to a remote R/3 system B.
  153.         // We will use this connected to dynamically
  154.         // request dictionary information for incoming function calls.
  155.         // !!! Please, fill in the necessary login and system parameters !!!
  156.         JCO.addClientPool&#40;POOL_B,3,"000","user","password","EN","system_b","02"&#41;;
  157.  
  158.         // Create repository for system B
  159.         repository = JCO.createRepository&#40;"SYSTEM_B", POOL_B &#41;;
  160.  
  161.         // Create a new server and register it with system B
  162.         servers[1] = new Server&#40;"SystemB", "sapgw02", "SERVER_B", repository&#41;;
  163.  
  164.         // Register ourselves such that we get exceptions from the servers
  165.         JCO.addServerExceptionListener&#40;this&#41;;
  166.  
  167.         // Register ourselves such that we get errors from the servers
  168.         JCO.addServerErrorListener&#40;this&#41;;
  169.     &#125;
  170.  
  171.     /**
  172.      *  Start the server
  173.      */
  174.     public void startServers&#40;&#41;
  175.     &#123;
  176.         try &#123;
  177.             for &#40;int i = 0; i < MAX_SERVERS; i++&#41; servers[i].start&#40;&#41;;
  178.         &#125;
  179.         catch &#40;Exception ex&#41; &#123;
  180.             System.out.println&#40;"Could not start servers !\n" + ex&#41;;
  181.         &#125;//try
  182.     &#125;
  183.  
  184.     /**
  185.      *  Simple main program driver
  186.      */
  187.     public static void main&#40;String[] argv&#41;
  188.     &#123;
  189.         Example7 obj = new Example7&#40;&#41;;
  190.         obj.startServers&#40;&#41;;
  191.     &#125;
  192. &#125;
  193.  
GeSHi ©


Damit du nun vom R/3 aus RFC requests an den Server schicken kannst, musst du in der SM59 noch eine TCP/IP Verbindung zu dem Server eintragen.

viele Grüsse,

Tim
Christian4831
..
..
 
Posts: 91
Joined: Mon Dec 02, 2002 7:33 pm

Verbindung über SM59 eintragen

Postby Rasmus4297 » Tue Apr 13, 2004 11:32 am

... Damit du nun vom R/3 aus RFC requests an den Server schicken kannst, musst du in der SM59 noch eine TCP/IP Verbindung zu dem Server eintragen...

Funktioniert wie ????

Any help appreciated

Seneca
Rasmus4297
..
..
 
Posts: 19
Joined: Thu Aug 14, 2003 2:06 pm

Postby Cara1734 » Thu Sep 09, 2004 8:52 pm

Dieses Posting habe ich entdeckt:

https://www.sdn.sap.com/sdn/collaborati ... start%3D30

Grüsse
Gregor
Cara1734
..
..
 
Posts: 37
Joined: Sun Jul 18, 2004 8:01 pm

Beispiel auf dem SDN-Blog

Postby Cara1734 » Tue Sep 14, 2004 12:02 pm

Gregor Wolf hat auf seinem SDN-Blog ein Beispiel erläuert:

https://www.sdn.sap.com/sdn/weblogs.sdn ... ub/wlg/739
Cara1734
..
..
 
Posts: 37
Joined: Sun Jul 18, 2004 8:01 pm


Return to Java & SAP®

Who is online

Users browsing this forum: No registered users and 5 guests