R12 – OPM Routing Creation using API
CURSOR c_routing_header IS
SELECT DISTINCT ROUTING_NO,
ROUTING_VERS,
ROUTING_DESC,
EFFECTIVE_START_DATE,
ROUTING_QTY,
ROUTING_UOM,
OWNER_ID,
OWNER_ORGANIZATION_ID,
ROUTING_STATUS,
DELETE_MARK
FROM mii_gmd_routing
WHERE flag IS NULL;
CURSOR c_routing_step (
p_routing_no varchar2
)
IS
SELECT ROUTINGSTEP_NO
, OPRN_NO
, STEP_QTY
, STEPRELEASE_TYPE
, ROUTINGSTEP_NO1
, DEP_ROUTINGSTEP_NO
, DEP_TYPE
, STANDARD_DELAY
, TRANSFER_PCT
, ROUTINGSTEP_NO_UOM
FROM mii_gmd_routing
WHERE flag IS NULL
AND routing_no = p_routing_no
ORDER BY routingstep_no;
l_routings gmd_routings%ROWTYPE;
l_routings_step_tbl gmd_routings_pub.gmd_routings_step_tab;
l_routings_step_dep_tbl gmd_routings_pub.gmd_routings_step_dep_tab;
l_count NUMBER := 0;
l_loop_cnt NUMBER := 0;
l_record_count NUMBER := 0;
l_data VARCHAR2 (4000);
l_return_status VARCHAR2 (1);
l_status VARCHAR2 (1);
i NUMBER := 1;
l_dummy_cnt NUMBER;
l_api_version NUMBER := 1;
l_init_msg_list BOOLEAN;
l_commit BOOLEAN;
return_sts BOOLEAN;
v_routingstep_no number;
v_oprn_id number;
v_oprn_no varchar2(100);
v_step_qty number;
v_steprelease_type number;
v_routingstep_no1 number;
v_dep_routingstep_no number;
v_dep_type number;
v_standard_delay number;
v_transfer_pct number;
v_routingstep_no_uom varchar2(100);
v_count number;
BEGIN
fnd_global.apps_initialize (user_id => 1090,
resp_id => 22882,
resp_appl_id => 552
);
l_init_msg_list := TRUE;
l_commit := TRUE;
FOR l_routing_header IN c_routing_header
LOOP
l_routings.routing_no := l_routing_header.routing_no;
l_routings.routing_vers := l_routing_header.routing_vers;
l_routings.routing_desc := l_routing_header.routing_desc;
l_routings.routing_qty := l_routing_header.routing_qty;
–l_routings.item_um := l_routing_header.item_um;
l_routings.routing_uom := l_routing_header.routing_uom;
l_routings.effective_start_date := l_routing_header.effective_start_date;
l_routings.owner_id := l_routing_header.owner_id;
l_routings.routing_status := l_routing_header.routing_status;
l_routings.delete_mark := l_routing_header.delete_mark;
l_routings.owner_organization_id := l_routing_header.owner_organization_id;
SELECT COUNT(*)
INTO v_count
FROM mii_gmd_routing
WHERE flag IS NULL
AND routing_no = l_routing_header.routing_no;
OPEN c_routing_step (l_routing_header.routing_no);
FOR i IN 1 .. v_count
LOOP
FETCH c_routing_step INTO v_routingstep_no,
v_oprn_no,
v_step_qty,
v_steprelease_type,
v_routingstep_no1,
v_dep_routingstep_no,
v_dep_type,
v_standard_delay,
v_transfer_pct,
v_routingstep_no_uom;
SELECT oprn_id
INTO v_oprn_id
FROM GMD_OPERATIONS_VL
WHERE oprn_no = v_oprn_no;
–dbms_output.put_line (‘v_oprn_id: ‘ || v_oprn_id);
l_routings_step_tbl (i).routingstep_no := v_routingstep_no;
l_routings_step_tbl (i).oprn_id := v_oprn_id;
l_routings_step_tbl (i).step_qty := v_step_qty;
l_routings_step_tbl (i).steprelease_type := v_steprelease_type;
–dbms_output.put_line (‘l_routings_step_tbl (‘||i||’).routingstep_no: ‘ || l_routings_step_tbl (i).routingstep_no);
–IF v_routingstep_no1 IS NOT NULL THEN
l_routings_step_dep_tbl (i).routingstep_no := v_routingstep_no1;
l_routings_step_dep_tbl (i).dep_routingstep_no := v_dep_routingstep_no;
l_routings_step_dep_tbl (i).dep_type := v_dep_type;
l_routings_step_dep_tbl (i).standard_delay := v_standard_delay;
l_routings_step_dep_tbl (i).transfer_pct := v_transfer_pct;
l_routings_step_dep_tbl (i).routingstep_no_uom := v_routingstep_no_uom;
–END IF;
UPDATE mii_gmd_routing
set flag = ‘Y’
WHERE routing_no = l_routing_header.routing_no
AND oprn_no = v_oprn_no;
END LOOP;
CLOSE c_routing_step;
–DBMS_OUTPUT.put_line (‘Value Test ‘ || l_routings.routing_no);
gmd_routings_pub.insert_routing
(p_api_version => 1.0,
p_init_msg_list => l_init_msg_list,
p_commit => l_commit,
p_routings => l_routings,
p_routings_step_tbl => l_routings_step_tbl,
p_routings_step_dep_tbl => l_routings_step_dep_tbl,
x_message_count => l_count,
x_return_status => l_return_status,
x_message_list => l_data
);
END LOOP;
IF l_count >= 0
THEN
l_loop_cnt := 1;
LOOP
fnd_msg_pub.get (p_msg_index => l_loop_cnt,
p_data => l_data,
p_encoded => fnd_api.g_false,
p_msg_index_out => l_dummy_cnt
);
DBMS_OUTPUT.put_line (‘Record = ‘ || l_loop_cnt);
DBMS_OUTPUT.put_line (l_data);
IF l_status = ‘E’ OR l_status = ‘U’
THEN
l_data := CONCAT (‘ERROR ‘, l_data);
END IF;
DBMS_OUTPUT.put_line (l_data);
IF (l_status = ‘U’)
THEN
l_return_status := l_status;
ELSIF (l_status = ‘E’ AND l_return_status <> ‘U’)
THEN
l_return_status := l_status;
ELSE
l_return_status := l_status;
END IF;
l_loop_cnt := l_loop_cnt + 1;
IF l_loop_cnt > l_count
THEN
EXIT;
END IF;
END LOOP;
END IF;
COMMIT;
END;
Leave a Reply
Want to join the discussion?Feel free to contribute!