C#通过NCO 调用RFC(写出)

半年前我写的一篇博客:

 一步一步教你用SAP NCO3.0调用RFC(菜鸟必看)
http://blog.csdn.net/szlaptop/article/details/8059480
是介绍了如何把外部的数据通过RFC写入SAP里。
这次是写将SAP的数据通过RFC写到外部系统。
配置NCO,配置app.config请参照原来的博客。

直接上代码:

        public static void getXml(DataTable dt)
        {
            RfcDestination SapRfcDestination = RfcDestinationManager.GetDestination("DEV");
            try
            {
                RfcRepository SapRfcRepository = SapRfcDestination.Repository;
                IRfcFunction myfun = SapRfcRepository.CreateFunction("ZRFC_EXPRESS_DD");
                myfun.Invoke(SapRfcDestination); //执行函数
                IRfcTable table = myfun.GetTable("IP_EXPRE");//获取相应的内表
                dt.Columns.Add("orderID");//表格添加一列
                dt.Columns.Add("logisticsName");
                dt.Columns.Add("logisticsTel");
                dt.Columns.Add("logisticsOrderID");
                for (int i = 0; i < table.RowCount; i++)
                {
                    table.CurrentIndex = i;//当前内表的索引行
                    DataRow dr= dt.NewRow();
                    dr[0] = table.GetString("TID"); //获取表格的某行某列的值
                    dr[1] = table.GetString("COMPANY_NAME");
                    dr[2] = table.GetString("SELLER_PHONE");
                    dr[3] = table.GetString("OUT_SID");
                    dt.Rows.Add(dr);
                }
            }
            catch (System.Exception ex)
            {
                throw ex;
            }
            finally
            {
                RfcSessionManager.EndContext(SapRfcDestination);
                SapRfcDestination = null;
            }
        }
    }

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值