Skip to content

Instantly share code, notes, and snippets.

@ankur0101
Last active June 4, 2025 09:34
Show Gist options
  • Save ankur0101/e21c98a2f342a8307931c90764fced19 to your computer and use it in GitHub Desktop.
Save ankur0101/e21c98a2f342a8307931c90764fced19 to your computer and use it in GitHub Desktop.
Setting TRACES for multiple iflows in SAP CPI
async function startPing(aiflows) {
const promise = $.ajax({
url: '/itspaces/ping',
method: 'GET',
headers: {
'Content-type': 'application/json',
'x-csrf-token': Global.CSRF_TOKEN.value
}
})
await promise;
this.timer_startPing = setTimeout(startPing, 1000 * 60 * 3)
}
async function setTrace() {
const pAll = []
const iflows = this.iflows
for (const flow of iflows) {
const promise = $.ajax({
url: '/itspaces/Operations/com.sap.it.op.tmn.commands.dashboard.webui.IntegrationComponentSetMplLogLevelCommand',
method: 'POST',
headers: {
'Content-type': 'application/json',
'x-csrf-token': Global.CSRF_TOKEN.value
},
data: JSON.stringify({
"artifactSymbolicName": flow.name,
"mplLogLevel": "TRACE",
"nodeType": "IFLMAP",
"runtimeLocationId": "cloudintegration"
})
})
pAll.push(promise)
}
await pAll
const seconds = 1000 * 60 * 9
this.timer_setTrace = setTimeout(setTrace, seconds)
this.titleUpdator(seconds)
}
async function getIflows(packageId) {
const promise = await $.ajax({
url: `/itspaces/api/1.0/contentpackage/${packageId}/artifacts?$resourceinfo=true`,
method: 'GET',
headers: {
'Content-type': 'application/json',
'x-csrf-token': Global.CSRF_TOKEN.value
},
success: function(response, satusText) {
debugger
//return response.filter(x => x.type === 'IFlow')
}
})
return promise.filter(x => x.type === 'IFlow')
}
async function getPackageId(name) {
return await $.ajax({
url: `/itspaces/odata/1.0/workspace.svc/ContentPackages('${name}')?$format=json&$select=reg_id`,
method: 'GET',
headers: {
'Content-type': 'application/json',
'x-csrf-token': Global.CSRF_TOKEN.value
},
success: function(response, satusText) {
//return response.filter(x => x.type === 'IFlow')
}
})
}
async function titleUpdator(countDownDuration){
const endTime = Date.now() + countDownDuration;
const interval = setInterval(function() {
const remaining = endTime - Date.now();
const secondsLeft = Math.round(remaining / 1000);
document.title = secondsLeft + ' seconds remaining';
if (remaining <= 0) {
clearInterval(interval);
document.title = 'Time is up!';
}
}, 1000);
}
async function start(){
const packageId = await this.getPackageId('<package-technical-name>')
this.iflows = await this.getIflows(packageId.d.reg_id)
const bSetTrace = await this.setTrace(iflows)
const bPingStarted = await this.startPing()
}
await start()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment