cancel
Showing results for 
Search instead for 
Did you mean: 

Reading a Table into the java model

Former Member
0 Kudos

Hello,

ich would like to read out the table returned by the function module into my java class.

How can I get the dataset of the table into a JCO.Structure class?

JCO.Function function = ftemplate.getFunction();

JCO.Table table = function.getTableParameterList().getTable("EXPORT_TABLE");

for (int loopCounter = 0; loopCounter < table.getNumRows(); loopCounter++) {

table.setRow(loopCounter);

==> here I would like to do the following:

JCO.Structure struc = ???.getStructure(???);

}

Regards,

Friederike

Accepted Solutions (1)

Accepted Solutions (1)

former_member182372
Active Contributor
0 Kudos

Hi Friederike,


final int fieldCount = table.getFieldCount();
final String[][] columnValues  = new String[table .getNumRows()][];
	
for (int i = 0; i < table.getNumRows(); i++, table.nextRow() ) {
	columnValues =  new String[fieldCount];
		
	for(int j=0;j<fieldCount;j++) {
		columnValues[j] = table.getString(j);
	}
}

columnValues contains two dimensional array of table values.

Check this http://help.sap.com/saphelp_nw04/helpdata/en/00/21e23d44d48e5be10000000a114084/frameset.htm

Best regards, Maksim Rashchynski.

Former Member
0 Kudos

Hello Maksim,

thank you for your reply.

But is it possible to get the JCO.Structure structure? Is it possible to get exactly this class?

Regards, and greetings from Germany,

Friederike

former_member182372
Active Contributor
0 Kudos

Hi Friederike,

From help:

<i>

...

Within this list, access the actual table (getTable()). The class JCO.Table contains all methods that are available for JCO.Structure, together with additional methods for navigation in a table

..

</i>

Why do you need exactly JCO.Structure? It is confusing for ABAPers, because in ABAP type of record table is structure. In java you are accessing fileds directly.

Best regards, Maksim Rashchynski.

Answers (0)