详解EBS接口开发之WIP模块接口

2014-07-23 22:53:49 caixingyun 阅读数 11780  收藏 更多

分类专栏: 详解EBS接口开发系列

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。

本文链接:https://blog.csdn.net/caixingyun/article/details/38071803

总体说明

文档目的

本文档针对WIP模块业务功能和接口进行分析和研究,对采用并发请求方式和调用API方式分别进行介绍

内容

WIP模块常用标准表简介

WIP事物处理组成

WIP相关业务流程

WIP相关API研究事例

(十)参考文档(七)采购相关的一些知识

(一)WIP模块常用标准表简介

1.1   常用标准表

如下表中列出了与WIP导入相关的表和说明:

表名

说明

其他信息

BOM_STRUCTURES_B

BOM头信息

BOM_COMPONENTS_B

BOM组件信息

BOM_OPERATIONAL_ROUTINGS

BOM工艺路线头信息

BOM_OPERATION_SEQUENCES

BOM工艺路线生产信息

WIP_ENTITIES

工单信息表

WIP_DISCRETE_JOBS

离散工单信息表

WIP_REQUIREMENT_OPERATIONS

任务领料需求发放表

WIP_OPERATIONS

离散作业工序(操作)表

WIP_OPERATION_RESOURCES

生产资源表

MTL_MATERIAL_TRANSACTIONS

事物处理表

WIP_TRANSACTIONS

WIP事物处理表

1.2  接口表大体介绍

如下表中列出了与WIP导入相关的接口表和说明:

表名

说明

其他信息

mtl_transactions_interface

事物处理接口表

mtl_serial_numbers_interface

事物处理序列表

mtl_transaction_lots_interface

事物处理批次表

cst_comp_snap_interface

wip_move_txn_interface

移动事物处理接口表

1.3   说明

这里只列出了WIP相关的大多数常用表。还有一些不经常用到的没有涉及,具体可以参考oracle网站上的

(二)WIP事物处理组成

WIP事物处理主要包括:工单生成,工单更改,投料退料,工单移动,工单完工

2.1  WIP事物处理组成

工单创建:生成工单

工单更改:更改工单信息

投料退料:工单的投料以及退料

工单移动:工单的正向移动和逆向移动

投料退料:工单的完工事物处理

(三)WIP相关业务流程

3.1   创建BOM

路径:Bill Of Materials > Bills > Bills

后台数据

SELECT * FROM bom_structures_b l WHERE l.assembly_item_id = 24815;

SELECT *

FROM bom_components_b

WHERE bill_sequence_id IN

(SELECT bill_sequence_id

FROM bom_structures_b

WHERE assembly_item_id = 24815);

发料方式

Push 推式发料,必须手工通过界面做发料 需严格控制数量或者波动比较大的物料
Assembly Pull 拉式发料,装配件完工或报废时自动按标准消耗量触发 消耗比较稳定的物料
Operation Pull 拉式发料,工序移动至To Move时自动按标准消耗量触发 消耗比较稳定的物料

BOM_COMPONENTS_B.WIP_SUPPLY_TYPE存储发料方式

Value

Meaning

1

Push

2

Assembly Pull

3

Operation Pull

4

Bulk

5

Supplier

6

Phantom

7

Based on Bill

3.2   定义ROUTING

路径:Bill Of Materials > Routings> Routings

Routings(工艺路线)最终解决的问题是生产过程中加工顺序、资源和用量的标准化。Routing是产品/半成品的生产步骤图,定义了生产特定物料所要经历的工序、加工部门(工作中心)、提前期、耗用的资源及其额定数量。

Routing头信息存储在表BOM_OPERATIONAL_ROUTINGS中,Routing的Operations信息存储在BOM_OPERATION_SEQUENCES表中,两个表通过字段ROUTING_SEQUENCE_ID字段关联

SELECT * FROM BOM_OPERATIONAL_ROUTINGS WHERE ASSEMBLY_ITEM_ID =  24815;

SELECT *

FROM bom_operation_sequences

WHERE routing_sequence_id IN

(SELECT routing_sequence_id

FROM bom_operational_routings

WHERE assembly_item_id = 24815);

3.2   定义离散工单

路径:WIP > Discrete > DiscreteJobs

Discrete,离散式,一种制造方法,用于装配件的分组或成批制造。制定标准离散任务,输入核心内容:任务名称(工单号)、生产类型、装配件、工单类型、生产数量、开工时间或完工时间。

这里在Discrete Job里定义job,保存,并release这个job。

工序

组件

涉及到几张表WIP_ENTITIES,WIP_DISCRETE_JOBS,WIP_REQUIREMENT_OPERATIONS和,这几张表都是通过WIP_ENTITY_ID相互关联.

<<WIP_ENTITIES>>

WIP_ENTITIES stores information about jobs,repetitive assemblies, and flow schedules. Each row includes a unique entityname, the entity type, and the assembly being built. Oracle Work in Process uses this information to controlproduction activities and to ensure that entities with duplicate names are notcreated.

Key Fields:

WIP_ENTITY_ID:Job or schedule Identifier

ORGANIZATION_ID:Organization Identifier

WIP_ENTITY_NAME:WIP job or repetitiveassembly name or flow schedule reference code

ENTITY_TYPE:WIP entity type code

1

Discrete job

2

Repetitive assembly

3

Closed discrete job

4

Flow schedule

PRIMARY_ITEM_ID:Assembly Item Item

<<WIP_DISCRETE_JOBS>>

WIP_DISCRETE_JOBS stores discrete jobinformation. Each row represents a discrete job, and contains information aboutthe assembly being built, the revision of the assembly, the job quantity, thestatus of the job, the material control method, accounting information, and jobschedule dates. Oracle Work in Process uses this information to controldiscrete production.

Key Fields:

WIP_ENTITY_ID:Job or schedule Identifier

ORGANIZATION_ID:Organization Identifier

PRIMARY_ITEM_ID:Assembly Item Item

STATUS_TYPE :Status of job
可以通过下边的SQL查得code的意义

SELECT lookup_code,meaning FROMFND_LOOKUP_VALUES
where LANGUAGE = 'US' AND Upper(lookup_type) LIKE Upper('WIP_JOB_STATUS')

Value

Meaning

7

Cancelled

8

Pending Bill Load

9

Failed Bill Load

10

Pending Routing Load

11

Failed Routing Load

12

Closed

13

Pending - Mass Loaded

14

Pending Close

15

Failed Close

1

Unreleased

3

Released

4

Complete

5

Complete - No Charges

6

On Hold

JOB_TYPE :Type of discrete job

Value

Meaning

1

Standard

3

Non-standard

WIP_SUPPLY_TYPE :Method of material consumption within WIP

Value

Meaning

1

Push

2

Assembly Pull

3

Operation Pull

4

Bulk

5

Supplier

6

Phantom

7

Based on Bill

START_QUANTITY:Job start quantity

QUANTITY_COMPLETED:Current job quantity completed

COMMON_BOM_SEQUENCE_ID:-->BOM_COMPONENTS_B.BILL_SEQUENCE_ID

COMMON_ROUTING_SEQUENCE_ID:-->BOM_OPERATIONAL_ROUTINGS.ROUTING_SEQUENCE_ID

<<WIP_REQUIREMENT_OPERATIONS>>

WIP_REQUIREMENT_OPERATIONS storesinformation about the material requirements of jobs and schedules. Each rowrepresents a material requirement and contains information about the componentitem, its usage quantities, the using department, requirement date, and thematerial control method. Oracle Work in Process uses this information to trackthe material usage of jobs and schedules.

Key Fields:

WIP_ENTITY_ID:Job or schedule Identifier

ORGANIZATION_ID:Organization Identifier

INVENTORY_ITEM_ID:Component Item Id

COMPONENT_SEQUENCE_ID:-->BOM_COMPONENTS_B.COMPONENT_SEQUENCE_ID

WIP_SUPPLY_TYPE :Method of material consumption within WIP

Value

Meaning

1

Push

2

Assembly Pull

3

Operation Pull

4

Bulk

5

Supplier

