How to call BIP Report from VBCS using JavaScript

How to call BIP Report from VBCS using JavaScript

How to call BIP Report from VBCS using JavaScript

In this section, we will see how to call BIP report from VBCS using JavaScript without Oracle Integration Cloud (OIC).

Let us create sample VBCS application and page to call BIP report on button click.

We will pass parameter to BIP report from Text field on VBCS page.

Follow the steps below to achieve the above requirements:

Step1: Create Sample VBCS application.

Navigate to VBCS URL and click on New.

A screenshot of a computer

AI-generated content may be incorrect.

A screenshot of a computer application

AI-generated content may be incorrect.

Click on Finish.

This will be launched below page:

A screenshot of a computer

AI-generated content may be incorrect.

Now create new Web apps:

A screenshot of a computer

AI-generated content may be incorrect.

Provide any valid Web application name.

A screenshot of a computer

AI-generated content may be incorrect.

Click on Create.

A computer screen shot of a computer

AI-generated content may be incorrect.

Now let us remove the Page header from the main page.

A screenshot of a computer

AI-generated content may be incorrect.

Remove code for Page header.

A screenshot of a computer

AI-generated content may be incorrect.

Step2: SOAP API details for calling BIP Report.

Let us consider the BIP report as shown below:

A blue and white screen with black text

AI-generated content may be incorrect.

Now we will call this report from VBCS using JavaScript by passing the report parameter from VBCS page item.

SOAP API for calling fusion BIP report is as follows:

WSDL : https://fa-XXXXXX-saasfaprod1.fa.ocs.oraclecloud.com:443/xmlpserver/services/ExternalReportWSSService?wsdl

Method: runReport

Content-Type: application/soap+xml; charset=UTF-8

Payload:

  1. <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:pub="http://xmlns.oracle.com/oxp/service/PublicReportService">
  2. <soap:Header/>
  3. <soap:Body>
  4. <pub:runReport>
  5. <pub:reportRequest>
  6. <pub:attributeFormat>csv</pub:attributeFormat>
  7. <pub:parameterNameValues>
  8. <pub:item>
  9. <pub:name>P_INVOICE_NUM</pub:name>
  10. <pub:values>
  11. <pub:item>1</pub:item>
  12. </pub:values>
  13. </pub:item>
  14. </pub:parameterNameValues>
  15. <pub:reportAbsolutePath>/Custom/VBCS/XX Test AP Invoice Report.xdo</pub:reportAbsolutePath>
  16. <pub:sizeOfDataChunkDownload>-1</pub:sizeOfDataChunkDownload>
  17. </pub:reportRequest>
  18. <pub:appParams>?</pub:appParams>
  19. </pub:runReport>
  20. </soap:Body>
  21. </soap:Envelope>

Sample Response:

  1. <env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope">
  2. <env:Header/>
  3. <env:Body>
  4. <ns2:runReportResponse xmlns:ns2="http://xmlns.oracle.com/oxp/service/PublicReportService">
  5. <ns2:runReportReturn>
  6. <ns2:reportBytes>77u/SU5WT0lDRV9JRCxWRU5ET1JfSUQsSU5WT0lDRV9OVU0sSU5WT0lDRV9DVVJSRU5DWV9DT0RFLFBBWU1FTlRfQ1VSUkVOQ1lfQ09ERSxJTlZPSUNFX0FNT1VOVCxWRU5ET1JfU0lURV9JRCxTT1VSQ0UsSU5WT0lDRV9UWVBFX0xPT0tVUF9DT0RFLEFQUFJPVkFMX1NUQVRVUwozMDAwMDAwMDI5NzYwMzAsMzAwMDAwMDAyOTEwOTE2LDEsVVNELFVTRCwwLDMwMDAwMDAwMjkxNjQ3MywiTWFudWFsIEludm9pY2UgRW50cnkiLFNUQU5EQVJELENBTkNFTExFRAo=</ns2:reportBytes>
  7. <ns2:reportContentType>text/plain;charset=UTF-8</ns2:reportContentType>
  8. <ns2:reportFileID xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
  9. <ns2:reportLocale xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
  10. <ns2:metaDataList xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
  11. </ns2:runReportReturn>
  12. </ns2:runReportResponse>
  13. </env:Body>
  14. </env:Envelope>
A screenshot of a computer

AI-generated content may be incorrect.

Step3: Create Service connection for BIP report in VBCS.

Navigate to Service connection and click on + Service connection.

A screenshot of a computer

AI-generated content may be incorrect.

Select “Define by Endpoint” as shown below:

A screenshot of a computer

AI-generated content may be incorrect.

A screen shot of a computer

AI-generated content may be incorrect.

Provide URL which we used in SOAP UI and select Action Hint as “Get One” and click on Create Backend.

https://fa-XXXXXX-saasfaprod1.fa.ocs.oraclecloud.com:443/xmlpserver/services/ExternalReportWSSService

Provide backend details as below:

A screenshot of a computer

AI-generated content may be incorrect.

Click on Next.

Provide Service Connection details as below:

A screenshot of a computer

AI-generated content may be incorrect.

Click on Request—>Headers and Provide content type

Content-Type: application/soap+xml; charset=UTF-8

A screenshot of a computer

AI-generated content may be incorrect.

Click on Test-to-verify Service Connection.

A screenshot of a computer

AI-generated content may be incorrect.

Click on Send Request.

A screenshot of a computer

AI-generated content may be incorrect.

Once response is verified. Click on Create.

Step4: Create VBCS page with Input Text field and Table region.

Create label field as shown below:

A screenshot of a computer

AI-generated content may be incorrect.

Now Create Input Text field:

A computer screen shot of a computer screen

AI-generated content may be incorrect.

