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

📄 jrfcserv.java

📁 SAP这个系统的一个转换器
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
// 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

public class JRfcServ extends RfcTest
    implements com.sap.mw.jco.JCO.ServerStateChangedListener, com.sap.mw.jco.JCO.ServerExceptionListener, com.sap.mw.jco.JCO.ServerErrorListener
{
    protected static class 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.getImportParameterList();
                com.sap.mw.jco.JCO.ParameterList exp = function.getExportParameterList();
                com.sap.mw.jco.JCO.ParameterList tab = function.getTableParameterList();
                com.sap.mw.jco.JCO.Attributes a = getAttributes();
                RfcTest.out.println("Start function '" + function.getName() + "'");
                RfcTest.out.println("Attributes:\n" + a.toString());
                if(function.getName().equals("STFC_CONNECTION"))
                {
                    exp.setValue(imp.getString("REQUTEXT"), "ECHOTEXT");
                    exp.setValue("SAP R/3 Rel " + a.getRelease() + "    Sysid: " + a.getSystemID() + "    Date: " + (new Date()).toString() + "    Logon Data: " + a.getClient() + "/" + a.getUser().trim() + "/" + a.getLanguage(), "RESPTEXT");
                } else
                if(function.getName().equals("STFC_PERFORMANCE"))
                {
                    String resultInfo = null;
                    String returnCode = "O";
                    resultInfo = checkTable(tab.getTable("ITAB0332"), "0332", imp.getInt("LGIT0332"), imp.getString("CHECKTAB"));
                    if(!resultInfo.endsWith("K"))
                        returnCode = "E";
                    exp.setValue(resultInfo, "TEXT0332");
                    resultInfo = checkTable(tab.getTable("ITAB1000"), "1000", imp.getInt("LGIT1000"), imp.getString("CHECKTAB"));
                    if(!resultInfo.endsWith("K"))
                        returnCode = "E";
                    exp.setValue(resultInfo, "TEXT1000");
                    exp.setValue(returnCode, "EXITCODE");
                    if(returnCode.equals("O"))
                    {
                        fillTable(tab.getTable("ETAB0332"), imp.getInt("LGET0332"));
                        fillTable(tab.getTable("ETAB1000"), imp.getInt("LGET1000"));
                    }
                } else
                if(function.getName().equals("STFC_STRUCTURE"))
                {
                    com.sap.mw.jco.JCO.Structure is = imp.getStructure("IMPORTSTRUCT");
                    com.sap.mw.jco.JCO.Structure es = exp.getStructure("ECHOSTRUCT");
                    es.setValue(is.getDouble("RFCFLOAT") + 1.0D, "RFCFLOAT");
                    es.setValue('X', "RFCCHAR1");
                    es.setValue(is.getInt("RFCINT2") + 1, "RFCINT2");
                    es.setValue(is.getInt("RFCINT1") + 1, "RFCINT1");
                    es.setValue(a.getSystemID(), "RFCCHAR4");
                    es.setValue(is.getInt("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.getString("RFCDATA1"), "RFCDATA1");
                    es.setValue(is.getString("RFCDATA2"), "RFCDATA2");
                    com.sap.mw.jco.JCO.Table t = tab.getTable("RFCTABLE");
                    t.copyFrom(es);
                    exp.setValue(is, "ECHOSTRUCT");
                    exp.setValue("SAP R/3 Rel " + a.getRelease() + "    Sysid: " + a.getSystemID() + "    Date: " + (new Date()).toString() + "    Logon Data: " + a.getClient() + "/" + a.getUser().trim() + "/" + a.getLanguage(), "RESPTEXT");
                } else
                if(function.getName().equals("STFC_CONNECTION_BACK"))
                {
                    int NRBACK = imp.getInt("NRBACK");
                    com.sap.mw.jco.JCO.Function back_func = getFunction("STFC_CONNECTION");
                    try
                    {
                        for(int i = 0; i < NRBACK; i++)
                        {
                            back_func.getExportParameterList().setValue(imp.getString("REQUTEXT"), "REQUTEXT");
                            ((com.sap.mw.jco.rfc.MiddlewareRFC.Server)getMiddlewareImplementation()).execute(this, back_func);
                            exp.setValue(back_func.getExportParameterList().getValue("RESPTEXT"), "RESPTEXT");
                            exp.setValue(back_func.getExportParameterList().getValue("ECHOTEXT"), "ECHOTEXT");
                            exp.setValue(i, "NOBACK");
                        }

                        exp.setValue("SAP R/3 Rel " + a.getRelease() + " Sysid " + a.getSystemID() + " Logon data " + a.getClient() + " " + a.getUser() + " " + (new Date()).toString(), "RESPTEXT");
                    }
                    catch(Exception ex)
                    {
                        RfcTest.displayException(ex);
                        exp.setValue(ex.getMessage(), "RESPTEXT");
                    }
                } else
                if(function.getName().equals("STFC_STRING"))
                {
                    if(imp.getString("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.getName() + "' not supported.");
                }
            }
            catch(Exception ex)
            {
                RfcTest.out.println("Exception in server " + getProgID() + " [handle: " + getConnectionHandle() + "]");
                RfcTest.displayException(ex);
            }
        }

        private String checkTable(com.sap.mw.jco.JCO.Table tab, String type, int len, String checkTab)
        {
            int numberOfRows = tab.getNumRows();
            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.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 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++)
                {

⌨️ 快捷键说明

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