Tuesday 30 July 2024

Adhoc run interface for rerun on certain timeframes

 

This interface is build to run the interface in adhoc basis and this will run with particular interval or automatically run on the actual duration. 

On the interface failure this will not update the current time so on the next run this takes a time from the previous successful run. Due to this we will not miss any timeframe data.

Interface design




  1. SetParameter- Content modifier

2. Run Time Local process:



2.1 Store Last Successful Run-Content Modifier




2.2 Last run Log Message-Content Modifier





Body: 


<Record>

<AdhocRun>${property.AdhocRun}</AdhocRun>

<AdhocRun_Date>${property.AdhocRun_Date}</AdhocRun_Date>

<LastModifiedDateTime_adhoc>${property.last_modified_on_adhoc}</LastModifiedDateTime_adhoc>

<LastModifiedDateTime>${property.ITR_I004_LastSuccessfulRun}</LastModifiedDateTime>

</Record>


3. Time Stamp -Groovy Script:


import com.sap.gateway.ip.core.customdev.util.Message;

import java.util.Date;

import java.text.SimpleDateFormat;

import java.text.DateFormat;



def Message processData(Message message)

{


def pMap = message.getProperties();


def whereString = new StringBuffer();

def ITR_I004_LastSuccessfulRun_LV = pMap.get("ITR_I004_Update_LastSuccessfulRun");

def lastRun_var = pMap.get("LastRun")

def AdhocRun_Date_var = pMap.get("AdhocRun_Date")

def AdhocRun_var = pMap.get("AdhocRun")

def last_modified_on_adhoc_var  = pMap.get("last_modified_on_adhoc");

def currentDate_var = pMap.get("CurrentDate");


     

        if(AdhocRun_var.equals("false")){

   

            lastRun_var = ITR_I004_LastSuccessfulRun_LV

            currentDate_var = currentDate_var

            } 

        else{


            lastRun_var = lastRun_var

            currentDate_var = AdhocRun_Date_var

            

        }


int Count = 0 ;

 message.setHeader("Count", Count);

 

    message.setProperty("LastRun",lastRun_var);

    message.setProperty("CurrentDate",currentDate_var);


return message;

}


4. Write Variables



5. Getrow Query – Content Modifier

{

"operation": "GetRows",

"conditionalColumns": [{

"name": "UPDATEDDATE",

"value": [

"${property.LastRun}",

"${property.CurrentDate}"

],

"operation": "BETWEEN",

"dataType": "timestamp_ntz"

},

{

"name": "STATUS",

"value": "ACTIVE",

"operation": "EQUALS",

"dataType": "varchar"

}

]

}


Continue with the business logic after this…..


Exception Subprocess:



1. Router:



2. Write Variable:




3. Dummy Content Modifier:



Functionality to run this interface

Incase you want to run some previous timeframe:
1. When Adhoc is set as true then interface run with manual from and to time


Incase you want to run on some time and after the automate then delete the write variable in data store:
2. When Adhoc is set as true then interface run with default datetime provided in content modifier and to time(current time)


Incase you want to run on some time and after the automate then delete the write variable in data store:
3. When Adhoc is set as false then interface run with automatic from(previous write variable datetime) and to time(current time)



No comments:

Post a Comment