JCo-Code nach ERPConnect migrieren 
From Theobald Software
Für Kunden oder Interessenten, die bestehende Java-Connector-Code (JCo) nach .NET und damit zu ERPConnect migrieren wollen, haben wir im folgenden ein Beispiel zusammengestellt.
Es werden drei Funktionsbausteine aufgerufen: BAPI_ALM_NOTIF_CREATE, BAPI_ALM_NOTIF_SAVE und BAPI_TRANSACTION_COMMIT, die PM/CD-Meldungen anlegen.
Die folgende Tabelle zeigt die Entsprechung der wichtigsten Klassen.
| JCo | ERPConnect |
|---|---|
| Repository / Client | R3Connection |
| IFunctionTemplate / Request | RFCFunction |
| Structure | RFCStructure |
[Java]
IFunctionTemplate notifCreate= repository.getFunctionTemplate("BAPI_ALM_NOTIF_CREATE"); JCO.Request request = notifCreate.getRequest(); JCO.Structure header = request.getStructure("NOTIFHEADER"); header.setValue("Meine Erste Meldung", "SHORT_TEXT"); request.setValue("M2","NOTIF_TYPE"); JCO.Response response = jcoclient.execute(request); JCO.Structure notif= response.getStructure("NOTIFHEADER_EXPORT"); String notifNumber= notif.getString("NOTIF_NO"); //Meldungsnummer System.out.println("notification:" +notifNumber); IFunctionTemplate save= repository.getFunctionTemplate("BAPI_ALM_NOTIF_SAVE"); JCO.Request request3 = save.getRequest(); request3.setValue(notifNumber, "NUMBER"); JCO.Response response3 = jcoclient.execute(request3); IFunctionTemplate transaction= repository.getFunctionTemplate("BAPI_TRANSACTION_COMMIT"); JCO.Request request2 = transaction.getRequest(); JCO.Response response2= jcoclient.execute(request2); jcoclient.confirmTID(transactionID); jcoclient.disconnect(); JCO.releaseClient(jcoclient); }
[C#]
static void Main(string[] args) { con = new R3Connection(...); con.Open(); RFCFunction notifCreate = con.CreateFunction("BAPI_ALM_NOTIF_CREATE"); RFCStructure header = notifCreate.Exports["NOTIFHEADER"].ToStructure(); header["SHORT_TEXT"] = "Meine Erste Meldung"; notifCreate.Exports["NOTIF_TYPE"].ParamValue = "M2"; notifCreate.Execute(); RFCStructure notif = notifCreate.Imports["NOTIFHEADER_EXPORT"].ToStructure(); string notifNumber = notif["NOTIF_NO"].ToString(); Console.WriteLine("notification:" +notifNumber); RFCFunction save = con.CreateFunction("BAPI_ALM_NOTIF_SAVE"); save.Exports["NUMBER"].ParamValue = notifNumber; save.Execute(); RFCFunction transaction = con.CreateFunction("BAPI_TRANSACTION_COMMIT"); save.Execute(); con.Close(); Console.WriteLine("Please press a Key to continue"); Console.ReadLine(); }


