红木脚本的多个步骤

2020-08-17 02:05发布

点击此处---> 群内免费提供SAP练习系统(在群公告中)加入QQ群:457200227(SAP S4 HANA技术交流) 群内免费提供SAP练习系统(在群公告中)我正在尝试通过多个步骤来创建工作...

         点击此处--->   EasySAP.com群内免费提供SAP练习系统(在群公告中)

加入QQ群:457200227(SAP S4 HANA技术交流) 群内免费提供SAP练习系统(在群公告中)


我正在尝试通过多个步骤来创建工作。 您能否在下面的代码中为一步创建工作链提供帮助?

 {
 字符串pPartition =" GLOBAL";
 字符串jdName =" MyJobChainWithPreconditionABAP";
 字符串stepName =" Step1";


 尝试
 {
//获取或创建一个分区(如果尚不存在,在这里创建一个分区)
 分区partition = jcsSession.getPartitionByName(pPartition);
 如果(分区==空)
 {
 partition = jcsSession.createPartition();
 partition.setName(pPartition);
 }
 jcsOut.println("-使用分区" + pPartition); //检查类型为JOB_CHAIN(链定义)的Job Definition是否已经存在
 jcsOut.println("-检查作业定义" + jdName +"是否存在!");
 JobDefinition jDefinition = jcsSession.getJobDefinitionByName(partition,jdName);
 如果(jDefinition == null)
 {
//创建类型为JOB_CHAIN的JobDefinition(链定义)
 jcsOut.println("-JobDefinition" + jdName +"不存在,将被创建!");
 jDefinition = jcsSession.createJobDefinition();
 jDefinition.setName(jdName);
 jDefinition.setJobDefinitionType(jcsSession.getJobDefinitionTypeByName(JobDefinitionType.JOB_CHAIN));
 jDefinition.setPartition(partition); //通过一个步骤和一个工作链调用创建JobChain对象
 jcsOut.println("-用一个步骤和一个作业链调用创建JobChain对象");
 JobChain jchain = jcsSession.createJobChain();
 jchain.setJobDefinition(jDefinition); //创建步骤


 jcsOut.println("-创建步骤");
 JobChainStep jcstep = jchain.createJobChainStep();
 jcstep.setSequenceNumber(Long.valueOf(0));
 jcstep.setName(stepName); //工作链调用
 jcsOut.println("-创建工作链");
 JobChainCall jccall = jcstep.createJobChainCall(); //设置步骤参数
 jcsOut.println("-为SAP_AbapRun设置步骤参数");
 JobDefinition jDefinitionStep = jcsSession.getJobDefinitionByName(" SAP_AbapRun");
 jccall.setJobDefinition(jDefinitionStep);
 jccall.setSequenceNumber(Long.valueOf(0));
 JobChainCallInExpressionParameter jcciep = jccall.createJobChainCallInExpressionParameter();
 jcciep.setLocalJobDefinitionParameter(jDefinitionStep.getJobDefinitionParameterByName(" SAP_SYSTEMS"));;
 jcciep.setExpression(" XXX");
 jcciep = jccall.createJobChainCallInExpressionParameter();
 jcciep.setLocalJobDefinitionParameter(jDefinitionStep.getJobDefinitionParameterByName(" CLIENT"));
 jcciep.setExpression(" 010");
 jcciep = jccall.createJobChainCallInExpressionParameter();
 jcciep.setLocalJobDefinitionParameter(jDefinitionStep.getJobDefinitionParameterByName(" ABAP_PROGRAM_NAME"));;
 jcciep.setExpression(" Z_TST_IDLE");
 jcciep = jccall.createJobChainCallInExpressionParameter();
 jcciep.setLocalJobDefinitionParameter(jDefinitionStep.getJobDefinitionParameterByName(" JOBNAME"));;
 jcciep.setExpression(" Step1");
 jcciep = jccall.createJobChainCallInExpressionParameter();
 jcciep.setLocalJobDefinitionParameter(jDefinitionStep.getJobDefinitionParameterByName(" LANGUAGE"));;
 jcciep.setExpression(" EN");






 队列队列= jcsSession.getQueueByName(partition," System");
 jcsOut.println("-队列:" +队列);


 JobChainCallSchedulingParameter jccsp = jccall.createJobChainCallSchedulingParameter();
//JobChainCallSchedulingParameter jccsp = jcciep.createJobChainCallSchedulingParameter();
 jccsp.setName(SchedulingParameterName.Queue);
 jccsp.setExpression(queue.getBusinessKey()。getPath()。toString());
 }
 其他
 {
 jcsOut.println(" JobDefinition" + jdName +"存在!");
 jcsOut.println("您可以在以下行上更改JobDefinition名称:\ n字符串jdName = \" MyJobChainWithPrecondition \";");
 }
//提交更改
 jcsOut.println("-提交更改");
 jcsSession.persist(); //脚本成功完成
 jcsOut.println("-脚本成功完成");
 }
 捕获(异常e)
 {
 jcsErr.println(e.getMessage());
 抛出e;
 }
 }
 
