Sign in or 

SAP Java Connector (SAP JCo) is a middleware component that enables the development of SAP-compatible components and applications in Java. SAP JCo supports communication with the SAP Server in both directions: inbound calls (Java calls ABAP) and outbound calls (ABAP calls Java). SAP JCo can be implemented with Desktop applications and with Web server applications. SAP JCo is used as an integrated component in the following applications:
|
| /* * Created on 2005/01/16 * * TODO To change the template for this generated file go to * Window - Preferences - Java - Code Style - Code Templates */ package cn.iceage; import com.sap.mw.jco.*; import java.io.*; import org.jconfig.*; /** * @author Baoning.Sun * * TODO To change the template for this generated type comment go to Window - * Preferences - Java - Code Style - Code Templates */ public class SavePicture { JCO.Client clnt; JCO.Repository repos; String picpath; String picname; private Configuration cfg; public SavePicture() { cfg = ConfigurationManager.getConfiguration(); String client = cfg.getProperty("client"); String userid = cfg.getProperty("userid"); String password = cfg.getProperty("password"); String language = cfg.getProperty("language"); String hostname = cfg.getProperty("hostname"); String system = cfg.getProperty("system"); picpath = cfg.getProperty("picpath"); picname = cfg.getProperty("picname"); // which loaded from config file try { clnt = JCO.createClient(client, userid, password, language, hostname, system); clnt.connect(); } catch (Exception e) { if (clnt != null) clnt.disconnect(); e.printStackTrace(); System.exit(1); } } public static void main(String[] args) { SavePicture sp = new SavePicture(); sp.exec(); } private void exec(){ try { // Read picture file as stream FileInputStream fis = new FileInputStream(picpath); int filesize = fis.available(); System.out.println(filesize + "bytes has been read."); byte[] buff = new byte[filesize]; fis.read(buff); JCO.MetaData input_md = new JCO.MetaData("INPUT"); input_md.addInfo("I_ID", JCO.MetaData.TYPE_CHAR, 20); input_md.addInfo("I_NAME", JCO.MetaData.TYPE_CHAR, 127); input_md.addInfo("I_COMMENTS", JCO.MetaData.TYPE_CHAR, 200); input_md.addInfo("I_PICTURE", JCO.MetaData.TYPE_XSTRING, filesize); // Create the input parameter list from the metadata object JCO.ParameterList input = JCO.createParameterList(input_md); // Set values to parameters input.setValue(String.valueOf(System.currentTimeMillis()),"I_ID"); input.setValue(picname, "I_NAME"); input.setValue("funny picture","I_COMMENTS"); input.setValue(buff,"I_PICTURE"); // Create metadata definition of the output parameter list JCO.MetaData output_md = new JCO.MetaData("OUTPUT"); output_md.addInfo("E_SIZE", JCO.MetaData.TYPE_CHAR, 128); // Create the output parameter list from the metadata object JCO.ParameterList output = JCO.createParameterList(output_md); // Call the function clnt.execute("ZBAO_PIC_RECV", input, output); // Capture the function's output System.out.println("Process status: " + output.getString("E_SIZE")); } catch (Exception ex) { ex.printStackTrace(); } finally{ if (clnt != null) clnt.disconnect(); } } } |
|
blueoxygen |
Latest page update: made by blueoxygen
, Jun 22 2007, 11:39 PM EDT
(about this update
About This Update
420 words added view changes - complete history) |
|
Keyword tags:
JCo
More Info: links to this page
|