采购入库migo 01 101
调拨入库MB1B 04 311
领料出库 MB1A 03 261 MD04 CO03
工单退料 03 261 加入XSTOB = ‘X’ 使用冲销移动类型标识符
查看库存 MMBE MB51
查询凭证 MB03
GM_CODE
- GM_Code 01: Goods receipt for purchase order
- GM_Code 02: Goods receipt for production order
- GM_Code 03: Goods issue
- GM_Code 04: Transfer posting
- GM_Code 05: Other goods receipts
- GM_Code 06: Reversal of goods movements
- 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);
}