2条回答
DafaDDDa
2020-08-17 02:45
我也尝试了此代码,但收到错误
 JCS-MULTI:发生多个错误
 20200612192529BST/8318d7e:com.redwood.scheduler.script.api.ScriptEngineEvaluationExceptionReturnCode = 2


 {
 字符串pPartition =" GLOBAL";
 字符串jdName =" MyJobChainWithPreconditionABAP1";
 字符串stepName =" Step1";




 尝试
 {
//获取或创建一个分区(如果尚不存在,在这里创建一个分区)
 分区partition = jcsSession.getPartitionByName(pPartition);
 如果(分区==空)
 {
 partition = jcsSession.createPartition();
 partition.setName(pPartition);
 }
 jcsOut.println("-使用分区" + pPartition); //检查类型为JOB_CHAIN(链定义)的Job Definition是否已经存在
 jcsOut.println("-检查作业定义" + jdName +"是否存在!");
 JobDefinition jDefinition = jcsSession.getJobDefinitionByName(partition,jdName);


//创建类型为JOB_CHAIN的JobDefinition(链定义)
 jcsOut.println("-JobDefinition" + jdName +"不存在,将被创建!");
 jDefinition = jcsSession.createJobDefinition();
 jDefinition.setName(jdName);
 jDefinition.setJobDefinitionType(jcsSession.getJobDefinitionTypeByName(JobDefinitionType.JOB_CHAIN));
 jDefinition.setPartition(partition); //通过一个步骤和一个工作链调用创建JobChain对象
 jcsOut.println("-用一个步骤和一个作业链调用创建JobChain对象");
 JobChain jchain = jcsSession.createJobChain();
 jchain.setJobDefinition(jDefinition); //创建步骤




 jcsOut.println("-创建步骤");
 JobChainStep jcstep = jchain.createJobChainStep();
 jcstep.setSequenceNumber(Long.valueOf(0));
 jcstep.setName(stepName); //工作链调用
 jcsOut.println("-创建工作链");
 JobChainCall jccall = jcstep.createJobChainCall(); //设置步骤参数
 jcsOut.println("-为SAP_AbapRun设置步骤参数");
 JobDefinition jDefinitionStep = jcsSession.getJobDefinitionByName(" SAP_AbapRun");
 jccall.setJobDefinition(jDefinitionStep);
 jccall.setSequenceNumber(Long.valueOf(0));
 JobChainCallInExpressionParameter jcciep = jccall.createJobChainCallInExpressionParameter();
 jcciep.setLocalJobDefinitionParameter(jDefinitionStep.getJobDefinitionParameterByName(" SAP_SYSTEMS"));;
 jcciep.setExpression(" XXX");






 JobChainCall jccall2 = jcstep.createJobChainCall(); //设置步骤参数
 jccall2.setJobDefinition(jDefinitionStep);
 jccall2.setSequenceNumber(Long.valueOf(0));
 JobChainCallInExpressionParameter jcciep2 = jccall.createJobChainCallInExpressionParameter();
 jcciep2.setLocalJobDefinitionParameter(jDefinitionStep.getJobDefinitionParameterByName(" SAP_SYSTEMS"));;
 jcciep2.setExpression(" XXX");








 队列队列= jcsSession.getQueueByName(partition," System");
 jcsOut.println("-队列:" +队列);




 JobChainCallSchedulingParameter jccsp = jccall.createJobChainCallSchedulingParameter();
 JobChainCallSchedulingParameter jccsp2 = jccall2.createJobChainCallSchedulingParameter();


 jccsp.setName(SchedulingParameterName.Queue);
 jccsp.setExpression(queue.getBusinessKey()。getPath()。toString());


 jccsp2.setName(SchedulingParameterName.Queue);
 jccsp2.setExpression(queue.getBusinessKey()。getPath()。toString());




//提交更改
 jcsOut.println("-提交更改");
 jcsSession.persist(); //脚本成功完成
 jcsOut.println("-脚本成功完成");
 }
 捕获(异常e)
 {
 jcsErr.println(e.getMessage());
 抛出e;
 }
 }
 

一周热门 更多>