This is my current JCO example code.
public class Get_Angebot {
static String IP="****",
USER="*****",
PASSWORD="*****",
CLIENT="100",
SYSNR="01",
LANG="en";
public static void main(String[] args) throws JCoException {
try {
String DESTINATION_NAME1 = "mySAPSystem";
Properties connectProperties = new Properties();
connectProperties.setProperty(DestinationDataProvider.JCO_ASHOST, IP);
connectProperties.setProperty(DestinationDataProvider.JCO_SYSNR, SYSNR);
connectProperties.setProperty(DestinationDataProvider.JCO_CLIENT, CLIENT);
connectProperties.setProperty(DestinationDataProvider.JCO_USER, USER);
connectProperties.setProperty(DestinationDataProvider.JCO_PASSWD, PASSWORD);
connectProperties.setProperty(DestinationDataProvider.JCO_LANG, LANG);
createDestinationDataFile(DESTINATION_NAME1,connectProperties);
JCoDestination destination = JCoDestinationManager.getDestination("mySAPSystem");
JCoFunction function = destination.getRepository().getFunction("RFC_GET_TABLE_ENTRIES");
if (function==null)
throw new RuntimeException("Function not found in SAP.");
function.getImportParameterList().setValue( "MAX_ENTRIES", " ");
function.getImportParameterList().setValue( "TABLE_NAME", "****** ");
JCoTable codes=function.getTableParameterList().getTable("ENTRIES");
codes.appendRow();
try
{ function.execute(destination);
}
catch (AbapException e)
{
System.out.println("error moffa" + e);
return;
}
It works fine but it is not very efficient. For one the login data is hardcoded but that can be fixed later.The real problem is that every call takes a lot of time(10-20sec) because it has to connect to the SAP-system first before it can excute a call and it does it for each call again. How can I make it stay connected so that the following calls wont take as long ?
question from:
https://stackoverflow.com/questions/65905464/how-to-make-sap-jco-stay-connected 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…