簡體   English   中英

IN或多個運算符SAP Java

[英]IN OR multiple operator SAP Java

我正在使用JCO,SAP util創建一個查詢,例如:

public static void TEST() throws JCoException {
            JCoDestination destination;
            JCoRepository sapRepository;

            destination = JCoDestinationManager.getDestination(ABAP_AS);
            JCoDestinationManager.getDestination(ABAP_AS);
            System.out.println("Attributes:");
            System.out.println(destination.getAttributes());
            System.out.println();

            try {
                JCoContext.begin(destination);
                sapRepository = destination.getRepository();

                if (sapRepository == null) {
                    System.out.println("Couldn't get repository!");
                    System.exit(0);
                } 
                JCoFunctionTemplate functionTemplate = sapRepository.getFunctionTemplate("EM_GET_NUMBER_OF_ENTRIES");
                JCoFunction function =  functionTemplate.getFunction();
                JCoTable itTable = function.getTableParameterList().getTable("IT_TABLES");
                itTable.appendRow();

                itTable.setValue("TABNAME", "USR02");
//              JCoTable returnOptions_ = function.getTableParameterList().getTable("OPTIONS");
//              returnOptions_.appendRow();
////                //returnOptions.setValue("TEXT", "MODDA GE '20140908' AND MODTI GT '000000'");
//              returnOptions_.setValue("TEXT", "BNAME EQ 'USER'");
                function.execute(destination);
                System.out.println( function.getTableParameterList().getTable("IT_TABLES").getInt("TABROWS"));
                JCoFunctionTemplate template2 = sapRepository.getFunctionTemplate("RFC_READ_TABLE");
                System.out.println("Getting template");
                JCoFunction function2 = template2.getFunction();
                function2.getImportParameterList().setValue("QUERY_TABLE", "USR02");
                function2.getImportParameterList().setValue("DELIMITER", ",");
                function2.getImportParameterList().setValue( "ROWCOUNT",5);
                function2.getImportParameterList().setValue( "ROWSKIPS",5);



                System.out.println("Setting OPTIONS");
//              Date date = new Date(1410152400000L);
                SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMddHHmmss");
//              String dateString = formatter.format(date);

//              String dt = dateString.substring(0, 8);
//              String tm = dateString.substring(8);
//              System.out.println("dt > " + dt + ", tm > " + tm);

                JCoTable returnOptions = function2.getTableParameterList().getTable("OPTIONS");
                returnOptions.appendRow();
                //returnOptions.setValue("TEXT", "MODDA GE '20140908' AND MODTI GT '000000'");
                returnOptions.setValue("TEXT", "BNAME LIKE 'S%'");

//              returnOptions.appendRow();
//              returnOptions.setValue("TEXT", "AND TYPE = 'DN'");

                System.out.println("Setting FIELDS");
                JCoTable returnFields = function2.getTableParameterList().getTable("FIELDS");
                returnFields.appendRow();
                returnFields.setValue("FIELDNAME", "BNAME");
                returnFields.appendRow();
                returnFields.setValue("FIELDNAME", "GLTGB");
                returnFields.appendRow();
                returnFields.setValue("FIELDNAME", "CLASS");
//              returnFields.appendRow();
                function2.execute(destination);

//              JCoTable jcoTablef = function2.getTableParameterList().getTable("FIELDS");
                JCoTable jcoTabled = function2.getTableParameterList().getTable("DATA");

                int icodeOffSet = 0;
                int icodeLength = 0;


                int numRows = jcoTabled.getNumRows();
                System.out.println("numRows > " + numRows);
                for(int i=0; i<numRows; i++) {
                    jcoTabled.setRow(i);
                    System.out.println(jcoTabled.getRow());
                    String BNAME = "BNAE:" +  jcoTabled.getString(0);
//                  String GLTGB = "GLTGB:" + jcoTabled.getString(2);
//                  String cls = "GLTGB:" + jcoTabled.getString(3);
                    System.out.println(BNAME + "..." );
                }

            } catch (Exception e) {
                e.printStackTrace();
                System.out.println("ERROR: " + e.getMessage());   
            } finally {
                JCoContext.end(destination);
            }
        }
        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);
            }
        }

當我使用EQ運算符時,前面的代碼運行良好。 但是,當我使用IN運算符時:

BNAME IN ('USER1','USER','USER3')

要么

BNAME EQ 'USER1' OR BNAME EQ 'USER' OR BNAME EQ 'USER3'

它拋出一個異常: Unexpected dynamic condition

條件大小有限制嗎? 由於我在IN條件下有22個字段,每個值的大小為10?

您需要指定有效的OpenSQL條件 ,您需要遵守動態條件規則,並且需要確保將條件正確地拆分為72個字符的行。 我的猜測是,如果你指定22個條件,最后一點可能是一個問題......

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM