on 10-20-2023 9:02 AM
Hi there, I am pulling data from SAP ECC via SAP JCo for the E070 table and storing it in a CSV file, but I am not able to pull the AS4TEXT column.
here is the code:
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import com.sap.conn.jco.JCoDestination;
import com.sap.conn.jco.JCoDestinationManager;
import com.sap.conn.jco.JCoException;
import com.sap.conn.jco.JCoFunction;
import com.sap.conn.jco.JCoParameterList;
import com.sap.conn.jco.JCoTable;
public class SAPDestinationTable {
public static void main(String[] args) {
try { // Establish connection JCoDestination destination = JCoDestinationManager.getDestination("SAP-ECC-NA"); destination.ping();
// Create function module call JCoFunction function = destination.getRepository().getFunction("RFC_READ_TABLE");
// Set up function module parameters JCoParameterList imports = function.getImportParameterList(); imports.setValue("QUERY_TABLE", "E070"); imports.setValue("DELIMITER", ",");
// Execute the function module call function.execute(destination);
System.out.println(function.getTableParameterList().getTable("OPTIONS")); // Get the data table JCoTable dataTable = function.getTableParameterList().getTable("DATA");
// Get the fields table JCoTable fieldsTable = function.getTableParameterList().getTable("FIELDS");
System.out.println(dataTable.getNumRows());
System.out.println(fieldsTable); // Create CSV file writer BufferedWriter writer = new BufferedWriter(new FileWriter("output-testing.csv"));
// Write column headings to CSV System.out.println(fieldsTable); for (int i = 0; i < fieldsTable.getNumRows(); i++) { fieldsTable.setRow(i); String fieldName = fieldsTable.getString("FIELDTEXT"); writer.write(fieldName); if (i < fieldsTable.getNumRows() - 1) { writer.write(","); } } writer.newLine();
// Write data rows to CSV for (int i = 0; i < dataTable.getNumRows(); i++) { dataTable.setRow(i); for (int j = 0; j < dataTable.getNumColumns(); j++) { String fieldValue = dataTable.getString(j); writer.write(fieldValue); if (j < dataTable.getNumColumns() - 1) { writer.write(","); } } writer.newLine(); }
// Close the writer writer.close();
System.out.println("Data written to output-testing.csv successfully.");
} catch (JCoException | IOException e) {
e.printStackTrace();
}
}
}
how can I oull AS4TEXT column as well.
User | Count |
---|---|
76 | |
9 | |
8 | |
7 | |
6 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.