cancel
Showing results for 
Search instead for 
Did you mean: 

Data from E070 table

amankumarchagti
Explorer
0 Kudos

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.

Ulrich_Schmidt
Product and Topic Expert
Product and Topic Expert

a) This code is unreadable. Please use the "CODE" button in the editor UI to format your post in a more readable way.

b) Don't use RFC_READ_TABLE. I have posted the reasons for that many times on this forum. Try to search for them, In a nutshell: RFC_READ_TABLE is not supported, it's a big security risk, and for more complex requirements, it doesn't work anyway.

amankumarchagti
Explorer
0 Kudos

Hi @ulrich.schmidt, the SAP ECC instance is one of our customers' instances. so I can't make any changes, but using RFC_READ_TABLE & above code, how can I pull AS4TEXT?

and I hope code is readable now

amankumarchagti
Explorer
0 Kudos

@ulrich.schmidt Can you lwt me know how to pull only a particular column from E070?

Ulrich_Schmidt
Product and Topic Expert
Product and Topic Expert
0 Kudos

Unfortunately no. My area of expertise is about "RFC protocol" in general, but not about how to use a "particular application level function module" (like what inputs it needs to return the desired output, etc.)

I checked the documentation of RFC_READ_TABLE (can be displayed in the ABAP system in SE37), but it doesn't say much... 😞 So you will have to read its source code, if you want to find out, how it works.

Accepted Solutions (0)

Answers (0)