Monday, 13 July 2015

API To Create Relationship Of Line With CONFIG Line Instance

To create relationship API CSI_II_RELATIONSHIPS_PUB.CREATE_RELATIONSHIP will be used as :-

DECLARE
V_RELATIONSHIP_ID       NUMBER;
X_RELATIONSHIP_TBL      CSI_DATASTRUCTURES_PUB.II_RELATIONSHIP_tbl;
X2_TXN_REC              CSI_DATASTRUCTURES_PUB.TRANSACTION_REC;
P2_COMMIT               VARCHAR2 (5);
P2_INIT_MSG_LST         VARCHAR2 (500);
P2_VALIDATION_LEVEL     NUMBER;
x2_return_status        VARCHAR2 (100);
x2_msg_count            NUMBER;
x2_msg_data             VARCHAR2 (2000);

l_object_id             NUMBER ;
l_subject_id            NUMBER ;
l_transaction_type_id   NUMBER ;
BEGIN
BEGIN
SELECT csi_ii_relationships_s.NEXTVAL
INTO V_RELATIONSHIP_ID
FROM DUAL;
EXCEPTION
WHEN OTHERS
THEN
V_RELATIONSHIP_ID := NULL;
END;
BEGIN
SELECT line_type_id
INTO l_transaction_type_id
FROM oe_order_lines_all 
WHERE line_id = <LINE_ID>;
EXCEPTION
WHEN OTHERS THEN
l_transaction_type_id := NULL;
END;
BEGIN
SELECT cii.instance_id
INTO l_object_id -- parent
FROM oe_order_lines_all oola, csi_item_instances cii
WHERE oola.line_id = cii.last_oe_order_line_id
AND oola.inventory_item_id = cii.inventory_item_id
AND oola.item_type_code = 'CONFIG'
AND oola.line_id = <LINE_ID>;
EXCEPTION
WHEN OTHERS THEN
l_object_id := NULL;
END;
BEGIN
SELECT cii.instance_id
INTO l_subject_id -- child
FROM oe_order_lines_all oola, csi_item_instances cii
WHERE oola.line_id = cii.last_oe_order_line_id
AND oola.inventory_item_id = cii.inventory_item_id
AND oola.line_id = <LINE_ID>;
EXCEPTION
WHEN OTHERS THEN
l_subject_id := NULL;
END;

X_RELATIONSHIP_TBL (1).RELATIONSHIP_ID := V_RELATIONSHIP_ID;
X_RELATIONSHIP_TBL (1).RELATIONSHIP_TYPE_CODE := 'COMPONENT-OF';
X_RELATIONSHIP_TBL (1).OBJECT_ID := l_object_id;             --22062065;
X_RELATIONSHIP_TBL (1).SUBJECT_ID := l_subject_id;           --33531940;
X_RELATIONSHIP_TBL (1).SUBJECT_HAS_CHILD := 'N';
X_RELATIONSHIP_TBL (1).POSITION_REFERENCE := NULL;
X_RELATIONSHIP_TBL (1).ACTIVE_START_DATE := SYSDATE;
X_RELATIONSHIP_TBL (1).ACTIVE_END_DATE := '';
X_RELATIONSHIP_TBL (1).DISPLAY_ORDER := NULL;
X_RELATIONSHIP_TBL (1).MANDATORY_FLAG := 'N';
X_RELATIONSHIP_TBL (1).CONTEXT := NULL;
X_RELATIONSHIP_TBL (1).ATTRIBUTE1 := NULL;
X_RELATIONSHIP_TBL (1).ATTRIBUTE2 := NULL;
X_RELATIONSHIP_TBL (1).ATTRIBUTE3 := NULL;
X_RELATIONSHIP_TBL (1).ATTRIBUTE4 := NULL;
X_RELATIONSHIP_TBL (1).ATTRIBUTE5 := NULL;
X_RELATIONSHIP_TBL (1).ATTRIBUTE6 := NULL;
X_RELATIONSHIP_TBL (1).ATTRIBUTE7 := NULL;
X_RELATIONSHIP_TBL (1).ATTRIBUTE8 := NULL;
X_RELATIONSHIP_TBL (1).ATTRIBUTE9 := NULL;
X_RELATIONSHIP_TBL (1).ATTRIBUTE10 := NULL;
X_RELATIONSHIP_TBL (1).ATTRIBUTE11 := NULL;
X_RELATIONSHIP_TBL (1).ATTRIBUTE12 := NULL;
X_RELATIONSHIP_TBL (1).ATTRIBUTE13 := NULL;
X_RELATIONSHIP_TBL (1).ATTRIBUTE14 := NULL;
X_RELATIONSHIP_TBL (1).ATTRIBUTE15 := NULL;
X_RELATIONSHIP_TBL (1).OBJECT_VERSION_NUMBER := 1;

X2_TXN_REC.TRANSACTION_DATE := TRUNC (SYSDATE);
X2_TXN_REC.SOURCE_TRANSACTION_DATE := TRUNC (SYSDATE);
X2_TXN_REC.TRANSACTION_TYPE_ID := l_transaction_type_id;         --1003;
X2_TXN_REC.OBJECT_VERSION_NUMBER := 1;
--
CSI_II_RELATIONSHIPS_PUB.CREATE_RELATIONSHIP (
p_api_version        => 1.0,
p_commit             => P2_COMMIT,
p_init_msg_list      => P2_INIT_MSG_LST,
p_validation_level   => P2_VALIDATION_LEVEL,
p_relationship_tbl   => X_RELATIONSHIP_TBL,
p_txn_rec            => X2_TXN_REC,
x_return_status      => X2_RETURN_STATUS,
x_msg_count          => X2_MSG_COUNT,
x_msg_data           => X2_MSG_DATA);
END;      

No comments:

Post a Comment

Lookup For Hold Release Reasons In Order Management

 Oracle has provided an OE lookup "RELEASE_REASON" where it stores all the hold release reason codes.  You can enter your release ...