Tuesday, March 10, 2020

Ways to Extract data from Oracle ERP Cloud through SOA

Why do we need to extract data from ERP Cloud? 
- Many times, there might be cases where we need to extract and share data to external systems. Unlike on-premise, we cannot query the source database of cloud directly through some adapter and get the data. 

So how do we get it? 
- Oracle Transaction Business Intelligence (OTBI) is the answer for it. Oracle ERP Cloud comes with Oracle Business Intelligence. Reports can be created through Oracle BI and ran to extract data.

Again, even through reports, there are different ways to extract data.

1) Create a BIP (Business Intelligence Publisher) report and run the report through webservice directly to extract the data
2) Create a Custom ESS job over the BIP report and extract data by calling webservice

We will go through the implementation steps and differences now.
Note: This blog does not cover the basics of ERP Cloud or Oracle SOA implementation.

Create a BIP report:

a. Login to BIP console. Click on home page -> More -> Reports and Analytics -> Select "Create Report" from dropdown -> Select New Data Model (PO_INVOICE_LINES). Under Diagram, select SQL Query.






b. Enter the sql query that you need to fetch relevant details.

c. Create new Report (PO_INVOICE_Report) based on the Data Model created above. I am saving the report into Shared_Folders/Custom/BIP_Reports/




d. Now edit the report. Select View a list at the upper right corner. In the "Output Formats" select both Data(CSV) and Data(XML).

Creating a report is common for both 1 and 2 methods.

1. Run BIP report

There are separate webservices to interact with Oracle BI Publisher. These services help to performs actions like schedule services, run reports, etc.

The service that specifically provides methods to interact with BI Publisher Report object is the ReportService
It is hosted at the following wsdl url -

http://{cloud-instance}/xmlpserver/services/v2/ReportService?wsdl

You can check oracle docs for the complete list of methods that ReportService provides.

In this case, we would need to call runReport() method, which sends request to the BI Publisher server to run a specific report.

a. Drop a SOAP adapter in your SOA composite. Give the wsdl url as below.

http://{cloud-instance}/xmlpserver/services/v2/ReportService?wsdl


b. Choose the operation as runReport. 

c. Map the following input through transformation in SOA.


reportAbsolutePath - Is the path at which we saved the newly created BIP report in Step c of "Create BIP Report" section above.

parameterNameValues - I have a query parameter in my sql which in Invoice Id. We should pass the same field name and value as defined in the report. If there are no parameters in your report, please ignore this section.


Sample request for runReport operation:
<runReport xmlns="http://xmlns.oracle.com/oxp/service/v2">
 <reportRequest>
   <reportAbsolutePath>/Financials/Receivables/Shared_Folders/Custom/BIP_Reports/PO_INVOICE_Report.xdo</reportAbsolutePath>
   <parameterNameValues>
     <listOfParamNameValues>
       <item>
          <name>INV_ID</name>
          <values>
            <item>1244785</item>
          </values>
        </item>
     </listOfParamNameValues>
   </parameterNameValues>
 </reportRequest>
 <userId>test</userId>
 <password>xyz</password>
</runReport>

d. Trigger the service from SOA. You would see that the report is ran successfully and response contains the data from the report returned in the form of base64.

Sample response from runReport operation:
<runReportResponse xmlns="http://xmlns.oracle.com/oxp/service/v2">
  <runReportReturn>
     <reportBytes>PEludm9pY2U+CiAgPEludklkPjEyNDQ3ODU8L0ludklkPgogIDxBbXQ+NTAuMDA8L0FtdD4KICA8SW52RGF0ZT4yMDE4LTA4LTExPC9JbnZEYXRlPgo8L0ludm9pY2U+</reportBytes>
  </runReportReturn>
</runReportResponse>

e. The base64 value in reportBytes is the actual response extract from the report execution. Convert it through any base64 conversion utility (say java code) and you can the response xml as follows -


<Invoice>
  <InvId>1244785</InvId>
  <Amt>50.00</Amt>
  <InvDate>2018-08-11</InvDate>
</Invoice>


2. Create Custom ESS Job

a. To create a Custom ESS job, login to ERP console. Go to Setup and Maintenance -> Name (Enter: Manage Custom Enterprise Scheduler Jobs for Financial and Supply Chain Management and Related Applications)

b. Go to Task Column and click on Create to navigate to create ESS job page.

