<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Help on accessing tables available in SAP through Java in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/help-on-accessing-tables-available-in-sap-through-java/m-p/1398693#M192897</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Nothing much you need to do. Just have to call the RFC &amp;lt;b&amp;gt;RFC_READ_TABLE&amp;lt;/b&amp;gt; with the table parameter&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;vijay&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 26 Jun 2006 15:37:34 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2006-06-26T15:37:34Z</dc:date>
    <item>
      <title>Help on accessing tables available in SAP through Java</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/help-on-accessing-tables-available-in-sap-through-java/m-p/1398692#M192896</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to access some tables available in SAP through my Java program.  Do I have to write any code for database connectivity or straightaway I can write SQL statements in my Java code?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can anyone please suggest the sample code for this?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in Advance,&lt;/P&gt;&lt;P&gt;Vijay.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 26 Jun 2006 15:30:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/help-on-accessing-tables-available-in-sap-through-java/m-p/1398692#M192896</guid>
      <dc:creator>former_member55105</dc:creator>
      <dc:date>2006-06-26T15:30:20Z</dc:date>
    </item>
    <item>
      <title>Re: Help on accessing tables available in SAP through Java</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/help-on-accessing-tables-available-in-sap-through-java/m-p/1398693#M192897</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Nothing much you need to do. Just have to call the RFC &amp;lt;b&amp;gt;RFC_READ_TABLE&amp;lt;/b&amp;gt; with the table parameter&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;vijay&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 26 Jun 2006 15:37:34 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/help-on-accessing-tables-available-in-sap-through-java/m-p/1398693#M192897</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-06-26T15:37:34Z</dc:date>
    </item>
    <item>
      <title>Re: Help on accessing tables available in SAP through Java</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/help-on-accessing-tables-available-in-sap-through-java/m-p/1398694#M192898</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;You need JCO(Java Connector)&lt;/P&gt;&lt;P&gt;Check this sample code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;import com.sap.mw.jco.*;

public class JcoTest {
 private static JCO.Client theConnection;
 private static IRepository theRepository;
  
 public static void main(String[] args) {
  createConnection();
  retrieveRepository();  
  try {
  JCO.Function function = getFunction("RFC_READ_TABLE");
  JCO.ParameterList listParams = function.getImportParameterList();
  
  listParams.setValue("BSAUTHORS", "QUERY_TABLE");
  
  theConnection.execute(function);
  
  JCO.Table tableList = function.getTableParameterList().getTable("DATA");
  
  if (tableList.getNumRows() &amp;gt; 0) {
   do {
    for (JCO.FieldIterator fI = tableList.fields();
      fI.hasMoreElements();)
     {
      JCO.Field tabField = fI.nextField();
      System.out.println(tabField.getName()
           + ":t" +
           tabField.getString());
     }
     System.out.println("n");
   }
   while (tableList.nextRow() == true);
  }
  }
  catch (Exception ex) {
   ex.printStackTrace();
  }
  
  
  
 }
 
 private static void createConnection() {
  try {
   theConnection = JCO.createClient("000", "DDIC", "minisap", "en", "sincgo", "00");
   theConnection.connect(); 
  }
  catch (Exception ex) {
   System.out.println("Failed to connect to SAP system");
  }
 }
 private static void retrieveRepository() {
  try {
   theRepository = new JCO.Repository("saprep", theConnection);
  }
  catch (Exception ex)
  {
   System.out.println("failed to retrieve repository");
  }
 }
  public static JCO.Function getFunction(String name) {
    try {
         return theRepository.getFunctionTemplate(name.toUpperCase()).getFunction();
    }
    catch (Exception ex) {
     ex.printStackTrace();
    }
      return null;
    }  
}&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;vijay&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 26 Jun 2006 15:39:56 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/help-on-accessing-tables-available-in-sap-through-java/m-p/1398694#M192898</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-06-26T15:39:56Z</dc:date>
    </item>
  </channel>
</rss>