6

Phantom

7

Based on Bill

REQUIRED_QUANTITY:Component quantityrequired

QUANTITY_ISSUED:Component quantity issued

SUPPLY_SUBINVENTORY:Subinventory used tosupply component to WIP

SUPPLY_LOCATOR_ID:Locator used to supplycomponent to WIP

SEGMENT1:Component Item segment

QUANTITY_ALLOCATED:Quantity allocated

QUANTITY_BACKORDERED:Quantity backordered

SELECT * FROM WIP_ENTITIES WHERE WIP_ENTITY_NAME = 'J2010113';

WIP_ENTITIES.PRIMARY_ITEM_ID= 24815与BOM关联

     

SELECT *

FROM wip_discrete_jobs

WHERE wip_entity_id =

(SELECT wip_entity_id

FROM wip_entities

WHERE wip_entity_name = 'J2010113');

SELECT *

FROM wip_requirement_operations

WHERE wip_entity_id =

(SELECT wip_entity_id

FROM wip_entities

WHERE wip_entity_name = 'J2010113');

3.2   发料

接下来我们就要从库存中给工单发货,这里有两种方法发料到工单

方法1:WIP > Material Transactions > WIP Material Transactions

这种方式比较简单,直接指定库存并发料

方法2:WIP > Discrete > Component Pick Release > Component Pick Releas(Form) / (SRS)

当BOM的组件很多,使用方法一发料的话,一个个指定库存会很麻烦,Oracle EBS提供了Pick Release的方式来发料,这样用户只要指定合适的Picking Rule,那么系统会自动帮你挑库。

系统会产生一个Move Order(Move Order Type:Manufacturing Pick),这一步实际上非常类似于订单的Pick Release。

接下来去Transact Move Order界面,Transact这个Move Order就完成发料动作了。

注意使用方式一发料的话,后台是不会产生Move Order的,只有方式二才会有Move Order产生。

3.2   事物处理

这个时候可以去Material Transaction form里查看,组件已经从库存中扣减,Transaction Type=WIP Issue(Transaction_Type_id:35,WIPcomponent issue)

这个时候MTL_MATERIAL_TRANSACTIONS表中几个JOB相关的字段

MMT.Transaction_Type_id:35

MMT.TRANSACTION_ACTION_ID:1

MMT.TRANSACTION_SOURCE_TYPE_ID:5

MMT.TRANSACTION_SOURCE_ID-->WIP_DISCRETE_JOBS.WIP_ENTITY_ID

MMT.TRX_SOURCE_LINE_ID-->WIP_REQUIREMENT_OPERATIONS.OPERATION_SEQ_NUM
MMT.SOURCE_LINE_ID -->MTL_TXN_REQUEST_LINES.LINE_ID

MMT.Move_Order_line_ID-->MTL_TXN_REQUEST_LINES.LINE_ID

3.2   退料

物料发到工单后,有可能因为各种原因要把料退回到仓库,可以使用WIP Return

路径:WIP > Material Transactions > WIPMaterial Transactions,Type选择 WIP Return

查看Material Transaction,就可以看到一条WIP Return的Transaction发生了,并且组件库存数量又恢复到发料前的数量。

Transaction_TYPE_ID:43(WIP Component Return)

ps:不管是上边所说的WIP Issue还是WIP Return,在WIP_TRANSACTIONS表中是没有数据产生的。

WIP_TRANSACTIONS stores information aboutWIP resource transactions.Each row represents a single resource transaction andincludes a uniquetransaction Identifier, a transaction date, the job orrepetitiveschedule charged, the WIP operation and resource charges, andthenumber of units of measure applied. Oracle Work in Process uses thisinformation to track resourcecharges and to calculate the values stored in WIP_TRANSACTION_ACCOUNTS.

(四)WIP相关API研究事例

相关接口字段说明参见参考例子里的说明

3.1  工单创建

PROCEDUREnew_work_order(p_wip_entity_id NUMBER,

p_organization_idNUMBER,

x_error_status OUTVARCHAR2,

x_error_message OUTVARCHAR2) IS

l_iface_rec wip.wip_job_schedule_interface%ROWTYPE; --工单任务接口表

CURSOR c_wdj IS

SELECT *

FROM cux_wip_discrete_jobs_temp cwdj

WHERE cwdj.wip_entity_id =p_wip_entity_id

AND cwdj.organization_id =p_organization_id;

BEGIN

--

l_iface_rec.last_update_date := SYSDATE;

l_iface_rec.last_updated_by := fnd_global.user_id;

l_iface_rec.creation_date := SYSDATE;

l_iface_rec.created_by := fnd_global.user_id;

--

l_iface_rec.group_id := wip.wip_job_schedule_interface_s.nextval;

/*================================================

WIP_LOAD_TYPE MFG_LOOKUPS

------------ --------------

1 Create Standard Job

2 Create Repetitive Schedule

3 Update Discrete Job

4 Create Non–standard Job

================================================*/

FOR rec_wdj IN c_wdj LOOP

g_status_type := rec_wdj.status_type;

--根据业务逻辑判断标准非标准工单

IF rec_wdj.job_type = 1 THEN

l_iface_rec.load_type := 1; --1标准

ELSE

l_iface_rec.load_type := 4; --非标准

END IF;

l_iface_rec.allow_explosion := 'Y';

l_iface_rec.process_phase := '2';

l_iface_rec.process_status := '1';

l_iface_rec.status_type := '3'/*rec_wdj.status_type*/

; --已发放

l_iface_rec.job_name := rec_wdj.job_num;

l_iface_rec.organization_id := rec_wdj.organization_id;

l_iface_rec.class_code :=rec_wdj.class_code;

l_iface_rec.primary_item_id :=rec_wdj.primary_item_id;

l_iface_rec.start_quantity :=rec_wdj.plan_quantity;

l_iface_rec.scheduling_method := '1';

l_iface_rec.first_unit_start_date :=rec_wdj.scheduled_start_date;

l_iface_rec.first_unit_completion_date :=rec_wdj.scheduled_completion_date;

l_iface_rec.attribute_category :=rec_wdj.temp_attribute_category;

l_iface_rec.attribute1 :=rec_wdj.temp_attribute1;

l_iface_rec.attribute2 :=rec_wdj.temp_attribute2;

l_iface_rec.attribute3 :=rec_wdj.temp_attribute3;

l_iface_rec.attribute4 :=rec_wdj.temp_attribute4;

l_iface_rec.attribute5 :=rec_wdj.temp_attribute5;

l_iface_rec.attribute6 :=rec_wdj.temp_attribute6;

l_iface_rec.attribute7 :=rec_wdj.temp_attribute7;

l_iface_rec.attribute8 :=rec_wdj.temp_attribute8;

l_iface_rec.attribute9 := rec_wdj.temp_attribute9;

l_iface_rec.attribute10 :=rec_wdj.temp_attribute10;

l_iface_rec.attribute11 :=rec_wdj.temp_attribute11;

l_iface_rec.attribute12 :=rec_wdj.temp_attribute12;

l_iface_rec.attribute13 := rec_wdj.temp_attribute13;

l_iface_rec.attribute14 :=rec_wdj.temp_attribute14;

l_iface_rec.attribute15 :=rec_wdj.temp_attribute15;

l_iface_rec.source_code := 'wip test';

l_iface_rec.source_line_id :=rec_wdj.job_id;

INSERT INTO wip.wip_job_schedule_interfaceVALUES l_iface_rec;

END LOOP;

--API

wip_massload_pub.massloadjobs(p_groupid => l_iface_rec.group_id, --Group ID

p_validationlevel => 2, -- Validation Level

p_commitflag=> 0, -- Commit 1 =Yes , 0 =' no '

x_returnstatus=> x_error_status,

x_errormsg=> x_error_message);

END;

3.2   工单更改

PROCEDUREchange_work_order_status(p_wip_entity_id NUMBER,

p_organization_id NUMBER,

p_status_type NUMBER,

p_group_idNUMBER := wip.wip_job_schedule_interface_s.nextval,

x_error_status OUT VARCHAR2,

x_error_message OUT VARCHAR2) IS