c. Enter the following details -
 Display Name, Name, Path, Job application name.

JobType - This field defines that the ESS job is going to run a report at the backend. Enter BIPJobType for this field.

ReportId - In this field, enter the report name and path which was created in the above section Step c of "Create BIP Report"



Under Parameters section, enter the one parameter InvoiceId that we need to pass to the report.

Now your ESS job is ready to be executed.

Call service from SOA composite:

All services/operations related to ESS jobs are hosted at the following service url in ERP cloud

http://{cloud-instance}/fscmService/ErpIntegrationService?wsdl

d. Drop an Oracle ERP adapter in your SOA composite. In the wsdl url section, provide the Service Catalog url - https://{cloud-instance}/fscmService/ServiceCatalogService?WSDL

Under the Service section, choose ErpIntegrationService and operation as exportBulkData and complete the wizard.

exportBulkData operation - This operation helps to submit an ESS job to export the data from the report and upload the job output file to Universal Content Management (UCM) server with callback and notification.

e. Transform the input as follows and trigger the service from your composite -

Request:
jobName - This will contain the Path and JobName with comma separation.
parameterList - If any parameters are defined, we provide the value of it in this list.

Request:
<exportBulkData xmlns="http://xmlns.oracle.com/apps/financials/commonModules/shared/model/erpIntegrationService/types/">
  <jobName>oracle/apps/ess/financials/receivables/collections/shared,GetInvoiceDetails</jobName>
  <parameterList>1244785</parameterList>
  <jobOptions/>
  <callbackURL>#NULL</callbackURL>
  <notificationCode>00</notificationCode>
</exportBulkData>

Response:
<exportBulkDataResponse xmlns="http://xmlns.oracle.com/apps/financials/commonModules/shared/model/erpIntegrationService/types/">
  <result>170249</result>
</exportBulkDataResponse>


Response: A job would be created in Cloud and job Id will be returned through this service.


This service will export the response from the response in the form of CSV and load it into UCM. Based on the JobId returned here, we will have to invoke few more services to get the actual data from UCM.

I will publish the detailed steps of the consequent services needed in next blog posts.

runReport vs exportBulkData


runReport exportBulkData
Operation of ReportService from BI Publisher Services Operation of ErpIntegrationService
Runs Report directlyRuns the ESS job encapsulating the Report
Returns the extracted data immediately to the calling service Loads the extracted data into UCM
Not recommended to extract large set of data Apt method to extract large set of data
http://{cloud-instance}/xmlpserver/services/v2/ReportService?wsdl http://{cloud-instance}/fscmService/ErpIntegrationService?wsdl

These are two common ways to extracting the data from ERP Cloud.

Monday, March 9, 2020

FBDI - Load data into ERP Cloud from SOA

Before proceeding with this blog, please go through Manual FBDI in Oracle ERP Cloud as a pre-requisite for better understanding. 

When we plan to load data into ERP cloud through SOA integration, one question for which we need to find the answer is, "what are the services available in ERP cloud to aid this functionality?"

Oracle Enterprise Repository:

Oracle provides Enterprise Repository for Fusion Applications in which all supported services are listed. 

This is the link for OER. In the page that opens, click on Cloud Applications. Choose the module that is relevant to you. Lets take an example of Financials.

REST APIs - On the left pane, you would find REST API -> Financials. On clicking this, you would find "You can view a list of all REST Endpoints". This link will show you all the REST services that are available for financial cloud. You can check for the ones applicable in your scenario and use them.

SOAP services - There are two ways of getting the list of services.

1. Service Catalog -
https://{cloud-instance}/fscmService/ServiceCatalogService?WSDL
Replace {cloud-instance} with your cloud url.
This service returns information about your cloud instances, any new services and also helps to programmatically find and retrieve the required data to invoke SOAP services.
This webservice exposes two operations - getAllServiceEndpoints and getServiceEndpoint. With getAllServiceEndpoints operation, you can find the list of all SOAP services (along with wsdl urls) supported by your cloud instance.

