cancel
Showing results for 
Search instead for 
Did you mean: 

read table field with getString()

Former Member
0 Kudos

public String[] getExportSParams(JCO.Function function, String structure,

String[]tablefield) {

JCO.ParameterList export = function.getExportParameterList();

JCO.Structure structures = export.getStructure(structure);

String[] exportField = null;

for (int i =0; i<tablefield.length;i++){

exportField<i> = structures.getString(tablefield<i>);

}

return exportField;

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

thank you very much, it helps me a lot.

regard

Former Member
0 Kudos

Hi,

Hope the following resolves your issue



public String[] getExportSParams(JCO.Function function, String structure,
String[]tablefield) {

JCO.ParameterList export = function.getExportParameterList();
JCO.Structure structures = export.getStructure(structure);
//Creating objects here i assume that your tablefield and export field will be of same size
String[] exportField = new String[ tablefield.length ]
for (int i =0; i<tablefield.length;i++){
exportField<i> = structures.getString(tablefield);
} 
return exportField;

Regards

Ayyapparaj

Former Member
0 Kudos

sorry, that was a mistake, I sent my code without my question.I was too fast. My question is: I get a "java.lang.NullPointerException" on the "exportField" of the above code. I don´t know why. Could you help me please?

regards

Former Member
0 Kudos

Bit confusing.

Assuming that what ever you had given in your question is exactly the "copy paste" from your code...

?Both "tableField" and "exportField" are arrays right. Why are you using those variables directly in places where you are supposed to use a "String".

?You are trying to put some string into exportField (which is an array) which is not yet initialized.

Can you try this out -

/* I guess, you are trying to extract the content of the structure into an array of strings and send it back */

public String[] getExportSParams(JCO.Function function, String structure,

String[]tablefield) {

JCO.ParameterList export = function.getExportParameterList();

JCO.Structure structures = export.getStructure(structure);

String[] exportField = null;

if(tablefield!=null && tablefield.length>0)

{

exportField=new String[tablefield.length];

for (int i =0; i<tablefield.length;i++){

exportField<i> = structures.getString(tablefield<i>);

}

}

return exportField;

Former Member
0 Kudos

Hi,

thank you for answer, but I dont understand it. I have tried with the following code. But I have the same errormessage. I need a String[] as return code. How can I solve this?

if(tablefield!=null && tablefield.length>0)
                            {		
		for (int i =0; i<tablefield.length;i++){	
			String tab = tablefield<i>;
			exportField<i> = structures.getString(tab);
			}
		}
		return exportField;

Former Member
0 Kudos

for (int i =0; i<tablefield.length;i++)

{

String tab = tablefield<i>;

if(tab!=null && tab.length>0)

{

try

{

exportField<i> = structures.getString(tab);

}

catch(Exception e)

{

//print error.

}

}

else

{

exportField<i> = //some condition what you want

}

}

return exportField;

I think this code might help you a lot

jayesh talreja