l_schedule_iface_rec wip.wip_job_schedule_interface%ROWTYPE; --工单任务接口表

--l_group_id NUMBER;

/*l_returnstatus VARCHAR2(40);

l_errormsg VARCHAR2(2000);*/

l_temp VARCHAR2(3);

BEGIN

BEGIN

SELECT 1

INTO l_temp

FROM wip_discrete_jobs wdj

WHERE wdj.wip_entity_id =p_wip_entity_id

AND wdj.organization_id =p_organization_id

AND wdj.status_type = p_status_type;

x_error_status := 'S';

RETURN;

EXCEPTION

WHEN no_data_found THEN

NULL;

END;

l_schedule_iface_rec.group_id := p_group_id;

--

l_schedule_iface_rec.last_update_date := SYSDATE;

l_schedule_iface_rec.last_updated_by := fnd_global.user_id;

l_schedule_iface_rec.creation_date := SYSDATE;

l_schedule_iface_rec.created_by := fnd_global.user_id;

--

-- l_schedule_iface_rec.group_id := l_group_id;

/*================================================

WIP_LOAD_TYPE MFG_LOOKUPS

------------ --------------

1 Create Standard Job

2 Create Repetitive Schedule

3 Update Discrete Job

4 Create Non–standard Job

================================================*/

l_schedule_iface_rec.load_type := 3; --Update standard or non-standardDiscrete Job

l_schedule_iface_rec.process_phase := 2; --Validation

l_schedule_iface_rec.process_status := 1; --Pending

--

l_schedule_iface_rec.wip_entity_id := p_wip_entity_id;

l_schedule_iface_rec.organization_id := p_organization_id;

l_schedule_iface_rec.status_type := p_status_type; --目标状态

INSERT INTO wip.wip_job_schedule_interface VALUES l_schedule_iface_rec;

wip_massload_pub.massloadjobs(p_groupid => p_group_id, -- Group ID

p_validationlevel => 2, -- Validation Level

p_commitflag=> 0, -- Commit 1 =Yes , 0 ='No'

x_returnstatus=> x_error_status,

x_errormsg=> x_error_message);

END;

3.3  工单移动

工单创建完成后,若不进行移动事务处理,则无法进行完工事务处理。移动数量需要按照完工数量的多少进行移动。完工事务处理中有超量完工的概念,因此,移动事务处理也有超量移动。

需要一个function 获取 可移动数量

/*=============================================

   *  FUNCTION / PROCEDURE

   *      get_available_to_move_qty

   *  DESCRIPTION:

   *       获取可移动数量

   *  ARGUMENT:

         

   *  RETURN:

   *      

   *  HISTORY:

   *       1.00 2014-7-11 cxy

*=============================================*/

FUNCTIONget_available_to_move_qty(p_wip_entity_id  IN NUMBER,

p_opr_seq_num     IN NUMBER,

p_organization_id IN NUMBER,

p_intraopr_step   IN NUMBER)

RETURN NUMBER IS

l_available_to_move_qty NUMBER;

CURSOR csr_wip_operations IS

SELECT decode(p_intraopr_step,

1,

wo.quantity_in_queue,

2,

wo.quantity_running,

3,

wo.quantity_waiting_to_move,

4,

wo.quantity_rejected,

5,

wo.quantity_scrapped,

wo.quantity_completed)

FROM wip_operations wo

WHERE wo.wip_entity_id = p_wip_entity_id

AND wo.operation_seq_num =p_opr_seq_num

AND wo.organization_id =p_organization_id

AND wo.repetitive_schedule_id ISNULL;

BEGIN

OPEN csr_wip_operations;

FETCH csr_wip_operations

INTO l_available_to_move_qty;

CLOSE csr_wip_operations;

RETURN l_available_to_move_qty;

END get_available_to_move_qty;

--Call API Process WIP Move Transaction

--Fixed:

--TRANSACTION_ID/GROUP_ID/PROCESS_PHASE/PROCESS_STATUS not valid. Please re-enter

--SELECT group_id

--    FROM wip_move_txn_interface

--   WHERE transaction_id = p_txn_id

--     AND process_phase = WIP_CONSTANTS.MOVE_VAL

--     AND process_status = WIP_CONSTANTS.RUNNING

--     AND group_id IS NOT NULL;

--Doc ID:  363753.1

--

PROCEDUREprocess_wip_move_txn(p_transaction_id IN NUMBER,

p_commit         IN VARCHAR2 := fnd_api.g_false,

x_return_status  IN OUT VARCHAR2,

x_error_message  IN OUT VARCHAR2)IS

--PRAGMA AUTONOMOUS_TRANSACTION;

l_groupid NUMBER;

l_errbuf VARCHAR2(1000);

l_retcode NUMBER;

BEGIN

-- Call the procedure

/***************************************************************************

* This procedure will be used to do move,easy-return, easy-completion, and

* scrap transaction for Discrete, OSFMjobs, and Repetitive Schedule. The

* caller need to insert the record intoWIP_MOVE_TXN_INTERFACE before calling

* this routine. Caller can generatewmti.transaction_id and wmti.group_id

* from the sequence wip_transactions_s.Caller need to insert both group_id

* and transaction_id before calling theprocedure below. These 2 columns

* should have to same value. Callershould always insert wmti.process_phase =

* 1(Validation) to make sure that thedata inserted is valid, and insert

* wmti.process_status = 2(Running) toprevent Move Manager from picking up

* this record.

*

* PARAMETER:

*

* p_txn_id             transaction_id inWIP_MOVE_TXN_INTERFACE

* p_do_backflush       this parameter determine whether moveprocesor has to

*                      backflush pull componentor not. Some customers use

*                      third party software toinsert backflush components, so

*                      they do not want moveprocessor to backflush them

*                     again. The defaultvalue is null. If the callers do not

*                      pass this parameter orpass fnd_api.g_true, we will

*                      backflush pull component.Otherwise, we will not

*                      backflush them. pass fnd_api.g_true orfnd_api.g_false.

* p_commmit            commit the change to the databaseif succesfully

*                      processing ? pass

*                      fnd_api.g_true orfnd_api.g_false

* x_returnStatus       There are 2 possible values

*                     *fnd_api.g_ret_sts_success*

*                      means the movetransaction succesfully processed

*                     *fnd_api.g_ret_sts_unexp_error*

*                     means anexception occurred

*                      The size of this variableshould be VARCHAR2(1)

* x_errorMsg           contains the error message onfailure. null on success.

*                      The size of this variableshould be VARCHAR2(1000)

*                      because there may beerrors in several columns.

*

* NOTE:

* 1. This procedure should be called ifcaller want to process one record at

*   a time such as Online transaction.

* 2. This procedure will returnfnd_api.g_ret_sts_unexp_error if this records

*   failed. The caller can check the error message from x_errorMsg.

* 3. The caller does not have to insertchild record for overmove/

*   overcompletion. This API will take care everything. The caller does not

*   have to call QA API either.

***************************************************************************/

cux_conc_utl.log_msg(p_msg => '   Begin Call Wip_movproc_pub.processinterface()');

l_groupid := p_transaction_id;

/*SELECT group_id

INTO l_groupid

FROM wip_move_txn_interface

WHERE transaction_id = p_transaction_id

AND process_phase =wip_constants.move_val

AND process_status =wip_constants.running

AND group_id IS NOT NULL;*/

--wip_move_validator.validate(p_group_id=> l_groupid, p_initmsglist => fnd_api.g_true);

/*--Wip_Movproc_Priv.move_worker()

wip_movproc_priv.move_worker(errbuf       => l_errbuf,

retcode      => l_retcode,

p_group_id   => l_groupid,

p_proc_phase=> wip_constants.move_proc,

p_time_out   => 30,

p_seq_move   =>wip_constants.yes);*/

-- This procedure should be called if caller want to do batch processing formultiple records in WMTI.

/*wip_movproc_pub.processinterface(p_group_id     => l_groupid,

p_do_backflush => fnd_api.g_false,

p_commit       => fnd_api.g_false,

x_returnstatus => x_return_status);*/

