zoukankan      html  css  js  c++  java
  • C# 使用sapnco连接SAP

                            RfcDestination SapRfcDestination = RfcDestinationManager.GetDestination("QAS");
    
                            RfcRepository SapRfcRepository = SapRfcDestination.Repository;
    
                            //// Create and invhuoke function moduleZCHANNEL_RFC_MESSAGE  
                            IRfcFunction myfun = SapRfcRepository.CreateFunction("ZOA_CREATE_PO");
    
                            // Set some input values for the structure.  
                            IRfcStructure import = null;
    
                            //myfun.SetValue("BSART", "NB");
                            myfun.SetValue("BSART", bb.BSART);
                            myfun.SetValue("WERKS_D", bb.WERKS_D);
                            myfun.SetValue("EKORG", bb.EKORG);
                            myfun.SetValue("BUKRS", bb.BUKRS);
                            myfun.SetValue("DZTERM", bb.DZTERM);
                            myfun.SetValue("EVERK", bb.EVERK);
                            myfun.SetValue("LIFNR", bb.LIFNR);
                            myfun.SetValue("KDATE", bb.KDATE);
                            myfun.SetValue("TAX_CODE", bb.TAX_CODE);
                            myfun.SetValue("LGORT", bb.LGORT);
                            myfun.SetValue("TELEPHONE", bb.TELEPHONE);
    
                            IRfcTable table = myfun.GetTable("ITEM");
    
                            for (int k = 0; k < bb.Table.Count; k++)
                            {
                                import = SapRfcRepository.GetStructureMetadata("ZOA_CREATE_PO").CreateStructure();
                                import.SetValue("MATNR", bb.Table[k].MATNR);
                                import.SetValue("BSTMG", bb.Table[k].BSTMG);
                                import.SetValue("NET_PRICE", Convert.ToDecimal(bb.Table[k].NET_PRICE));
                                table.Insert(import);
                            }
                            myfun.Invoke(SapRfcDestination); //执行函数
                            string RETURNStr = myfun.GetString("ZTYP");
                            string msg = myfun.GetString("MESSAGE");
                            res = RETURNStr + ";" + msg;


    App.config
    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
        <configSections>
          <sectionGroup  name="SAP.Middleware.Connector">
            <sectionGroup  name="ClientSettings">
              <section  name="DestinationConfiguration" type="SAP.Middleware.Connector.RfcDestinationConfiguration,sapnco"/>
            </sectionGroup>
          </sectionGroup>
        </configSections>
        <SAP.Middleware.Connector>
          <ClientSettings>
            <DestinationConfiguration>
              <destinations>
                <add NAME="QAS" USER="PIUSER" PASSWD="" CLIENT="700"
                     LANG="ZH" ASHOST="192.168.244.21" SYSNR="00"
                     MAX_POOL_SIZE="10" IDLE_TIMEOUT="10"/>
              </destinations>
            </DestinationConfiguration>
          </ClientSettings>
        </SAP.Middleware.Connector>
        <connectionStrings>
          <add name="officialConnection" connectionString="Server=192.168.100.1DBSH;Database=BPMDB;User Id=sa;Password=;Max Pool Size=1024;min pool size=0;Trusted_Connection=False"/>
          <add name="testConnection" connectionString="Server=192.168.100.183DBSH;Database=BPMDB;User Id=sa;Password=;Max Pool Size=1024;min pool size=0;Trusted_Connection=False"/>
        </connectionStrings>
        <startup> 
            <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
        </startup>
    </configuration>
  • 相关阅读:
    windows下 文件资源管理器 的操作
    Visual Studio Code 折叠代码快捷键
    windows 10 取消alt+tab的预览功能
    String.prototype.replace
    Webpack的tapable 为什么要使用 new Funtion 来生成静态代码
    Visual Studio Code 断点调试Nodejs程序跳过node内部模块(internal modules)
    【社群话题分享】有哪些奇葩的技术人员考核方式?
    工信部要求应用商店上新 App 检查 IPv6,这里有一份 IPv6 快速部署指南
    读完这篇文章,5G 就没有秘密了
    双剑合璧——掌握 cURL 和 Dig 走天涯
  • 原文地址:https://www.cnblogs.com/KSalomo/p/6475497.html
Copyright © 2011-2022 走看看