//JCoTable主体参数,可为多个主体参数。。。JCoTableheaderImportParam=functiogetTableParameterList().getTable('_TABLE');//返回的值i个字段作为一个表//如果为参数集合,在外层加for循环即可headerImportParaappendRow();//附加表的最后一个新行,行指针,它指向新添加的行。headerImportParasetValue('NAME1','VALUE1');//参数headerImportParasetValue('NAME2','VALUE2');//参数
/*****
publicclassDisplaySalesActivity{staticStringDESTINATION_NAME1='ABAP_AS_WITHOUT_POOL';staticStringDESTINATION_NAME2='ABAP_AS_WITH_POOL';//配置连接static{PropertiesconnectProperties=newProperties();connectProperties.setProperty(DestinationDataProvider.JCO_ASHOST,'120.0.1');//IPconnectProperties.setProperty(DestinationDataProvider.JCO_SYSNR,'00');//系统编号connectProperties.setProperty(DestinationDataProvider.JCO_CLIENT,'001');//客户端编号connectProperties.setProperty(DestinationDataProvider.JCO_USER,'username');//用户名connectProperties.setProperty(DestinationDataProvider.JCO_PASSWD,'password');//密码connectProperties.setProperty(DestinationDataProvider.JCO_LANG,'zh');//语言createDestinationDataFile(DESTINATION_NAME1,connectProperties);connectProperties.setProperty(DestinationDataProvider.JCO_POOL_CAPACITY,'30');//最大空闲连接数connectProperties.setProperty(DestinationDataProvider.JCO_PEAK_LIMIT,'150');//最大活动连接数createDestinationDataFile(DESTINATION_NAME2,connectProperties);}/**创建配置连接文件/staticvoidcreateDestinationDataFile(StringdestinationName,PropertiesconnectProperties){FiledestCfg=newFile(destinationName+'.jcoDestination');try{FileOutputStreamfos=newFileOutputStream(destCfg,fals;connectProperties.store(fos,'Fortestsonly!');fos.close();}catch(Exception{thrownewRuntimeException('Unabletocreatethedestinationfiles',;}}
PropertiesconnectProperties=newProperties();connectProperties.setProperty(DestinationDataProvider.JCO_ASHOST,properFilgetProperty('jco.client.ashost'));connectProperties.setProperty(DestinationDataProvider.JCO_SYSNR,properFilgetProperty('jco.client.sysnr'));connectProperties.setProperty(DestinationDataProvider.JCO_CLIENT,properFilgetProperty('jco.client.client'));connectProperties.setProperty(DestinationDataProvider.JCO_USER,properFilgetProperty('jco.client.user'));connectProperties.setProperty(DestinationDataProvider.JCO_PASSWD,properFilgetProperty('jco.client.passwd'));connectProperties.setProperty(DestinationDataProvider.JCO_POOL_CAPACITY,properFilgetProperty('jco.destinatiopool_capacity'));connectProperties.setProperty(DestinationDataProvider.JCO_PEAK_LIMIT,properFilgetProperty('jco.destinatiopeak_limit'));connectProperties.setProperty(DestinationDataProvider.JCO_LANG,properFilgetProperty('jco.client.lang'));
*函数功能描述:重新获取JCODestination*@return*****/publicstaticJCoDestinationRegetJocodestination(){try{PropertiesproperFile=newProperties();ClassLoadercl=ThreacurrentThread().getContextClassLoader();StringfilePath=cgetResource('').toString()+'SAPConnectionPooproperties';filePath=filePatreplace('file:','');filePath=filePatreplace('%20','');//替换文件名包含空格的FileInputStreaminputFile=newFileInputStream(filePat;properFilload(inputFil;inputFilclose();
//单独的参数,不在表结构下functiogetImportParameterList().setValue('NAME1','VALUE1');//参数
CustomDestinationDataProviderprovider=newCustomDestinationDataProvider();provider.addDestinationProperties(SAP_CONN,connectProperties);Environment.registerDestinationDataProvider(provider);try{JCoDestinationdest=JCoDestinationManager.getDestination(SAP_CON;returndest;}catch(JCoExceptionex){Systeout.println(ex);Systeout.println('重新连接失败');}}catch(Exception{printStackTrace();}returnnull;}
第二种连接配置
publicclassCustomDestinationDataProviderimplementsDestinationDataProvider{privateMapproviders=newHashMap();@OverridepublicPropertiesgetDestinationProperties(StringdestNam{if(destName==nulthrownewNullPointerException('请指定目的名称');if(providers.size()==0)thrownewIllegalStateException('请加入一个目的连接参数属性给提供者');return(Properties)providers.get(destNam;}
publicstaticvoidmain(String[]args)throwsJCoException{getSAPDestination();}配置好后运行main方法,生成2个连接配置文件和2个日志文件,如果在Tomcat中运行,配置好生成地址可以直接在应用中调连接方法。
JCoDestinationdestination=SAPConnectionPoogetSAPDestination();//获取连接//返回一个JCoFunction初始参数的传递函数名。获取东方财富股票交易接口价格,接口方法JCoFunctionfunction=destinatiogetRepository().getFunction('Function_NAME');
/**获取连接/publicstaticJCoDestinationgetSAPDestination()throwsJCoException{JCoDestinationdestination=JCoDestinationManager.getDestination(DESTINATION_NAME;
第一种连接配置
@OverridepublicvoidsetDestinationDataEventListener(DestinationDataEventListenerlistener){thrownewUnsupportedOperationException();}
publicvoidaddDestinationProperties(StringdestName,Propertiesprovider){providers.put(destName,provider);}}东方财富股票交易接口价格,接口调用
以下是我在项目中用到的参数传递的方法调用,应该基本满足部分东方财富股票交易接口价格,接口调用,例:
JCO采用的是中间式东方财富股票交易接口价格,接口,即外部系统将SAP系统所需的信息生成中间数据表,SAP系统直接读取中间文件或将中间表中的信息写入数据库中,中间式东方财富股票交易接口价格,接口是比较常用的一种方式,这种方式外部系统和SAP系统相对独立,东方财富股票交易接口价格,接口不涉及双方内部的结构,而且东方财富股票交易接口价格,接口的责任也很明确,数据的安全性也得到了保证。但这种方式存在的问题就是两个系统的数据同步性稍差一些,但只要合理地规定读写中间文件或数据表的时间,数据的同步性是不会影响使用的。
}
jco.client.lang=zh#语言jco.destinatiopeak_limit=150#最大活动连接数jco.client.client=001#客户端编号jco.client.passwd=password#密码jco.client.user=username#用户名jco.client.sysnr=00#系统编号jco.destinatiopool_capacity=30#最大空闲连接数jco.client.ashost=120.0.1#IP
封装获取链接池链接Java类,以便东方财富股票交易接口价格,接口使用时调用
publicstaticJCoDestinationgetSAPDestination(){try{JCoDestinationdest=JCoDestinationManager.getDestination(SAP_CON;returndest;}catch(JCoExceptionex){//Systeout.println(ex);//Systeout.println('连接失败,重新连接!');//重新连接returnRegetJocodestination();}}
配置访问属性文件SAPConnectionPooproperties
@Service('SAPConnectionPool')publicclassSAPConnectionPool{privatestaticfinalStringSAP_CONN='SAP_CONN';
//没有实现事件处理@OverridepublicbooleansupportsEvents(){returnfalse;}
配置环境:下载sapjcodll插件置放在JDK或Tomcat的bin文件夹下下载sapjcojar置放工程中
文章为作者独立观点,不代表股票交易接口观点