DECLARE
vOrganizationId wip_discrete_jobs_v.organization_id%TYPE := 00;
vWipEntityName wip_discrete_jobs_v.wip_entity_name%TYPE := 123456;
vOlditem mtl_system_items_vl.concatenated_segments%TYPE := 'A';
vNewitem mtl_system_items_vl.concatenated_segments%TYPE := 'B';
vGroupId wip_job_schedule_interface.group_id%TYPE;
vJob wip.wip_job_schedule_interface%ROWTYPE;
vRequirement wip.wip_job_dtls_interface%ROWTYPE;
vWipEntity wip_discrete_jobs_v%ROWTYPE;
vWipRequirement wip_requirement_operations_v%ROWTYPE;
vReturnStatus VARCHAR2(1);
vErrorMessage VARCHAR2(2000);
BEGIN
SELECT *
INTO vWipEntity
FROM wip_discrete_jobs_v wdj
WHERE wdj.organization_id = vOrganizationId
AND wdj.wip_entity_name = vWipEntityName;
SELECT *
INTO vWipRequirement
FROM wip_requirement_operations_v
WHERE organization_id = vWipEntity.organization_id
AND wip_entity_id = vWipEntity.wip_entity_id
AND concatenated_segments = vOlditem;
--app init
fnd_global.apps_initialize(user_id => 00, resp_id => 00, resp_appl_id => 00);
/*================================================
WIP_LOAD_TYPE MFG_LOOKUPS
------------ --------------
1 Create Standard Job
2 Create Repetitive Schedule
3 Update Discrete Job
4 Create Non–standard Job
================================================*/
vGroupId := wip.wip_job_schedule_interface_s.nextval;
vJob.load_type := 3;
vJob.last_update_date := SYSDATE;
vJob.last_updated_by := fnd_global.user_id;
vJob.creation_date := SYSDATE;
vJob.created_by := fnd_global.user_id;
vJob.process_phase := '2';
vJob.process_status := '1';
vJob.job_name := vWipEntity.wip_entity_name;
vJob.wip_entity_id := vWipEntity.wip_entity_id;
vJob.status_type := vWipEntity.status_type;
vJob.organization_id := vWipEntity.organization_id;
vJob.group_id := vGroupId;
vJob.header_id := vGroupId;
vJob.source_code := 'TEST';
INSERT INTO wip.wip_job_schedule_interface
VALUES vJob;
vRequirement.load_type := 2;
vRequirement.operation_seq_num := vWipRequirement.operation_seq_num;
vRequirement.department_id := vWipRequirement.department_id;
vRequirement.inventory_item_id_new := inv_value_to_id.Inventory_Item(p_organization_id => vOrganizationId,
p_inventory_item => vNewitem);
vRequirement.inventory_item_id_old := inv_value_to_id.Inventory_Item(p_organization_id => vOrganizationId,
p_inventory_item => vOlditem);
vRequirement.wip_supply_type := vWipRequirement.wip_supply_type;
vRequirement.date_required := vWipRequirement.date_required;
vRequirement.quantity_per_assembly := vWipRequirement.quantity_per_assembly;
vRequirement.required_quantity := vWipRequirement.required_quantity;
vRequirement.group_id := vGroupId;
vRequirement.parent_header_id := vGroupId;
vRequirement.substitution_type := 3;
vRequirement.process_phase := 2; --validation
vRequirement.process_status := 1; --pending
vRequirement.last_update_date := SYSDATE;
vRequirement.last_updated_by := fnd_global.user_id;
vRequirement.creation_date := SYSDATE;
vRequirement.created_by := fnd_global.user_id;
vRequirement.last_update_login := fnd_global.login_id;
INSERT INTO wip.wip_job_dtls_interface
VALUES vRequirement;
wip_massload_pub.massloadjobs(p_groupid => vGroupId,
p_validationlevel => 2,
p_commitflag => 0, -- Commit 1 =Yes , 0 ='No'
x_returnstatus => vReturnStatus,
x_errormsg => vErrorMessage);
dbms_output.put_line(vReturnStatus);
dbms_output.put_line(vErrorMessage);
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line(dbms_utility.format_error_stack);
END;
沒有留言:
張貼留言