javasaprfcjco

Why does SAP JCo raise an error "Field ... not a member of ..." even though the field exists?


I want to send data to SAP RFC table from my Servlet Application.

I am trying to do this below way.

JCO.Function function = null;
Connection conn = new Connection();
JCO.Client mConnection = conn.open();
JCO.Repository mRepository;
mConnection.connect();

mRepository = new JCO.Repository("KEYWORD",mConnection);

try{
    function = this.createFunction("MY RFC NAME");
    if(function != null){
         function.getImportParameterList.setValue("ID1","USERID");
         function.getImportParameterList.setValue("Test Name","UNAME");
         function.getImportParameterList.setValue("CLASSA","UCLASS");

         mConnection.execute(function);
    }
}catch(Exception ex){
    // Exception handling goes here.
}
conn.disconnected();

But I am getting following error

com.sap.mw.jco.JCO$Exception:<127> JCO_ERROR_FIELD_NOT_FOUND: Field USERID not a member of INPUT

But I checked, There is exist column in SAP.

What is missing here? Should I pass RFC table name also? Then How?


Solution

  • I solve this question by following code.

    JCO.Function function = null;
    Connection conn = new Connection();
    JCO.Client mConnection = conn.open();
    JCO.Table GET_DATA = null;
    JCO.Repository mRepository;
    mConnection.connect();
    
    mRepository = new JCO.Repository("KEYWORD",mConnection);
    
    try{
        function = this.createFunction("MY RFC NAME");
        if(function != null){
    
             GET_DATA = function.getTableParameterList.getTable(TABLE_NAME);
             GET_DATA.appendRow();
    
             function.getImportParameterList.setValue("ID1","USERID");
             function.getImportParameterList.setValue("Test Name","UNAME");
             function.getImportParameterList.setValue("CLASSA","UCLASS");
    
             GET_DATA.nextRow();
             mConnection.execute(function);
        }
    }catch(Exception ex){
        // Exception handling goes here.
    }
    conn.disconnected();