-- This procedure should be called if caller want to process one record at atime.

wip_movproc_pub.processinterface(p_txn_id       => p_transaction_id,

p_do_backflush => fnd_api.g_false,

p_commit       =>fnd_api.g_false,

x_returnstatus => x_return_status,

x_errormsg     =>x_error_message);

IF x_return_status =fnd_api.g_ret_sts_success THEN

NULL;

cux_conc_utl.log_msg(p_msg =>'   The Transaction_ID : ' ||

p_transaction_id ||

'Succesfully Processed');

--COMMIT;

ELSE

cux_conc_utl.log_msg(p_msg =>'   The Transaction_ID : ' ||

p_transaction_id ||

' WIP APIError : ' ||

x_error_message);

cux_conc_utl.out_msg(p_msg =>'   The Transaction_ID : ' ||

p_transaction_id ||

' WIP API Error : '||

x_error_message);

--RAISE fnd_api.g_exc_error;

--ROLLBACK;

END IF;

cux_conc_utl.log_msg(p_msg => '   End Call Wip_movproc_pub.processinterface()');

END process_wip_move_txn;

/*=============================================

   *  FUNCTION / PROCEDURE

   *      process_wip_move

   *  DESCRIPTION:

   *      工单移动事物处理

   *  ARGUMENT:

         

   *  RETURN:

   *      

   *  HISTORY:

   *       1.00 2014-7-18 cxy

 *=============================================*/

FUNCTIONprocess_wip_move(p_init_msg_list IN VARCHAR2 DEFAULT fnd_api.g_false,

p_commit        IN VARCHAR2 DEFAULT fnd_api.g_false,

x_return_status OUT NOCOPYVARCHAR2,

x_msg_count     OUT NOCOPY NUMBER,

x_msg_data      OUT NOCOPY VARCHAR2,

p_parameter1    IN VARCHAR2) RETURN VARCHAR2 IS

l_api_name       CONSTANT VARCHAR2(30) :='process_wip_move';

l_savepoint_name CONSTANT VARCHAR2(30) :='sp_process_wip_move';

l_return_status VARCHAR2(1);

l_msg_data      VARCHAR2(2000);

l_rec_move_txn  wip_move_txn_interface%ROWTYPE;

l_group_id  NUMBER;

l_txn_id    NUMBER;

l_available NUMBER;

l_trn_intermtl_transactions_interface%ROWTYPE;

v_transaction_header_id NUMBER DEFAULTNULL;

v_transaction_action_id NUMBER DEFAULTNULL;

v_quantity_flag         NUMBER DEFAULT 1;

v_return_status  VARCHAR2(3) DEFAULT NULL;

v_return_message VARCHAR2(6000) DEFAULTNULL;

v_on_hand_enough VARCHAR2(1) DEFAULT 'N';

x_over_qty       NUMBER;

l_wip_entity_id        NUMBER := 265057;

l_organization_id      NUMBER := 353;

l_transaction_quantity NUMBER := 3;

-- v_lot_number              VARCHAR2(15) := 'zhw007';*\

BEGIN

-- start activity to create savepoint,check compatibility

-- and initialize message list, includedebug message hint to enter api

x_return_status :=cux_api.start_activity(p_pkg_name      => g_pkg_name,

p_api_name       => l_api_name,

p_savepoint_name=> l_savepoint_name,

p_init_msg_list  =>p_init_msg_list);

IF (x_return_status =fnd_api.g_ret_sts_unexp_error) THEN

RAISE fnd_api.g_exc_unexpected_error;

ELSIF (x_return_status =fnd_api.g_ret_sts_error) THEN

RAISE fnd_api.g_exc_error;

END IF;

-- API body

-- logging parameters

IF l_debug = 'Y' THEN

cux_log.debug('p_parameter1 : ' ||p_parameter1);

END IF;

-- todo

SELECT wip_transactions_s.nextval INTOl_group_id FROM dual;

--loop

l_txn_id       := NULL;

l_rec_move_txn := NULL;

SELECT wip_transactions_s.nextval INTOl_txn_id FROM dual;

l_rec_move_txn.transaction_id :=l_txn_id;

l_rec_move_txn.group_id       := l_group_id;

l_rec_move_txn.process_phase  := 1;

l_rec_move_txn.process_status := 2;--runing

l_rec_move_txn.created_by        := fnd_global.user_id;

l_rec_move_txn.creation_date     := SYSDATE;

l_rec_move_txn.last_updated_by   := fnd_global.user_id;

l_rec_move_txn.last_update_date  := SYSDATE;

l_rec_move_txn.last_update_login :=fnd_global.login_id;

l_rec_move_txn.wip_entity_id :=l_wip_entity_id;

--l_rec_move_txn.wip_entity_name :=rec_grp.wo_no;

l_rec_move_txn.organization_id      := l_organization_id;

l_rec_move_txn.transaction_date     := SYSDATE;

l_rec_move_txn.transaction_quantity := abs(l_transaction_quantity);--不管怎样,事务处理数量始终取正值

l_rec_move_txn.transaction_uom      := '个';

IF l_transaction_quantity > 0 THEN

--移动数量大于0时,正向移动,由排队到移动工序号由最小走到最大

l_rec_move_txn.transaction_type := 1;--1.normal move;2.combination move or completion/return transaction

SELECT MIN(wo.operation_seq_num),MAX(wo.operation_seq_num)

INTOl_rec_move_txn.fm_operation_seq_num,

l_rec_move_txn.to_operation_seq_num

FROM wip_operations wo

WHERE wo.wip_entity_id =l_wip_entity_id

AND wo.organization_id =l_organization_id;

l_rec_move_txn.fm_intraoperation_step_type := 1; --排队

l_rec_move_txn.to_intraoperation_step_type := 3; --移动

l_available                                :=get_available_to_move_qty(p_wip_entity_id  => l_wip_entity_id,

p_opr_seq_num     => l_rec_move_txn.fm_operation_seq_num,

p_organization_id => l_organization_id,

p_intraopr_step   => 1);

IF l_available <l_transaction_quantity THEN

--如果可移动数量小于移动数量,则启用超量移动

l_rec_move_txn.overcompletion_transaction_qty := l_transaction_quantity-

l_available;

l_rec_move_txn.overcompletion_primary_qty     := l_transaction_quantity -

l_available;

x_over_qty :=l_transaction_quantity - l_available;

END IF; --IF l_available <p_move_qty THEN

ELSE

--移动数量小于0时,反向移动,由移动到排队工序号由最大走到最小

l_rec_move_txn.transaction_type := 1;--1.normal move;2.combination move or completion/return transaction

SELECT MAX(wo.operation_seq_num),MIN(wo.operation_seq_num)

INTO l_rec_move_txn.fm_operation_seq_num,

l_rec_move_txn.to_operation_seq_num

FROM wip_operations wo

WHERE wo.wip_entity_id =l_wip_entity_id

AND wo.organization_id =l_organization_id;

l_rec_move_txn.fm_intraoperation_step_type:= 3; --移动

l_rec_move_txn.to_intraoperation_step_type := 1; --排队

END IF; -- IF p_move_qty > 0 THEN

l_rec_move_txn.last_updated_by_name :=fnd_global.user_name;

l_rec_move_txn.created_by_name      := fnd_global.user_name;

--以下两字段视业务逻辑取数

l_rec_move_txn.source_code    := 'CXY_MES_WIP_MOVE_TEST';

l_rec_move_txn.source_line_id := 265057;

BEGIN

INSERT INTO wip_move_txn_interfaceVALUES l_rec_move_txn;

EXCEPTION

WHEN OTHERS THEN

cux_conc_utl.log_msg('insert intowip_move_txn_interface error : ' ||

SQLERRM);

RAISE fnd_api.g_exc_error;

END;

wip_movproc_pub.processinterface(p_txn_id       => l_txn_id,

p_commit       => 'F',

x_returnstatus => l_return_status,

x_errormsg     => l_msg_data);

--END IF;

-- API end body

-- end activity, include debug messagehint to exit api

