Posts

Showing posts with the label predefined functions

Abap predefined function line_index

As part of the ABAP  predefined functions  series, today I wanted to talk about the predefined function  LINE_INDEX . As the name suggests, the function returns the row index of an internal table found using table expressions. Syntax:   result =  line_index ( table_expression). Features : - If the row in question is not found, no exception is raised. The value 0 is returned instead. - Supports table expression chaining as long as the result of the expression is also table-like in     the case of nested tables. - Effectively, a functional replacement of READ TABLE statement followed by sy-tabix check. Notes :  - If a hashed table is specified then the result would be -1.  - If a hash key is specified then the result would be -1.   Example : you might think that it's not that impressive as it's not that hard or frequent to know an index of the row in internal tables till you have to know the index of a...

Abap Predefined function nmax and nmin

As part of the ABAP predefined functions series, today I wanted to talk about numerical Extremum functions: NMIN, and NMAX. These functions return the minimum/maximum values out of the input argument. Syntax: result = nmax|nmin ( val1 = arg1 val2 = arg2....val5 = arg5 ..val9 = arg9 ). Features: - All the input arguments are of type numeric data object/ numeric expressions. - A minimum of two arguments must be passed up to 9. Example: It's elementary to start undermining the function as an extreme of two can be easily calculated with a simple if-else: but what if 3, or 4 or more fields were involved: You can notice how the ifs are increasing but it's a simple method call to NMAX or NMIN to achieve the same. Below is a small ready-to-execute report to calculate the least or highest value of input values of up to 9 variables, As always, I hope this information helps you with your day-to-day work.

ABAP predefined length functions STRLEN and NUMOFCHAR

 Many a time when traversing a text, you would want to know the actual length of the text. in today's predefined function series post, I wanted to welcome you with ABAP length predefined functions: strlen , numofchar . While strlen is pretty well-known, numofchar is relatively unknown so I thought we should take a look at its feature and usage as well. Let's dive right in. STRLEN : Syntax : STRLEN ( arg ). Features :  It returns the number of characters in arg.  If the data object is of fixed length then trailing blanks are ignored.  If the data object is of type string, then trailing blanks are also counted. Example : NUMOFCHAR : Syntax : NUMOFCHAR ( arg ). Features :  It returns the number of characters in arg.  Trailing blanks are ignored regardless of the data object type. Example: As you would have noticed from the examples,  numofchar always ignores the trailing blanks whereas strlen behaves differen...

ABAP BOOLC and XSDBOOL use-cases

 In the previous post  ABAP Convert Logical Expressions Into Boolean Values , I talked about BOOLC and XSDBOOL functions and their respective features. I thought I would elaborate on their use cases with examples. BOOLC: Set boolean flag:

ABAP predefined functions - LINES

When dealing with internal tables, many a time, you are looking to know the number of records the table holds. In this bite-sized post, I will try to show you how to use ABAP predefined function LINES over the traditional approach of using DESCRIBE keyword.

ABAP Convert Logical Expressions Into Boolean Values

In my last post on  ways to flip a boolean , I talked about how we can use boolean   functions to flip a boolean by passing a logical expression. I thought I will elaborate further on these. Boolean in ABAP is not that straightforward . However, boolean functions help us capture the results of logical expressions as a form of truth value. Let's dive further;

ABAP Predefined Case functions

 Today's topic is case handling, Abap has support for handling cases of string using both keywords and built-in methods. I wanted to talk about the built-in methods that you can use to modify the case of a string and how they are better than their keyword counterparts. 1. To_upper: Converts the input string/literal to uppercase and returns the uppercased string which can be used in operand positions. Example : 2. To_lower: Converts the input string/literal to lowercase and returns the uppercased string which can be used in operand positions.  Example: 3. To_mixed: Converts the input string/literal to mixed case and returns the uppercased string which can be used in operand positions.  There is no equivalent keyword for this function and the function can be really helpful in manipulating the string cases. Example: Of course, it's just a demonstration, you can play around with a more complex scenario of mixed case function.  A...