Вот код:
Код: Выделить всё
import com.sap.conn.jco.*;
import java.util.logging.*;
public class Transport {
private static final Logger logger = Logger.getLogger(Transport.class.getName());
public static void main(String[] args) {
// Configure logger
LogManager.getLogManager().reset();
logger.setLevel(Level.ALL);
ConsoleHandler consoleHandler = new ConsoleHandler();
consoleHandler.setLevel(Level.ALL);
logger.addHandler(consoleHandler);
// Establish connection
JCoDestination destination;
try {
destination = JCoDestinationManager.getDestination("SAP-ECC-Dest");
destination.ping();
} catch (JCoException e) {
logger.log(Level.SEVERE, "Connection error", e);
return;
}
// Create function module call
JCoFunction function;
try {
function = destination.getRepository().getFunction("RFC_READ_TABLE");
} catch (JCoException e) {
logger.log(Level.SEVERE, "Function module error", e);
return;
}
// Set up function module parameters
JCoParameterList imports = function.getImportParameterList();
imports.setValue("QUERY_TABLE", "E070"); // Table name for transport requests
imports.setValue("DELIMITER", "|"); // Set delimiter for the result
JCoParameterList tableOptions = function.getTableParameterList();
JCoTable data = tableOptions.getTable("DATA");
// System.out.println(data);
// Add filters if required
// imports.setValue("OPTIONS", ...);
// Execute the function module call
try {
function.execute(destination);
} catch (JCoException e) {
logger.log(Level.SEVERE, "Function module execution error", e);
return;
}
// Process the results
String[] rows = data.getString().split("\\|");
for (String row : rows) {
String[] columns = row.split("\\|");
if (columns.length >= 3) {
String transportRequestId = columns[0]; // Request ID column
String description = columns[2]; // Description column
logger.info("Transport Request ID: " + transportRequestId);
logger.info("Description: " + description);
logger.info("-----------------------------------");
}
}
}
}
Может быть, кто-нибудь с большим опытом подскажет мне, как мне настроить этот пример кода, чтобы он работал.
Подробнее здесь: https://stackoverflow.com/questions/765 ... le-in-java
Мобильная версия