1.销售系统销售出库,更新U811.1材料库存的EAI的XML生成.
2.主要根据U8配置会生成出库单和同时是否更新库存量,还是更新现存量等等。
3.具体参考代码如下:
作者:王春天 2013-11-06
地址:http://www.cnblogs.com/spring_wang/p/3409925.html
代码中调用的通用方法在:http://www.cnblogs.com/spring_wang/p/3406230.html
//==================================================================== // 函数: gf_voucher_xml.gf_storeout_xml( ) //-------------------------------------------------------------------- // 描述:生成材料出库XML文件 //-------------------------------------------------------------------- // 参数: // value datawindow adw_head 主表数据所在数据窗口 // value datawindow adw_detail 细表数据所在数据窗口 // value datawindow adw_batch 条码表数据所在数据窗口 // value string as_proc 操作类型:Add(新增),Edit(修改),Delete(删除),Query(查询) // value string as_exportneedexch 导出时是否要根据对照表替换 Y/N // value string as_codeexchanged 编码是否已转换 Y/N // value string as_renewproofno 是否重新编码Y/N //-------------------------------------------------------------------- // 返回: integer //-------------------------------------------------------------------- // 日期: 2013年10月10日 Thursday 09:45:31 //-------------------------------------------------------------------- // 修改历史: // //==================================================================== string ls_sender,ls_xml string ls_data,ls_detail_pkid long ll_i,ll_find decimal ldc_price,ldc_num string ls_financial_sort datawindow ldw_temp string ls_key ls_sender = '002'//需要在数据库中配置 //固定表头 ls_xml = "" + "~r~n" //数据的表头格式 ls_xml = ls_xml + "" + "~r~n" //增加文件中数据项信息 header ls_xml = ls_xml + " " + "~r~n" ls_xml = ls_xml + " " + "~r~n" ls_data = "0" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //收发标志 入库单-收 1,出库单-发 0 ls_data = "32" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //单据类型 09:其他出库单 11:材料出库单 32:销售出库单 ls_data = "普通销售" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //业务类型 ls_data = "库存" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //单据来源 采购、销售、库存、存货 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //对应业务单号 ls_data = adw_batch.Object.stock_code[1]//"0001" 仓库号需要从条码表获取 ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //仓库编码 ls_data = string(date(adw_head.Object.out_date[1]),'yyyy-mm-dd')//"2013-10-17" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //单据日期 ls_data = adw_head.Object.delivery_code[1]//"002" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //单据号 ls_data = "" //根据出库类别基本档案表 ls_xml = ls_xml + "
" + ls_data + "" + "~r~n" //收发类别编码 //获取事务所对应的成本中心 传入U8做为部门 前一个为合同大类,后一个为事务所 ls_data = gf_get_costcentre('收入',adw_detail.Object.business_type[1],adw_detail.Object.office_code[1]) if gf_str_isnull(ls_data) then MessageBox("系统提示","未获取到事务所对应的成本中心!") return 0 end if ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //部门编码 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //职员编码 业务员 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //采购类型编码 采购入库用 ls_data = adw_detail.Object.pact_sort[1]// 合同类型 SELECT sms_pact_type.pact_area_type INTO :ls_data FROM sms_pact_type Where sms_pact_type.pk_id = :ls_data;//根据合同类型获取 if gf_str_isnull(ls_data) then MessageBox("系统提示","未获取到合同类型对应的编码!") Return 0 end if ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //销售类型编码 销售出库用 ls_data = adw_head.Object.buddy_code[1]//"00001" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //客户编码 销售出库单、其他出库单用 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //客户分类 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //不清楚做什么用的 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //供应商编码 采购入库单、其他入库单用 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //订单号 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //产量 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //到货单号 采购入库单用 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //发票号 采购入库单、销售出库单用 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //发货单号 销售出库单用 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //到货日期 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //检验单号 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //检验日期 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //检验员 编码 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //模版号 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //生产批号 产成品入库单、材料出库单用 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //经手人 编码 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //备注 ls_data = user.user_name ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //制单人 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //审核人 ls_data = adw_detail.Object.pact_code[1]//自定义字段1,传输合同编号 ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //自定义字段1 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //自定义字段2 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //自定义字段3 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //自定义字段4 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //自定义字段5 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //自定义字段6 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //自定义字段7 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //自定义字段8 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //自定义字段9 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //自定义字段10 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //自定义字段11 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //自定义字段12 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //自定义字段13 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //自定义字段14 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //自定义字段15 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //自定义字段16 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //审核日期 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //税率 ls_data = adw_detail.describe("Evaluate('Lookupdisplay(money_sort)',1)") ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //币种名称 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //汇率 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //扣税类别 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //不清楚XML中含义 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //不清楚XML中含义 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //不清楚XML中含义 ls_data = "" ls_xml = ls_xml + "" + ls_data + "" + "~r~n" //不清楚XML中含义 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //不清楚XML中含义 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //不清楚XML中含义 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //不清楚XML中含义 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //不清楚XML中含义 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //不清楚XML中含义 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //不清楚XML中含义 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //不清楚XML中含义 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //不清楚XML中含义 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //不清楚XML中含义 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //不清楚XML中含义 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //补料标志 ls_xml = ls_xml + "" + "~r~n" //body ls_xml = ls_xml + "" + "~r~n" For ll_i = 1 To adw_batch.RowCount() ls_detail_pkid = adw_batch.Object.stock_out_detail_pkid[ll_i] ll_find = adw_detail.Find("pk_id = '" + ls_detail_pkid + "'",1,adw_detail.RowCount()) ls_xml = ls_xml + " " + "~r~n" ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //条形码 ls_data = adw_batch.Object.special_prot_code[ll_i]//"0002" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //存货编码 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //自由项1 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //自由项2 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //自由项3 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //自由项4 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //自由项5 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //自由项6 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //自由项7 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //自由项8 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //自由项9 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //自由项10 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //应收(发)数量 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //应收(发)件数 ldc_num = adw_batch.Object.prot_num[ll_i] ls_data = string(ldc_num) ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //数量(主记量数量) 应收(发)数量和数量不能同时为空。 ls_data = adw_batch.describe("Evaluate('Lookupdisplay(prot_unit)'," + string(ll_i) + ")") ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //主记量单位名称? ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //辅记量单位 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //辅记量单位名称 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //换算率? ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //件数 ldc_price = adw_detail.object.sale_price[ll_find] ls_data = string(ldc_price)//销售单价 ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //单价 ls_data = string(round(ldc_num * ldc_price,2)) ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //金额 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //计划单价? ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //计划金额? ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //批号 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //生产日期 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //失效日期) ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //调拨单子表ID号 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //发票子表ID号 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //采购订单子表ID号 ls_data = adw_batch.Object.stack_code[ll_i] ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //货位 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //项目大类编码 ls_data = "00"//项目大类编码固定为00 ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //项目大类名称 ls_financial_sort = adw_detail.Object.financial_sort[ll_find] if gf_get_sanyoerp_encode("SMS",'SAP',ls_financial_sort,ls_data,'09') = 0 then MessageBox("系统提示","获取财务类别:" + ls_financial_sort + "对应业务范围失败!") Return 0 end if ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //项目编码 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //项目名称 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //表体自定义项22 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //表体自定义项23 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //表体自定义项24 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //表体自定义项25 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //表体自定义项26 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //表体自定义项27 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //表体自定义项28 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //表体自定义项29 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //表体自定义项30 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //表体自定义项31 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //表体自定义项32 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //表体自定义项33 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //表体自定义项34 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //表体自定义项35 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //表体自定义项36 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //表体自定义项37 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //发货单子表ID ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //委托代销发货单子表 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //生产订单子表ID ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //检验单子表ID ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //不良品处理单号 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //不良品处理单ID ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //检验员 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //检验日期 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //检验单号 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //保质期天数 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //不清楚XML中具体含义 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //不清楚XML中具体含义 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //不清楚XML中具体含义 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //不清楚XML中具体含义 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //不清楚XML中具体含义 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //不清楚XML中具体含义 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //不清楚XML中具体含义 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //不清楚XML中具体含义 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //保质期单位 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //代管商编码 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //库管员编码 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //库管员名称 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //属性1 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //属性2 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //属性3 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //属性4 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //属性5 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //属性6 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //属性7 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //属性8 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //属性9 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //属性10 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //有效期推算方式 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //有效期计算项 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //有效期至 ls_data = "" ls_xml = ls_xml + " " + ls_data + "" + "~r~n" //备注 ls_xml = ls_xml + "" + "~r~n" Next ls_xml = ls_xml + "" + "~r~n" //增加文件尾相关信息 ls_xml = ls_xml + "" + "~r~n" ls_xml = ls_xml + "" + "~r~n" //此段代码生成一个XML文件,可用于查看生成的数据 //oleobject ixmldom //long ll_return //ixmldom = CREATE OLEObject //ll_return = ixmldom.connecttonewobject( "microsoft.xmldom")//创建DOM对象 //if ll_return <> 0 then // destroy ixmldom // messagebox("","创建DOM对象失败!") // Return 0 //end if //iXMLDOM.loadXML(ls_xml) //iXMLDOM.save("d:\temp.xml") //destroy ixmldom if gf_interface_eai(ldw_temp,ls_xml,as_proc,ls_key) = 0 then Return 0 end if MessageBox("系统提示","上传成功!") Return 1