In this blog, We will see how can we add the custom XML segments/fields that can be extended in PO XML output.
PO_CUSTOM_XMLGEN_PKG package is the place where the business can implement their custom logic to bring the introducing/adding the XML segments/fields in PO XML outputs.
Package: PO_CUSTOM_XMLGEN_PKG
Procedure: generate_xml_fragment
PROCEDURE generate_xml_fragment
(p_document_id IN NUMBER
, p_revision_num IN NUMBER
, p_document_type IN VARCHAR2
, p_document_subtype IN VARCHAR2
, x_custom_xml OUT NOCOPY CLOB)
IS
–1). Declare context
context DBMS_XMLGEN.ctxHandle;
BEGIN
–2). Init context with custom query sql statement
context := dbms_xmlgen.newContext(‘select 1,2,3 from dual’);
–3). Set XML tag of the XML fragment for the result set
dbms_xmlgen.setRowsetTag(context,’CUSTOM_RESULT’);
–4). Set XML tag for each row of the result set
dbms_xmlgen.setRowTag(context,NULL);
dbms_xmlgen.setConvertSpecialChars (context, TRUE);
–5). Call dbms_xmlgen to get XML and assign it to output CLOB
x_custom_xml := dbms_xmlgen.getXML(context,DBMS_XMLGEN.NONE);
dbms_xmlgen.closeContext(context);
EXCEPTION
WHEN OTHERS THEN
–6). Capture any exceptions and handle them properly
NULL;
END;
*/