Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Inserting to Ztable using SAP Enterprise connector

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

Former Member
Former Member replied

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.

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question