cancel
Showing results for 
Search instead for 
Did you mean: 

RFC_READ_TABLE

Former Member
0 Kudos

Hello All,

I have been searching for some example code for pulling

some fields out of SAP from my Java app using JCo. I

just need to know how to load the imports/then get my

data back out of the exports or tables. I am very new

to SAP, but I am a Java Developer, just the documentation

does not make sense to me. Right now RFC_READ_TABLE

just complains about overflow, and I don't even know how

I overflowed it...... Thanks in advance for any help.

-Greg

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi Greg,

I have some documents on JCO.

Ishall send it to you.

Please let me knwo your email address.

Regards,

Tanveer.

<b>Please mark helpful answers</b>

Former Member
0 Kudos

Thanks for all the help Gentlemen. Tanveer, I appreciate

any and all docs you can provide. gculp@shurtape.com

-Greg

Former Member
0 Kudos

Hey Gents,

Check this out:

http://sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/

library/ep/portal-content/Simplified%20Queries%20of%20SAP%20Tables%20from%20Java

This really helped a lot. Hope it helps someone else too.

-Greg

Former Member
0 Kudos

Greg,

How are things going. I just noticed this thread and wanted to know if things were going ok?

Stephen

Former Member
0 Kudos

Hello Stephen,

Yes, I figured it out with that link I posted. That paper

is very useful. We did have to make our own object in

SAP to handle the overflows, just like the paper said ...

Those guys, know their stuff. Thanks for asking.

-Greg

former_member182372
Active Contributor
0 Kudos
former_member188685
Active Contributor
0 Kudos

Hi,

refer the thread

import com.sap.mw.jco.*;

public class JcoTest {
 private static JCO.Client theConnection;
 private static IRepository theRepository;
    private static final String POOL_NAME = "myPool";
      
 public static void main(String[] args) {
  
    JCO.Pool connPool = JCO.getClientPoolManager().getPool(POOL_NAME);
    if (connPool == null) {
      JCO.addClientPool(POOL_NAME,
                        5,      //number of connections in the pool
                        "client",
                        "username",
                        "paswword",
                        "EN",
                        "hostname",
                        "00");
    }  
    
        theConnection = JCO.getClient(POOL_NAME);
  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() > 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();
  }
  
  JCO.releaseClient(theConnection);
  
 }
 
 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;
    }  
}

Regards

vijay

Former Member
0 Kudos

This message was moderated.