<soapenv:Body xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <ns0:getAllServiceEndPointsResponse xmlns:ns0="http://xmlns.oracle.com/oracle/apps/fnd/applcore/webservices/types/" xmlns:ns1="http://xmlns.oracle.com/oracle/apps/fnd/applcore/webservices/">
    <ns1:result>
      <ns0:qName>{http://xmlns.oracle.com/apps/scm/productCatalogManagement/advancedItems/custExtn/model/extnService/}EgoAdvancedItemsReferenceService</ns0:qName>
      <ns0:lbo>SCM-SCM : EGP-Product Model : EGP_ITEM-Item</ns0:lbo>
      <ns0:lifecycle>Deprecated</ns0:lifecycle>
      <ns0:xsdLocation>https://{cloud-instance}/fscmService/EgoAdvancedItemsReferenceService?XSD=/oracle/apps/scm/productCatalogManagement/advancedItems/custExtn/model/extnService/EgoAdvancedItemsReferenceService.xsd</ns0:xsdLocation>
      <ns0:wsdlAddress>https://{cloud-instance}/fscmService/EgoAdvancedItemsReferenceService?WSDL</ns0:wsdlAddress>
      <ns0:serviceType>BUSINESS_OBJECT</ns0:serviceType>
    </ns1:result>
    <ns1:result>
      <ns0:qName>{http://xmlns.oracle.com/apps/financials/commonModules/shared/model/erpIntegrationService/}ErpIcsIntegrationService</ns0:qName>
      <ns0:lbo xsi:nil="true" />
      <ns0:lifecycle>Active</ns0:lifecycle>
      <ns0:xsdLocation>https://{cloud-instance}/fscmService/ErpIcsIntegrationService?XSD=/oracle/apps/financials/commonModules/shared/model/erpIntegrationService/ErpIcsIntegrationService.xsd</ns0:xsdLocation>
      <ns0:wsdlAddress>https://{cloud-instance}/fscmService/ErpIcsIntegrationService?WSDL</ns0:wsdlAddress>         
      <ns0:serviceType>BUSINESS_OBJECT</ns0:serviceType>
    </ns1:result>
    <ns1:result>
      <ns0:qName>{http://xmlns.oracle.com/apps/financials/commonModules/shared/model/erpIntegrationService/}ErpIntegrationService</ns0:qName>
      <ns0:lbo xsi:nil="true" />
      <ns0:lifecycle>Active</ns0:lifecycle>
      <ns0:xsdLocation>https://{cloud-instance}/fscmService/ErpIntegrationService?XSD=/oracle/apps/financials/commonModules/shared/model/erpIntegrationService/ErpIntegrationService.xsd</ns0:xsdLocation>
      <ns0:wsdlAddress>https://{cloud-instance}/fscmService/ErpIntegrationService?WSDL</ns0:wsdlAddress>
      <ns0:serviceType>BUSINESS_OBJECT</ns0:serviceType>
    </ns1:result>
  </ns0:getAllServiceEndPointsResponse>
</soapenv:Body>

Note: Above example has only 3 services listed. But the actual response would have the list of all services.
2. Oracle Help Center - In the above OER link, go to Cloud Applications -> Financials -> Tasks -> Integrate -> Click on Learn about ERP Cloud Integrations.
It will redirect you to Oracle support page, where you can find the details of the services.

https://{cloud-instance}/fscmService/ErpIntegrationService?WSDL is the cloud webservice in which you would find operations to import data to cloud, export data from cloud, submitting jobs, etc.

For FBDI, we are interested in the operation importBulkData. The JobDetails sections in importBulkData operation carry the job parameters, job definition, package name, callback url, etc, which need to be populated while invoking the service.

Integration from SOA:

Before we call importBulkData operation from SOA, we need to ensure that all the steps taken care as part of Manual FBDI in Oracle ERP Cloud blog are handled programmatically in our SOA process.

Here are the steps and their explaination -

1. Write csv file in the format of RaInterfaceLinesAll.csv we saw in the previous blog.

   a. Using file adapter in BPEL, convert the csv file from the previous blog to a schema. From BPEL, transform the input into file schema format, and using a WriteFile operation, write the input into a file (in your local cloud domain) with name RaInterfaceLinesAll.csv.

Note: The name of the file should be exactly same as what got auto-generated in the previous blog.

The adapter configuration looks as follows - 

<adapter-config name="writeInvoiceFile" adapter="file" wsdlLocation="../WSDLs/writeInvoiceFile.wsdl">
   <connection-factory location="eis/FileAdapter"/>
   <endpoint-interaction portType="writeInvoiceCSV_ptt" operation="WriteCSV">
      <interaction-spec className="oracle.tip.adapter.file.outbound.FileInteractionSpec">
         <property name="PhysicalDirectory" value="/tmp/invoice"/>
         <property name="Append" value="false"/>
         <property name="FileNamingConvention" value="RaInterfaceLinesAll.csv"/>
      </interaction-spec>
   </endpoint-interaction>
</adapter-config>

2. Create a zip file of the above csv file(s) created.
You can use java code to take files from the above location, zip it and write back to the same location.

3. Convert the zip into base64 format.
Here as well, we can use java code to convert the above zip file into base64 format.

4. Hit ERPIntegrationService, importBulkData operation with the job parameters and above base64 content as input.

Lets see what input this operation takes -

<typ:importBulkData>    
   <typ:document>      
      <erp:Content>{content in base64 format}</erp:Content>     
      <erp:FileName>AutoInvoiceImport.zip</erp:FileName>
      <erp:ContentType>zip</erp:ContentType>        
      <erp:DocumentTitle/>
      <erp:DocumentAuthor/>
      <erp:DocumentSecurityGroup/>
      <erp:DocumentAccount/>
      <erp:DocumentName/>
      <erp:DocumentId/>
   </typ:document>
   <typ:jobDetails>       
      <erp:JobName>/oracle/apps/ess/financials/receivables/transactions/autoInvoices/,AutoInvoiceImportEss</erp:JobName>       
      <erp:ParameterList>8098090,CONTRACT INTERNAL INVOICES,2018-07-01,#NULL,#NULL,#NULL,#NULL,#NULL,#NULL,#NULL,#NULL,#NULL,#NULL,#NULL,#NULL,#NULL,#NULL,#NULL,#NULL,#NULL</erp:ParameterList>       
      <erp:JobRequestId/>
   </typ:jobDetails>    
   <typ:notificationCode/>
   <typ:callbackURL/>
   <typ:jobOptions/>
</typ:importBulkData>
Content - This is the base64 content that we converted in step 3.
FileName - The zip file name that we created in Step 2.
ContentType - zip
JobName - As per my previous blog, the job that we used is Import AutoInvoice. But for the job parameter, the exact name can be derived as follows.

Go to ERP Cloud console -> Setup and Maintenance -> Search for Financials in the Setup dropdown -> Search for Manage Custom Enterprise Scheduler Jobs for Financials and Supply Chain Management and Related Applications.

The page shows a list of all the jobs available under Financials and Supply Chain Management and Related Applications.

Search for Import AutoInvoice. The result would show you details about Import AutoInvoice job. 



Click on the job link. You would see two fields Name and Path. The concatenation of Job path and Job name with a comma separation should be given in the JobName parameter in the above service.




Eg:/oracle/apps/ess/financials/receivables/transactions/autoInvoices/,AutoInvoiceImportEss

ParameterList - For this field, please refer to any manually submitted job.
Referring to the manual job I submitted in the previous blog - 
Image 2.7 - Import AutoInvoice Submitted Job Parameters

As per the image above, there are 20 arguments that need to be passed as input (in the same sequence). Give input for whatever fields applicable. For rest of them, pass #NULL.

Note: Parameter list is very important. Else the job submission will fail.

This way we can invoke the importBulkData operation from SOA.

Testing and Validation of the service:

1. Once you test your BPEL process and if importBulkData operation is successful, open the instance and see. You should find a jobId/processId returned in response. Just getting the jobId in response doesnt mean that the process completed successfully. 

You should validate it in ERP Cloud console.

2. Go to ERP Console -> Tools -> Scheduled Processes -> Search for the above JobId.

3. For one call made to importBulkData with above parameters, you can find the following jobs created in Cloud.
  • Load Interface File to Import
  • Transfer File
  • Load File to Interface
  • Import AutoInvoice
  • Import AutoInvoice: Execution Report
Jobs starting bottom up from the above image.

First three steps ensure that the data from the file is loaded to Interface tables.
Fourth step ensures that the data is loaded from interface tables to base tables.
The last step will show the entire execution log and also errors if any.


Wednesday, March 4, 2020

Manual File Based Data Integration in Oracle ERP Cloud

File Based Data Integration (FBDI) - a famous and simplified way of loading bulk data into Oracle ERP (Enterprise Resource Planning) cloud. This process allows one to load large data files into the tables of ERP.

In this blog, we will see how to manually upload data to ERP through FBDI process. Similar to on-premise EBS, Oracle ERP cloud also has many modules like Finance, Sales, SCM, etc. Each of them are different clouds with subscriptions. We will take one template from Oracle Financial Cloud as example.

For any kind of FBDI updates, templates have been predefined in Cloud and the data load can be done only and only in those formats.

1. Download FBDI template and Generate ZIP file:

1. First step is to download the required template. Go to google and type "Financials Fusion FBDI". Open the first link which says "File Based Data Import for Oracle Financials Cloud".

Note: For other clouds, you can search as "SCM Fusion FBDI", etc

2. You can see different FBDI templates for different operations like Invoice, Billing Data, Revenue, Receivables, etc. For our example, lets use AutoInvoice Import. 


1.1 FBDI Import Modules

3. Click on the link for AutoInvoice Import and down load the XLSM template - AutoInvoiceImportTemplate.xlsm
4. This template has different tabs. Ignore the Instructions tab for now. Rest of the tabs will to help load data into different tables.
5. Enter the data that you need to load in the excel template. In my example, I just need to load invoice data into Interface lines table. Hence, I entered data in just RA_INTERFACE_LINES_ALL tab.
1.2 FBDI Template with data

6. After the data has been prepared, go back to Instructions and CSV Generation tab and click Generate CSV File.
7. A zip file with name ArAutoinvoiceImport.zip is generated and a message "CSV and ZIP file have been generated" will appear on screen. 
8. If you extract the zip and see, you will find many CSV files. If data is added in all tabs of AutoInvoiceImportTemplate.xlsm, the zip will contain 4 CSV files. If data is added to one tab, only one CSV will be seen in the zip folder.

In my example, as I added data only in one tab, hence, I can see one CSV file with name RaInterfaceLinesAll.csv.


1.3 Generated ZIP and CSV


Now save the zip at some place. We will use this zip with data in ERP cloud console.

2. Load ZIP file into ERP Cloud:

Before we get into the technical aspects of how to load data into ERP cloud, lets first understand the concept of two tables in ERP - Interface tables and base tables. 
Interface tables are kind of staging tables. Data is present in Interface tables only until they are processed further and moved to base tables.
Base tables are the ones in which you can find the final data loaded into cloud. The same data will be visible in all screens of cloud.

1. Login to Oracle ERP Cloud console. Go to Tools -> Scheduled Processes.
2.1 ERP Console Scheduled Processes

2. Click on New Process. Search for job - "Load Interface File for Import".
2.2 Load Interface File for Import Job

Load Interface File for Import - This job allows any kind of imports into Cloud.
3. In the Import Process, enter name Import AutoInvoice. This job specifically loads Invoice data into cloud tables.
4. In the Data File, upload the ArAutoinvoiceImport.zip zip file that you saved in the above section and click on Submit. 
2.3 Load Interface File for Import Job Details

Job has been successfully created and Job Id will be shown on screen. Keep a note of this job id.

The above job extracts the data from the zip file and loads them into Interface tables.  You can see the log of the job and the file that has been loaded.


2.4 Load Interface File for Import Job Log

There is yet another step to move data from interface to base tables. 

Import Auto-Invoice: This job takes care of moving invoice data from interface tables to base tables. When we are loading data manually, we need to submit 2 jobs. But when submitting through a service, there is one service which takes care of the above two steps. Service details are not covered as part of this blog.
5. Go to Scheduled Processes again -> Click New Process and search for "Import AutoInvoice". This job will ask for many parameters like BU, Transaction Source, etc. Enter whatever is mandatory/applicable and click submit. 


2.5 Import Auto-Invoice Job Input


This job will do the following internally. If the interface table has 50 records, the job will filter the records based on the parameters submitted above, fetch the applicable records from interface table and load into the base table.

For eg: If the interface two records, one with Business Unit Name - US and other with UK. And in Import AutoInvoice job, you give the parameter as US, it will fetch and load only US record into base tables.

You can check the status of the job as follows - 


2.6 Import AutoInvoice Job Status



For the submitted job, you can also check the parameters that are passed. Keep a note of these parameters. When we try to trigger a service to create this job, we would need to pass all the below parameters to the service (including nulls).
2.7 Import AutoInvoice Submitted Job Parameters

This way, FBDI can be done manually. 

Before implementing FBDI process by calling the associated service in your relevant technologies, I would highly recommend the developer to perform this process once manually, so that you are aware of the steps that take place in the process and the parameters that need to be passed.