Posts

Showing posts with the label examples

ABAP Chaining Operator && and how to use it

I am not particularly fond of the excess of the ABAP statements to achieve simple tasks and really like the new adaption to operators and predefined functions to achieve similar or sometimes better results. In line with that, this post is about my favourite, chaining operator or && . For folks who have never seen this or want to know more about it, What is a Chaining Operator? The chaining operator concatenates two operands in a string expression as a character string. It has the ability to allow string expressions, predefined functions or functional methods, and even method chaining at its operand position.  To Me, It's an upgrade over the good old CONCATENATE statement. Syntax: … operand1  && operand2 … . Below are a few examples of Chaining Operator and its usage. Simple Concatenation:  Adding Separator: Adding Different Separators in a text: Notice how effortlessly different separators can be embe...

Application Logging in ABAP

Image
Whether you are working with integration or a critical application or a complex report, logging becomes an obvious choice and activity.  Traditionally, Abapers have been logging information using a custom DB table defined specifically for a particular application. While useful, The approach has some flaws,      - Every application needs to have its own logging table      - Record purging/archiving needs to be set up in order to make sure old records are either deleted         or archived.      - There is no reusability of either the setup or the logic to log. With the introduction of Application Logging from SAP, the traditional approach can be left out.  In this post, I will be talking about how we can leverage the SAP application Logging Library to make logging easy. What is an application log? An application log is a rich type log. It contains information like User...

ABAP text field literal vs text string literal

Have you ever had a variable containing text? I am sure you did and regularly do. What is your preferred way to do declare it? If you don't know or use the second option, then this post is for you. There is a minute difference in the way text literal has been defined in options one and two.  First of all the declaration is a literal being passed to a variable, and some of you may ask: what is a literal?     L iterals are defined in the source code of a program by specifying a string representing a value.     Possible literals are numeric literals and character literals. The character literal comprises text       field literals and text string literals. So there are two kinds of text literal, let's see them in detail. Text Field Literals:   - Defined using single inverted commas (').   - Data type is c  with the length of the included characters, including trailing blanks.   ...

ABAP Characters , Strings and Traps of Trailing Blanks

Image
No matter how much I try to move away, I keep coming back to this. I have talked about this multiple times in multiple posts and yet it seems less. So bear with me and hope you stay sane/awake by the time we reach the end. Alright, The issue is simple. Handling of trailing blanks . No need to read further if you know it all. For the rest of the mortals like me, let's proceed. When it comes to character string processing, ABAP gives you two built-in options:  C - Fixed length, trailing blanks are ignored , minimum length is 1. STRING - Dynamic length, trailing blanks are relevant , minimum length is 0. Before you start feeling unrewarded for all the build-up at the start, I have a program to share: Running the program gives this output. The Output is different even with the seemingly same code.  Why? Because the devil is in the details, c_text_space is type c and contains one blank (trailing) which gets i...

ABAP String templates Examples

 After talking about string templates in the last post String processing using string templates , I was tempted to provide more examples of just how powerful and simple to use string templates can be. so without much writing, here we go. Adding Whitespaces and Comments:

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: