cancel
Showing results for 
Search instead for 
Did you mean: 

error executing custom function module

Former Member
0 Kudos

Hi all,

am trying to read a function module form my java code as below.

There is no problem with the function module.

I think there is some problem with the java code that is written. I am sure the problem lies with the TABLES IT_PRODUCT_DATA STRUCTURE ZOG_ITEM_SCREENSTR.

Function module parameters and signature.

FUNCTION ZGET_CUST_ORDERGUIDE_ITEMDATA.

*"----


""Local Interface:

*" IMPORTING

*" VALUE(IV_ORDER_GUID) TYPE CRMT_OBJECT_GUID OPTIONAL

*" VALUE(IV_CUSTOMER) TYPE BU_PARTNER

*" TABLES

*" IT_PRODUCT_DATA STRUCTURE ZOG_ITEM_SCREENSTR

*"----


Java Code that is Implemented is attached above.

public ArrayList fetchOrderGuide(String customerNumber) {

ArrayList itemList = new ArrayList();

ItemSalesDoc itemSalesDoc = new ItemSalesDoc();

if (log.isDebugEnabled()) {

log.debug("inside ZAdminLogin");

}

try

{

JCoConnection aJCoCon = (JCoConnection) getConnectionFactory().getConnection(com.sap.isa.core.eai.init.InitEaiISA.FACTORY_NAME_JCO,

com.sap.isa.core.eai.init.InitEaiISA.CON_NAME_ISA_STATEFUL);

try

{

try

{

JCO.Function zFetchSalesOrderFunctionModule = aJCoCon.getJCoFunction("ZGET_CUST_ORDERGUIDE_ITEMDATA");

// set the import values

Table zItemsTable = new Table("ITEMS");

//zPackagesTable.addColumn(Table.TYPE_STRING,"HUI");

zItemsTable.addColumn(Table.TYPE_STRING,"JOGITEM");

zItemsTable.addColumn(Table.TYPE_INT,"JPRUOM");

zItemsTable.addColumn(Table.TYPE_STRING,"JPRSEQ");

zItemsTable.addColumn(Table.TYPE_STRING,"JOGDESC");

zItemsTable.addColumn(Table.TYPE_STRING,"JLINE");

zItemsTable.addColumn(Table.TYPE_STRING,"JOGNR");

zItemsTable.addColumn(Table.TYPE_STRING,"JPACK");

zItemsTable.addColumn(Table.TYPE_STRING,"JSIZE");

zItemsTable.addColumn(Table.TYPE_STRING,"JBRAND");

zItemsTable.addColumn(Table.TYPE_STRING,"JWEEKAVG");

zItemsTable.addColumn(Table.TYPE_STRING,"JDELFLAG");

JCO.ParameterList importParams = zFetchSalesOrderFunctionModule.getImportParameterList();

importParams.setValue("BP-104", "IV_CUSTOMER");

aJCoCon.execute(zFetchSalesOrderFunctionModule);

JCO.Table zRtItems = zFetchSalesOrderFunctionModule.getTableParameterList().getTable("IT_PRODUCT_DATA");

int numberOfPackages = zRtItems.getNumRows();

if (log.isDebugEnabled()) {

log.debug("number of packages " + numberOfPackages);

}

if (numberOfPackages > 0)

{

for (int j=0; j<numberOfPackages; j++)

{

TableRow itemRow = zItemsTable.insertRow();

//itemRow.setRowKey(new TechKey(zRtItems.getString("EXIDV")));

//packageRow.getField("HUI").setValue(zGoods.getString("EXIDV"));

itemRow.getField("JOGITEM").setValue(zRtItems.getString("OGITEM"));

itemRow.getField("JPRSEQ").setValue(zRtItems.getString("PRSEQ"));

itemRow.getField("JOGDESC").setValue(zRtItems.getString("OGDESC"));

itemRow.getField("JLINE").setValue(zRtItems.getString("LINE"));

itemRow.getField("JOGNR").setValue(zRtItems.getString("OGNR"));

itemRow.getField("JPACK").setValue(zRtItems.getString("PACK"));

itemRow.getField("JSIZE").setValue(zRtItems.getString("SIZE"));

itemRow.getField("JBRAND").setValue(zRtItems.getString("BRAND"));

itemRow.getField("JWEEKAVG").setValue(zRtItems.getString("WEEKAVG"));

itemRow.getField("JDELFLAG").setValue(zRtItems.getString("DELFLAG"));

zRtItems.nextRow();

}

}

}

catch(JCO.AbapException abapException)

{

//Exception thrown, user is not valid

if(log.isDebugEnabled())

{

log.debug( abapException.getKey());

}

}

}

catch (Exception ex)

{

if (log.isDebugEnabled()) {

log.debug(ex);

}

}

finally

{

aJCoCon.close();

}

}

catch(BackendException beeEx)

{

if(log.isDebugEnabled())

{

}

}

return itemList;

}

LOGDETAILS

ZGET_CUST_ORDERGUIDE_ITEMDATA:: - IN: INPUT * IV_CUSTOMER='BP-104' IV_ORDER_GUID='00000000000000000000000000000000'

Oct 9, 2008 6:48:41 AM,507 SAPEngine_Application_Thread[impl:3]_7 Error com.sap.isa.core.eai.sp.jco.JCoConnectionStateful Error occcurred in EAI layer "com.sap.mw.jco.JCO$Exception: (106) JCO_ERROR_RESOURCE: Trying to access row values in a table which does not have any rows yet".

[EXCEPTION]

com.sap.mw.jco.JCO$Exception: (106) JCO_ERROR_RESOURCE: Trying to access row values in a table which does not have any rows yet

at com.sap.mw.jco.JCO$Record.checkRowCapacity(JCO.java:12354)

at com.sap.mw.jco.JCO$Record.getString(JCO.java:12827)

at com.sap.mw.jco.JCO$Field.getString(JCO.java:11055)

at com.sap.isa.core.eai.sp.jco.JCoUtil.paramIterator(JCoUtil.java:412)

at com.sap.isa.core.eai.sp.jco.JCoUtil.logCall(JCoUtil.java:382)

at com.sap.isa.core.eai.sp.jco.JCoUtil.logCall(JCoUtil.java:236)

at

All helpful answers will be rewarded heavily

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

You are trying to insert row after executing the query where you need to do before.

The following code explains how to retrieve data from a Table.

Table resultTable = func.getTableParameterList().getTable("Table_Name");
for (int i = 0; i < resultTable.getNumRows(); i++, resultTable.nextRow()) {
 result = resultTable.getString("Field_Name");
}
(or)
for (int i = 0; i < resultTable.getNumRows(); i++) {
resultTable.setRow(i);
 result = resultTable.getString("Field_Name");
}

Regards,

[Sateesh Chandra|http://sateeshchandrach.googlepages.com/]

Former Member
0 Kudos

hi,

first of all you do not set the import values for your table correct. You should do something similar like this:

-


Function myFunction = connection.getJCoFunction(Z_FM");

Table myTable = myFunction.getTableParameterList().getTable("Z_TABLE");

for(int i=0; i<2; i++) {

myTable.appendRow();

myTable.setValue(value1,"VALUE1");

myTable.setValue(value2,"vALUE2");

}

connection.execute(myFunction);

-


Did you debug your java class? You should check at which point your java class throws the error.

Regards

Michael