Thursday, August 20, 2026

EBS R12.2.14 Script to Update the PO Requisition Lines

 DECLARE

    l_req_changes            po_req_changes_rec_type;

    l_line_changes           po_req_lines_rec_type;

    l_return_status          VARCHAR2 (1);

    l_msg_count              NUMBER;

    l_msg_data               VARCHAR2 (4000);


    -- Collections for line changes

    l_req_line_id            po_tbl_number := po_tbl_number ();

    l_unit_price             po_tbl_number := po_tbl_number ();

    l_curr_unit_price        po_tbl_number := po_tbl_number ();

    l_quantity               po_tbl_number := po_tbl_number ();

    l_sec_quantity           po_tbl_number := po_tbl_number ();

    l_need_by_date           po_tbl_date := po_tbl_date ();

    l_deliver_to_loc         po_tbl_number := po_tbl_number ();

    l_assign_start           po_tbl_date := po_tbl_date ();

    l_assign_end             po_tbl_date := po_tbl_date ();

    l_amount                 po_tbl_number := po_tbl_number ();


    l_new_quantity           NUMBER := 5;  -- the new quantity you want to set for all lines

    l_idx                    NUMBER := 0;


    CURSOR c_lines

    IS

        SELECT requisition_line_id

          FROM po_requisition_lines_all

         WHERE requisition_header_id = 1203243;

