SAP仓库移动操作 JAVA源码

采购入库migo 01 101
调拨入库MB1B 04 311
领料出库 MB1A 03 261 MD04 CO03
工单退料 03 261 加入XSTOB = ‘X’ 使用冲销移动类型标识符
查看库存 MMBE MB51
查询凭证 MB03

GM_CODE

  1. GM_Code 01: Goods receipt for purchase order
  2. GM_Code 02: Goods receipt for production order
  3. GM_Code 03: Goods issue
  4. GM_Code 04: Transfer posting
  5. GM_Code 05: Other goods receipts
  6. GM_Code 06: Reversal of goods movements
  7. GM_Code 07: Subsequent adjustment to a subcontract order
//存储地点间转储 调拨入库
	public void GoodsTransfer() throws Exception {

		JCoDestination destination1 = JCoDestinationManager.getDestination("EM_SAP");

		JCoFunction function = destination1.getRepository().getFunction("BAPI_GOODSMVT_CREATE");// 从对象仓库中获取 RFC-BAPI 函数:获取公司列表

		if (function == null)

			throw new RuntimeException("BAPI_GOODSMVT_CREATE not found in SAP.");

		try {

			function.execute(destination1);

		} catch (AbapException e) {

			System.out.println(e.toString());

		}
		
		//2.JCoStructure 一般为HEADER参数
		JCoStructure Structure=function.getImportParameterList().getStructure("GOODSMVT_HEADER");
		Structure.setValue("PSTNG_DATE", "2019-05-16");//参数凭证中的过帐日期
		Structure.setValue("DOC_DATE",  "2019-05-16");//参数凭证中的凭证日期

		
		JCoStructure Structure1=function.getImportParameterList().getStructure("GOODSMVT_CODE");
		Structure1.setValue("GM_CODE", "04");
		
		//3.JCoTable 主体参数,可为多个主体参数。。。
		JCoTable headerImportParam = function.getTableParameterList().getTable("GOODSMVT_ITEM");//返回的值i个字段作为一个表
		//如果为参数集合,在外层加for循环即可
		headerImportParam.appendRow();//附加表的最后一个新行,行指针,它指向新添加的行。
		headerImportParam.setValue("MOVE_TYPE", "311");//参数101收货 102退货 311 261
		//headerImportParam.setValue("MVT_IND", "K");//移动标识
		headerImportParam.setValue("PLANT", "1012");
		headerImportParam.setValue("MATERIAL", "000000000000100010");		
		headerImportParam.setValue("ENTRY_QNT", "10");
		headerImportParam.setValue("ENTRY_UOM", "KG");
		//headerImportParam.setValue("REF_DOC_IT", "0002");
		headerImportParam.setValue("BATCH", "E21902643X"); //批号
		headerImportParam.setValue("STGE_LOC", "1011");//原库存地点
		headerImportParam.setValue("MOVE_STLOC", "1021");//接收库存地点
	

		//必須有
		JCoFunction function1 = destination1.getRepository().getFunction("BAPI_TRANSACTION_COMMIT");
		function1.getImportParameterList().setValue("WAIT", "X");
		 
		//开启一个事务
		 JCoContext.begin(destination1);
		//执行接口
		function.execute(destination1);//执行函数
		function1.execute(destination1);//执行确认
		JCoContext.end(destination1);
		

		String returnStr=function.getExportParameterList().getString("MATERIALDOCUMENT");
		
		System.out.println("生成物料号ok:" + returnStr);
		
		String Rmessage = "";
		JCoTable returnStructure = function.getTableParameterList().getTable("RETURN");

		for (int i = 0; i < returnStructure.getNumRows(); i++) {
		    returnStructure.setRow(i);  
		    Rmessage += i + ":" + returnStructure.getString("MESSAGE") + "\n";
		} 
		
		System.out.println("错误信息:" + Rmessage);
		

	}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值