Job Scheduling on SAP PO ( SAP PI Java stack )Posted: February 1, 2014 Filed under: SAP, SAP Java | Tags: java, SAP PI, SAP PO Leave a comment
From my post on SCN : http://scn.sap.com/community/pi-and-soa-middleware/blog/2014/02/01/job-scheduling-on-sap-po-sap-pi-java-stack
Job Scheduling on SAP PO ( SAP PI Java stack )
Scheduled jobs are one of the most common mechanisms to carry out repetitive tasks. In SAP ABAP stack, we have a comprehensive functionality to schedule jobs in SM36/SM37 etc.
With SAP PO being a SAP AS Java system, there is a need schedule jobs to carry out repetitive housekeeping tasks. However, there could sometimes be additional information to be sent out from SAP AS Java system – an example could be custom information from SAP AS Java tables. There’re web services creates by SAP but in some situations they may not be comprehensive enough for our requirements and hence a way needs to be found to send this information out regularly.
The below diagram describes our requirement – the system on left is SAP PI Java stack.
On the receiving side, it can be replaced by a different mechanism – e..g ABAP proxy if sending the information to an ABAP system.
1. Generate proxy for outbound interface: The steps are already described in my previous blog.
We’re using asynchronous mechanism in this case .Verify that Interface pattern is Stateless.
Initially I tried using a service interface with Stateless ( XI 3.0-Comptabible) but the generated proxy won’t have XI logical port .
Where as for FlightBookingOrderConfirmation_Out we get a XI Logical Port.
After this step, we have a web and an EAR project.
2. Generate a Job Bean : Create a normal EJB project and then use NWDS options to create a new “scheduler job”.
It’ll create an EJB project with a class file to write the logic for our job and extra descriptor files based on values provided in wizard.
job-definition.xml is a descriptor unique for jobs and holds the job name.
It should match the values generated in the Java file.
Looking at the SendAproxyAsync.java where we implement the job execution logic, add the Proxy Service name.
Main parts of this class:
Logger can be created to log information useful in troubleshooting issues.
and of course any errors can be logged.
Now, do the usual bit – create XI contect objects, update business data to be sent out and do the outbound proxy call.
Deploy this project.
3. Create an iFlow for this scenario – Nothing too complicated here .We need to create an iFLow for the sender / receiver / interface values. Make sure that the sender communication channel has XI as the message protocol.
4. Set up in NWA:
We can look at the job definition in NWA by going to Java Scheduler -> Job Definitions.
As we have already deployed our project, we can see the job definition here.
To start executing the job, we need to create a task specifying conditions ( as begin / end time / recurring frequency etc ) .
We select our job and complete the wizard – it’s similar to what we’ll give in SM37 on ABAP stack.
After this step, the jobs will start executing at the specified frequency.
‘’The executed jobs can be checked in the tab “Jobs”.
And a log can be displayed with the various messages we have put in the Job Bean – similar to messages on ABAP stack.
Verification : Navigate to PIMON and check messages
Logs confirm it’s working fine.
The code is at https://github.com/viksingh/PIJavaProxyAsJob . I’ve put the code for only the Java file as others are generated by wizards. For
troubleshooting, looking at system Java logs .