BEGIN

    mo_global.set_policy_context ('S', 81);

    fnd_global.apps_initialize (3699876

                              , 20707

                              , 201);


    -- Dynamically build collections from all lines under the header

    FOR rec IN c_lines

    LOOP

        l_idx := l_idx + 1;


        l_req_line_id.EXTEND;

        l_unit_price.EXTEND;

        l_curr_unit_price.EXTEND;

        l_quantity.EXTEND;

        l_sec_quantity.EXTEND;

        l_need_by_date.EXTEND;

        l_deliver_to_loc.EXTEND;

        l_assign_start.EXTEND;

        l_assign_end.EXTEND;

        l_amount.EXTEND;


        l_req_line_id (l_idx) := rec.requisition_line_id;

        l_quantity (l_idx) := l_new_quantity;

        l_unit_price (l_idx) := NULL;

        l_curr_unit_price (l_idx) := NULL;

        l_sec_quantity (l_idx) := NULL;

        l_need_by_date (l_idx) := NULL;

        l_deliver_to_loc (l_idx) := NULL;

        l_assign_start (l_idx) := NULL;

        l_assign_end (l_idx) := NULL;

        l_amount (l_idx) := NULL;

    END LOOP;


    DBMS_OUTPUT.put_line (   'Total lines to update: '

                          || l_idx);


    IF l_idx = 0

    THEN

        DBMS_OUTPUT.put_line ('No requisition lines found for header 1203243.');

        RETURN;

    END IF;


    -- Build the line changes object

    l_line_changes :=

        po_req_lines_rec_type (req_line_id => l_req_line_id

                             , unit_price  => l_unit_price

                             , currency_unit_price => l_curr_unit_price

                             , quantity    => l_quantity

                             , secondary_quantity => l_sec_quantity

                             , need_by_date => l_need_by_date

                             , deliver_to_location_id => l_deliver_to_loc

                             , assignment_start_date => l_assign_start

                             , assignment_end_date => l_assign_end

                             , amount      => l_amount);


    -- Build the main changes record

    l_req_changes :=

        po_req_changes_rec_type (req_header_id => 1203243

                               , line_changes => l_line_changes

                               , distribution_changes => NULL);


    -- Call the API

    po_req_document_update_grp.update_requisition (p_api_version => 1.0

                                                 , p_req_changes => l_req_changes

                                                 , p_update_source => 'PO'

                                                 , 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

        COMMIT;

        DBMS_OUTPUT.put_line ('All requisition lines updated successfully.');

    ELSE

        ROLLBACK;

        DBMS_OUTPUT.put_line (   'API failed with status: '

                              || l_return_status);


        FOR i IN 1 .. l_msg_count

        LOOP

            DBMS_OUTPUT.put_line (fnd_msg_pub.get (p_msg_index => i, p_encoded => fnd_api.g_false));

        END LOOP;

    END IF;

END;

/

Tuesday, July 30, 2024

Sample Payload for Creating Customer Account Relationships in Oracle Fusion

SOAP API: crmService/CustomerAccountService

Service Name: mergeCustomerAccount

Payload: 

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:typ="http://xmlns.oracle.com/apps/cdm/foundation/parties/customerAccountService/applicationModule/types/"
xmlns:cus="http://xmlns.oracle.com/apps/cdm/foundation/parties/customerAccountService/"
xmlns:cus1="http://xmlns.oracle.com/apps/cdm/foundation/parties/flex/custAccountContactRole/"
xmlns:par="http://xmlns.oracle.com/apps/cdm/foundation/parties/partyService/"
xmlns:sour="http://xmlns.oracle.com/apps/cdm/foundation/parties/flex/sourceSystemRef/"
xmlns:cus2="http://xmlns.oracle.com/apps/cdm/foundation/parties/flex/custAccountContact/"
xmlns:cus3="http://xmlns.oracle.com/apps/cdm/foundation/parties/flex/custAccountRel/"
xmlns:cus4="http://xmlns.oracle.com/apps/cdm/foundation/parties/flex/custAccountSiteUse/"
xmlns:cus5="http://xmlns.oracle.com/apps/cdm/foundation/parties/flex/custAccountSite/"
xmlns:cus6="http://xmlns.oracle.com/apps/cdm/foundation/parties/flex/custAccount/">
<soapenv:Header/>
<soapenv:Body>
<typ:mergeCustomerAccount>
<typ:customerAccount>
<!--Optional:-->
<cus:CustomerAccountId>100000024833854</cus:CustomerAccountId>
<!--Optional:-->
<cus:PartyId>100000014253697</cus:PartyId>
<!--Optional:-->
<cus:CreatedByModule>ORA_HZ_DATA_IMPORT</cus:CreatedByModule>
<!--Zero or more repetitions:-->
<cus:CustomerAccountRelationship>
<!--Optional:-->
<cus:CustomerAccountId>100000024833854</cus:CustomerAccountId>
<!--Optional:-->
<cus:RelatedCustomerAccountId>300000036314223</cus:RelatedCustomerAccountId>
<cus:CustomerReciprocalFlag>false</cus:CustomerReciprocalFlag>
<!--Optional:-->
<cus:Status>A</cus:Status>
<!--Optional:-->
<cus:BillToFlag>false</cus:BillToFlag>
<!--Optional:-->
<cus:ShipToFlag>true</cus:ShipToFlag>
<!--Optional:-->
<cus:StartDate>2024-07-31</cus:StartDate>
<!--Optional:-->
<cus:CreatedByModule>POS_SUPPLIER_MGMT</cus:CreatedByModule>
<!--Optional:-->
<cus:SetId>300000000003311</cus:SetId>
</cus:CustomerAccountRelationship>
</typ:customerAccount>
</typ:mergeCustomerAccount>
</soapenv:Body>
</soapenv:Envelope>

Sunday, April 7, 2024

Page Composer - Enabling Button and executing SOAP/REST API in Oracle fusion

Using Page Composer one can enable a custom Button and execute the SOAP/REST API dynamically by passing the parameters using the Bind parameters available in Oracle Fusion page. 
Follow the steps mentioned below.
 
Enable the Page Composer using Sandbox. (Configuration > Sandboxes > Create Sandbox)

Name : customButton
Publishable: Yes
Select Checkbox for Page Composer 

Navigate to the Page where the button needed. For the blog I'm creating the button On "Transactions" Page where user can click the button and submit an ESS job "Print Receivables Transactions" to print the invoice and attach the pdf to the invoice also send an copy of invoice to the customer. 

Navigate to Receivables > Billing > Manage Transaction

After opening the transaction window Click on Tools > Page Composer

Click On the "Structure" tab and pull the page towards Up from the bottom so that the technical components of the page can be visible.

Under the "Miscellaneous" Tab, just above the Generate Bill will be adding the Button so hover the cursor and select the main frame of the "Generate Bill" Section.

Click the Add "+" button on the Dock. Make sure the Frame element "panelFromLayout" is selected.

Click on "Open" next to "Component" in the Add Content window.

Click on "+ Add" next to the HTML Markup in the available components and click on "Close" button.

After adding the HTML Markup, you should see the "HTML Markup" is added on the page and two new elements added to "panelFormLAyout". 


Select the "<>outputTest: New HTML Markup" and click on gear icon (Show the properties of New HTML Markup).
In the "Component Properties" window click the Down arrow next to the "Value" and select the "Expression Builder".

In the "Expression Builder Copy paste the below code (Kindly modify the code as per your requirement" and test the code before deploying it in the Production or any of your environment. 


<html>
<body>
<button id="custCompleteAndReview" class="button" onclick="(function(p_org_id, p_trx_number){
//console.log('Parameters received are : '+p_org_id+'-'+p_trx_number);
var xmlhttp = new XMLHttpRequest();
var finalurl = 'https://' + window.location.host + '/fscmService/ErpIntegrationService';
xmlhttp.open('POST', finalurl, true);
credentials = 'Basic ' + 'c3ZjLnBOkludGVncmF0aW9zZXJAMTIzNA==';
xmlhttp.setRequestHeader('Authorization', credentials);
var sr = '<soapenv:Envelope xmlns:soapenv=&quot;http://schemas.xmlsoap.org/soap/envelope/&quot; xmlns:typ=&quot;http://xmlns.oracle.com/apps/financials/commonModules/shared/model/erpIntegrationService/types/&quot;> ' +
'<soapenv:Header/> ' +
'<soapenv:Body> ' +
'<typ:submitESSJobRequest> ' +
'<typ:jobPackageName>/oracle/apps/ess/financials/receivables/transactions/shared/</typ:jobPackageName> ' +
'<typ:jobDefinitionName>TransactionPrintProgramEss</typ:jobDefinitionName> ' +
'<typ:paramList>'+ p_org_id + '</typ:paramList> ' +
'<typ:paramList>#NULL</typ:paramList> ' +
'<typ:paramList>ANY</typ:paramList> ' +
'<typ:paramList>TRX_NUMBER</typ:paramList> ' +
'<typ:paramList>#NULL</typ:paramList> ' +
'<typ:paramList>#NULL</typ:paramList> ' +
'<typ:paramList>#NULL</typ:paramList> ' +
'<typ:paramList>#NULL</typ:paramList> ' +
'<typ:paramList>#NULL</typ:paramList> ' +
'<typ:paramList>#NULL</typ:paramList> ' +
'<typ:paramList>#NULL</typ:paramList> ' +
'<typ:paramList>#NULL</typ:paramList> ' +
'<typ:paramList>'+ p_trx_number + '</typ:paramList> ' +
'<typ:paramList>'+ p_trx_number + '</typ:paramList> ' +
'<typ:paramList>#NULL</typ:paramList> ' +
'<typ:paramList>#NULL</typ:paramList> ' +
'<typ:paramList>#NULL</typ:paramList> ' +
'<typ:paramList>N</typ:paramList> ' +
'<typ:paramList>#NULL</typ:paramList> ' +
'<typ:paramList>#NULL</typ:paramList> ' +
'<typ:paramList>#NULL</typ:paramList> ' +
'<typ:paramList>#NULL</typ:paramList> ' +
'<typ:paramList>PDF</typ:paramList> ' +
'<typ:paramList>Default Invoice Template</typ:paramList> ' +
'<typ:paramList>Default Credit Memo Template</typ:paramList> ' +
'<typ:paramList>Default Debit Memo Template</typ:paramList> ' +
'<typ:paramList>Default Chargeback Template</typ:paramList> ' +
'<typ:paramList>N</typ:paramList> ' +
'<typ:paramList>#NULL</typ:paramList> ' +
'<typ:paramList>-1</typ:paramList> ' +
'</typ:submitESSJobRequest> ' +
'</soapenv:Body> ' +
'</soapenv:Envelope> ' ;
xmlhttp.onreadystatechange = function () {
if (xmlhttp.readyState == 4) {
if (xmlhttp.status == 200) {
let result = extractResultValue(xmlhttp.responseText);
alert ('Print Receivables Transactions ESS job Submitted successfully. Process ID : ' + result );
}
}
}
xmlhttp.setRequestHeader('Content-Type', 'text/xml');
xmlhttp.send(sr);
function extractResultValue(text) {
var xmlStartIndex = text.indexOf('<env:Envelope');
var xmlEndIndex = text.lastIndexOf('</env:Envelope>') + '</env:Envelope>'.length;
var xmlContent = text.substring(xmlStartIndex, xmlEndIndex);

var parser = new DOMParser();
var xmlDoc = parser.parseFromString(xmlContent, 'text/xml');

var resultTag = xmlDoc.querySelector('result');
if (resultTag) {
return resultTag.textContent;
} else {
return null;
}
}
String.prototype.obfs = function(key, n = 126) {
if (!(typeof(key) === 'number' && key % 1 === 0)
|| !(typeof(key) === 'number' && key % 1 === 0)) {
return this.toString();
}
var chars = this.toString().split('');
for (var i = 0; i < chars.length; i++) {
var c = chars[i].charCodeAt(0);
if (c <= n) {
chars[i] = String.fromCharCode((chars[i].charCodeAt(0) + key) % n);
}
}
return chars.join('');
};
})('', '');return false" > Reprint</button>
</body>
</html> <!-- typo -->


