cancel
Showing results for 
Search instead for 
Did you mean: 

Import Action

0 Kudos

Hello,

the following Import Action is working for one Job, but if I have a car-File with more than one JobDefinition I get an error message (attached file). What I have to Change so that the Action is working also for a bundle of JobDefinitions?

Import Action:


{

  for (Java.util.Iterator it = jcsImportRuleSet.getObjects().iterator(); it.hasNext();)

  {

    Object o = (Object) it.next();

    if (o instanceof JobDefinition)

    {

      JobDefinition jd = (JobDefinition) o;

      JobDefinition jdNeu = jd.duplicate();

      jdNeu.setName(jd.getName().replace("FIG","FIW"));

      jdNeu.setDescription(jd.getDescription().replace("FIG";"FIW"));

      jdNeu.setParentApplication(jcsSession.getApplicationByName(jd.getParentApplication().getName()replace("FIG","FIW")));

    }

  }

}

Best regards

Dana Ullrich

Accepted Solutions (1)

Accepted Solutions (1)

h_carpenter
Active Contributor
0 Kudos

Hi Dana,

In this case I would use an array, jcsImportRuleSet.size() will give you the total number of objects, even if not all are JobDefinitions, should be fine to initialize as the size of the List.

so:

Object[] jd = new Object[jcsImportRuleSet.size()];

int i = 0;

for(....
{
Object jd[i] = (Object) it.next();

if ( jd[i].instanceOf JobDefinition )

{

...

}

i++;
}

}

It does not work because you are overwriting o each time, that creates a dirty dirty list ... 😉

Regards,

HP

0 Kudos

Hello,

thanks for your fast help.

I combined your's and Gerben's answer an it works fine.

Best regards

Dana Ullrich

gmblom
Active Contributor
0 Kudos

Sorry HP,

You are overthinking and making things complex. Overwriting objects and the dirty list 'ist nicht im frage' here.

Regards Gerben

Answers (1)

Answers (1)

gmblom
Active Contributor
0 Kudos

Hi Dana,

My suspicion is that some of the object you try to create already exist in the target system. You cannot overwrite them like this. Maybe if you change your code like this it will work, but I would still doubt it. It is not really the way to do this.


  for (Java.util.Iterator it = jcsImportRuleSet.getObjects().iterator(); it.hasNext();) 

  { 

    Object o = (Object) it.next(); 

    if (o instanceof JobDefinition) 

    { 

      JobDefinition jd = (JobDefinition) o;

      String neuName = jd.getName().replace("FIG","FIW");

      JobDefinition jdNeu = jcsSession.getJobDefinitionByName(jd.getPartition(), neuName);

      if (jdNeu != null)

      {

        jdNeu.deleteObject();

      }

      jdNeu = jd.duplicate();

      jdNeu.setName(jd.getName().replace("FIG","FIW")); 

      jdNeu.setDescription(jd.getDescription().replace("FIG";"FIW")); 

      jdNeu.setParentApplication(jcsSession.getApplicationByName(jd.getParentApplication().getName()replace("FIG","FIW"))); 

    } 

  } 

Regards Gerben