‎2006 Nov 28 1:23 PM
we are trying to get the data from ekko table by using RFC_READ_TABLE.
But we are unable to get the data, Please send me the sample code and
i am not understand the following lines of code.
importParamList.setValue("/AIN/DM_DEVCTR", "QUERY_TABLE");
importParamList.setValue(";", "DELIMITER");
Regards,
Rajesh
‎2006 Nov 28 1:32 PM
Rajesh,
are you calling it from Java using JCO then...
Check this sample code.you have to call the RFC RFC_READ_TABLE
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() > 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;
}
}Regards
vijay
‎2006 Nov 28 1:33 PM
the above one is with out connection pool, check this with connection pool.
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