x_return_status :=cux_api.end_activity(p_pkg_name  =>g_pkg_name,

p_api_name  => l_api_name,

p_commit    => p_commit,

x_msg_count => x_msg_count,

x_msg_data  => x_msg_data);

RETURN l_return_status || l_msg_data;

EXCEPTION

WHEN fnd_api.g_exc_error THEN

x_return_status :=cux_api.handle_exceptions(p_pkg_name      => g_pkg_name,

p_api_name       => l_api_name,

p_savepoint_name => l_savepoint_name,

p_exc_name       =>cux_api.g_exc_name_error,

x_msg_count      =>x_msg_count,

x_msg_data       =>x_msg_data);

WHEN fnd_api.g_exc_unexpected_error THEN

x_return_status :=cux_api.handle_exceptions(p_pkg_name      => g_pkg_name,

p_api_name       => l_api_name,

p_savepoint_name=> l_savepoint_name,

p_exc_name       =>cux_api.g_exc_name_unexp,

x_msg_count      =>x_msg_count,

x_msg_data       =>x_msg_data);

WHEN OTHERS THEN

x_return_status :=cux_api.handle_exceptions(p_pkg_name      => g_pkg_name,

p_api_name       => l_api_name,

p_savepoint_name => l_savepoint_name,

p_exc_name       =>cux_api.g_exc_name_others,

x_msg_count      => x_msg_count,

x_msg_data       =>x_msg_data);

END process_wip_move;

3.4   工单投料退料

/*=============================================

   *  FUNCTION / PROCEDURE

   *      process_wip_issues_returns

   *  DESCRIPTION:

   *      工单投料&退料事物处理

   *  ARGUMENT:

         

   *  RETURN:

   *      

   *  HISTORY:

   *       1.00 2014-7-18 cxy

   *=============================================*/

FUNCTIONprocess_wip_issues_returns(p_init_msg_list IN VARCHAR2 DEFAULT fnd_api.g_false,

p_commit        IN VARCHAR2DEFAULT fnd_api.g_false,

x_return_status OUT NOCOPY VARCHAR2,

x_msg_count     OUT NOCOPY NUMBER,

x_msg_data      OUT NOCOPYVARCHAR2,

p_parameter1    IN VARCHAR2)

RETURN VARCHAR2 IS

l_api_name       CONSTANT VARCHAR2(30) :='process_wip_issues_returns';

l_savepoint_name CONSTANT VARCHAR2(30) :='sp_process_wip_issues_returns';

l_iface_recinv.mtl_transactions_interface%ROWTYPE;

l_trn_serial    mtl_serial_numbers_interface%ROWTYPE;

x_error_message VARCHAR2(2000);

l_request_id    NUMBER;

l_return_status VARCHAR2(2);

x_error_status  VARCHAR(2);

l_msg_count   NUMBER;

l_msg_data    VARCHAR2(2000);

l_trans_count VARCHAR2(20000);

l_transaction_source_id NUMBER := 265056;--WIP_DISCRETE_JOBS.WIP_ENTITY_ID

l_inventory_item_id     NUMBER := 325265; --投的料

l_organization_id       NUMBER := 353;

l_subinventory_code     VARCHAR2(30) := 'YC01';

l_transaction_quantity  NUMBER := -4;

BEGIN

-- start activity to create savepoint,check compatibility

-- and initialize message list, includedebug message hint to enter api

x_return_status :=cux_api.start_activity(p_pkg_name      => g_pkg_name,

p_api_name       => l_api_name,

p_savepoint_name => l_savepoint_name,

p_init_msg_list  =>p_init_msg_list);

IF (x_return_status =fnd_api.g_ret_sts_unexp_error) THEN

RAISE fnd_api.g_exc_unexpected_error;

ELSIF (x_return_status =fnd_api.g_ret_sts_error) THEN

RAISE fnd_api.g_exc_error;

END IF;

-- API body

-- logging parameters

IF l_debug = 'Y' THEN

cux_log.debug('p_parameter1 : ' ||p_parameter1);

END IF;

-- todo

--cux_debug.test_log('1', '1', 'beginprocess');

SELECTmtl_material_transactions_s.nextval

INTO l_iface_rec.transaction_interface_id

FROM dual;

/* l_trn_serial                          := NULL;

l_trn_serial.transaction_interface_id :=l_iface_rec.transaction_interface_id;

l_trn_serial.source_code              := v_source_code;

l_trn_serial.source_line_id           := v_source_line_id;

l_trn_serial.creation_date            := SYSDATE;

l_trn_serial.created_by               := g_user_id;

l_trn_serial.last_update_date         := SYSDATE;

l_trn_serial.last_updated_by          := g_user_id;

l_trn_serial.last_update_login        := g_login_id;

l_trn_serial.program_application_id   := g_prog_appl_id;

l_trn_serial.program_id               := g_conc_program_id;

l_trn_serial.program_update_date      := SYSDATE;

l_trn_serial.request_id               := g_request_id;

l_trn_serial.fm_serial_number         := NULL; --redo

l_trn_serial.to_serial_number         := NULL; -- redo

l_trn_serial.process_flag             := 1;

BEGIN

INSERT INTOmtl_serial_numbers_interface VALUES l_trn_serial;

EXCEPTION

WHEN OTHERS THEN

cux_conc_utl.log_msg('insert intomtl_serial_numbers_interface error : ' ||

SQLERRM);

RAISE fnd_api.g_exc_error;

END;*/

l_iface_rec.last_update_date      := SYSDATE;

l_iface_rec.last_updated_by       := fnd_global.user_id;

l_iface_rec.creation_date         := SYSDATE;

l_iface_rec.created_by            := fnd_global.user_id;

l_iface_rec.last_update_login     := fnd_global.user_id;

l_iface_rec.transaction_header_id :=l_iface_rec.transaction_interface_id;

/************transaction_mode*********************

* transaction_mode

*2 Concurrent, Process transactioninterface不处理,

* 需要程序调用Inventory transaction worker处理

*3 Background, 由Process transaction interface处理

***************************************************/

l_iface_rec.transaction_mode := 3;

/************process_flag*********************

* process_flag

*1 Yes

*2 No

*3 Error

***************************************************/

l_iface_rec.process_flag := 1;

IF l_transaction_quantity >= 0 THEN

l_iface_rec.transaction_type_id := 35;--mtl_transaction_types--WIP Issue--投料

ELSE

l_iface_rec.transaction_type_id := 43;--wip return 退料

END IF;

l_iface_rec.transaction_source_type_id :=5; --mtl_txn_source_types--生产管理

/*************************************************

*账户别名杂项,用别名ID即disposition_id

*账户杂项,用账户ID即code_combination_id

*WIP物料事务,用任务ID即wip_entity_id

*SO物料事务,用mtl_sales_orders.sales_order_id

*子库转移或组织间转移,为空

************************************************/

/*SELECT wdj.wip_entity_id

INTO l_iface_rec.transaction_source_id

FROM wip_discrete_jobs wdj, wip_entitieswe

WHERE (wdj.source_line_id =rec_issue.job_id OR

(wdj.wip_entity_id,wdj.organization_id) IN

(SELECTcwdj.wip_entity_id, cwdj.organization_id

FROM cux_wip_discrete_jobs_vcwdj

WHERE cwdj.job_id =rec_issue.job_id

AND cwdj.order_wip_entity_idIS NULL))

AND we.wip_entity_id = wdj.wip_entity_id

AND we.organization_id =wdj.organization_id;*/

l_iface_rec.transaction_source_id :=l_transaction_source_id;

l_iface_rec.inventory_item_id     := l_inventory_item_id;

l_iface_rec.organization_id       := l_organization_id;

l_iface_rec.subinventory_code     := l_subinventory_code;

l_iface_rec.locator_id            := NULL;

l_iface_rec.transaction_quantity  := -l_transaction_quantity;

l_iface_rec.transaction_uom       := '个';

l_iface_rec.reason_id             := NULL;

l_iface_rec.transaction_date      := SYSDATE;

l_iface_rec.source_code           := 'CXY_MES_WIP_TEST_CODE';

