0% found this document useful (0 votes)
36 views4 pages

01-Xxgme Update Qty Insert Alloc

This procedure updates batch material lines based on item and quantity. It loops through each material line, updating the plan quantity from production data. If the quantity is greater than zero, it inserts an allocation record for the material line with the quantity, batch ID, date, warehouse and location. Any errors are logged.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views4 pages

01-Xxgme Update Qty Insert Alloc

This procedure updates batch material lines based on item and quantity. It loops through each material line, updating the plan quantity from production data. If the quantity is greater than zero, it inserts an allocation record for the material line with the quantity, batch ID, date, warehouse and location. Any errors are logged.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 4

-- START THE UPDATE OF THE BATCH MATERIAL LINES BASED ON THE ITEM AND QUANTITY

--batch_no = 005362
--batch_id = 96622 --96623
--item no = FSHDC00002-0
--item id = 689

create or replace procedure xxgme_update_qty_insert_alloc (p_batch_id number,


p_batch_no varchar2, p_prod_date date, p_whse_code varchar2, p_location varchar2)
as
--definition of update qty
cursor cur1 is
select a.material_detail_id, a.batch_id, a.line_no, a.item_id, b.item_no,
a.plan_qty, a.item_um, a.item_um2
from apps.gme_material_details a, apps.ic_item_mst b
where a.batch_id = p_batch_id
--and a.line_type = 1
and a.item_id = b.item_id
order by a.batch_id, a.line_no;

L_MATERIAL_DETAIL GME_MATERIAL_DETAILS%ROWTYPE;
X_MATERIAL_DETAIL GME_MATERIAL_DETAILS%ROWTYPE;
X_MESSAGE_COUNT NUMBER;
X_MESSAGE_LIST VARCHAR2 (1000);
X_RETURN_STATUS VARCHAR2 (1);
L_VALUE_TAB GME_API_PUB.FIELD_VALUES_TAB;
L_INDEX NUMBER;
L_BATCH_ID APPS.GME_BATCH_HEADER.BATCH_ID%TYPE;
L_MATERIAL_DETAIL_ID APPS.GME_MATERIAL_DETAILS.MATERIAL_DETAIL_ID%TYPE;
V_MATERIAL_DETAIL_ID APPS.GME_MATERIAL_DETAILS.MATERIAL_DETAIL_ID%TYPE;
P_VALIDATION_LEVEL NUMBER DEFAULT GME_API_PUB.MAX_ERRORS;
V_PLANT_CODE VARCHAR2 (10);
V_ITEM_ID NUMBER;
V_NUM NUMBER := 2;
V_SCALE_TYPE NUMBER;
V_COST_ALLOC NUMBER := 0;
V_CONTRIBUTE_YIELD_IND VARCHAR2 (10) := NULL;
V_ITEM_NO varchar2(40);
V_QTY_HEADS NUMBER;
V_QTY_KG NUMBER;
--definition for update qty

--definition for insert allocation


p_api_version NUMBER := gme_api_pub.api_version;
-- p_validation_level NUMBER := gme_api_pub.max_errors;
p_init_msg_list BOOLEAN := FALSE ;
p_commit BOOLEAN := FALSE ;
ltran_row gme_inventory_txns_gtmp%ROWTYPE;
p_lot_no VARCHAR2 (40) DEFAULT NULL;
p_sublot_no VARCHAR2 (40) DEFAULT NULL;
p_create_lot BOOLEAN DEFAULT FALSE;
p_ignore_shortage BOOLEAN DEFAULT FALSE ;
p_scale_phantom BOOLEAN DEFAULT FALSE ;
xa_material_detail gme_material_details%ROWTYPE;
x_tran_row gme_inventory_txns_gtmp%ROWTYPE;
x_def_tran_row gme_inventory_txns_gtmp%ROWTYPE;
xa_message_count NUMBER;
xa_message_list VARCHAR2 (4000);
xa_return_status VARCHAR2 (10);
LX_TRAN_ROW GME_INVENTORY_TXNS_GTMP%ROWTYPE;
LX_MATERIAL_DETAIL GME_MATERIAL_DETAILS%ROWTYPE;
LX_DEF_TRAN_ROW GME_INVENTORY_TXNS_GTMP%ROWTYPE;
--defintion for insert allocation

begin

--fnd_global.apps_initialize(user_id =>6987,
-- resp_id => null,
-- resp_appl_id => null);

--apps.Fnd_File.put_line('Update Batch ID =' || TO_CHAR (p_batch_id));

for c1 in cur1 loop


begin

begin
select b.item_no , sum(nvl(a.quantity_heads,a.quantity_kg)) qty_heads,
sum(nvl(a.quantity_kg,0)) qty_kg --defaults null head equal to quantity kg
into v_item_no, v_qty_heads, v_qty_kg
from sms.SMS_DC_PROD_V1_TEMP a, sms.SMS_ITEM_MASTER_LIST b
where a.prod_report_date = to_char(p_prod_date,'RRRR-MM-DD')
and a.sheet = 33
and a.classification is not null
and b.item_no = c1.item_no
and a.classification = b.sms_item_code (+)
group by b.item_no ;
exception when no_data_found then
v_qty_heads := 0;
v_qty_kg := 0;

end;