Now go to Data and create variable to hold value for input Invoice Number.

A screenshot of a computer

AI-generated content may be incorrect.

A screenshot of a computer

AI-generated content may be incorrect.

Click on Create.

A screenshot of a computer

AI-generated content may be incorrect.

Now Create Table region.

A screenshot of a computer

AI-generated content may be incorrect.

Go to Data and create ADP variable to hold table data.

A screenshot of a computer

AI-generated content may be incorrect.

A screenshot of a computer

AI-generated content may be incorrect.

Click on Create.

A screenshot of a computer

AI-generated content may be incorrect.

Now let us define Type for this variable.

A screenshot of a computer

AI-generated content may be incorrect.

A screenshot of a computer

AI-generated content may be incorrect.

Add fields as per BIP report output manually as shown above.

Assign the above type to ADP variable.

A screenshot of a computer

AI-generated content may be incorrect.

Now add ADP fields on page.

A screenshot of a computer

AI-generated content may be incorrect.

Create Button on this page to call BIP report.

A screenshot of a computer

AI-generated content may be incorrect.

Run this application to verify changes.

A screenshot of a computer

AI-generated content may be incorrect.

Now we will add code on Submit button to call BIP report and display output in table.

Step5: Create Action Chain and JavaScript Code.

Go to Submit button properties —>Events and click on new Event Listener.

A screenshot of a computer

AI-generated content may be incorrect.

A screenshot of a computer

AI-generated content may be incorrect.

Now add below logic step by step to call BIP report from action chain.

  1. Assign Variable to store Request Payload.
A screenshot of a computer

AI-generated content may be incorrect.

Click on Create.

Click on Expression editor to assign static value to this variable.

A screenshot of a computer

AI-generated content may be incorrect.

A screen shot of a computer program

AI-generated content may be incorrect.

  1. `<soap:Envelope xmlns:soap=”http://www.w3.org/2003/05/soap-envelope” xmlns:pub=”http://xmlns.oracle.com/oxp/service/PublicReportService”>
  2. <soap:Header/>
  3. <soap:Body>
  4. <pub:runReport>
  5. <pub:reportRequest>
  6. <pub:attributeFormat>csv</pub:attributeFormat>
  7. <pub:parameterNameValues>
  8. <pub:item>
  9. <pub:name>P_INVOICE_NUM</pub:name>
  10. <pub:values>
  11. <pub:item>${$variables.Var_InvoiceNum_IN}</pub:item>
  12. </pub:values>
  13. </pub:item>
  14. </pub:parameterNameValues>
  15. <pub:reportAbsolutePath>/Custom/VBCS/XX Test AP Invoice Report.xdo</pub:reportAbsolutePath>
  16. <pub:sizeOfDataChunkDownload>-1</pub:sizeOfDataChunkDownload>
  17. </pub:reportRequest>
  18. </pub:runReport>
  19. </soap:Body>
  20. </soap:Envelope>`

Click on Save.

A screenshot of a computer

AI-generated content may be incorrect.

  1. Call BIP SOAP API using service connection:
A screen shot of a computer

AI-generated content may be incorrect.

A screenshot of a computer

AI-generated content may be incorrect.

Click on Select.

A screenshot of a computer

AI-generated content may be incorrect.

Click on Body and Map to variable created in step A.

A screenshot of a computer

AI-generated content may be incorrect.

Click on Save.

A screenshot of a computer

AI-generated content may be incorrect.

  1. Create JavaScript Function parse XML response and decode base 64.

Navigate to JavaScript section and add the code below.

A screenshot of a computer program

AI-generated content may be incorrect.

JavaScript Code:

  1. define([“ojs/ojarraydataprovider”], function(ArrayDataProvider) {
  2. ‘use strict’;
  3. class PageModule {
  4. getReportBytes(bipxmlResponse) {
  5. const parser = new DOMParser();
  6. const xmlDoc = parser.parseFromString(bipxmlResponse, “application/xml”);
  7. // Use localName or fully-qualified name with namespace handling
  8. const reportBytes = xmlDoc.getElementsByTagNameNS(
  9. http://xmlns.oracle.com/oxp/service/PublicReportService”,
  10. “reportBytes”
  11. )[0]?.textContent;
  12. const decodedString = atob(reportBytes);
  13. const lines = decodedString.trim().split(“\n”);
  14. const headers = lines[0].split(“,”);
  15. const jsonArray = lines.slice(1).map(line => {
  16. const values = line.split(“,”);
  17. const obj = {};
  18. headers.forEach((header, index) => {
  19. obj[header.trim()] = values[index]?.trim();
  20. });
  21. return obj;
  22. });
  23. return new ArrayDataProvider(
  24. jsonArray, { keyAttributes: “INVOICE_ID” });
  25. }
  26. }
  27. return PageModule;
  28. });

Now call this function from action chain.

A screenshot of a computer

AI-generated content may be incorrect.

Now pass output of step B as parameter to this function (bipxmlResponse).

A screenshot of a computer

AI-generated content may be incorrect.

Click on Save.

A screenshot of a computer

AI-generated content may be incorrect.

Note: Due to VBCS bug, it automatically adds single quotes around parameter value. We can remove that by editing code.

A screenshot of a computer

AI-generated content may be incorrect.

  1. Assign function response to ADP variable to display data.
A screenshot of a computer

AI-generated content may be incorrect.

Open expression editor for this assigned variable to assign reportBytes result.

A screenshot of a computer

AI-generated content may be incorrect.

Click on Save.

Now run the application.

A screenshot of a computer

AI-generated content may be incorrect.

Here we can see data is getting populated when we provide invoice numbers and click on Submit button.

Leave a Reply

Your email address will not be published. Required fields are marked *

Back To Top