l_iface_rec.source_header_id      := 4;

l_iface_rec.source_line_id        := 4;

l_iface_rec.final_completion_flag := 'N';

--cux_debug.test_log('1', '1', 'begininsert mtl');

BEGIN

INSERT INTOinv.mtl_transactions_interface VALUES l_iface_rec;

EXCEPTION

WHEN OTHERS THEN

cux_conc_utl.log_msg('insert intomtl_transactions_interface error : ' ||

SQLERRM);

RAISE fnd_api.g_exc_error;

END;

--cux_debug.test_log('1', '1', 'endinsert mtl');

l_request_id   := inv_txn_manager_pub.process_transactions(p_api_version      => 1,

p_init_msg_list    =>fnd_api.g_false,

p_commit           => fnd_api.g_true,

p_validation_level => fnd_api.g_valid_level_full,

x_return_status    =>l_return_status,

x_msg_count        => l_msg_count,

x_msg_data         =>l_msg_data,

x_trans_count      =>l_trans_count,

p_table            => 1,

p_header_id        =>l_iface_rec.transaction_header_id);

x_error_status := l_return_status;

BEGIN

SELECT mti.error_code || ',' ||mti.error_explanation || ',' ||

mli.error_code

INTO x_error_message

FROM mtl_transactions_interface     mti,

mtl_transaction_lots_interfacemli

WHERE mti.transaction_interface_id =

l_iface_rec.transaction_interface_id

AND mli.transaction_interface_id(+)=

mti.transaction_interface_id;

EXCEPTION

WHEN no_data_found THEN

NULL;

END;

IF x_error_status != 'S' THEN

/*DELETEmtl_transaction_lots_interface t

WHERE t.source_code ='cux_wip_issue_txn'

AND t.source_line_id =rec_issue.wip_issue_txn_id;*/

/*DELETE mtl_transactions_interface t

WHERE t.source_code ='CXY_MES_WIP_TEST_CODE'

AND t.source_line_id = 4

AND t.source_header_id = 4;*/

NULL;

END IF;

--END IF;

RETURN x_error_status || x_error_message;

-- API end body

-- end activity, include debug messagehint to exit api

x_return_status :=cux_api.end_activity(p_pkg_name  =>g_pkg_name,

p_api_name  => l_api_name,

p_commit    => p_commit,

x_msg_count => x_msg_count,

x_msg_data  => x_msg_data);

EXCEPTION

WHEN fnd_api.g_exc_error THEN

x_return_status :=cux_api.handle_exceptions(p_pkg_name      => g_pkg_name,

p_api_name       => l_api_name,

p_savepoint_name => l_savepoint_name,

p_exc_name       =>cux_api.g_exc_name_error,

x_msg_count      =>x_msg_count,

x_msg_data       => x_msg_data);

WHEN fnd_api.g_exc_unexpected_error THEN

x_return_status :=cux_api.handle_exceptions(p_pkg_name      => g_pkg_name,

p_api_name       => l_api_name,

p_savepoint_name => l_savepoint_name,

p_exc_name       =>cux_api.g_exc_name_unexp,

x_msg_count      =>x_msg_count,

x_msg_data       =>x_msg_data);

WHEN OTHERS THEN

x_return_status :=cux_api.handle_exceptions(p_pkg_name      => g_pkg_name,

p_api_name       => l_api_name,

p_savepoint_name => l_savepoint_name,

p_exc_name       => cux_api.g_exc_name_others,

x_msg_count      =>x_msg_count,

x_msg_data       =>x_msg_data);

END process_wip_issues_returns;

3.4   工单完工

/*=============================================

   *  FUNCTION / PROCEDURE

   *      process_wip_completions

   *  DESCRIPTION:

   *      工单完成事物处理

   *  ARGUMENT:

         

   *  RETURN:

   *      

   *  HISTORY:

   *       1.00 2014-7-18 cxy

   *=============================================*/

FUNCTIONprocess_wip_completions(p_init_msg_list IN VARCHAR2 DEFAULT fnd_api.g_false,

p_commit        IN VARCHAR2DEFAULT fnd_api.g_false,

x_return_status OUT NOCOPYVARCHAR2,

x_msg_count     OUT NOCOPY NUMBER,

x_msg_data      OUT NOCOPYVARCHAR2,

p_parameter1    IN VARCHAR2)

RETURN VARCHAR2 IS

l_api_name       CONSTANT VARCHAR2(30) :='process_wip_completions';

l_savepoint_name CONSTANT VARCHAR2(30) :='sp_process_wip_completions';

l_iface_rec  inv.mtl_transactions_interface%ROWTYPE;

l_cst_rec    cst_comp_snap_interface%ROWTYPE;

l_trn_serialmtl_serial_numbers_interface%ROWTYPE;

l_return_status VARCHAR2(1);

l_msg_count     NUMBER;

l_msg_data      VARCHAR2(2000);

l_trans_count   NUMBER;

x_error_message VARCHAR2(2000);

l_transaction_quantity  NUMBER := 3;

l_transaction_source_id NUMBER := 265057;--wip_entity_id

l_inventory_item_id     NUMBER := 325264; --CXY_制造件

l_organization_id       NUMBER := 353;

l_subinventory_code     VARCHAR2(30) := 'CP01';

l_request_id            NUMBER;

BEGIN

-- start activity to create savepoint,check compatibility

-- and initialize message list, includedebug message hint to enter api

x_return_status := cux_api.start_activity(p_pkg_name       => g_pkg_name,

p_api_name       => l_api_name,

p_savepoint_name => l_savepoint_name,

p_init_msg_list  => p_init_msg_list);

IF (x_return_status =fnd_api.g_ret_sts_unexp_error) THEN

RAISE fnd_api.g_exc_unexpected_error;

ELSIF (x_return_status =fnd_api.g_ret_sts_error) THEN

RAISE fnd_api.g_exc_error;

END IF;

-- API body

-- logging parameters

IF l_debug = 'Y' THEN

cux_log.debug('p_parameter1 : ' ||p_parameter1);

END IF;

-- todo

SELECTmtl_material_transactions_s.nextval

INTO l_iface_rec.transaction_interface_id

FROM dual;

l_iface_rec.transaction_header_id :=l_iface_rec.transaction_interface_id;

/* l_trn_serial                          := NULL;

l_trn_serial.transaction_interface_id :=l_iface_rec.transaction_interface_id;

l_trn_serial.source_code              := v_source_code;

l_trn_serial.source_line_id           := v_source_line_id;

l_trn_serial.creation_date            := SYSDATE;

l_trn_serial.created_by               := g_user_id;

l_trn_serial.last_update_date         := SYSDATE;

l_trn_serial.last_updated_by          := g_user_id;

l_trn_serial.last_update_login        := g_login_id;

l_trn_serial.program_application_id   := g_prog_appl_id;

l_trn_serial.program_id               := g_conc_program_id;

l_trn_serial.program_update_date      := SYSDATE;

l_trn_serial.request_id               := g_request_id;

l_trn_serial.fm_serial_number         := NULL; --redo

l_trn_serial.to_serial_number         := NULL; -- redo

l_trn_serial.process_flag             := 1;

BEGIN

INSERT INTOmtl_serial_numbers_interface VALUES l_trn_serial;

EXCEPTION

WHEN OTHERS THEN

cux_conc_utl.log_msg('insert intomtl_serial_numbers_interface error : ' ||

SQLERRM);

RAISE fnd_api.g_exc_error;

END;*/

l_iface_rec.last_update_date  := SYSDATE;

l_iface_rec.last_updated_by   := fnd_global.user_id;

l_iface_rec.creation_date     := SYSDATE;

l_iface_rec.created_by        := fnd_global.user_id;

l_iface_rec.last_update_login :=fnd_global.user_id;

/************transaction_mode*********************

* transaction_mode

*2 Concurrent, Process transactioninterface不处理,

* 需要程序调用Inventory transaction worker处理

*3 Background, 由Process transaction interface处理

***************************************************/

l_iface_rec.transaction_mode := 3;

