• 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>
  • 相关阅读:
    java23种设计模式-结构型模式-适配器模式
    java23种设计模式-创建者模式-抽象工厂模式
    java23种设计模式-创建者模式-工厂模式
    从jvm运行数据区分析字符串是否相同
    Linux常见安全策略
    MySQL 报错案例分析
    Linux系统网络监控工具
    海量运维架构
    Linux运维面试技巧
    DBA机遇于风险并存
  • 原文地址:https://www.cnblogs.com/KSalomo/p/6475497.html
Copyright © 2020-2023  润新知