SAP Rules
The SAP action rules can be used in any SAP process that accepts action rules. The results of these rules are stored in the RULE_RESULT
parameter.
ColumnGet
Retrieve column information from a space delimited list.
Notes for processing space delimited lists. This mainly refers to parameter minCols
in rule definitions.
- To select the correct lines, the first column is checked for being numeric.
- If no column should be checked to be numeric, add
#>!<
to<minCols>
. Note that this might not filter the list correctly!. - If another column should be used, add
#<col>
to<minCols>
. - If a numeric check is not possible, an amount check can be used instead. Add
##<col>
to<minCols>
. - If a list line starts or ends with a
|
, then these are automatically removed. - As the list line can contain descriptions, the number of columns is unclear for those after the description. In this case one can use negative column numbers which are calculated form the end.
Syntax
ColumnGet(<output selection>,<minCols>,<column>[[,<column>])
<output selection>
- List with Outputs. Defaults tostep1_spool1.txt
.<minCols>
- Minimum number of columns to expect. If the<minCols>
ends with!
, then no return code is set.<column>
- Column in report to retrieve. More columns can be added dynamically.
Example
You want to retrieve the account, item, and account type field from RFITEMGL
. You submit FCA_SAP_Abap_RFITEMGL
with the necessary parameters on the Variant, Accounting: Secondary Index for G/L Accounts. G/L Account Master (Chart of Accounts ), and G/L account master (company code) tabs. On the Infrastructure tab, fill the following into the Action Rule(s) to process field:
ColumnGet(,1#>!<!,1,2,3)
Result
The RULE_RESULT
parameter contains the following:
The;XYZ;Company|G/L;Account;100000|Company;Code;1000|Account;&<Vertical>Itm&<Vertical>AccTy&<Vertical>CoCd&<Vertical>S&<Vertical>Type;&<Vertical>Doc.|100000;&<Vertical>;1&<Vertical>S|100000;&<Vertical>;2&<Vertical>S[...]
ColumnGetByPosition
Retrieve column information by specifying columns by position and length.
Syntax
ColumnGetByPosition([[START=<text>,][[END=<text>,]<output selection>,<minChars>,<column>[[,<column>])
[START=<text>]
- Skip lines until line starts with<text>
including line found.[END=<text>]
- Stop processing when line starts with<text>
.<output selection>
- List with Outputs. Defaults tostep1_spool1.txt
.<minChars>
- Minimum number of characters to expect in a line. If the<minChars>
ends with!
, then no return code is set.<column>[,<column>]
- Column(s) in report to retrieve.Column is specified by<position>#<length>
.
Example
ColumnGetByPosition(START=T O T A L S F R O M A L L C O M P A N Y C O D E S, Step 1, job 2:step1_spool1.txt,110#>!<!,2#1,3#4,97#19)
Result
- The spool file is filtered first per line. Only lines with minimum 110 characters are kept. All others are excluded from the result.
- No numeric check is performed.
- No return code is set.
- 3 columns are retrieved, starting at positions 2 (length 1), 3 (length 4), 97 (length 19).
The result is set as merge record.
ConvertResultListAmounts
Process amounts in list and return converted result list.
Syntax
ConvertResultListAmounts(<cmd>[[=<option>][[,<cmd>])
<cmd>[=<option>]
- Command name with option to execute (can be a list of subsequent key words).E_ABS
- Replace the current field by its absolute value.E_ADD=<int>
- Add Current field to specified field. The result is provided as an extra element in the list.E_FORMAT=<format>
- Set the decimal separator to either period.
(<format>
set toPERIOD
) or comma,
(<format>
set toCOMMA
).E_NEGATE
- Set the absolute value to negative value.E_SUBTRACT=<int>
- Subtract the specified field from the current Field. The result is provided as an extra element in the list.FIELD=<int>
- Set field in result set to work on, if FIELD command is not specified, it is implicitly set to default 1.MAP=<string>
- Map value in tabledefault parameter by system
using prefix.MAX[=<int>[,<int>]
- Return only the highest result. Field specified are key fields.SUM[=<int>[,<int>]
- Return only the sum result. Field specified are key fields.
Example
INPUT="1;2,5-;3,22-|10,5-;7;4,11-" -> (FIELD=3,E_ABS,E_ADD=1) -> "1;2,5-;4,22|10,5-;7;6,39-"
DeleteSapJob
This rule will delete either the current SAP Job or the one specified.
Syntax
DeleteSapJob([[<jobName>,<jobCount>])
[<jobName>,<jobCount>]
- Optionally defined jobname and count. If not defined, the current SAP Job is deleted.
FilterResultListAmount
Filters the content of the result list using amounts.
Syntax
FilterResultListAmount([[<check>,]<action>,<options>[[,<option>])
[<check>]
Empty
- Flag that generates RC=4 if action execution produces an empty list.NotEmpty
- Flag that generates RC=4 if action execution produces a not empty list.NoForceCompleted
- Does not reset Error status of a job to completed, ignoring the Empty or NotEmpty indicator.
<action>
_Columns
<col>,<compare>,<col>
- Checks column<col>
against<col>
using operation and removes matching entries.ColSumZero,<col>,<col>
- Checks sum of columns<col>
is empty using operation and removes matching entries.ColZero,<cols>,<compare>
- Checks column<col>
is empty using operation and removes matching entries. Multiple columns can be used.ColValuei,<cols>,<compare>,<amounts>
- Checks column<col>
for<amounts>
using operation and removes matching entries. Multiple columns can be used.<amounts> ::= <amount>[<amounts>]
- More than one amount can be specified. (m cols, n amounts are possible). ForNE
andN_NE
anAND
compare is done, otherwise anOR
.
Parameter,<col>,<compare>,<parm>
- Checks column<col>
and check against parameter<parm>
value. The parameter can be relative or named.<compare>
BT
- Column value is between range.EQ
- Column value equals value.NB
- Column value is not between range.NE
- Column value not equal value.GT
- Column value greater than value.GE
- Column value greater / equal to value.LT
- Column value less than value.LE
- Column value less / equal to value.
Example
FilterResultListAmount(ColValue,1,2,BT,100..101,9..10)
- Removes entry from the list if 1st or the 2nd column is between 100..101 or 9..10.
INPUT: 100;a;b|c;150;d;e|f;200;g;h|99;i;j;k;l|h;9;mno;pqr;stu|10;aaa;bbb;ccc;ddd
RESULT: c;150;d;e|f;200;g;h|99;i;j;k;l
FilterResultListDate
Filters the content of the result list using dates. The date formatting of the user is automatically used.
Batch Date formatting is automatically taken into account.
Syntax
FilterResultListDate([[<check>,]<action>,<options>[[,<option>])
This removes the entry from the list if the 3rd column contains the date "01.01.2000".
[<check>]
Empty
- Flag that generates RC=4 if action execution produces an empty list.NotEmpty
- Flag that generates RC=4 if action execution produces a not empty list.
<action>
ColDate,<col>,<compare>,<date>
- Checks column<col>
against<date>
using<operation>
and removes entries that match.ColPeriod,<col>,<compare>,<period>[,<year>,<kokrs>,<bukrs>]
- Checks column<col>
against<period>
using<operation>
and removes entries that match.
(space) - Checks column
<col>
against<period>
using operation and removes entries that match.EQ
checks for date inside Period. The period is taken from the org unit provided or the current org unit.<compare>
- Compare Operations:EQ
- Column value equals value.NE
- Column value not equal value.GT
- Column value greater than value.GE
- Column value greater / equal to value.LT
- Column value less than value.LE
- Column value less / equal to value.
Example
FilterResultListDate(ColDate,3,EQ,01.01.2000))
GetDocumentUser
From the data transfer, retrieve the responsible Users. The users are stored in the data transfer and output parameter.
Syntax
GetDocumentUser(<col DocNo>[[,<col CC>[,<col FY>]])
<col DocNo>
- Column which contains the document number.[<col CC>]
- Column which contains the company code (Optional). Defaults to parameterBURKS
.[<col FY>]
- Column which contains the fiscal year (Optional). Defaults to parameterTASKLIST_YEAR
.
ALV Validation
ALV is a general technique used by many SAP reports to create the output that can be manipulated (columns, accumulation, sort, filter, export) by the end users in the SAP system. For batch processing it is often possible to define a specific Display Layout
to be used. As the layout used is generic, it can be used for the below validations without coding.
ALV reports usually contain levels representing group sums, subtotals or totals for the respective hierarchy level. Levels are often represented by asterisks. The number of asterisks represent the level in a report.
Rules for ALV validation contain a parameter <levels>
in which the level handling can be controlled.
In addition the first column of an ALV list is normally numeric or an amount. It is used to differentiate real entries from headers. If the handling in the action rule execution should be different, this can be specified in the Level parameter as described below.
Level handling within ALV validation
:- If no levels should be checked, set Levels to
>!<
. - If no column should be checked to be numeric, extend the level with
#>!<
. Note that this might not filter the list correctly !. - If another column should be used for the numeric check, then it can be defined by extending the level specification with
#<column>
, for example#1
. - If the column should be checked for amount instead of number use
##
instead of#
. - If the numeric check can only be performed on part of the field, then the level can be extended with
%<before>
(column is split and first part is taken) or%<len>
(first<len>
is taken, or last<len>
if negative is taken).
- If no levels should be checked, set Levels to
note
If a numeric value is put behind %
, for example %13
, it is interpreted as <len>
, so the first 13 characters are taken. If a character like value (including a SPACE) is put behind %
, for example %
, it is interpreted as <before>
, In the last example the column is split after the first occurrence of SPACE and the first part is taken.
ALVColumnCompare
The rule checks if the specified (numeric) columns in the report contain the same value (optionally within a range). Depending on the Operation requested, the ReturnCode is set.
Syntax
ALVColumnCompare(<output selection>,<level>,<column set>,<low>[[<<high][[,<sum>][[,<operation>])
<output selection>
- List with Outputs. Defaults tostep1_spool1.txt
.<level>
- Reporting level to filter (specify*
s or space for detailed level). Refer to general options of Level handling.<column set>
:=<column1>=<column2>
- Columns in report to compare.<low>[<<high>]
- Range to check. If<high>
is skipped, the comparison is only done on the Low value. If both are skipped, all values are compared.[<sum>]
:=SUM
- Instead of comparing columns, the sum of the columns is compared against zero.[<operation>]
:EQ
- Compare on equal (default).NE
- Compare on not equal.
Example
If you want to validate that in the spool output all numeric values in column 5 are the same as the numeric values in column 6 on level '', you need to validate there is no example on level '' where column 5 is not equal column 6.
The rule would look as follows:
ALVColumnCompare(*,*,5=6,,NE)
The rule will set a return code there is a record on level **
where the values in columns 5 and 6 differ.
ALVColumnGet
The rule retrieves specified column values from the report.
The RULE_RESULT
will contain a list with resulting values. If single column is retrieved, a comma separated list is returned. Otherwise a MergeResult list is returned which can be used directly in a loop.
Syntax
ALVColumnGet(<output selection>,<level>,<column>[[,<column>])
<output selection>
- List with Outputs. Defaults to step1_spool1.txt.<level>
- Reporting level to filter (specify*
s or space for detailed level). If the<level>
ends with!
, then no return code is set.<column>
- Column value(s) to retrieve.
Example
ALVColumnGet(,!,1,2,3,4,5)
ALVColumnRange
The rule checks if the specified (numeric) column in the report contains a value inside the defined range. Depending on the Operation requested, the ReturnCode is set to 2.
Syntax
ALVColumnRange(<output selection>,<level>,<column>,<low>[[<<high][[,<operation>])
<output selection>
- List with Outputs. Defaults to step1_spool1.txt.<level>
- Reporting level to filter (specify*
s or space for detailed level).<column>
- Column in report to check.<low>[<<high>]
- Range to check.[<operation>]
- OperationEQ
(default) andNE
are supported.
Example
If you want to validate that for level '*' all values in column 5 are within a range between 0 and 100, you actually need to validate that there is no counter example not in the range of 0 and 100.
ALVColumnRange(*,,5,0<100,NE)
Will return a return code greater than 0 if there is a record in column 5 which is not between 0 and 100.
ALVColumnZero
The rule checks if the specified (numeric) column in the report contains a ZERO value. Depending on the Operation requested, the ReturnCode is set.
The RULE_RESULT
will contain a list with resulting values. If single column is retrieved, a comma separated list is returned. Otherwise a MergeResult list is returned which can be used directly in a loop.
Syntax
ALVColumnZero(<output selection>,<level>,<column>[[,<operation>])
<output selection>
- List with Outputs. Defaults to step1_spool1.txt.<levels>
- Reporting level to filter (specify*
s or space for detailed level).<column>
- Column in report to check.[<operation>]
- OperationEQ
(default) andNE
are supported.
Example
ALVColumnZero(*,*,4,NE)
Logfile handling
SapApplLogCheckError
This rule will check the SAP Application Log for error messages. Normally these messages do not result in a process reaching status Error. With this rule, an error will be raised if an error message is found.
Syntax
SapApplLogCheckError(<types>[[<msgClass>,<msgNo>[[,[[<msgClass>,<msgNo>]])
<types>
- String of Message Types (ISWE) can be specified to generate errors. Depending on the type(s), the appropriate return code is set.[<msgClass>,<msgNo>]
- List of messages that need to be ignored.
SapApplLogCheckMessage
This rule will check the SAP Application Log for a specific message. Normally these messages do not result in a process reaching status Error. With this rule, an error can be raised if an error message is found.
Syntax
SapApplLogCheckMessage(<type>,<ID>,<NO>[[,<operation>][[,<not>][[,<force>])
<type>
- Message Type (I
,W
,S
, orE
).<ID>
- Message ID (Application area in SAP, for example BS).<NO>
- Message number, for example023
.[<operation>] EQ** - (default) or **NE
to find or not find the message.[<not>]
:=NOT
- (inverts result, error becomes ok).[<force>]
:=FORCE
(set also RC=0).
Example
SapApplLogCheckMessage(E, BS,023,EQ)
SapApplLogFilterMessage
This rule will check the SAP Application Log for a specific message. The variables used in these messages can filtered. The filtered result is stored in the rule result parameter and can be used by the next rules.
Syntax
SapApplLogFilterMessage(<type>,<ID>,<NO>,<msgV>[[,<msgV>])
<type>
- Message Type (I,W,S,E
).<ID>
- Message ID (like00
).<NO>
- Message number.<msgV>
- Variable number to use (0=Current Text, 1->4 variables of current message, -4->-4 variables of previous message).
Example
SapApplLogFilterMessage(E,BS,023,1,2)
SapApplLogFilterShow
This rule checks the SAP Application Log for a specific message type. The messages found for the message type are then available in a separate output file. This is useful if the job log contains many info messages and the warnings / errors are difficult to locate.
Syntax
SapApplLogFilterShow(<type>[[,<type>])
<type>
- List with Message Types (I
,W
,S
, orE
) to show.
SapLogCheckError
This rule checks the SAP Log for error messages. Normally these messages do not result in a process reaching status Error. With this rule, an error will be raised if an error message is found.
Syntax
SapLogCheckError(<type>[[,<msgClass>,<msgNo>[[,<msgClass>,<msgNo>]])
[<types>]
- String of Message Types (ISWE) can be specified to generate errors. Depending on the type, the appropriate return code is set.[<msgClass>,<msgNo>]
- List of messages that need to be ignored.
Example
SapLogCheckError(W,BS,023,BS,024)
SapLogCheckMessage
This rule checks the SAP Log for a specific messages. Normally these messages do not result in a process reaching status Error. With this rule, an error will be raised if the message is found (default) or not found (using NE
).
Syntax
SapLogCheckMessage(<type>,<ID>,<NO>[[,<operation>][[,<not>][[,<force>])
<type>
- Message Type (I
,W
,S
, orE
).<ID>
- Message ID (Application area in SAP, for example BS).<NO>
- Message number, for example 023.[<operation>]
-.EQ
- (default) orNE
to find or not find the message.
[<not>]
:=NOT
- (inverts result error becomes ok).[<force>]
:=FORCE
- (set also RC=0).[V1=<text>]
- Check if Text in Variable 1 fits.[V2=<text>]
- Check if Text in Variable 2 fits.[V3=<text>]
- Check if Text in Variable 3 fits.[V4=<text>]
- Check if Text in Variable 4 fits.
Example
The following check message will set the process to status Completed with return code 0
if an SAP message matching of type E
(Error) and Id``023
is found.
SapLogCheckMessage(E,BS,023,EQ,NOT,FORCE)
SapLogFilterMessage
This rule will check the SAP Job Log for a specific message. The variables used in these messages can filtered. The filtered result is stored in the rule result parameter and can be used by the next rules.
Syntax
SapLogFilterMessage(<type>,<ID>,<NO>,<msgV>[[,<msgV>])
<type>
- Message Type (I
,W
,S
, orE
).<ID>
- Message ID (Application area in SAP, for example BS).<NO>
- Message number, for example099
.<msgV>
- Variable number to use (1-4).
SapLogFilterShow
This rule will check the SAP Job Log for a specific message type. The messages found for the message type are then available in a separate output file. This is useful if the job log contains many info messages and the warnings / errors are difficult to locate.
Syntax
SapLogFilterShow(<type>[[,<type>])
<type>
- List of Message Type(s) (I
,W
,S
, orE
) to show.
financeTopic