0% found this document useful (0 votes)
46 views16 pages

Script To Extract Job Chain Details - SAP Community

Uploaded by

ARPITA BISWAS
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
46 views16 pages

Script To Extract Job Chain Details - SAP Community

Uploaded by

ARPITA BISWAS
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 16

10/22/24, 3:05 PM Script to Extract job Chain details - SAP Community

m
m
Products and Technology Groups Partners Topics Events What's New Get
u
ni
t
y
SAP Community  Products and Technology  Technology  Technology Blogs by Members
 Script to Extract job Chain details

Technology Blogs by Members


Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP
products, technology, and events. Get in the mix!

Blog  What are you looking for today?

Script to Extract job Chain details

Former Member


‎2015 Feb 19 3:47 PM

 6 Kudos  3,818

SAP Managed Tags: SAP Business Process Automation by Redwood

Below script will help to extract all job chain parameter details .

import com.redwood.scheduler.api.model.*;
import java.util.*;

{
String P_PARAMETERS =
"SAP_SYSTEMS,CLIENT,ABAP_PROGRAM_NAME,ABAP_VARIANT_NAME,JOBNAME,N
AME,EXT_COMMAND_NAME,EXT_COMMAND_PARAMETERS,EXT_PROGRAM_NAME,
EXT_PROGRAM_PARAMETERS";
chains = new ArrayList();

https://community.sap.com/t5/technology-blogs-by-members/script-to-extract-job-chain-details/ba-p/13150373 1/16
10/22/24, 3:05 PM Script to Extract job Chain details - SAP Community

String query = "select jc.* from JobChain jc,JobDefinition jd"


+ " where jc.JobDefinition = jd.UniqueId"
+ " and jd.UniqueId = jd.MasterJobDefinition"
+ " and jd.UniqueId not in (select distinct JobChainCall.JobDefinition from
JobChainCall)";

for (Iterator it = jcsSession.executeObjectQuery(query, null); it.hasNext();)


{
JobChain jc = (JobChain)it.next();
JobDefinition jd = jc.getJobDefinition();
listChain(P_PARAMETERS, "", jd);
}
}

List chains;
Partition partition;

public void listChain(String P_PARAMETERS, String ident, JobDefinition jd)


{
jcsOut.print(ident + " " + jd.getPartition().getName() + "." + jd.getName());
String paramList = null;
String[] paramArray = P_PARAMETERS.split(",");
String paramValue = "";
for (int i = 0; i < paramArray.length; i++)
{
if (jd.getJobDefinitionParameterByName(paramArray[i]) != null)
{
if (paramList == null)
{
paramList = "";
}
paramValue =
jd.getJobDefinitionParameterByName(paramArray[i]).getDefaultExpression();
if (paramValue == null)
{
paramValue = "";
}
paramList = paramList + "(" + paramArray[i] + "=" + paramValue + ") ";
}

https://community.sap.com/t5/technology-blogs-by-members/script-to-extract-job-chain-details/ba-p/13150373 2/16
10/22/24, 3:05 PM Script to Extract job Chain details - SAP Community

}
if (paramList != null)
{
jcsOut.print(" " + paramList);
}
jcsOut.println("");
showEvents(ident, jd);
showChain(P_PARAMETERS, ident, jd);
jcsOut.println("");
jcsOut.println("");
jcsOut.println("");
}

public void showEvents(String ident, JobDefinition jd)


{
boolean hasEvents = false;
int raiseAantal = 0;
int waitAantal = 0;
// wait events
for (Iterator it = jd.getJobDefinitionWaitEvents(); it.hasNext();)
{
JobDefinitionWaitEvent re = (JobDefinitionWaitEvent)it.next();
jcsOut.println(ident + " <== " + re.getEventDefinition().getName());
hasEvents = true;
waitAantal++;
}
// raise events
for (Iterator it = jd.getJobDefinitionRaiseEvents(); it.hasNext();)
{
JobDefinitionRaiseEvent re = (JobDefinitionRaiseEvent)it.next();
jcsOut.println(ident + " ==> " + re.getEventDefinition().getName());
hasEvents = true;
raiseAantal++;
}
}

public boolean isParameterDefined(JobChainCall jc, String pName)


{
JobDefinitionParameter p =
jc.getJobDefinition().getJobDefinitionParameterByName(pName);

https://community.sap.com/t5/technology-blogs-by-members/script-to-extract-job-chain-details/ba-p/13150373 3/16
10/22/24, 3:05 PM Script to Extract job Chain details - SAP Community

return (p != null);
}

