Automatic transfer of variable values in BatchMan

Every SAP Basis admin knows this problem: Text variables and values in batch jobs, such as ident numbers of payment or dunning runs, can usually only be transferred manually to subsequent processes. To make this frequent activity easier for you, BatchMan offers an automatic transfer of variable values with the TXV report. This way, results can be searched in text variables and the values can be used directly for the next job.

In this documentation we show you with examples how you can use this report TXV from BatchMan version 5.1.3:

Search and replace variables

For searching, the text can be taken from the job log, spool list or application log. The report only runs in the background, but the search settings and the search results can be checked in test mode.

The report must be scheduled as the last step in the job so that it can examine the job data:

Screenshot search pattern in BatchMan
Search pattern in BatchMan

Before you save a variant for the /BTCMAN/C_TXV report, you can test the search criteria and the results in test mode:

Screenshot test mode job log in BatchMan
Test Mode in Joblog BatchMan
Screenshot Enter search criteria in test mode in BatchMan
Enter search criteria in test mode in BatchMan

In test mode you need a text for the search. This can be a job log, a spool list or a free text.

You can take a joblog or a spoollist of a job that has already been run and use it as a template. For this you have to enter a job name and a job count and load a text from the job.

Screenshot example of spool list search in test mode in BatchMan
Example of Spool list search in test mode in BatchMan

The text from the spool list or from the job log cannot be edited. However, you can select the text mode and edit the any texts.

ScreenshotExample of Text search in test mode in BatchMan
Example of Text search in test mode in BatchMan

You can now select the following combinations for the search pattern:

  • determine the start position with the search pattern,
  • determine the end position with the search pattern
  • or search pattern using the various options of the text to be extracted.

Press the Start Search button to start the search, and the search result will be displayed as text.

Screenshot Options for starting search pattern in BatchMan
Options for starting search pattern in BatchMan

The search result is a text that lies between a start and an end position.

For the determination of the start and end position one can use a text or a RegEx:

  • With an empty field Start position, the text from the start of the line / text to the end position was selected.
  • If the End position field is empty, the text from the start position to the end of the line / text was selected.
  • If both fields are ’empty’, the whole text was selected.


Example:

Screenshot Determination of start and end position in BatchMan
Determination of start and end position in BatchMan

A RegEx can also be used with the search pattern.

Example for the time/date selection with the RegEx in the text “STEP 001 started on 26.11.2020 16:05:00”:

Screenshot Suchmuster mit RegEX
Search pattern with RegEX

Screenshot Search pattern with RegEX Result
Search pattern with RegEX Result

Search pattern for the start/end position can also consist of two patterns connected with OR.

The found text can be further examined. The following search settings can be selected as search result:

  • All characters up to the end position: The result is a string between the found start and end position.
  • All characters up to the first space: The result is a string up to the first space after the found start position
  • Whole line: The result is the whole line if the start position was found
  • All numbers: From the found string all numbers are displayed as result
  • RegEx: The found string was examined with the RegEx

The following example shows how a found text can be further examined:

Screenshot Text Examination Example
Text Examination Example

Mit dem RegEx kann auch die Zeit aus dem Text gewählt werden:

Screenshot Time result with RegEx
Time result with RegEx

The found value was saved as a value for TVARV variable. If the entered TVARV variable is already created in the TVARVC table, the values are overwritten. Otherwise a new TVARV variable is created.

The TVARV variable can be used as a parameter or select option variable.

For the parameter variable, only the LOW values must be maintained in the search pattern; for the select option variable, the HIGH values can also be maintained.

Screenshot Parameter for variable in BatchMan
Parameter for variable in BatchMan

The Select-Options TVARV variables are maintained with the number. If the LOW and HIGH search criteria are maintained, the variable was updated with the BT option, and if only LOW is maintained, with the EQ option.

If more than one value is found, then:

  • for parameters, the first hit was saved as a value in the TVARV variable,
  • for select options, one number per hit was generated.
Screenshot LOW and HIGH search criteria in BatchMan
LOW and HIGH search criteria in BatchMan

If no text is found, the following actions can be triggered:

  • no action
  • Cancel job
  • Send message to a team
Screenshot No Text actions in BatchMan
No Text actions in BatchMan

The following example shows how the /BTCMAN/C_TXV report can be used:

A spool list was created in the job. The earliest and latest start times are to be determined with the report and saved as values in the TVARV variable.

The job consists of two steps: in step 1 a list was created, in step 2 the list was examined.

Screenshot Step list in BatchMan
Step list in BatchMan

Step 1 generates the following spool list:

Screenshot Spool list generated from Step in BatchMan
Spool list generated from Step in BatchMan

The report /BTCMAN/C_TXV runs in Step 2 with the following variant:

Screenshot Search pattern in Step 2 in BatchMan
Search pattern in Step 2 in BatchMan

The earliest start time should be saved as LOW value in the TVARV variable VL_SO_FR_SP, the latest start time – as HIGH value.

The results are already visible in the job log.

Screenshot Results in Job log in BatchMan
Results in Job log in BatchMan

In the TVARVC table you can now find a TVARV variable with the name VL_SO_FR_SP.

Screenshot TVARV Variable in BatchMan
TVARV Variable in BatchMan