⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jrfctest.java

📁 SAP这个系统的一个转换器
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
        {
            propValues.setProperty("jco.client.client", propValues.getProperty("jco.client.iclient"));
            propValues.setProperty("jco.client.user", propValues.getProperty("jco.client.iuser"));
            propValues.setProperty("jco.client.passwd", propValues.getProperty("jco.client.ipasswd"));
            propValues.setProperty("jco.client.lang", propValues.getProperty("jco.client.ilang"));
        }
    }

    private static void initCall(String functionName)
    {
        if(numberOfCall == 0)
            correctProperties();
        if(propValues.getProperty("jco.run.close_connect").equalsIgnoreCase("y") || numberOfCall == 0)
        {
            try
            {
                client = JCO.createClient(propValues);
                client.connect();
            }
            catch(Throwable thr)
            {
                RfcTest.out.println("Cannot create client, error message: \n");
                RfcTest.displayException(thr);
                System.exit(1);
                return;
            }
            if(propValues.getProperty("jco.client.type").equals("E"))
                JCO.addClientPool(REPOS_CLIENTS, 10, propReposValues);
            else
                JCO.addClientPool(REPOS_CLIENTS, 10, propValues);
            myRepos = JCO.createRepository("MYRepository", REPOS_CLIENTS);
        }
        try
        {
            IFunctionTemplate ftemplate = myRepos.getFunctionTemplate(functionName);
            if(ftemplate == null)
                throw new RuntimeException("No meta data are available for " + functionName);
            function = new com.sap.mw.jco.JCO.Function(ftemplate);
        }
        catch(Throwable thr)
        {
            RfcTest.out.println("Cannot get function object of " + functionName + ", error message: \n");
            RfcTest.displayException(thr);
            if(client != null)
                client.disconnect();
            System.exit(1);
            return;
        }
    }

    protected static void displayParameters(com.sap.mw.jco.JCO.Record input, int index, boolean displayText)
    {
        switch(input.getType(index))
        {
        case 17: // '\021'
            com.sap.mw.jco.JCO.Structure struct = input.getStructure(index);
            for(int j = 0; j < struct.getFieldCount(); j++)
                displayParameters(((com.sap.mw.jco.JCO.Record) (struct)), j, displayText);

            break;

        case 99: // 'c'
            com.sap.mw.jco.JCO.Table table = input.getTable(index);
            if(table.isEmpty())
                break;
            table.firstRow();
            for(int i = 0; i < table.getNumRows(); table.nextRow())
            {
                if(displayText)
                    RfcTest.out.println("\nLine No.: " + (i + 1));
                for(int j = 0; j < table.getNumColumns(); j++)
                    displayParameters(((com.sap.mw.jco.JCO.Record) (table)), j, displayText);

                i++;
            }

            break;

        case -1: 
            RfcTest.out.println("Parameter " + input.getName(index) + " has invalid type " + input.getType(index));
            break;

        default:
            if(displayText)
                RfcTest.out.println(input.getName(index) + ": " + input.getString(index));
            else
                RfcTest.out.println(input.getString(index));
            break;
        }
    }

    private static void finalizeCall()
    {
        if(propValues.getProperty("jco.run.close_connect").equalsIgnoreCase("y") || numberOfCall + 1 == numberOfCalls)
            try
            {
                client.disconnect();
                JCO.removeClientPool(REPOS_CLIENTS);
            }
            catch(Throwable thr)
            {
                RfcTest.out.println("Cannot disconnect clients, error message: \n");
                RfcTest.displayException(thr);
                System.exit(1);
            }
    }

    private static String checkTable(String iType, com.sap.mw.jco.JCO.Table tab, String type, int len, String checkTab)
    {
        int numberOfRows = tab.getNumRows();
        String returnMess = iType + " table (length " + type + "):";
        if(numberOfRows != len)
            returnMess = returnMess + "  ERROR:  #Lines = " + numberOfRows + "  Expected: " + len;
        else
        if(!checkTab.toUpperCase().equals("Y"))
        {
            returnMess = returnMess + "  #Lines = " + numberOfRows + ": OK,  Contents: NO CHECK";
        } else
        {
            if(!tab.isEmpty())
            {
                String field = "";
                int pos = 0;
                int value = 0;
                for(int i = 0; i < numberOfRows; i++)
                {
                    tab.setRow(i);
                    for(int j = 0; j < tab.getNumColumns(); j++)
                    {
                        field = tab.getString(j);
                        if(j == 0)
                            pos = 40;
                        else
                            pos = 0;
                        for(int k = pos; k < field.length(); k++)
                        {
                            value = k % 10;
                            if(!field.substring(k, k + 1).equals(String.valueOf(value)))
                                return returnMess = returnMess + " ERROR at line " + (i + 1) + " position " + k + ":  " + field.substring(k, k + 1) + "/" + value;
                        }

                        if(field.length() < tab.getField(j).getLength())
                        {
                            int currPos;
                            int expectValue;
                            if(j == 0 && field.length() < 40)
                            {
                                currPos = 40;
                                expectValue = 0;
                            } else
                            {
                                currPos = field.length();
                                expectValue = field.length() % 10;
                            }
                            return returnMess = returnMess + " ERROR at line " + (i + 1) + " position " + currPos + ":   /" + expectValue;
                        }
                    }

                }

            }
            returnMess = returnMess + "  #Lines = " + numberOfRows + ": OK,  Contents: OK";
        }
        return returnMess;
    }

    private static void fillTable(com.sap.mw.jco.JCO.Table tab, int len)
    {
        if(len < 1)
            return;
        tab.deleteAllRows();
        tab.appendRows(len);
        for(int i = 0; i < len; i++)
        {
            tab.setRow(i);
            String field = "Line Length: " + tab.getTabLength() + " Line No.: " + (i + 1);
            for(int j = field.length(); j < 40; j++)
                field = field + " ";

            int pos = 0;
            for(int j = 0; j < tab.getNumColumns(); j++)
            {
                if(j == 0)
                {
                    pos = 40;
                } else
                {
                    pos = 0;
                    field = "";
                }
                for(int k = pos; k < tab.getField(j).getLength(); k++)
                    field = field + String.valueOf(k % 10);

                tab.setValue(field, j);
            }

        }

    }

    private static String RFC_SYSTEM_INFO = "RFC SYSTEM INFO";
    private static String CONNECTION_TEST = "CONNECTION TEST";
    private static String PERFORMANCE_TEST = "PERFORMANCE TEST";
    private static String RFC_WITH_SAPGUI = "RFC with SAPGUI";
    private static String STRUCTURE_TEST = "INHOMOGENEOUS STRUCTURE/TABLE";
    private static String TRANSACTIONAL_RFC = "TRANSACTIONAL RFC";
    private static String CONNECTION_PARAM = "CONNECTION PARAMETERS:";
    private static String RFC_SPECIFIC_PARAM = "RFC-SPECIFIC PARAMETERS:";
    private static String SAP_LOGON_PARAM = "SAP LOGON DATA:";
    private static String PERFORMANCE_PARAM = "PERFORMANCE TEST DATA:";
    private static String SAPGUI_PARAM = "RFC WITH SAPGUI TEST DATA:";
    private static String NUMBER_ANSWER = "number_answer";
    private static String SERVER_TYPE_ANSWER = "server_type_answer";
    private static String YN_ANSWER = "yn_answer";
    private static String FT_ANSWER = "ft_answer";
    private static String space1;
    private static String space2;
    private static String rhomb1 = ">>>>>>>>>>>>>>>>";
    private static String rhomb2 = "<<<<<<<<<<<<<<<<";
    private static String properties_filename = "jrfctest.props";
    private static Properties propLabels;
    private static Properties propValues = new Properties();
    private static Properties propReposValues = new Properties();
    private static int numberOfCalls = 1;
    private static int numberOfCall = 0;
    private static com.sap.mw.jco.JCO.Client client = null;
    private static String REPOS_CLIENTS = "REPOS_CLIENTS";
    private static IFunctionTemplate ftemplate = null;
    private static com.sap.mw.jco.JCO.Function function = null;
    private static IRepository myRepos = null;

    static 
    {
        space1 = "                 ";
        space2 = "               ";
        propLabels = new Properties();
        initProperties();
        propLabels.setProperty("jco.client.type", space1 + "Server is R/2, R/3 or External (2/3/F/E):");
        propLabels.setProperty("jco.client.load_balancing", space1 + "Use load balancing (Y/N)Y...............:");
        propLabels.setProperty("jco.client.iashost", space1 + "Host name of an application server......:");
        propLabels.setProperty("jco.client.isysnr", space1 + "System number...........................:");
        propLabels.setProperty("jco.client.ir3name", space1 + "R/3 system name.........................:");
        propLabels.setProperty("jco.client.imhost", space1 + "Message server..........................:");
        propLabels.setProperty("jco.client.igroup", space1 + "Selected group..........................:");
        propLabels.setProperty("jco.client.isnc_mode", space1 + "Working with SNC (Y/N)N.................:");
        propLabels.setProperty("jco.client.idest", space1 + "DEST in 'sideinfo' for the SAP gateway..:");
        propLabels.setProperty("jco.client.igwhost", space1 + "Host name of the SAP gateway............:");
        propLabels.setProperty("jco.client.igwserv", space1 + "Service of the specified gateway........:");
        propLabels.setProperty("jco.client.registprog", space1 + "Using registering feature (Y/N)Y........:");
        propLabels.setProperty("jco.client.tpid", space1 + "Program ID of registered partner program:");
        propLabels.setProperty("jco.client.itpname", space1 + "Fully qualified name of partner program.:");
        propLabels.setProperty("jco.client.itphost", space1 + "Host name of the partner program........:");
        propLabels.setProperty("jco.client.iprofile_name", space1 + "Profile file name (profil_gen.txt)......:");
        propLabels.setProperty("jco.client.isnc_lib", space1 + "SNC Library Name........................:");
        propLabels.setProperty("jco.client.isnc_partnername", space1 + "SNC name of partner program.............:");
        propLabels.setProperty("jco.client.iclient", space1 + "Client..................................:");
        propLabels.setProperty("jco.client.iuser", space1 + "UserID..................................:");
        propLabels.setProperty("jco.client.ipasswd", space1 + "Password................................:");
        propLabels.setProperty("jco.client.ilang", space1 + "Language (E)............................:");
        propLabels.setProperty("jco.client.iabap_debug", space1 + "Working with ABAP debugger (Y/N)N.......:");
        propLabels.setProperty("jco.client.iuse_sapgui", space1 + "Use SAPGUI (Y/N)N.......................:");
        propLabels.setProperty("jco.client.sapgui_invisible", space1 + "Automatically invisible SAPGUI (Y/N)N...:");
        propLabels.setProperty("jco.client.itrace", space1 + "RFC trace (Y/N)N........................:");
        propLabels.setProperty("jco.client.jco_trace_level", space1 + "JCo trace level (0-10)..................:");
        propLabels.setProperty("jco.gui.test_type", space1 + "Start transaction or function (T/F)F....:");
        propLabels.setProperty("jco.gui.fm_name", space1 + "Name of function module in R/3..........:");
        propLabels.setProperty("jco.gui.transaction_name", space1 + "Name of transaction (SE38)..............:");
        propLabels.setProperty("jco.perform.elength0332", space1 + "#Lines in export table (length 0332)....:");
        propLabels.setProperty("jco.perform.elength1000", space1 + "#Lines in export table (length 1000)....:");
        propLabels.setProperty("jco.perform.ilength0332", space1 + "#Lines in import table (length 0332)....:");
        propLabels.setProperty("jco.perform.ilength1000", space1 + "#Lines in import table (length 1000)....:");
        propLabels.setProperty("jco.perform.checktable", space1 + "Check contents of tables (Y/N)N.........:");
        propLabels.setProperty("jco.perform.display_tab", space1 + "Output tables on screen (Y/N)N..........:");
        propLabels.setProperty("jco.run.number_of_calls", space2 + "#Calls of this JCo Test...................:");
        propLabels.setProperty("jco.run.close_connect", space2 + "Close connection after each call (Y/N)N...:");
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -