Below anonymous block will Add Attachment to Sales order header level in Order Management.
(Note:
a ) Change values as per your requirement also ON DBMS Output window to see DBMS Output message.
b) Similarly you Can add attachment on On Line level wit suitable changes in Add_Attachment API. )
(Note:
a ) Change values as per your requirement also ON DBMS Output window to see DBMS Output message.
b) Similarly you Can add attachment on On Line level wit suitable changes in Add_Attachment API. )
DECLARE
l_rowid rowid;
l_attached_document_id NUMBER;
l_document_id NUMBER;
l_document_id1 NUMBER;
l_media_id NUMBER;
l_file_id NUMBER;
l_category_id NUMBER :=1000881; --1000728; -- Invoice Internal
l_pk1_value fnd_attached_documents.pk1_value%TYPE := '5';
l_description fnd_documents_tl.description%TYPE := 'WHT_Detail';
-- l_filename fnd_documents_tl.file_name%TYPE := 'b1.jpg.bmp';
l_seq_num NUMBER;
l_blob BLOB;
l_bfile bfile;
l_byte NUMBER;
l_return_status VARCHAR2(2000);
l_msg_count NUMBER(10);
l_msg_data VARCHAR2(1000);
l_debug_file VARCHAR2(200);
l_debug_level NUMBER := 5; -- OM DEBUG LEVEL (MAX 5)
l_org NUMBER := 194; -- OPERATING UNIT
BEGIN
-- INITIALIZATION REQUIRED FOR R12
mo_global.set_policy_context ('S', l_org);
mo_global.init('ONT');
-- INITIALIZE DEBUG INFO
IF (l_debug_level > 0) THEN
l_debug_file := OE_DEBUG_PUB.Set_Debug_Mode('FILE');
oe_debug_pub.initialize;
oe_debug_pub.setdebuglevel(l_debug_level);
Oe_Msg_Pub.initialize;
END IF;
-- INITIALIZE ENVIRONMENT
fnd_global.apps_initialize (user_id => 2106, resp_id => 50663, resp_appl_id => 660);
mo_global.set_policy_context ('S', 194);
--- context done ------------
dbms_output.put_line('Before Calling the API to Create_Short_Text_Document' );
Oe_Fnd_Attachments_Pub.Create_Short_Text_Document
(
p_api_version => 1.0,
p_document_text => 'PRPTEST NEW ORDER RECORD',
p_document_category =>l_category_id,
p_document_description =>'PRPTEST NEW desc',--l_doc_description,
p_language =>'AMERICAN',
p_security_type =>4,
p_security_id => NULL,
p_publish_flag =>'Y',
p_usage_type => 'O',
p_start_date_active => SYSDATE,
p_end_date_active => SYSDATE,
p_commit => 'Y',
x_document_id =>l_document_id,
x_return_status => l_return_status,
x_msg_count => l_msg_count,
x_msg_data => l_msg_data
);
IF l_return_status = FND_API.G_RET_STS_SUCCESS THEN
dbms_output.put_line('success:');
COMMIT;
ELSIF l_return_status IS NULL THEN
DBMS_OUTPUT.PUT_LINE('Status is null');
ELSE
DBMS_OUTPUT.PUT_LINE('failure:'|| l_msg_data ||'v_msg_count'||l_msg_count);
FOR i IN 1 .. l_msg_count
LOOP
l_msg_data := oe_msg_pub.get( p_msg_index => i, p_encoded => 'F');
dbms_output.put_line( i|| ') '|| l_msg_data);
END LOOP;
ROLLBACK;
END IF;
dbms_output.put_line('Before Calling the API to Add_Attachment' );
OE_FND_ATTACHMENTS_PUB.Add_Attachment
(
p_api_version =>1.0,
p_entity_name =>'OE_ORDER_HEADERS',
p_pk1_value =>l_pk1_value,
p_document_id =>l_document_id,
x_attachment_id =>l_document_id1,
x_return_status =>l_return_status,
x_msg_count =>l_msg_count,
x_msg_data =>l_msg_data
);
IF l_return_status = FND_API.G_RET_STS_SUCCESS THEN
dbms_output.put_line('success:');
COMMIT;
ELSIF l_return_status IS NULL THEN
DBMS_OUTPUT.PUT_LINE('Status is null');
ELSE
DBMS_OUTPUT.PUT_LINE('failure:'|| l_msg_data ||'v_msg_count'||l_msg_count);
FOR i IN 1 .. l_msg_count
LOOP
l_msg_data := oe_msg_pub.get( p_msg_index => i, p_encoded => 'F');
dbms_output.put_line( i|| ') '|| l_msg_data);
END LOOP;
ROLLBACK;
END IF;
END XXVIS5_PROC;
No comments:
Post a Comment