Posts

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.

Boolean in ABAP

Dealing with two state flags is nothing new and a very common scenario in ABAP development, Historically they have been used to represent a true or false state. For example: Y or N, X or ' ', 0 or 1. Booleans are data objects that store truth values i.e. True or False , which are results of logical expressions. Truth values are the results of logical expressions. A truth value is either true or false. ABAP does not yet support boolean data types and thus does not support data objects for truth values. Therefore, the result of a logical expression cannot be assigned directly to a data object. However, it can be achieved using Boolean functions. It has become common practice to express the truth value "true" as value " X " and the truth value "false" as a blank (" ").  which leads to one of the bad practices still prevalent: Using the Data Type abap_bool for Truth Values The type group ABAP contains a data type abap_bool of elementary type...

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...

Ways to flip a Boolean

Whenever working with booleans while writing code there is almost always a scenario where one has to flip the boolean state i.e. true to false or vice-versa based on some condition. In this post, I wanted to showcase different ways to do so. Using Control statements:

Case Statement usage

Case statements in ABAP are great. Not only do they let you handle your logic flow like other control flow statements but also provide a clean/ better readable way to branch into multiple sublogics. A typical use of a case statement is something like this as [ CASE  variable:  WHEN  value]: