简体   繁体   English

使用JAVA SAP RFC_READ_TABLE时Table_not_available

[英]Table_not_available when using JAVA SAP RFC_READ_TABLE

There are three different tables (OPTIONS, FIELDS and DATA) in import parameter "QUERY_TABLE" = "LTAP". 导入参数“ QUERY_TABLE” =“ LTAP”中有三个不同的表(OPTIONS,FIELDS和DATA)。 I created a java program to display column FIELDNAME from the table FIELDS with helping function RFC_READ_TABLE. 我创建了一个Java程序来使用帮助功能RFC_READ_TABLE从表FIELDS中显示字段FIELDNAME。

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(). 当我调用方法step2WorkWithTable()时,总是出现错误com.sap.conn.jco.AbapException:(126)TABLE_NOT_AVAILABLE:TABLE_NOT_AVAILABLE消息类为DA类型E的消息300 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"));
   }

}
}

I see you are connecting to an ABAP system using JCoDestinationManager. 我看到您正在使用JCoDestinationManager连接到ABAP系统。 It means your are using the properties from mySAPSystem destination. 这意味着您正在使用mySAPSystem目标中的属性。 Please check if the mySAPSystem connects to a proper ABAP system. 请检查mySAPSystem是否连接到正确的ABAP系统。

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... 似乎他们没有应用到您的连接中...

There is nothing wrong with your JCo code. 您的JCo代码没有错。 The error message comes from the SAP system. 该错误消息来自SAP系统。 So you need to check in the SAP system, what that error code means. 因此,您需要检查SAP系统中该错误代码的含义。 This can be done in transaction SE91. 这可以在事务SE91中完成。 You enter message class = "DA" and message number = "300" and click display. 输入消息类别=“ DA”,消息编号=“ 300”,然后单击显示。

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. 我为您完成了此操作,结果是:“不存在&的活动nametab”,其中“&”需要替换为输入,在这种情况下为“ LTAP”。 So we have "No active nametab exists for LTAP". 因此,我们有“ LTAP不存在活动的名称标签”。

This error basically means: the database table "LTAP" exists on the database, but has not yet been activated in the ABAP DDIC. 此错误的基本含义是:数据库表“ LTAP”存在于数据库中,但尚未在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. 解决方案:转到事务SE11,然后尝试激活该表。 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. 注意:如果LTAP是SAP提供的标准表,则此错误可能意味着从SAP安装包含对该表的修改的传输/热包时出现了问题。 In this case you should better contact SAP support to get the table back into a "consistent" state again. 在这种情况下,您最好联系SAP支持人员以使表再次回到“一致”状态。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM