on 12-12-2006 6:09 AM
Hi all,
I am using SAP Enterprise Connector(using java proxy classes) to connect to R/3 and I am able to get the data from the table, but I am unable to insert data to table.
Does any one know how to do this? If anyone gives the code, that will be so helpful for me
Thanks
Fahad Hamsa
Fahad,
Could you clarify what do you mean: updating tables in database or inserting/deleting/updating parameters of type TABLE?
Valery Silaev
SaM Solutions
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Valery,
Thanks for ur reply and sorry for the late response.
I am trying to update the tables in database using RFC
I used the following code
JCO.Client jcoclient =JCO.createClient(.....);
jcoclient.connect();
Zcreate_Espn_Input input_insert=new Zcreate_Espn_Input();
ZexpenseheaderType h=new ZexpenseheaderType();
h.setAdvanceamount(new BigDecimal("100"));
h.setAdvancelocation("JAVA TEST");
h.setClaimdate(new Date(System.currentTimeMillis()));
h.setExpenseamount(new BigDecimal("10000"));
h.setFromdate(new Date(System.currentTimeMillis()));
h.setPurposeofvisit("TEST PURPOSE BY FAHAD");
h.setRemarks("TEST REMARKS BY FAHAD");
h.setSmuid("0050000017");
h.setTodate(new Date(System.currentTimeMillis()));
h.setUserid("FAHAD");
input_insert.setExpenseheader(h);
System.out.println("A");
Zcreate_Espn_Input input_insert=new Zcreate_Espn_Input();
//ZexpparticularsType part[]=new ZexpparticularsType[4];
try
{
ZexpparticularsType_List exp=new ZexpparticularsType_List();
//exp=input_insert.getExpparticulars();//get_as_listExpparticulars();
if(exp==null)
{
System.out.println("EXP NULL");
}
ZexpparticularsType e=new ZexpparticularsType();
for(int i=0;i<4;i++)
{
e.setAmount(new BigDecimal(""+i));
e.setDateofexpense(new Date(System.currentTimeMillis()));
e.setExpensetypeid("E00"(i1));
e.setEspn("281");
exp.addZexpparticularsType(e);
}
input_insert.setExpparticulars(exp);
}
catch(Exception e)
{
System.out.println("EXCEPTION IN ADDING EXPENSE "+e);
}
InsertTest_PortType output_port=new InsertTest_PortType();
output_port.messageSpecifier.setJcoClient(jcoclient);
output_port.zcreate_Espn(input_insert);
jcoclient.disconnect();
Thanks
Fahad Hamsa
I dont know how to call update from this.
I thought
output_port.zcreate_Espn(input_insert);
will call the RFC.
How can I call RFC from this java project.
My RFC Name is ZCreate_Espn
Input parameters are:
ZExpenseHeader(Structure)
ZExpparticulars(Table) etc
Some more tables are there. Now I am trying with only with this two in which ZExpenseHeader entry is a mandatory one
Thanks
Fahad Hamsa
Hi Satyajith,
jcoClient.execute() is asking parameter of type JCO.Function.
But I am not having any variable like that.
One more thing, When I was executing the following code, it inserted data(without calling jcoClient.execute()) to ZExpenseHeader table.
I used the link http://help.sap.com/saphelp_nw04/helpdata/en/f6/6a9266482d114f9b3e312768578c94/frameset.htm
and took "Connectivity an Interoperability/ SAP Enterprise Connector" in left to get information abt this. But there, only information to get data is mentioned. There also jcoClient.execute() was not there.
JCO.Client jcoclient =JCO.createClient(.....);
jcoclient.connect();
Zcreate_Espn_Input input_insert=new Zcreate_Espn_Input();
ZexpenseheaderType h=new ZexpenseheaderType();
h.setAdvanceamount(new BigDecimal("100"));
h.setAdvancelocation("JAVA TEST");
h.setClaimdate(new Date(System.currentTimeMillis()));
h.setExpenseamount(new BigDecimal("10000"));
h.setFromdate(new Date(System.currentTimeMillis()));
h.setPurposeofvisit("TEST PURPOSE BY FAHAD");
h.setRemarks("TEST REMARKS BY FAHAD");
h.setSmuid("0050000017");
h.setTodate(new Date(System.currentTimeMillis()));
h.setUserid("FAHAD");
input_insert.setExpenseheader(h);
InsertTest_PortType output_port=new InsertTest_PortType();
output_port.messageSpecifier.setJcoClient(jcoclient);
output_port.zcreate_Espn(input_insert);
jcoclient.disconnect();
But when I executed my full code in the post, it is not inserting to any of the table.
Thanks
Fahad Hamsa
Hi Fahad,
I have modified your original code a bit. Try this:
JCO.Client jcoclient =JCO.createClient(.....);
jcoclient.connect();
Zcreate_Espn_Input input_insert=new Zcreate_Espn_Input();
ZexpenseheaderType h=new ZexpenseheaderType();
h.setAdvanceamount(new BigDecimal("100"));
h.setAdvancelocation("JAVA TEST");
h.setClaimdate(new Date(System.currentTimeMillis()));
h.setExpenseamount(new BigDecimal("10000"));
h.setFromdate(new Date(System.currentTimeMillis()));
h.setPurposeofvisit("TEST PURPOSE BY FAHAD");
h.setRemarks("TEST REMARKS BY FAHAD");
h.setSmuid("0050000017");
h.setTodate(new Date(System.currentTimeMillis()));
h.setUserid("FAHAD");
input_insert.setExpenseheader(h);
System.out.println("A");
try
{
ZexpparticularsType_List exp=new ZexpparticularsType_List();
if(exp==null)
{
System.out.println("EXP NULL");
}
ZexpparticularsType e=new ZexpparticularsType();
for(int i=0;i<4;i++)
{
e.setAmount(new BigDecimal(""+i));
e.setDateofexpense(new Date(System.currentTimeMillis()));
e.setExpensetypeid("E00"+(i+1));
e.setEspn("281");
exp.addZexpparticularsType(e);
}
input_insert.setExpparticulars(exp);
}
catch(Exception e)
{
System.out.println("EXCEPTION IN ADDING EXPENSE "+e);
}
InsertTest_PortType output_port=new InsertTest_PortType();
output_port.messageSpecifier.setJcoClient(jcoclient);
output_port.zcreate_Espn(input_insert);
jcoclient.disconnect();
Regards,
Satyajit.
Hi Satyajith,
Now it is working.
Thanks
Fahad Hamsa
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
80 | |
9 | |
9 | |
7 | |
7 | |
6 | |
6 | |
6 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.