/************process_flag*********************

* process_flag

*1 Yes

*2 No

*3 Error

***************************************************/

l_iface_rec.process_flag := 1;

IF l_transaction_quantity >= 0 THEN

l_iface_rec.transaction_type_id := 44;--mtl_transaction_types--WIP Completion 完工事务处理

ELSE

l_iface_rec.transaction_type_id := 17;--如果数量为负数17 WIP Completion Return 完工事务处理退回

END IF;

l_iface_rec.transaction_source_type_id :=5; --mtl_txn_source_types--生产管理

/*************************************************

*账户别名杂项,用别名ID即disposition_id

*账户杂项,用账户ID即code_combination_id

*WIP物料事务,用任务ID即wip_entity_id

*SO物料事务,用mtl_sales_orders.sales_order_id

*子库转移或组织间转移,为空

************************************************/

/* BEGIN

SELECT wdj.wip_entity_id,we.primary_item_id

INTOl_iface_rec.transaction_source_id,

l_iface_rec.inventory_item_id

FROM wip_discrete_jobs wdj, wip_entitieswe

WHERE (wdj.source_line_id =rec_completion.job_id AND

wdj.source_code = 'wipplatform')

AND we.wip_entity_id =wdj.wip_entity_id

AND we.organization_id =wdj.organization_id;

EXCEPTION

WHEN no_data_found THEN

NULL;

END;*/

l_iface_rec.transaction_source_id :=l_transaction_source_id;

l_iface_rec.inventory_item_id     := l_inventory_item_id;

IF l_transaction_quantity > 0 THEN

--若数量大于零,需要先进行移动事务处理

l_msg_data :=process_wip_move(p_init_msg_list => fnd_api.g_false,

p_commit        =>fnd_api.g_false,

x_return_status => l_return_status,

x_msg_count     => l_msg_count,

x_msg_data      => l_msg_data,

p_parameter1    => NULL);

IF l_return_status != 'S' THEN

cux_debug.test_log('MOVE_COM' ||l_return_status,

l_msg_count,

l_msg_data);

NULL;

END IF; --IF x_error_status != 'S'THEN

END IF; -- IF rec_completion.quantity> 0 THEN

--移动成功则继续

l_iface_rec.organization_id       := l_organization_id;

l_iface_rec.subinventory_code     := l_subinventory_code;

l_iface_rec.locator_id            := NULL;

l_iface_rec.transaction_quantity  := l_transaction_quantity;

l_iface_rec.transaction_uom       := '个';

l_iface_rec.transaction_date      := SYSDATE;

l_iface_rec.final_completion_flag := 'N';

l_iface_rec.wip_entity_type := 1;

--l_iface_rec.transaction_header_id :=l_iface_rec.transaction_interface_id;

--以下三字段,视业务逻辑不同取数

l_iface_rec.source_code :='CXY_MES_WIP_COM_TEST1';

l_iface_rec.source_header_id := 265057;

l_iface_rec.source_line_id := 265057;

BEGIN

INSERT INTOinv.mtl_transactions_interface VALUES l_iface_rec;

EXCEPTION

WHEN OTHERS THEN

cux_conc_utl.log_msg('insert intomtl_transactions_interface error : ' ||

SQLERRM);

RAISE fnd_api.g_exc_error;

END;

l_cst_rec.transaction_interface_id :=l_iface_rec.transaction_header_id;

l_cst_rec.wip_entity_id            := 265057;

l_cst_rec.operation_seq_num        := 10;

l_cst_rec.last_update_date         := SYSDATE;

l_cst_rec.last_updated_by          := fnd_global.user_id;

l_cst_rec.creation_date            := SYSDATE;

l_cst_rec.created_by               := fnd_global.user_id;

l_cst_rec.quantity_completed       := l_transaction_quantity; --QuantityCompleted

l_cst_rec.primary_quantity         := l_transaction_quantity; --PriamryQuantity

BEGIN

INSERT INTO cst_comp_snap_interfaceVALUES l_cst_rec;

EXCEPTION

WHEN OTHERS THEN

cux_conc_utl.log_msg('insert intocst_comp_snap_interface error : ' ||

SQLERRM);

RAISE fnd_api.g_exc_error;

END;

l_request_id :=inv_txn_manager_pub.process_transactions(p_api_version      => 1,

p_init_msg_list    =>fnd_api.g_false,

p_commit           =>fnd_api.g_true,

p_validation_level=> fnd_api.g_valid_level_full,

x_return_status    =>l_return_status,

x_msg_count        => l_msg_count,

x_msg_data         =>l_msg_data,

x_trans_count      =>l_trans_count,

p_table            => 1,

p_header_id        =>l_iface_rec.transaction_header_id);

x_return_status := l_return_status;

BEGIN

SELECT mti.error_code || ',' ||mti.error_explanation || ',' ||

mli.error_code

INTO x_error_message

FROM mtl_transactions_interface     mti,

mtl_transaction_lots_interfacemli

WHERE mti.transaction_interface_id =

l_iface_rec.transaction_interface_id

AND mli.transaction_interface_id(+)=

mti.transaction_interface_id;

EXCEPTION

WHEN no_data_found THEN

NULL;

END;

IF x_return_status != 'S' THEN

NULL;

/*DELETE mtl_transactions_interface t

WHERE t.source_code ='cux_wip_issue_txn'

AND t.source_line_id =rec_issue.wip_issue_txn_id

AND t.source_header_id =rec_issue.job_id;*/

ENDIF; --IF x_error_status != 'S' THEN

--END IF;

-- API end body

-- end activity, include debug messagehint to exit api

x_return_status :=cux_api.end_activity(p_pkg_name  =>g_pkg_name,

p_api_name  => l_api_name,

p_commit    => p_commit,

x_msg_count => x_msg_count,

x_msg_data  => x_msg_data);

RETURN l_return_status ||x_error_message;

EXCEPTION

WHEN fnd_api.g_exc_error THEN

x_return_status :=cux_api.handle_exceptions(p_pkg_name      => g_pkg_name,

p_api_name       => l_api_name,

p_savepoint_name => l_savepoint_name,

p_exc_name       =>cux_api.g_exc_name_error,

x_msg_count      =>x_msg_count,

x_msg_data       =>x_msg_data);

WHEN fnd_api.g_exc_unexpected_error THEN

x_return_status := cux_api.handle_exceptions(p_pkg_name       => g_pkg_name,

p_api_name       => l_api_name,

p_savepoint_name => l_savepoint_name,

p_exc_name       => cux_api.g_exc_name_unexp,

x_msg_count      =>x_msg_count,

x_msg_data       =>x_msg_data);

WHEN OTHERS THEN

x_return_status :=cux_api.handle_exceptions(p_pkg_name      => g_pkg_name,

p_api_name       => l_api_name,

p_savepoint_name => l_savepoint_name,

p_exc_name       =>cux_api.g_exc_name_others,

x_msg_count      =>x_msg_count,

x_msg_data       => x_msg_data);

END process_wip_completions;

WIP完工入库及完工退回的几个重要问题

1.必须向CST_COMP_SNAP_INTERFACE表中插入此工单全部工序的数据(也就是说相同的工单插入多条,仅仅是工序号不一样)

标准文档:

Note: If there are multiple operation sequences then,

Insert multiple records in CST_COMP_SNAP_INTERFACE, one record for each
OPERATION_SEQ_NUM in WIP_OPERATIONS for the appropriate WIP_ENTITY_ID (with the
same transaction_interface_id).

否则会出现故障:

(1)工单通过mtl_transactions_interface接口表,完工入库了。可是没有扣减最后一站移动站(to move站)数量
“接口表提交后,没有错误信息,数据成功提交了。;  查询物料交易事务处理表,此工单已有完工入库记录(库存也有添加)。但就是没有扣减最后一站移动站(to move站)数量(同一时候工单已完工量也没有对应添加)。

CST_COMP_SNAP_INTERFACE 表中的数据一点都不动(成本管理器正常)”

(2)报错:

CSTPACMS:validate_snap_interface 30 : OPERATION_SEQ_NUM in CST_COMP_SNAP_INTERFACE is missing or incorrect.

