#for tests only !
#Tue May 15 16:51:44 CET 2019
jco.client.lang=EN
jco.client.client=100
jco.client.passwd= <Put the password of the S4HC API User of the CommScenario here>
jco.client.user=<Put the name of the S4HC API User of the CommScenario here>
jco.client.sysnr=00
jco.client.ashost=<Adress of the SCC, e.g. xxx.mo.sap.corp>
package jne;
import com.sap.conn.jco.AbapException;
// import com.sap.conn.jco.JCoContext;
import com.sap.conn.jco.JCoDestination;
import com.sap.conn.jco.JCoDestinationManager;
import com.sap.conn.jco.JCoException;
// import com.sap.conn.jco.JCoField;
import com.sap.conn.jco.JCoFunction;
// import com.sap.conn.jco.JCoFunctionTemplate;
import com.sap.conn.jco.JCoStructure;
// import com.sap.conn.jco.JCoTable;
// import com.sap.conn.jco.ext.DestinationDataProvider;
/**
* basic examples for Java to ABAP communication
*/
public class RFCBAPI
{
// static String SCC = "SCC_JNE";
static String SCC = "SCC_PRACTICE";
/**
* This example demonstrates the destination concept introduced with JCO 3.
* The application does not deal with single connections anymore. Instead
* it works with logical destinations like ABAP_AS and ABAP_MS which separates
* the application logic from technical configuration.
* @throws JCoException
*/
public static void step1Connect() throws JCoException
{
JCoDestination destination = JCoDestinationManager.getDestination(SCC);
System.out.println("Attributes:");
System.out.println(destination.getAttributes());
System.out.println();
}
public static void step5CallBAPI() throws JCoException
{
System.out.println("Initiating");
JCoDestination destination = JCoDestinationManager.getDestination(SCC);
System.out.println("Calling:");
JCoFunction function = destination.getRepository().getFunction("BAPI_EQUI_GETDETAIL");
if(function == null)
throw new RuntimeException("BAPI_EQUI_GETDETAIL not found in SAP.");
try
{
function.getImportParameterList().setValue("EQUIPMENT", "000000000010000000");
function.execute(destination);
}
catch(AbapException e)
{
System.out.println("ABAP Exception");
System.out.println(e.toString());
}
try
{
System.out.println("BAPI_EQUI_GETDETAIL finished:");
// System.out.println(function.toXML());
printStruct(function,"DATA_GENERAL_EXP");
// printStruct(function,"DATA_SPECIFIC_EXP");
// printStruct(function,"DATA_FLEET_EXP");
// printStruct(function,"RETURN");
}
catch(Exception e)
{
e.printStackTrace();
}
}
public static void step6PrintBAPI() throws JCoException
{
System.out.println("Initiating:");
JCoDestination destination = JCoDestinationManager.getDestination(SCC);
System.out.println("Calling:");
JCoFunction function = destination.getRepository().getFunction("BAPI_EQUI_GETDETAIL");
if(function == null)
throw new RuntimeException("BAPI_EQUI_GETDETAIL not found in SAP.");
try
{
function.getImportParameterList().setValue("EQUIPMENT", "000000000010000000");
// function.getImportParameterList().setValue("REQUEST_INSTALLATION_DATA", "X");
function.execute(destination);
}
catch(AbapException e)
{
System.out.println("ABAP Exception");
System.out.println(e.toString());
}
try
{
System.out.println("BAPI_EQUI_GETDETAIL finished:");
System.out.println(function.toXML());
// System.out.println(function.getFunctionTemplate());
// printStruct(function,"DATA_GENERAL_EXP");
// printStruct(function,"DATA_SPECIFIC_EXP");
// printStruct(function,"DATA_FLEET_EXP");
// printStruct(function,"RETURN");
}
catch(Exception e)
{
e.printStackTrace();
}
}
public static void printStruct(JCoFunction BAPI, String StrucName) {
System.out.println("\n" + "Structure: " + StrucName);
JCoStructure BAPIStruc = BAPI.getExportParameterList().getStructure(StrucName);
for (int i = 0; i < BAPIStruc.getFieldCount(); i++)
{
System.out.println(i + ": " + BAPIStruc.getString(i));;
}
}
public static void main(String[] args) throws JCoException
{
// Set Destination
// step0DestinationFile();
step1Connect();
// step2ConnectUsingPool();
// step3SimpleCall();
// step4WorkWithTable();
// step4SimpleStatefulCalls();
// step5CallBAPI();
step6PrintBAPI();
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
13 | |
11 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 | |
4 |