4

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?

Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
Chirag Savsani
  • 6,020
  • 4
  • 38
  • 74
  • `function.getImportParameterList.setValue` is a strong indicator that what you posted is not the actual code, as is the fact that `MY TABLE FIELD` does not appear anywhere in your code. If you leave out the important bits, it's unlikely you'll get a helpful answer. – vwegert Sep 22 '16 at 13:03
  • Please see updated answer. replaced `My TABLE FIELD` with `USERID`. – Chirag Savsani Sep 22 '16 at 13:04
  • Again - I doubt that this is the actual code, it should be `getImportParameterList().setValue`. What is MY RFC NAME, what is its signature? – vwegert Sep 22 '16 at 13:19
  • My RFC NAME is name of `FUNCTION MODULE`. – Chirag Savsani Sep 22 '16 at 13:22
  • Yes. What is THE ACTUAL NAME of the function module? What is its signature? Please post some more information if you want an actual answer. – vwegert Sep 22 '16 at 13:22

2 Answers2

2

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();
Chirag Savsani
  • 6,020
  • 4
  • 38
  • 74
1

does this function exist on the sap system connected? If so I would suggest to use function = conn.getRepository.getFunction('MY_RFC_NAME') instead. With that method you get the meta data and signature of the function modul as it exist on the connected SAP system. This allows you to check if the function exist if(function == null) throw new Exception("Function Module MY_RFC_NAME does not exist on connected SAP Syste"); and also to check each parameter if he exist and does have the name and type you expect.

In most cases that kind of error occures because a parameter is named slightly different. For example USER_ID instead of USERID.

lichtbringer
  • 120
  • 9