应为 不须要投料的工序也是要计算成本的,所以工单全部工序都必须插值。工序来自wip_operations

2.完工入库之前先移动工单至最后一道工序的move状态

3.完工退回之前先移动工单至第一道工序的排队状态

报错信息:

Serial number &TOKEN does not exist for the given item; and you cannot dynamically create a new one for this item.

解决:

metalink上的一些解决的方法

Wip Assembly Completion For A Job Through MTL_TRANSACTIONS_INTERFACE Is Not Updating Job Completed Quantity [ID 745112.1]
          改动时间 11-SEP-2010     类型 PROBLEM     状态 MODERATED

In this Document
  Symptoms
  Cause
  Solution
  References

Platforms: 1-914CU;

This document is being delivered to you via Oracle Support's Rapid Visibility (RaV) process and therefore has not been subject to an independent technical review.

Applies to:
Oracle Work in Process - Version: 11.5.9 to 12.0.4 - Release: 11.5 to 12
Information in this document applies to any platform.
Checked for relevance 11-SEP-2010
Symptoms
On 12.0.4 in Production:
Find that when WIP Assembly Completion transaction is performed for a Discrete job through
mtl_transaction_interface, the transaction is getting processed successfully but the completed
quantity is not getting updated in the Discrete job also quantity still remaining in To Move of
last operation.

EXPECTED BEHAVIOR
Expect that the quantity should get updated in the discrete jobs.

STEPS
The issue can be reproduced at will with the following steps:
1. Create a discrete job, release it
2. Perform Move transaction to the last operation to move step.
3. Perform WIP Assembly Completion through the MTI, it gets processed successfully
4. Verify the job header infoformation, still the quantity is not completed.

BUSINESS IMPACT
The issue has the following business impact:
Due to this issue, there is lot of discrepancy in the job.

.
Cause

The cause of the issue is invalid / incorrect data in cst_comp_snap_interface table.

The cause for this invalid data has been determined as the data in cst_comp_snap_interface corresponding
to completion record in MTI (linked with transaction_interface_id) was not populated with the correct op_seq_num.

This has explained in the following bug.
Bug 5746008  'CSTPACMS:VALIDATE_SNAP_INTERFACE 30' ERROR IN TRANSACTION OPEN INTERFACE

Customer was incorrectly populating the interface data.
cst_comp_snap_interface corresponding to completion record in MTI (linked with
transaction_interface_id) was not populated with the op_seq_num.

In the current scenario, user populated the op_seq_num but it is wrong value.

For any reference related to WIP Assembly Completion through MTI, can refer  Note 458801.1

Solution

To implement the solution, please execute the following steps:

1. Insert the correct operation sequence number in to cst_comp_snap_interface table which corresponds
to the operation sequence of that particular job.

Note: If there are multiple operation sequences then,

Insert multiple records in CST_COMP_SNAP_INTERFACE, one record for each
OPERATION_SEQ_NUM in WIP_OPERATIONS for the appropriate WIP_ENTITY_ID (with the
same transaction_interface_id).

2. Retest the issue.

References
NOTE:458801.1 - Standard API/Interface Needed to Perform Work Order Completion: WIP Assembly Completion Transaction For Discrete Jobs Can Be Performed Through Mtl_Transactions_Interface Table
SR 7174967.993

显示相关信息 相关的
产品

* Oracle E-Business Suite > Manufacturing > Discrete Manufacturing > Oracle Work in Process

keyword
CST_COMP_SNAP_INTERFACE; DISCRETE JOB; OPEN INTERFACES; COMPLETION TRANSACTIONS
错误
30 ERROR

详解EBS接口开发之WIP模块接口相关推荐

  1. android mqtt详解_安卓开发之mqtt协议

    首先物联网协议mqtt协议是基于tcp/ip协议的,使用了官方的mqttclient框架 /* *初始化mqttclient */ private void init() { try { //MQTT ...

  2. 详解EBS接口开发之采购申请导入

    更多内容可以参考我的博客  详解EBS接口开发之采购订单导入 http://blog.csdn.net/cai_xingyun/article/details/17114697 /*+++++++ ...

  3. 详解EBS接口开发之供应商导入(转载)

    详解EBS接口开发之供应商导入(转载) https://blog.csdn.net/f_zhangyu/article/details/80254191 (一)供应商常用标准表简介 1.1 常用标准表 ...

  4. 端口详解及如何开起端口关闭端口

    端口详解及如何开起端口关闭端口 端口概念 在网络技术中,端口(Port)大致有两种意思:一是物理意义上的端口,比如,ADSL Modem.集线器.交换机.路由器用于连接其他网络设备的接口,如RJ-45 ...

  5. android qt 串口通信,Qt串口通信开发之QSerialPort模块详细使用方法与实例

    Qt串口通信开发之QSerialPort模块详细使用方法与实例 发布时间:2020-10-23 12:19:05 来源:脚本之家 阅读:111 作者:沧海一笑-dj Qt串口通信基础及名词说明 串口通 ...

  6. 32 --> 详解 OpenWRT系统框架基础软件模块之netifd

    一.简介 OpenWrt路由操作系统的框架基础软件有很多,大部分是通用的软件模块,如 dhcp .dnsmasq.iproute.cmwp.vpn.ipsec等等:OpenWrt还集成部分具有专属特征 ...

  7. Pygame详解(十七):joystick 模块

    pygame.joystick 与游戏杆.游戏手柄.追踪球进行交互的 pygame 模块. 函数 pygame.joystick.init()  -  初始化 joystick 模块 pygame.j ...

  8. 【RK356X Android11】开发之4G模块(广和通模块NL668)

    目录 前言 一.Kernel调试 二.Android层调试 三.移植过程 四.问题与解决 前言   4G模块主要利用于无线上网和通话功能的移动设备,或者用以没有WIFI或者以太网的地方:这篇文章主要以 ...

  9. 硬件接口开发之Modem来电显示

    硬件接口开发之Modem来电显示 本文介绍下如何实现Modem的来电显示的功能.Modem的来电显示是在我最早的送水管理软件中实现的,大概是05年完成的,由于Modem的成本比较低(普通的在100元之 ...

最新文章

  1. Consultanting Service
  2. python pandas DataFrame 修改数据
  3. vector嵌套vector嵌套pair
  4. mac睡眠快捷键_告别Mac新手,MacOS电脑高手不得不会的10个使用技巧!
  5. 1562: 比较大小(思维)
  6. jquery的一个代码
  7. html transform属性,css3 transform属性详解
  8. 理解 Delphi 的类(七) - 认识类的多态
  9. 类Array对象中是否该直接使用Array的原型方法?
  10. java windows wrapper_Java Service Wrapper 发布Java程序为Windows服务
  11. 微信消息模板配置文档对接himall
  12. 超宽带 DWM1000模块 简介补充
  13. css建立一个简单的设备登记表,员工登记表格的CSS块
  14. 含泪整理最优质草食动物unity3d模型素材,你想要的这里都有
  15. hikaricp mysql_HikariCP 个人实例
  16. 二、SSM即Spring、SpringMVC、Mybatis整合
  17. Oracle 19c VLDB and Partitioning Guide 第1章:Introduction to Very Large Databases 读书笔记
  18. 软件工程导论—总体设计
  19. 北京圣思园JAVA培训教学视频汇总
  20. APP安全之SQL注入之什么是SQL注入(一)

热门文章

  1. latex 伪代码 algorithm2e方式
  2. 电话本管理系统(c++代码)
  3. [附源码]Java计算机毕业设计SSM儿童成长记录与分享系统
  4. 数字格式化工具:Numeral.js 简介
  5. 大数据学习笔记1:数据仓库的历史
  6. 服务器ap终端服务什么意思,终端与ap的连接过程是什么
  7. python使用hdfs库操作Hadoop的HDFS
  8. 倍福--控制汇川伺服出现报警
  9. FRM基础薄弱的你知道该如何高效率地进行备考嘛?
  10. 用二极管、三极管和MOS管搭建逻辑门电路