Skip to Content
avatar image
Former Member

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    avatar image
    Former Member
    Dec 13, 2006 at 09:35 AM

    Fahad,

    Could you clarify what do you mean: updating tables in database or inserting/deleting/updating parameters of type TABLE?

    Valery Silaev

    SaM Solutions

    http://www.sam-solutions.net

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      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.

  • avatar image
    Former Member
    Dec 14, 2006 at 06:09 AM

    Hi Satyajith,

    Now it is working.

    Thanks

    Fahad Hamsa

    Add comment
    10|10000 characters needed characters exceeded