cancel
Showing results for 
Search instead for 
Did you mean: 

Renaming parameterized jobs when scheduling

Former Member
0 Kudos

Hello,

I have a job chain where in the first step is a ABAP-Job with different parameters (e.g. SAP-System) fifteen times.

In the prerunning action I rename the jobs like SAP-System + "_" + Jobname.

While the job chain is only scheduled I cannot differ the jobs. So it is difficult to identify a job who e.g. should be canceled one time.

Is it possible to change the job name when the job chain will be scheduled? Is there another possibility to differ the jobs without expanding the parameters?

Best regards

Dana


Accepted Solutions (0)

Answers (2)

Answers (2)

h_carpenter
Active Contributor
0 Kudos

Hi Dana,

In the job monitor, you can use IntelliSearch to locate the specific job based on parameters :

p:ABAP_PROGRAM_NAME==rsusr007 p:ABAP_VARIANT_NAME==myVariant

Regards,

HP

nanda_kumar21
Active Contributor
0 Kudos

I guess you can try writing a trigger for either Before Job Pre Running or the Before Job on Change to change the job name.

Thanks

Nanda

gmblom
Active Contributor
0 Kudos

Hi Dana,

Like Nanda says, you can switch to an OnChange action instead of PreRunning and check for the status Scheduled:

if (jcsOnChangeContext.getNewStatus().equals(JobStatus.Scheduled))

{

... change the job name

}

Regards Gerben

Former Member
0 Kudos

Hello,

I checked the hint and it works fine with a single job, thanks.

But if the job is in a chain and in the job I use the OnChange-Action

if(jcsOnChangeContext.getNewStatus().equals(Jobstatus.Chained))

{

}

it doesn't work. Why not?

Best regards

Dana

h_carpenter
Active Contributor
0 Kudos

Hi Dana,

I assume it does not work because the Chained is the "first" status these jobs get.

So, use JobStatus.Scheduled as Gerben wrote, do

  // Get an iterator over the steps of the job chain

  for (Iterator it = jcsJob.getChildJobs(); it.hasNext();)

  {

    Job job = (Job) it.next();

  // Get an iterator over the jobs of the job chain step

    for (Iterator jt = job.getChildJobs(); jt.hasNext();)

    {

      Job j = (Job) jt.next();

       //code here to set job name

    }

  }

Regards,

HP

gmblom
Active Contributor
0 Kudos

Hello Dana,

Yes, the onchange does not fire for Chained status. You can try to loop through all of the childs of your chain from the top to set the description.

Or use the suggestion from HP below to search.

Regards Gerben

Former Member
0 Kudos

Hello,

it works fine with the OnChange-action and the iterator.

But have always a little problem.

If I define the parameter in the job chain definition I can use

j.setDescription("C_" + j.getJobParameterByName("SAP_SYSTEM").getInValueString() + "_" + j.getDescription().substring(6))

for setting the specific name of the job chain.

But I want to set the parameter "SAP_SYSTEM"  not in the definition but in the field "Input parameters". In this case j.getJobParameterByName("SAP_SYSTEM").getInValueString() is null.

Is it possible to use the input field value for the job chain name?

Best regards

Dana

PS: I hope it is not too confusing.

h_carpenter
Active Contributor
0 Kudos

Hi Dana,

Please check the name of the parameter, it should be SAP_SYSTEMS.

Try:

j.setDescription("C_" + j.getJobParameterByName("SAP_SYSTEMS").getInValueString() + "_" + j.getDescription().substring(6))

Regards,

HP