0

There are three different tables (OPTIONS, FIELDS and DATA) in import parameter "QUERY_TABLE" = "LTAP". I created a java program to display column FIELDNAME from the table FIELDS with helping function RFC_READ_TABLE.

It always appears Error com.sap.conn.jco.AbapException: (126) TABLE_NOT_AVAILABLE: TABLE_NOT_AVAILABLE Message 300 of class DA type E, when I call the method step2WorkWithTable(). Can anybody explain the error? And how to fix it?

My codes:

import java.util.Properties;
import com.sap.conn.jco.AbapException;
import com.sap.conn.jco.JCoDestination;
import com.sap.conn.jco.JCoDestinationManager;
import com.sap.conn.jco.JCoException;
import com.sap.conn.jco.JCoFunction;
import com.sap.conn.jco.ext.DestinationDataProvider;
import com.sap.conn.jco.JCoStructure;
import com.sap.conn.jco.JCoTable;

public class RFC_Read_Table {
public static void main(String[] args) throws JCoException
{

    System.out.println("Step1: connect SAP without Pool");
    step1Connect();       

    System.out.println("");

    System.out.println("Step2: call RFC_Read_Table ");
    step2WorkWithTable();



    System.out.println("--------------------------------");
    System.out.println("finished");

}
static {
    String DESTINATION_NAME1 = "mySAPSystem";

    Properties connectProperties = new Properties();
    connectProperties.setProperty(DestinationDataProvider.JCO_ASHOST, "ABC"); 
    connectProperties.setProperty(DestinationDataProvider.JCO_SYSNR,  "33");
    connectProperties.setProperty(DestinationDataProvider.JCO_SAPROUTER, "/A/123/");               
    connectProperties.setProperty(DestinationDataProvider.JCO_CLIENT, "100"); 
    connectProperties.setProperty(DestinationDataProvider.JCO_USER,   "UserID");  
    connectProperties.setProperty(DestinationDataProvider.JCO_PASSWD, "Passwort"); 
    connectProperties.setProperty(DestinationDataProvider.JCO_LANG,   "de");
    createDestinationDataFile(DESTINATION_NAME1, connectProperties);
}


private static void createDestinationDataFile(String destinationName, Properties connectProperties) {
    File destCfg = new File(destinationName+".jcoDestination");
    try
    {
        FileOutputStream fos = new FileOutputStream(destCfg, false);
        connectProperties.store(fos, "for tests only !");
        fos.close();
    }
    catch (Exception e)
    {
        throw new RuntimeException("Unable to create the destination files", e);
    }

}   

public static void step1Connect() throws JCoException
{
     try {
         JCoDestination destination = JCoDestinationManager.getDestination("mySAPSystem");
         System.out.println("connected");
         destination.ping();
     } catch (JCoException e) {
         e.printStackTrace();
         System.out.println("not connected");
     } 

}




public static void step2WorkWithTable() throws JCoException
{
    JCoDestination destination = JCoDestinationManager.getDestination("mySAPSystem");
    JCoFunction function = destination.getRepository().getFunction("RFC_READ_TABLE");

    if (function == null)
        throw new RuntimeException("RFC_Read_Table not found in SAP.");
    try
    {
        function.execute(destination);
    }
    catch(AbapException e)
    {
        System.out.println(e.toString());
        return;
    }

    function.getImportParameterList().setValue("QUERY_TABLE","LTAP");

    JCoTable codes = function.getTableParameterList().getTable("FIELDS");
    codes.appendRow();

    for (int i = 0; i < codes.getNumRows(); i++) 
    {
        codes.setRow(i);
        System.out.println(codes.getString("FIELDNAME"));
    }
    codes.firstRow();
    for (int i = 0; i < codes.getNumRows(); i++, codes.nextRow()) 
    {
        function = destination.getRepository().getFunction("RFC_READ_TABLE");
        if (function == null) 
            throw new RuntimeException("RFC_READ_TABLE not found in SAP.");
        function.getImportParameterList().setValue("FIELDNAMEID", codes.getString("FIELDNAME"));


        try
        {
            function.execute(destination);
        }
        catch (AbapException e)
        {
            System.out.println(e.toString());
            return;
        }


        JCoStructure detail = function.getExportParameterList().getStructure("FIELDS");

        System.out.println(detail.getString("FIELDNAME"));
   }

}
}
  • Hi and welcome to Stack Overflow, please take a time to go through the [welcome tour](https://stackoverflow.com/tour) to know your way around here (and also to earn your first badge), read how to create a [Minimal, Complete, and Verifiable example](https://stackoverflow.com/help/mcve) and also check [How to Ask Good Questions](https://stackoverflow.com/help/how-to-ask) so you increase your chances to get feedback and useful answers. – DarkCygnus Jun 28 '17 at 15:51
  • In what line are you getting the error, please add that to your question – DarkCygnus Jun 28 '17 at 15:52
  • @GrayCygnus: thanks for your information. When I call method step2(), it appears the error com.sap.conn.jco.AbapException: (126) TABLE_NOT_AVAILABLE: TABLE_NOT_AVAILABLE Message 300 of class DA type E – Elisha Hachiko Jun 29 '17 at 07:01
  • In function " function.getImportParameterList().setValue("QUERY_TABLE","LTAP"); " what are thouse tow parameters ? I recevie the same error and I get get data from my sap system. – Adrian Sep 06 '18 at 07:59

2 Answers2

1

There is nothing wrong with your JCo code. The error message comes from the SAP system. So you need to check in the SAP system, what that error code means. This can be done in transaction SE91. You enter message class = "DA" and message number = "300" and click display.

I did this for you, and the result is: "No active nametab exists for &" where '&' needs to be replaced by the input, which is "LTAP" in this case. So we have "No active nametab exists for LTAP".

This error basically means: the database table "LTAP" exists on the database, but has not yet been activated in the ABAP DDIC. (Perhaps because it still contains a syntax error, or a required data element/domain is missing, etc.)

Solution: go to transaction SE11 and try to activate the table. This will probably give you an error message about what is wrong with this table. Fix all the syntax errors, activate it, and then you can use it.

Note: if LTAP is a standard table delivered by SAP, this error probably means that something went wrong when installing a transport/hotpackage from SAP that contained modifications to this table. In this case you should better contact SAP support to get the table back into a "consistent" state again.

Lanzelot
  • 15,976
  • 4
  • 18
  • 14
0

I see you are connecting to an ABAP system using JCoDestinationManager. It means your are using the properties from mySAPSystem destination. Please check if the mySAPSystem connects to a proper ABAP system.

What are these lines are needed for

Properties connectProperties = new Properties();
connectProperties.setProperty(DestinationDataProvider.JCO_ASHOST, "ABC"); 
connectProperties.setProperty(DestinationDataProvider.JCO_SYSNR,  "33");                       
connectProperties.setProperty(DestinationDataProvider.JCO_CLIENT, "100"); 
connectProperties.setProperty(DestinationDataProvider.JCO_USER,   "UserID");  
connectProperties.setProperty(DestinationDataProvider.JCO_PASSWD, "Passwort"); 
connectProperties.setProperty(DestinationDataProvider.JCO_LANG,   "de"); 

I don't see them to be used anywhere in your program. It seems their are not applied to your connection...

Skalozub
  • 539
  • 7
  • 26
  • Thanks for your answer. Acctually I created a methode createDestinationDataFile() and call createDestinationDataFile(DESTINATION_NAME1, connectProperties) to connect directly SAP Server . Sorry for another dumb question: how I can check if the mySAPSystem connects to a proper ABAP System? – Elisha Hachiko Jun 29 '17 at 13:14
  • Could you please provide your code for createDestinationDataFile? – Skalozub Jun 29 '17 at 13:19
  • Did you try the next example? http://www.erpworkbench.com/java/jco/jco_callfunc.htm – Skalozub Jun 30 '17 at 10:08
  • is this above example for JCO 2.x? I tried following example for JCO 3.x: https://github.com/hisataka/JcoRfcCall. It worked. – Elisha Hachiko Jul 03 '17 at 07:23