📄 sapinfo.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: SapInfo.java
package com.sap.mw.jco.support;
import com.sap.mw.jco.*;
import com.sap.mw.jco.util.AboutDialog;
import java.io.*;
import java.util.*;
public class SapInfo
{
public static class MyRepository extends com.sap.mw.jco.JCO.BasicRepository
implements IRepository
{
public MyRepository(String name)
{
super(name);
}
}
public SapInfo(String connAttrs[])
{
connAttrList = connAttrs;
loadProperties();
}
protected void displayInfo()
{
if(connAttr.containsKey("-v"))
{
String args[] = new String[1];
args[0] = "-stdout";
(new About()).show(args);
}
if(!connAttr.containsKey("-v") && connAttr.size() < 2)
{
displayHelp();
} else
{
connAttr.remove("-v");
if(connAttr.size() > 1)
getSystemInfo();
}
}
private void getSystemInfo()
{
com.sap.mw.jco.JCO.Client client = null;
com.sap.mw.jco.JCO.Function function = null;
try
{
client = JCO.createClient(connAttr);
}
catch(Throwable thr)
{
out.println("Cannot create client, error message: \n" + thr);
return;
}
turnOnTracingAndDebugging(client);
try
{
client.connect();
}
catch(Throwable thr)
{
out.println("Cannot open connection, error message: \n" + thr);
if(client != null)
client.disconnect();
return;
}
try
{
com.sap.mw.jco.IFunctionTemplate ftemplate = myRepos.getFunctionTemplate("RFC_SYSTEM_INFO");
function = new com.sap.mw.jco.JCO.Function(ftemplate);
client.execute(function);
}
catch(Throwable thr)
{
out.println("Cannot call RFC_SYSTEM_INFO, error message: \n" + thr);
if(client != null)
client.disconnect();
return;
}
displaySystemInfo(function.getExportParameterList().getStructure("RFCSI_EXPORT"));
try
{
client.disconnect();
}
catch(Throwable thr)
{
out.println("Cannot disconnect client, error message: \n" + thr);
return;
}
}
private void turnOnTracingAndDebugging(com.sap.mw.jco.JCO.Client client)
{
int traceLevel = 0;
if(connAttr.containsKey("jco_trace_level"))
try
{
traceLevel = Integer.parseInt(connAttr.getProperty("jco_trace_level"));
}
catch(NumberFormatException ex)
{
out.println("JCo trace level must be a number.");
System.exit(1);
}
JCO.setTraceLevel(traceLevel);
if(connAttr.containsKey("jco_trace_path"))
JCO.setTracePath(connAttr.getProperty("jco_trace_path"));
else
if(traceLevel > 0)
JCO.setTracePath(".");
if(connAttr.containsKey("rfc_trace_level"))
try
{
client.setTrace(Integer.parseInt(connAttr.getProperty("rfc_trace_level")) > 0);
}
catch(NumberFormatException ex)
{
out.println("Rfc trace level must be a number.");
System.exit(1);
}
if(connAttr.containsKey("abap_debug"))
try
{
client.setAbapDebug(Integer.parseInt(connAttr.getProperty("abap_debug")) > 0);
}
catch(NumberFormatException ex)
{
out.println("Abap debug option must be a number.");
System.exit(1);
}
if(connAttr.containsKey("use_sapgui"))
try
{
client.setSapGui(Integer.parseInt(connAttr.getProperty("use_sapgui")));
}
catch(NumberFormatException ex)
{
out.println("Sapgui option must be a number.");
System.exit(1);
}
}
private void displaySystemInfo(com.sap.mw.jco.JCO.Structure sysInfo)
{
String systemInfo = "\nSAP System Information:\n-----------------------------------------------------\n";
systemInfo = systemInfo + "Destination \t" + sysInfo.getField("RFCDEST").getValue() + "\n\n";
systemInfo = systemInfo + "Host \t" + sysInfo.getField("RFCHOST").getValue() + "\n";
systemInfo = systemInfo + "System ID \t" + sysInfo.getField("RFCSYSID").getValue() + "\n";
systemInfo = systemInfo + "Database \t" + sysInfo.getField("RFCDATABS").getValue() + "\n";
systemInfo = systemInfo + "DB Host \t" + sysInfo.getField("RFCDBHOST").getValue() + "\n";
systemInfo = systemInfo + "DB System \t" + sysInfo.getField("RFCDBSYS").getValue() + "\n\n";
systemInfo = systemInfo + "SAP Release \t" + sysInfo.getField("RFCSAPRL").getValue() + "\n";
systemInfo = systemInfo + "SAP Kernel Release\t" + sysInfo.getField("RFCKERNRL").getValue() + "\n\n";
systemInfo = systemInfo + "RFC Protocol \t" + sysInfo.getField("RFCPROTO").getValue() + "\n";
systemInfo = systemInfo + "Characters \t" + sysInfo.getField("RFCCHARTYP").getValue() + "\n";
systemInfo = systemInfo + "Integers \t" + sysInfo.getField("RFCINTTYP").getValue() + "\n";
systemInfo = systemInfo + "Floating P. \t" + sysInfo.getField("RFCFLOTYP").getValue() + "\n";
systemInfo = systemInfo + "SAP Computer Id \t" + sysInfo.getField("RFCMACH").getValue() + "\n\n";
systemInfo = systemInfo + "Timezone \t" + sysInfo.getField("RFCTZONE").getValue() + "\n";
out.println(systemInfo);
}
private static void displayHelp()
{
String help = "Syntax: sapinfo -v displays JCo versions\n or\n sapinfo <options>\n\nOptions must have the following structure:\n ID=value ID=value ... ID=value \nSome of them are directly used as RFC connection parameters.\nValues are case-sensitive but ID's are not. Values which include blanks \nmust be set between quotation marks. Following options are possible:\n\n ID's FOR SAP LOGON:\n client=... user=... passwd=... lang=...\n\n SPECIAL ID's\n jco_trace_level=[0,1,..,10] jco_trace_path=<directory> \n rfc_trace_level=[0,1] abap_debug=[0,1] sap_gui=[0,1,2]\n\n CONNECT TO R/3\n + LOAD BALANCING \n sapinfo r3name=BIN mshost=hs0311 [group=...]\n or\n sapinfo r3name=BIN mshost=/H/sapgate1/S/3297/H/hs0311\n\n + SPECIFIC APPLICATION SERVER\n sapinfo ashost=pcintel sysnr=53\n or\n sapinfo ashost=/H/sapgate1/S/3297/H/pcintel sysnr=53\n\n + CONNECT VIA FASTRFC\n sapinfo type=F profile_name=C:\\\\profile\\\\B6Q_D25_PWDF0633\n\n CONNECT TO R/2\n sapinfo type=2 dest=K50 gwhost=... gwserv=...\n\n CONNECT TO EXTERNAL PROGRAM\n + RFC SERVER IS ALREADY REGISTERED AT SAP GATEWAY\n sapinfo type=E gwhost=... gwserv=... tpname=...\n\n + RFC SERVER WILL BE STARTED BY SAP GATEWAY\n sapinfo type=E gwhost=... gwserv=... tpname=... tphost=...\n";
out.println(help);
}
protected void loadProperties()
{
Properties connAttrTmp = new Properties();
for(int i = 0; i < connAttrList.length; i++)
try
{
connAttrTmp.load(new ByteArrayInputStream(connAttrList[i].getBytes()));
}
catch(IOException ex)
{
out.println("Call has incorrect syntax: " + ex + "\nHave a look at the help:");
displayHelp();
}
connAttr = new Properties();
String key;
for(Enumeration propKeys = connAttrTmp.propertyNames(); propKeys.hasMoreElements(); connAttr.put(key.toLowerCase(), connAttrTmp.getProperty(key)))
key = (String)propKeys.nextElement();
connAttr.setProperty("lcheck", "0");
}
public static void main(String argv[])
{
SapInfo SapInfo = new SapInfo(argv);
SapInfo.displayInfo();
}
String connAttrList[];
Properties connAttr;
static IRepository myRepos;
static String REPOS_NAME = "SYSTEM_INFO_REPOS";
static PrintStream out;
static
{
out = System.out;
myRepos = new MyRepository("REPOS_NAME");
int length_factor = 1;
com.sap.mw.jco.JCO.MetaData mdRFCSI = new com.sap.mw.jco.JCO.MetaData("RFCSI");
mdRFCSI.addInfo("RFCPROTO", 0, 3 * length_factor, 0, 0, null, "RFC log version", 0, null, null);
mdRFCSI.addInfo("RFCCHARTYP", 0, 4 * length_factor, 3, 0, null, "Character set (SAP name)", 0, null, null);
mdRFCSI.addInfo("RFCINTTYP", 0, 3 * length_factor, 7, 0, null, "Integer format (1 / 2 = little / big endian)", 0, null, null);
mdRFCSI.addInfo("RFCFLOTYP", 0, 3 * length_factor, 10, 0, null, "Floating point format (1=IEEE, 2=IBM/370 format)", 0, null, null);
mdRFCSI.addInfo("RFCDEST", 0, 32 * length_factor, 13, 0, null, "Logical destination (specified in function call)", 0, null, null);
mdRFCSI.addInfo("RFCHOST", 0, 8 * length_factor, 45, 0, null, "Character field of length 8", 0, null, null);
mdRFCSI.addInfo("RFCSYSID", 0, 8 * length_factor, 53, 0, null, "R/3 System, name of R/3 System", 0, null, null);
mdRFCSI.addInfo("RFCDATABS", 0, 8 * length_factor, 61, 0, null, "R/3 System, name of R/3 System", 0, null, null);
mdRFCSI.addInfo("RFCDBHOST", 0, 32 * length_factor, 69, 0, null, "Database host name", 0, null, null);
mdRFCSI.addInfo("RFCDBSYS", 0, 10 * length_factor, 101, 0, null, "R/3 System, name of central database system", 0, null, null);
mdRFCSI.addInfo("RFCSAPRL", 0, 4 * length_factor, 111, 0, null, "R/3 System, system release", 0, null, null);
mdRFCSI.addInfo("RFCMACH", 0, 5 * length_factor, 115, 0, null, "RFC: SAP machine ID", 0, null, null);
mdRFCSI.addInfo("RFCOPSYS", 0, 10 * length_factor, 120, 0, null, "R/3 System, operating system of application server", 0, null, null);
mdRFCSI.addInfo("RFCTZONE", 0, 6 * length_factor, 130, 0, null, "Time zone (difference from UTC in seconds)", 0, null, null);
mdRFCSI.addInfo("RFCDAYST", 0, 1 * length_factor, 136, 0, null, "Date and time, Daylight savings time flag", 0, null, null);
mdRFCSI.addInfo("RFCIPADDR", 0, 15 * length_factor, 137, 0, null, "IP address", 0, null, null);
mdRFCSI.addInfo("RFCKERNRL", 0, 4 * length_factor, 152, 0, null, "Kernel Release", 0, null, null);
mdRFCSI.addInfo("RFCHOST2", 0, 32 * length_factor, 156, 0, null, "R/3 System, Name of application server", 0, null, null);
mdRFCSI.addInfo("RFCSI_RESV", 0, 12 * length_factor, 188, 0, null, "Reserve field in RFCSI", 0, null, null);
myRepos.addStructureDefinitionToCache(mdRFCSI);
com.sap.mw.jco.JCO.MetaData mdRFC_SYSTEM_INFO = new com.sap.mw.jco.JCO.MetaData("RFC_SYSTEM_INFO");
mdRFC_SYSTEM_INFO.addInfo("CURRENT_RESOURCES", 8, 4 * length_factor, 0, 0, null, "See structure RFCSI", 2, null, null);
mdRFC_SYSTEM_INFO.addInfo("MAXIMAL_RESOURCES", 8, 4 * length_factor, 4, 0, null, "See structure RFCSI", 2, null, null);
mdRFC_SYSTEM_INFO.addInfo("RECOMMENDED_DELAY", 8, 4 * length_factor, 8, 0, null, "See structure RFCSI", 2, null, null);
mdRFC_SYSTEM_INFO.addInfo("RFCSI_EXPORT", 17, 12 * length_factor, 12, 0, null, "See structure RFCSI", 2, "RFCSI", null);
myRepos.addFunctionInterfaceToCache(mdRFC_SYSTEM_INFO);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -