最近公司线材半成品需要分层成多个半成品,由一束线的半成品变成三四十多个半成品,该业务需求会带来哪些影响呢?
仓库就提出任务单能不能批量发料功能?从技术角度来说,理论上是可以实现在的。经过对业务部关键用户的需求调研和分析得出如下:
本次开发借鉴标准系统标准API:
1. WIP_POPULATE_TEMP.Insert_Temp 往表mtl_material_transactions_temp
2. inv_quantity_tree_pub.query_quantities 判断现有量 API
主要代码如下,其中核心代码CUX_WIPBATTXMAT_PKG.InsertTemp
CREATE OR REPLACE Package CUX_WIPBATTXMAT_PKG As
--任务单装配
Type CUX_WIPDISCRETEJOBS Is Record(
TRANSACTION_HEADER_ID Number,
WIP_ENTITY_ID Number, --任务单ID
WIP_ENTITY_NAME Varchar2(240), --任务单编号
JOB_TYPE_MEANING Varchar2(80), --类型
ASSEMBLY_NUM Varchar2(40), --装配件
ASSEMBLY_DESC Varchar2(240), --装配件说明
CLASS_CODE Varchar2(10), --分类
STATUS_TYPE_DISP Varchar2(80), --状态
START_QUANTITY Number, --数量
DATE_RELEASED Date, --发放日期
INVENTORY_ITEM_ID Number, --装配件ID
TRANSACTION_TYPE Varchar2(80), --事务处理类型
TRANSACTION_DATE Date, --事务处理日期
TRANSFER_SUBINVENTORY Varchar2(8), --子库存
TRANSFER_LOCATION_ID Number, --货位ID
TRANSFER_LOCATION_CODE Varchar2(30) --货位代码
);
--提交请求 GB任务单批量发料请求
procedure SubmitRpt(ERRBUF OUT VARCHAR2,
RETCODE OUT NUMBER,
P_ORGANIZATION_ID NUMBER,
P_GROUP_ID Number,
P_USER_ID Number);
--提交单个任务单组件发放
Procedure WipCmpRelRequest(P_GROUP_ID In Number,
P_WIP_ENTITY_ID IN NUMBER,
P_TRANSACTION_DATE IN Date,
P_ORGANIZATION_ID IN NUMBER,
P_SUBINVENTORY IN VARCHAR2,
P_LOCATOR_ID IN NUMBER,
P_TRANSACTION_HEADER_ID In NUMBER,
P_USER_ID IN NUMBER,
P_DEBUG_FLAG Varchar2);
procedure WipCmpRel(ERRBUF OUT VARCHAR2,
RETCODE OUT NUMBER,
P_GROUP_ID In Number,
P_WIP_ENTITY_ID IN NUMBER,
P_TRANSACTION_DATE IN Varchar2,
P_ORGANIZATION_ID IN NUMBER,
P_SUBINVENTORY IN VARCHAR2,
P_LOCATOR_ID IN NUMBER,
P_TRANSACTION_HEADER_ID In NUMBER,
P_USER_ID IN NUMBER,
P_DEBUG_FLAG Varchar2);
Procedure InsertTemp(P_TRANSACTION_MODE IN NUMBER,
P_WIP_ENTITY_ID IN NUMBER,
P_LINE_ID IN NUMBER,
P_TRANSACTION_DATE IN DATE,
P_TRANSACTION_TYPE_ID IN NUMBER,
P_TRANSACTION_ACTION_ID IN NUMBER,
P_SUBINVENTORY IN VARCHAR2,
P_LOCATOR_ID IN NUMBER,
P_ASSEMBLY_QUANTITY IN NUMBER,
P_OPERATION_SEQ_NUM IN NUMBER,
P_DEPARTMENT_ID IN NUMBER,
P_CRITERIA_SUB IN VARCHAR2,
P_ORGANIZATION_ID IN NUMBER,
P_ACCT_PERIOD_ID IN NUMBER,
P_LAST_UPDATED_BY IN NUMBER,
P_ENTITY_TYPE IN NUMBER,
P_TRANSACTION_HEADER_ID IN NUMBER,
P_DEBUG_FLAG Varchar2,
X_COMMIT_COUNT In Out Number);
End CUX_WIPBATTXMAT_PKG;
CREATE OR REPLACE Package Body CUX_WIPBATTXMAT_PKG As
Procedure Log(p_Msg In Varchar2) Is
Begin
Fnd_File.Put_Line(Fnd_File.Log, p_Msg);
End Log;
--===============================================================
-- Output
--===============================================================
Procedure Output(p_Msg In Varchar2) Is
Begin
Fnd_File.Put_Line(Fnd_File.Output, p_Msg);
End Output;
--批量发料失效的明细
procedure WipCmpRelFailure(P_ORGANIZATION_ID NUMBER, P_GROUP_ID Number) Is
Cursor Cr Is
Select WDJ.WIP_ENTITY_ID,
WDJ.WIP_ENTITY_NAME,
WDJ.STATUS_TYPE_DISP,
MSI.SEGMENT1 COMP_NUM,
MSI.DESCRIPTION COMP_DESC,
WRO.REQUIRED_QUANTITY,
WRO.QUANTITY_ISSUED,
WRO.SUPPLY_SUBINVENTORY
From CUX.CUX_WIPBATISSUED_ALL WIPB,
WIP_DISCRETE_JOBS_V WDJ,
WIP_REQUIREMENT_OPERATIONS WRO,
MTL_SYSTEM_ITEMS_B MSI
Where WIPB.WIP_ENTITY_ID = WDJ.WIP_ENTITY_ID
And WDJ.WIP_ENTITY_ID = WRO.WIP_ENTITY_ID
And WRO.Inventory_Item_Id = MSI.INVENTORY_ITEM_ID
And WRO.organization_id = MSI.ORGANIZATION_ID
And WIPB.Group_Id = P_GROUP_ID
And WIPB.ORGANIZATION_ID = P_ORGANIZATION_ID
And (WRO.WIP_SUPPLY_TYPE = 1 Or WRO.WIP_SUPPLY_TYPE = 2)
And WDJ.STATUS_TYPE = 3
And Nvl(WRO.QUANTITY_ISSUED, 0) - WRO.REQUIRED_QUANTITY < 0
Order By WDJ.WIP_ENTITY_ID;
i Number :=1;
Begin
OUTPUT('任务单未发料明细 ');
Output('
序号
任务单
状态
任务单标识
组件
组件说明
子库存
数量
已发料
未发数 ');
For Rs In Cr Loop
Output('
'|| i ||'
'||Rs.Wip_Entity_Name||'
'||Rs.Status_Type_Disp||'
'||Rs.Wip_Entity_Id||'
'||Rs.Comp_Num||'
'||Rs.Comp_Desc||'
'||Rs.Supply_Subinventory||'
'||Rs.Required_Quantity||'
'||Rs.Quantity_Issued||'
'||(Rs.Required_Quantity - Nvl(Rs.Quantity_Issued,0))||' ');
i := i +1;
End Loop;
End WipCmpRelFailure;
--提交请求 GB任务单批量发料请求
procedure SubmitRpt(ERRBUF OUT VARCHAR2,
RETCODE OUT NUMBER,
P_ORGANIZATION_ID NUMBER,
P_GROUP_ID Number,
P_USER_ID Number) Is
Cursor Cr Is
Select *
From CUX.CUX_WIPBATISSUED_ALL
Where GROUP_ID = P_GROUP_ID
And ORGANIZATION_ID = P_ORGANIZATION_ID
And PROCESS_FLAG =2 ;
l_TrxHdrId Number;
Begin
---更新为处理中
Update CUX.CUX_WIPBATISSUED_ALL
Set PROCESS_FLAG = 2
Where GROUP_ID = P_GROUP_ID
And ORGANIZATION_ID = P_ORGANIZATION_ID
And PROCESS_FLAG = 1;
Commit;
CUX_GOBAOPUBLIC_PKG.HTMLSTART('GB任务单批量发料请求');
OUTPUT('
提交日期:' || TO_CHAR(SYSDATE, 'YYYY-MM-DD HH24:MI:SS') || '
组标识:' ||P_GROUP_ID || ' ');
Select mtl_material_transactions_s.NEXTVAL
INTO l_TrxHdrId
FROM SYS.dual;
For Rs In Cr Loop
WipCmpRelRequest(P_GROUP_ID,
Rs.Wip_Entity_Id,
Rs.Transaction_Date,
Rs.Organization_Id,
Rs.Subinventory_Code,
Rs.Locator_Id,
l_TrxHdrId,
P_USER_ID,
'Y');
End Loop;
WipCmpRelFailure(P_ORGANIZATION_ID, P_GROUP_ID);
OUTPUT('