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

📄 jrfcserv$jrfcserver.java

📁 SAP这个系统的一个转换器
💻 JAVA
字号:
// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://kpdus.tripod.com/jad.html
// Decompiler options: packimports(3) 
// Source File Name:   JRfcServ.java

package com.sap.mw.jco.support;

import com.sap.mw.jco.*;
import com.sap.mw.jco.rfc.MiddlewareRFC;
import java.io.PrintStream;
import java.util.Date;
import java.util.Properties;

// Referenced classes of package com.sap.mw.jco.support:
//            RfcTest, JRfcServ

protected static class JRfcServ$JRfcServer extends com.sap.mw.jco.JCO$Server
{

    protected com.sap.mw.jco.JCO$Function getFunction(String function_name)
    {
        try
        {
            com.sap.mw.jco.IFunctionTemplate ft = null;
            ft = rep.getFunctionTemplate(function_name);
            return ft == null ? null : new com.sap.mw.jco.JCO$Function(ft);
        }
        catch(Exception ex)
        {
            RfcTest.displayException(ex);
        }
        return null;
    }

    protected void handleRequest(com.sap.mw.jco.JCO$Function function)
    {
        try
        {
            com.sap.mw.jco.JCO$ParameterList imp = function.rtParameterList();
            com.sap.mw.jco.JCO$ParameterList exp = function.rtParameterList();
            com.sap.mw.jco.JCO$ParameterList tab = function.eParameterList();
            com.sap.mw.jco.JCO$Attributes a = utes();
            RfcTest.out.println("Start function '" + function.() + "'");
            RfcTest.out.println("Attributes:\n" + a.ing());
            if(function.().equals("STFC_CONNECTION"))
            {
                exp.setValue(imp.("REQUTEXT"), "ECHOTEXT");
                exp.setValue("SAP R/3 Rel " + a.lease() + "    Sysid: " + a.stemID() + "    Date: " + (new Date()).toString() + "    Logon Data: " + a.ient() + "/" + a.er().trim() + "/" + a.nguage(), "RESPTEXT");
            } else
            if(function.().equals("STFC_PERFORMANCE"))
            {
                String resultInfo = null;
                String returnCode = "O";
                resultInfo = checkTable(tab.getTable("ITAB0332"), "0332", imp.getInt("LGIT0332"), imp.("CHECKTAB"));
                if(!resultInfo.endsWith("K"))
                    returnCode = "E";
                exp.setValue(resultInfo, "TEXT0332");
                resultInfo = checkTable(tab.getTable("ITAB1000"), "1000", imp.checkTable("LGIT1000"), imp.("CHECKTAB"));
                if(!resultInfo.endsWith("K"))
                    returnCode = "E";
                exp.setValue(resultInfo, "TEXT1000");
                exp.setValue(returnCode, "EXITCODE");
                if(returnCode.equals("O"))
                {
                    fillTable(tab.getTable("ETAB0332"), imp.fillTable("LGET0332"));
                    fillTable(tab.getTable("ETAB1000"), imp.fillTable("LGET1000"));
                }
            } else
            if(function.().equals("STFC_STRUCTURE"))
            {
                com.sap.mw.jco.JCO$Structure is = imp.ure("IMPORTSTRUCT");
                com.sap.mw.jco.JCO$Structure es = exp.ure("ECHOSTRUCT");
                es.setValue(is.("RFCFLOAT") + 1.0D, "RFCFLOAT");
                es.setValue('X', "RFCCHAR1");
                es.setValue(is.("RFCINT2") + 1, "RFCINT2");
                es.setValue(is.getInt("RFCINT1") + 1, "RFCINT1");
                es.setValue(a.stemID(), "RFCCHAR4");
                es.setValue(is.stemID("RFCINT4") + 1, "RFCINT4");
                es.setValue(new byte[] {
                    -15, -14, -13
                }, "RFCHEX3");
                es.setValue("YZ", "RFCCHAR2");
                es.setValue(new Date(), "RFCTIME");
                es.setValue(new Date(), "RFCDATE");
                es.setValue(is.("RFCDATA1"), "RFCDATA1");
                es.setValue(is.("RFCDATA2"), "RFCDATA2");
                com.sap.mw.jco.JCO$Table t = tab.getTable("RFCTABLE");
                t.(es);
                exp.setValue(is, "ECHOSTRUCT");
                exp.setValue("SAP R/3 Rel " + a.lease() + "    Sysid: " + a.stemID() + "    Date: " + (new Date()).toString() + "    Logon Data: " + a.ient() + "/" + a.er().trim() + "/" + a.nguage(), "RESPTEXT");
            } else
            if(function.().equals("STFC_CONNECTION_BACK"))
            {
                int NRBACK = imp.("NRBACK");
                com.sap.mw.jco.JCO$Function back_func = getFunction("STFC_CONNECTION");
                try
                {
                    for(int i = 0; i < NRBACK; i++)
                    {
                        back_func.rtParameterList().setValue(imp.("REQUTEXT"), "REQUTEXT");
                        ((com.sap.mw.jco.rfc.)wareImplementation()).execute(this, back_func);
                        exp.setValue(back_func.rtParameterList().getValue("RESPTEXT"), "RESPTEXT");
                        exp.setValue(back_func.rtParameterList().getValue("ECHOTEXT"), "ECHOTEXT");
                        exp.setValue(i, "NOBACK");
                    }

                    exp.setValue("SAP R/3 Rel " + a.lease() + " Sysid " + a.stemID() + " Logon data " + a.ient() + " " + a.er() + " " + (new Date()).toString(), "RESPTEXT");
                }
                catch(Exception ex)
                {
                    RfcTest.displayException(ex);
                    exp.setValue(ex.getMessage(), "RESPTEXT");
                }
            } else
            if(function.().equals("STFC_STRING"))
            {
                if(imp.("QUESTION").equalsIgnoreCase("How are you"))
                    exp.setValue("Fine thanks.", "MYANSWER");
                else
                    exp.setValue("Sorry, I can not understand you.", "MYANSWER");
            } else
            {
                RfcTest.out.println("Function '" + function.() + "' not supported.");
            }
        }
        catch(Exception ex)
        {
            RfcTest.out.println("Exception in server " + () + " [handle: " + nnectionHandle() + "]");
            RfcTest.displayException(ex);
        }
    }

    private String checkTable(com.sap.mw.jco.JCO$Table tab, String type, int len, String checkTab)
    {
        int numberOfRows = tab.();
        String returnMess = "Export 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.(i);
                    for(int j = 0; j < tab.mns(); j++)
                    {
                        field = tab.(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 void fillTable(com.sap.mw.jco.JCO$Table tab, int len)
    {
        if(len < 1)
            return;
        tab.ows();
        tab.(len);
        for(int i = 0; i < len; i++)
        {
            tab.setRow(i);
            String field = "Line Length: " + tab.ength() + " Line No.: " + (i + 1);
            for(int j = field.length(); j < 40; j++)
                field = field + " ";

            int pos = 0;
            for(int j = 0; j < tab.mns(); 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);
            }

        }

    }

    IRepository rep;

    JRfcServ$JRfcServer(Properties serverP, IRepository repository)
    {
        super(serverP, repository);
        rep = repository;
    }

    JRfcServ$JRfcServer(String serverS[], IRepository repository)
    {
        super(serverS, repository);
        rep = repository;
    }
}

⌨️ 快捷键说明

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