Click on "Test" and Ok to close the Expression Builder Window. 
Click on Apply and OK button in the Component Properties window to close the Properties window. 


Test your code.












Sunday, March 31, 2024

Party / Organization / Customer Merge in Oracle Fusion

Profile Options:
==================
Role: Data Steward Manager
Task: Manage Administrator Profile Value

Set the below Profile options

ZCA_MERGE_REQUEST Site=Yes
ZCH_AUTO_MERGE_THRESHOLD level =0
ZCH_USER_MERGE_REQUESTS to have Allow processing without approval.

Please follow the next steps:

Step1: Navigate to Customer Data Management > Duplicate Resolution 
     > Task List > Create Resolution Request > Search for Customer 
     > select it > Create Request

Step2: Duplicate Resolution (CDM) > Request is in status Pending 
> select the row > Actions > Submit

Step3: Go to Setup and Maintenance > search for Run Request Dispatch Job 
> do not modify anything, just Submit

Step4: After Request ID run successfully > Return to Duplicate Resolution 
> Status is now New

Step5: Enter on Request ID > Override

Step6: Next > Select Accounts to be merged > Merge 
> You can choose the Master Account > Next > Next > Submit

Step7: Duplicate Resolution (CDM) > Request is in status Submitted

Step8: Go to Setup and Maintenance > search for Run Request Dispatch Job 
> do not modify anything, just Submit

