Grok all the things

grok (v): to understand (something) intuitively.

ABAP

👶  Children (ELI5)

Gather 'round, folks! Today, we'll take a journey to the fantastical world of programming, where we'll discover a wondrous language called ABAP! ABAP, which stands for "Advanced Business Application Programming," is a high-level programming language. To our delight, it has the power to create incredible business applications!

You might wonder, who brings this magic to life? Well, my friends, it's conjured by the wizards at a magical place called SAP (Systems, Applications, and Products in Data Processing). With this language, they created great systems that help businesses run their daily operations more effectively. Join me as we explore the charm and peculiarities of ABAP!

Origins of the Enchanted Language 🔍📜

A long time ago (circa 1980s), the magicians at SAP developed ABAP – initially called ABAP/4 – to build the backbone of their business software solutions. Later, they introduced a new version named ABAP Objects. Although older spells still work in this version, the new one lets sorcerers cast more powerful incantations!

ABAP is not like other programming languages. It has its own unique enchantments, which make it particularly suited for conjuring business applications. Let's unveil the secrets of ABAP!

The Magical Potion: ABAP Development Environment ✨🔧

Just like how potions need cauldrons to be brewed in, ABAP needs an environment to be developed in. This magical workspace is called "ABAP Development Environment" or "ABAP Workbench." It has tools like the ABAP Editor, Data Dictionary, and Function Builder that let you write, compile, and execute code. Before diving deeper into the realm of ABAP, let's learn about these fantastical tools.

  • ABAP Editor (SE38): This is where the magic of writing ABAP code happens. Wizards use it to create, edit, and test their code.
  • Data Dictionary (SE11): In this enchanted library, programmers store definitions for all data types, tables, and structures in their program.
  • Function Builder (SE37): This mystical workshop is used to create and maintain function modules that can be reused across projects.

Enchanting Data Types and Variables 🧞‍♂️🔠

Before we learn how to write spells in ABAP, it's essential to understand the various data types and variables. Data types define the different kinds of information (like numbers, letters, or even whole sentences) that our code can handle.

ABAP has several data types, such as:

  1. Elementary Data Types: These are the building blocks of data in ABAP. They include:
    • Numeric: I, F, and P (for integer, floating-point, and packed numbers)
    • Character: C and N (for characters and numbers stored as characters)
    • Date/Time: D and T (for date and time values)
  2. Complex Data Types: These are made up of other data types. They include:
    • Structures: Group of elementary data types
    • Internal Tables: Similar to arrays in other programming languages
    • Objects: Instances of ABAP classes

Now that we know the different data types let's learn how to declare variables that store these values.

To declare a variable in ABAP, we use the DATA keyword followed by the variable name and its type. For example:

DATA: magical_number TYPE I,
      enchanting_text TYPE STRING.

This spell creates two variables: a number called magical_number and a string (a group of characters) named enchanting_text.

Casting Spells with ABAP: Keywords and Syntax 🪄🔮

With our trusty wand and newfound knowledge of data types and variables, we can now learn some basic ABAP spells!

  1. Writing Output: To display a message on the screen, use the WRITE keyword.
WRITE: 'Welcome to the magical world of ABAP!'.
  1. Performing Calculations: ABAP has mathematical operators like +, -, *, and / for adding, subtracting, multiplying, and dividing.
DATA: number1 TYPE I VALUE 5,
      number2 TYPE I VALUE 7,
      result TYPE I.

result = number1 * number2.
WRITE: 'The magic multiplication result is:', result.
  1. Conditional Spells: Sometimes, we need to make decisions in our code based on certain conditions. We can use the IF...ENDIF statement for this.
DATA: wizard_age TYPE I VALUE 200.

IF wizard_age > 100.
  WRITE: 'The wizard is wise beyond their years!'.
ENDIF.
  1. Repeating Actions: To repeat an action multiple times, we use loops. In ABAP, there's the DO...ENDDO loop and the LOOP...ENDLOOP loop.
DO 5 TIMES.
  WRITE: 'I am repeating this magical phrase!'.
ENDDO.

Summoning Magical Creatures with ABAP Objects 🦄✨

In the world of ABAP, magicians can summon magical creatures known as "ABAP Objects." These are the manifestations of the powerful object-oriented programming paradigm, giving life to Classes, Objects, and Methods.

Here's how we can create a simple ABAP class:

CLASS magical_creature DEFINITION.
  PUBLIC SECTION.
    METHODS: say_hello.
ENDCLASS.

CLASS magical_creature IMPLEMENTATION.
  METHOD say_hello.
    WRITE: 'Hello! I am a magical creature!'.
  ENDMETHOD.
ENDCLASS.

And now, we can summon our magical creature:

DATA: mystic_being TYPE REF TO magical_creature.

CREATE OBJECT mystic_being.

mystic_being->say_hello( ).

With this incantation, our mystical being will appear and greet us with its enchanted message!

Conclusion: The End of Our Enchanting Journey 🚪✨

As we close the door to the magical world of ABAP, remember all the wondrous tales and spells you've learned! From understanding data types and variables to casting spells with keywords and syntax, you've become a true ABAP conjurer. The art of summoning magical objects is now within your grasp as well!

Now that you know the charm of ABAP, fearlessly venture forth and enchant the world of business applications with your newfound powers!

Grok.foo is a collection of articles on a variety of technology and programming articles assembled by James Padolsey. Enjoy! And please share! And if you feel like you can donate here so I can create more free content for you.