public String getParameterValue(JobChainCall jc, String pName)


{
String valueParam = null;
JobDefinitionParameter p =
jc.getJobDefinition().getJobDefinitionParameterByName(pName);
if (p != null)
{
if (jc.getJobChainCallInReferenceParameterByLocalJobDefinitionParameter(p) != null)
{
valueParam = "ref(" +
jc.getJobChainCallInReferenceParameterByLocalJobDefinitionParameter(p).getSourceJo
bDefinitionParameter().getName() + ")";
}
else
{
if (jc.getJobChainCallInExpressionParameterByLocalJobDefinitionParameter(p) !=
null)
{
valueParam = "expr(" +
jc.getJobChainCallInExpressionParameterByLocalJobDefinitionParameter(p).getExpressi
on() + ")";
}
else
{
if
(jc.getJobDefinition().getJobDefinitionParameterByName(pName).getDefaultExpression()
!= null)
{
valueParam =
jc.getJobDefinition().getJobDefinitionParameterByName(pName).getDefaultExpression();
}
else
{
valueParam = "";
}
}
}

https://community.sap.com/t5/technology-blogs-by-members/script-to-extract-job-chain-details/ba-p/13150373 4/16
10/22/24, 3:05 PM Script to Extract job Chain details - SAP Community

}
return valueParam;
}

public String buildParamList(String P_PARAMETERS, JobDefinition jd, JobChainCall ja)


{
String paramList = null;
String[] paramArray = P_PARAMETERS.split(",");
for (int i = 0; i < paramArray.length; i++)
{
if (isParameterDefined(ja, paramArray[i]))
{
if (paramList == null)
{
paramList = "";
}
paramList = paramList + "(" + paramArray[i] + "=" + getParameterValue(ja,
paramArray[i]) + ") ";
}
}
return paramList;
}

public void showChain(String P_PARAMETERS, String ident, JobDefinition jd)


