Saturday, December 14, 2024

OIC - Implementing Robust Error Handling with Backup Service and Custom Fault Response

Usecase:

Enhancing the API's resilience by introducing error handling to fall back to a backup service if the primary REST API for retrieving country details fails. Additionally, global fault handling will be implemented to deliver a custom fault response for consistent error messaging.

Primary service:

https://restcountries.com/v3.1/alpha/IND

Backup service:

https://api.worldbank.org/v2/country/IND?format=json

Logic steps:

  1. Create 2 Rest invoke connections for primary and backup services.
  2. Create a application integration and configure the trigger with
    1. Uri: /country/{code}
    2. Get operation
    3. Provide json response
  3. Configure Primary service Rest api
  4. Take a scope and keep the primary service inboke and map inside of it.
  5. Add scope fault handler and do the following
    1. Configure backup service
    2. Map the input code 
    3. Take a return action and map the details.
  6. Configure global fault
    1. Add  "throw new fault" action to send custom fault to OIC Error Hospital 
Trigger response:
{
    "name": "United States of America",
    "alpha2Code": "US",
    "alpha3Code": "USA",
    "capital": "Washington
}

Detailed screenshots:
































Friday, December 13, 2024

OIC - How can we adjust a date to ensure it falls on a valid working day, excluding weekends and public holidays while comparing the feeded input day with the header record date in javascript?

Usecase:

If the input day of D1 record is greater than the day of the value date of RH record, the year and month should be set at 1 month before the value date of RH record.

(Note: Input day may be any day of the month i.e. 01 to 31,

but value date can only be a working day, i.e. Monday to Saturday except public holidays)

Example 1:

If input day = 25, value date of RH record = 20020926 (Thursday)

Then the input date is derived as 20020925 (Wednesday)

Example 2:

If input day = 31, value date of RH record = 20020902 (Monday)

Then the input date is derived as 20020831 (Saturday)

Example 3:

If input day = 31, value date of RH record = 20030102 (Thursday)

Then the input date is derived as 20021231 (Tuesday)

Example 4:

If input day = 31, value date of RH record = 20030204 (Tuesday)

Then the input date is derived as 20030131 (Friday)

Example 5:

If input day = 25, value date of RH record = 20250104

Then the input date is derived as 20241226


Javascript codes used:

function deriveInputDate1(inputDay, rhValueDate, publicHolidays) {

  // Convert rhValueDate to a Date object

  const rhDate = new Date(rhValueDate.slice(0, 4), rhValueDate.slice(4, 6) - 1, rhValueDate.slice(6));

  // If inputDay is greater than the day of rhDate, adjust the year and month

  if (inputDay > rhDate.getDate()) {

    rhDate.setMonth(rhDate.getMonth() - 1);

  }

  // Set the date to the inputDay

  rhDate.setDate(inputDay);

  // Ensure the date is a working day (Monday to Saturday, excluding public holidays)

  // Sunday is a non-working day

  while (rhDate.getDay() === 0 || isPublicHoliday(rhDate, publicHolidays)) {

    rhDate.setDate(rhDate.getDate() + 1);

  }

  // Format the derived date as YYYYMMDD

  const derivedDate = rhDate.getFullYear() +

    ('0' + (rhDate.getMonth() + 1)).slice(-2) +

    ('0' + rhDate.getDate()).slice(-2);

  return derivedDate;

}

// Helper function to check if a date is a public holiday

function isPublicHoliday(date, publicHolidays) {

  // Format the date as YYYY-MM-DD for comparison

  const formattedDate = date.getFullYear() +

    ('0' + (date.getMonth() + 1)).slice(-2) +

    ('0' + date.getDate()).slice(-2);

  return publicHolidays.includes(formattedDate);

}

Screenshot of the code:


OIC steps for integration creation:








Test result:






Note: Create a lookup and store the public holidays list which we will call from oic and assign to a variable and map to the derived function in mapper to exclude the public holidays.


Wednesday, December 11, 2024

OIC - Major steps to import HDL file To HCM | Upload to UCM and Run import and load data job

Usecase:

Here, we will demonstrate how we can import worker data as HDL filwle to HCM using following multple steps:

  1. Upload the hdl file(.zip file) to ucm
    1. Security group: FAFusionImportExport
    2. Doc account: hcm$/dataloader$/import$/
  2. Run importAndLoadData operation 
    1. Query, create update or delete information >> HCMDataloader service

Detailed screenshots:


















Featured Post

11g to 12c OSB projects migration points

1. Export 11g OSB code and import in 12c Jdeveloper. Steps to import OSB project in Jdeveloper:   File⇾Import⇾Service Bus Resources⇾ Se...