Knowledge Base > Automation Engine and Target Systems > SAP > Compare values in SAP Spool lists

Compare Values in SAP Spool Lists

SAP Spool lists show print jobs that have not yet been transferred to a device. The data needed for printing or output on a device is temporarily saved to an intermediate format until they will be called. The values for such spool requests in the respective lists may be compared by using Automation Engine SAP jobs.

Comparing Spool Request Values - Workflow

Create a workflow with two SAP Job objects. Each Job produces a spool list. A third Job object will be used to compare the numbers of the spool list values.

When both Jobs have been finished, the values will be extracted from the spool lists and be passed to the third Job in the workflow.

The status of the workflow is set according to the comparison:

Numbers are equal ==> ENDED_OK

Numbers are unequal ==> ENDED_NOT_OK

 

Transferring Spool List Content to Job Report

Below you find an example of one of the two SAP Jobs in the workflow, each of them consisting of two steps:

In the first step the program is executed and in the second step the content of the spool list is added to the report.

The report of this job look like this:

It contains the Job log from SAP followed by the spool list.

Extracting Values

Job 1:

To extract the value from the spool list the following UC4 Script is used in the post process tab of the Job.

This script is executed after the Job has finished. It processes the report and extracts the values:

The PREP_PROCESS_REPORT function filters all rows which contain a "|" character.

This returns these values only:

| USD 123.456.789,01 1.234.567,89 |
| BEF 12.345.678.901 123.456.789 |
| KUD 123.456.789,01 365.413.243,87 |
| KUD 123.456.789,01 365.413.243,87

With PSET the object variable &JOB1_SUMME# of the Workflow is updated.

The workflow also contains a second variable &JOB2_SUMME# which is set by the second SAP Job.

 

Job 2:

The report of the second Job looks like this:

UC4 Script is also used in this case to get the value:

This script filters for all rows containing the word "SQ".The result is one row:

|SQ| 26|28.02.1995|365.413.243,86 | |DC-10-10| 380 | 2 |1.684,00 | 0 | 0 | 0 | 0 |

The character "|" is defined as separator of columns. Therefore the value 5 (variable &column#) can be used directly get 365.413.243,86 from the report.

STR_TRIM is used to remove spaces. The result is published as &JOB2_SUMME#

 

Compare Jobs

Both Jobs must have finished before the compare job may be started:

It has access to the variables &JOB1_SUMME# and &JOB2_SUMME#.

This Job has the setting "Generate at runtime" activated on the "Attributes" tab.

In this example it starts an SAP program with parameters that depend on the result of the comparison.

The simple program Z_INFO uses MESSAGE of the I or type E depending on the SUCCESS parameter:

REPORT Z_INFO.
parameter text1 type string.
parameter text2 type string.
parameter text3 type string.
parameter success type c.
if success is initial.
MESSAGE I002(SY) WITH text1.
MESSAGE I002(SY) WITH text2.
MESSAGE E002(SY) WITH text3.
else.
MESSAGE I002(SY) WITH text1.
endif.

 

The workflow can be set to ENDED_NOT_OK when the compare jobs fails:

Comments

The special parameter value (REPORT,REP) for the FILE parameter in the R3_GET_JOB_SPOOL command is not documented, but exists since v9.
Normally the R3_GET_JOB_SPOOL command can only write files. However the SAP Agent cannot read them. An OS Agent would be required to extract the values with PREP_PROCESS_FILE and delete the old files when they are not needed anymore. This would also be a possible solution, but more complex than the one described here.

See also:

SAP - Custom Solutions