{
String paramList = null;
JobChain jc = jcsSession.getJobChainByJobDefinition(jd);
if (jc != null)
{
for (Iterator it = jc.getJobChainSteps(); it.hasNext();)
{
JobChainStep js = (JobChainStep) it.next();

jcsOut.println(ident + " | ");


if (it.hasNext())
{
jcsOut.println(ident + " | " + " (step) "+ js.getName());
}
else
{

https://community.sap.com/t5/technology-blogs-by-members/script-to-extract-job-chain-details/ba-p/13150373 5/16
10/22/24, 3:05 PM Script to Extract job Chain details - SAP Community

jcsOut.println(ident + " + " + " (step) " + js.getName());


}
for (Iterator it2 = js.getJobChainCalls(); it2.hasNext();)
{
JobChainCall ja = (JobChainCall) it2.next();
paramList = null;
JobChain jcc = jcsSession.getJobChainByJobDefinition(ja.getJobDefinition());
paramList = buildParamList(P_PARAMETERS, jd, ja);
paramList = paramList;

String indent2 = " | ";


if (jcc == null)
{
jcsOut.print(ident + " +- " + ja.getJobDefinition().getPartition().getName() + "." +
ja.getJobDefinition().getName());
if (paramList != null)
{
jcsOut.print(" " + paramList);
}
if (ja.getJobDefinition().getTimeWindow() != null) {
jcsOut.print(" [" + ja.getJobDefinition().getTimeWindow().getName() + "]");
}
jcsOut.println("");
showEvents(ident + indent2, ja.getJobDefinition());
}
else
{
if (!chains.contains(ja.getJobDefinition().getPartition().getName() + "." +
ja.getJobDefinition().getName()))
{
chains.add(ja.getJobDefinition().getPartition().getName() + "." +
ja.getJobDefinition().getName());
jcsOut.print(ident + " +- " + " " + ja.getJobDefinition().getPartition().getName() +
"." + ja.getJobDefinition().getName());
if (paramList != null)
{
jcsOut.print(" " + paramList);
}
if (ja.getJobDefinition().getTimeWindow() != null) {
jcsOut.print(" [" + ja.getJobDefinition().getTimeWindow().getName() + "]");

https://community.sap.com/t5/technology-blogs-by-members/script-to-extract-job-chain-details/ba-p/13150373 6/16
10/22/24, 3:05 PM Script to Extract job Chain details - SAP Community

}
jcsOut.println("");
showEvents(ident + indent2, ja.getJobDefinition());
showChain(P_PARAMETERS, ident + indent2, ja.getJobDefinition());
}
else
{
jcsOut.print(ident + " +- " + " *** " +
ja.getJobDefinition().getPartition().getName() + "." + ja.getJobDefinition().getName() + "
***");
if (paramList != null)
{
jcsOut.print(" " + paramList);
}
if (ja.getJobDefinition().getTimeWindow() != null) {
jcsOut.print(" [" + ja.getJobDefinition().getTimeWindow().getName() + "]");
}
jcsOut.println("");
}
}
if (it2.hasNext())
{
jcsOut.println(ident + " |");
}
}
}
}
}

Tags:

cps cps report

7 Comments

https://community.sap.com/t5/technology-blogs-by-members/script-to-extract-job-chain-details/ba-p/13150373 7/16
10/22/24, 3:05 PM Script to Extract job Chain details - SAP Community

former_member212336
Explorer

‎2015 Feb 23 12:03 PM

 0 Kudos

Thank you very much for this, works perfect!

Question: Could the output be exported to Excel in any way?

former_member184334
Explorer

‎2015 Jun 19 11:01 AM

 0 Kudos

Hi gurbakhshindersingh,

Kindly let me know how to run this script in CPS.

Whether we have to run in report section or anywhere else.

I am having following query posting below scn thread.

JD Parameter export information from job chains

Please can you help me on this to get it done.

Appreciate your help.

https://community.sap.com/t5/technology-blogs-by-members/script-to-extract-job-chain-details/ba-p/13150373 8/16
10/22/24, 3:05 PM Script to Extract job Chain details - SAP Community

Regards

Zameer Ahamad

former_member184334
Explorer

‎2015 Jun 25 12:56 PM

 0 Kudos

Hi Experts,

Please anyone can look into my request.

We need to pull the report in excel or csv for the job definition which contains multiple
times in single chain and it is having parameters with different values.

Is it able to get all the details through any script or report to know all the values for the
particular job definition parameters.

former_member214642
Explorer

‎2016 May 22 7:33 PM

 0 Kudos

https://community.sap.com/t5/technology-blogs-by-members/script-to-extract-job-chain-details/ba-p/13150373 9/16
10/22/24, 3:05 PM Script to Extract job Chain details - SAP Community

Thanks Expert, the script is working perfectly in V9. However this is extracting whole
chain detail existing in CPS.Can this be customized as follows:

1- Can it be customized for only a single process chain?

2- Can it be customized to showcase all the ABAp parameter defined for each jobs
defined inside the chain.

3- Would be great if you can provide a script to extract the forecast report from cronacle
which will include the queue, application and partition.

Thanks a lot in advance!

Former Member


‎2017 Jun 05 2:41 PM

 0 Kudos

Hi ,

Could anyone please let us know how to run this script in CPS because we are not able
to find redwood script in definition. Also when we ran this script on shell in Scripting but
still no luck.

Thanks in Advance !!

Akash

https://community.sap.com/t5/technology-blogs-by-members/script-to-extract-job-chain-details/ba-p/13150373 10/16
10/22/24, 3:05 PM Script to Extract job Chain details - SAP Community

former_member482590
Discoverer

‎2018 Jun 06 8:53 PM

 0 Kudos

Hi

This does not work on redwood 8.0

It popped 100 + errors showing that " is an illegal character

Reg

Sharath

former_member710483
Discoverer

‎2021 Aug 20 1:30 PM

 0 Kudos

Hi ,

This works perfectly !

https://community.sap.com/t5/technology-blogs-by-members/script-to-extract-job-chain-details/ba-p/13150373 11/16
10/22/24, 3:05 PM Script to Extract job Chain details - SAP Community

But is there any way we can pull independent (single) job defination other than Job
chains/step ?

Along with their respective schedules, events, program and variants.

Thanks,

Puneet

 You must be a registered user to add a comment. If you've already registered,


sign in. Otherwise, register and sign in.

Comment

Labels In This Area


"aaMarian_Zeis_is_the_best" 1 "automatische backups" 1 "regelmäßige sicherung" 1

"SAP BW" 2 "SAP VARIANT CONFIGURAITION 2 "SAPDatasphere" 1

"TypeScript" "Development" "FeedBack" 1 2YM 1 3-TIER Extensibility 1

505 Technology Updates​53 1 @RetroDate_HireDateCorrection 1

@sapilm @archiving @sapiq 1

A Comprehensive Guide to Using OLE Objects in SAP ABAP 1 aATP 1 ABAP 35

ABAP 7.4 2 ABAP API 1 ABAP CDS VIEW 2 ABAP CDS Views 10

ABAP CDS Views - BW Extraction 3 ABAP CDS Views - CDC (Change Data Capture) 2

ABAP class 2 ABAP Cloud 4 ABAP Cloud Developer Trial 1

ABAP DDIC CDS view 1 ABAP Development 9 ABAP Environment & RAP 2

ABAP Extensibility 2 ABAP in Eclipse 3 ABAP New Syntax 1 ABAP OOABAP 1

ABAP Platform Trial 2 ABAP Programming 6 ABAP Push Channels 1

https://community.sap.com/t5/technology-blogs-by-members/script-to-extract-job-chain-details/ba-p/13150373 12/16
10/22/24, 3:05 PM Script to Extract job Chain details - SAP Community

ABAP Query 1 ABAP RAP 2 ABAP RAP custom action 1

ABAP RAP(RESTful Application Programming) 4 ABAP RESTFul API 1

ABAP RESTful Application Programming Model 2 ABAP String functions 1

abap technical 1 ABAP test cokpit 1 abap to xml 1 abapGit 1 absl 2

Access data from datasphere to ADF Azure Data Factory 2

access data from SAP Datasphere directly from Snowflake 1

Access data from SAP datasphere to Qliksense 2 Accessibility 1

Accessibility in SAPUI5 1 Accrual 1 Acquire SAC Knowledge 2 action 1

actions 1 adapter 2 adapter modules 1 ADDING LEAN SERVICES 2 Addon 2

Adobe Document Services 1 ADS 1 ADS Config 1 ADS with ABAP 1

ADS with Java 1 ADT 3 Advance Shipping and Receiving 1

Advanced Event Mesh 4 Advanced formula 1 Advanced Metric 1

Advanced SAP Techniques 1 Advanced Scripting in SAC 1 Advanced Workflow 1

AEM 1 AEM Event Portal 1 agile 2 agile development 1 agile teams 1 ai 15

AI Agents 1 AI Essentials 1 ai generated content 1 ai in transportation 1

AI Integration 2 AI Launchpad 3 AI Optimizer 1 AI Projects 2 AI TOOLS 1

aichallenges 1 aicompliance 1 aicreators 1 AIF Logs 1 AIML 11 aimodels 1

aiupdate 1 AL11 1 Alert in Sap analytical cloud 1 alm 1 ALM Nuggets 2

ALV 1 Amazon S3 1

Related Content
TECH DETAILS - E2E Oracle to SAP HANA Cloud migration with SAP Advanced SQL
Migration & SAP HANA SDI
in Technology Blogs by SAP Thursday

SAP BTP: The Foundation for Intelligent Enterprise with SAP Business AI
in Technology Blogs by SAP Thursday

How to submit Process definition in RunMyJobs aka Redwood aka SAP CPS
in Technology Blogs by Members Thursday

https://community.sap.com/t5/technology-blogs-by-members/script-to-extract-job-chain-details/ba-p/13150373 13/16
10/22/24, 3:05 PM Script to Extract job Chain details - SAP Community

Need help with printing of an https:// URL in background without reading the contents
in Technology Q&A Wednesday

DEMO - E2E Oracle to SAP HANA Cloud migration with SAP Advanced SQL Migration
& SAP HANA SDI
in Technology Blogs by SAP Tuesday

Popular Blog Posts

SAP PI for Beginners

former_member200339
Participant

 716426  153  387

https://community.sap.com/t5/technology-blogs-by-members/script-to-extract-job-chain-details/ba-p/13150373 14/16
10/22/24, 3:05 PM Script to Extract job Chain details - SAP Community

ABAP 7.40 Quick Reference

jeffrey_towell2
Explorer

 1172750  75  335

Fiori: technical installation and configuration of one app from A - Z

mstitsel
Active Participant

https://community.sap.com/t5/technology-blogs-by-members/script-to-extract-job-chain-details/ba-p/13150373 15/16
10/22/24, 3:05 PM Script to Extract job Chain details - SAP Community

 201208  133  300


Top Kudoed Authors

prashanth01  7

ManasaManu  6

MartinRaepple  5

raunak_varshney  4

vvdries  4

MichalKrawczyk  3

Bhavani_Baisani  3

Privacy Terms of Use

sooriyasudhakar  3
Copyright Legal Disclosure

fredrik_borlie  3
Trademark Support

Cookie Preferences
FreekKeijzer  3
Follow

View all

https://community.sap.com/t5/technology-blogs-by-members/script-to-extract-job-chain-details/ba-p/13150373 16/16

You might also like