Step9: Duplicate Resolution (CDM) > Request is in status Completed

Step10: Check Customer in Receivables > Billing > Manage Customers

The accounts are now merged

Tuesday, March 19, 2024

SOAP API to FindPerson (Contact Details) using FirstName and LastName

 SOAP API
===============
 https://servername/crmService/FoundationPartiesPersonService

Service Name
=================
findPerson

Sample Payload 
=================

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:typ="http://xmlns.oracle.com/apps/cdm/foundation/parties/personService/applicationModule/types/" xmlns:ns43="http://xmlns.oracle.com/adf/svc/types/">
   <soapenv:Header/>
   <soapenv:Body>
<typ:findPerson>
<typ:findCriteria>
<ns43:fetchStart>0</ns43:fetchStart>
<ns43:fetchSize>1</ns43:fetchSize>
<ns43:filter>
<ns43:group>
<ns43:item>
<ns43:attribute>PersonFirstName</ns43:attribute>
<ns43:operator>=</ns43:operator>
<ns43:value>Seth</ns43:value>
</ns43:item>
<ns43:item>
<ns43:attribute>PersonLastName</ns43:attribute>
<ns43:operator>=</ns43:operator>
<ns43:value>Laskarzewski</ns43:value>
</ns43:item>
</ns43:group>
</ns43:filter>
<ns43:sortOrder>
<ns43:sortAttribute>
<ns43:name>CreationDate</ns43:name>
<ns43:descending>true</ns43:descending>
</ns43:sortAttribute>
</ns43:sortOrder>
<ns43:childFindCriteria>
<ns43:fetchStart>0</ns43:fetchStart>
<ns43:fetchSize>1</ns43:fetchSize>
<ns43:filter>
<ns43:group>
<ns43:item>
<ns43:attribute>RoleType</ns43:attribute>
<ns43:operator>=</ns43:operator>
<ns43:value>CONTACT</ns43:value>
</ns43:item>
</ns43:group>
</ns43:filter>
</ns43:childFindCriteria>
</typ:findCriteria>
</typ:findPerson>
   </soapenv:Body>
</soapenv:Envelope>