V_MATERIAL_DETAIL_ID := c1.material_detail_id;
L_MATERIAL_DETAIL.BATCH_ID := p_batch_id;
L_MATERIAL_DETAIL.MATERIAL_DETAIL_ID := c1.material_detail_id;
L_MATERIAL_DETAIL.PLAN_QTY := v_qty_kg;
L_MATERIAL_DETAIL.ITEM_ID := v_item_id;
L_INDEX := 1;
L_VALUE_TAB (L_INDEX).P_VALUE := 'PLAN_QTY';

GME_API_PUB.UPDATE_MATERIAL_LINE (
P_API_VERSION => 1,
P_VALIDATION_LEVEL => P_VALIDATION_LEVEL,
P_INIT_MSG_LIST => FALSE,
P_COMMIT => FALSE,
X_MESSAGE_COUNT => XA_MESSAGE_COUNT,
X_MESSAGE_LIST => XA_MESSAGE_LIST,
X_RETURN_STATUS => XA_RETURN_STATUS,
P_MATERIAL_DETAIL => L_MATERIAL_DETAIL,
P_VALUES_TAB => L_VALUE_TAB,
P_SCALE_PHANTOM => FALSE,
X_MATERIAL_DETAIL => XA_MATERIAL_DETAIL
);
-- TO DISPLAY THE RESULT OF THE ABOVE LINE UPDATE

GME_DEBUG.DISPLAY_MESSAGES (XA_MESSAGE_COUNT);
apps.Fnd_File.put_line(apps.Fnd_File.LOG, 'Update quantity of material
line = ' || TO_CHAR (c1.line_no) || ' and item = '||c1.item_no);
-- apps.Fnd_File.put_line('x_message_list ='|| LENGTH (XA_MESSAGE_LIST)||
SUBSTR (XA_MESSAGE_LIST, LENGTH (XA_MESSAGE_LIST) - 20, 20));
-- apps.Fnd_File.put_line('x_message_list =' || XA_MESSAGE_LIST);
apps.Fnd_File.put_line(apps.Fnd_File.LOG, 'Return status for material line
= ' || XA_RETURN_STATUS);
-- apps.Fnd_File.put_line('x_batch_header.batch_id= '|| TO_CHAR
(X_MATERIAL_DETAIL.PLAN_QTY));
if xa_return_status = 'E' then
xxgme_sms_insert_error (p_prod_date, p_batch_no, p_location, 'Insert Allocation',
'Update Material Line API', to_char(xa_message_count), xa_message_list);
end if;

end;

if v_qty_kg != 0 then
-- insert allocation
begin
LTRAN_ROW.DOC_ID := p_batch_id;
LTRAN_ROW.MATERIAL_DETAIL_ID := c1.material_detail_id;
LTRAN_ROW.WHSE_CODE := p_whse_code;
LTRAN_ROW.ALLOC_QTY := v_qty_kg;
LTRAN_ROW.TRANS_QTY := v_qty_kg;
LTRAN_ROW.TRANS_QTY2 := v_qty_heads;
LTRAN_ROW.TRANS_DATE := p_prod_date;
LTRAN_ROW.LOCATION := p_location;

GME_API_PUB.INSERT_LINE_ALLOCATION (
P_API_VERSION => 1,
P_VALIDATION_LEVEL => GME_API_PUB.MAX_ERRORS,
P_INIT_MSG_LIST => TRUE,
P_COMMIT => TRUE,
P_TRAN_ROW => LTRAN_ROW,
P_LOT_NO => ltrim(rtrim(p_whse_code||'DC'||
to_char(p_prod_date,'RRMMDD'))),
P_CREATE_LOT => TRUE,
X_MATERIAL_DETAIL => LX_MATERIAL_DETAIL,
X_TRAN_ROW => LX_TRAN_ROW,
X_DEF_TRAN_ROW => LX_DEF_TRAN_ROW,
X_MESSAGE_COUNT => X_MESSAGE_COUNT,
X_MESSAGE_LIST => X_MESSAGE_LIST,
X_RETURN_STATUS => X_RETURN_STATUS
);

-- apps.Fnd_File.put_line('x_message_count for line allocation ='||


TO_CHAR (X_MESSAGE_COUNT));
-- apps.Fnd_File.put_line('x_message_list = '|| LENGTH
(X_MESSAGE_LIST)|| SUBSTR (X_MESSAGE_LIST, LENGTH (X_MESSAGE_LIST) - 20, 20));
-- apps.Fnd_File.put_line('x_message_list for line allocation =' ||
X_MESSAGE_LIST);
apps.Fnd_File.put_line(apps.Fnd_File.LOG, 'Inserting allocations for
Material line.');
apps.Fnd_File.put_line(apps.Fnd_File.LOG, 'Return status for line
allocation = ' || X_RETURN_STATUS);

if x_return_status = 'E' then


xxgme_sms_insert_error (p_prod_date, p_batch_no, p_location, 'Insert Allocation',
'Insert Line Allocation API', to_char(x_message_count), x_message_list);
end if;

end;
end if;
--insert allocation

end loop;
end;
/

drop public synonym xxgme_update_qty_insert_alloc


/

create public synonym xxgme_update_qty_insert_alloc for


xxgme_update_qty_insert_alloc
/

grant all on xxgme_update_qty_insert_alloc to public


/

You might also like