Navigating the ABAP Programming Landscape: Pretty Printers, Comments, Data Types, and Objects

Welcome back everyone, So basically we have completed our DDIC part in our previous blog and just started with our programming part, So let’s continue with our ABAP programming part.

Some more Functionalities of ABAP Editor :-

  • The use of pretty printer is used to format the ABAP code. It makes the code more readable.
  • The shortcut key for pretty printer is Shift + F1.
  • The various functionalities of pretty printer are as follows :-
    • Indentation
    • Convert uppercase/lowercase

    


Note :- To check the various functionalities of the pretty printer.

Click on utilities → settings → pretty printer





  • So, you can use the pretty printer in any way as you prefer.

Comments in ABAP Programming :-

  • A comment is an explanation that is added to the source code of a program to help the person reading the program to understand it.
  • Comments are ignored when the program is generated by the ABAP compiler.
  • The * character at the start of a program line indicates that the entire line is comment.
  • The “character, which can be entered at any position in the line, indicates that the remaining content in the line is a comment.
  • Comment our lines - Ctrl + ,
  • Uncomment lines - Ctrl +.
*******************
*Examples of if statement
if sy-subrc eq 0.
	write : 1, 2.
endif. "End of if statement

************

Note :- Don’t worry, much about the code at this moment, just try to understand how things are going, it will get easier to understand with time.

  • As you can see, in the above code, how we have used * and “ to use single line comments.
  • For commenting and uncommenting multiple lines at the same, select all the lines and press Ctrl + , to comment and Ctrl + . to uncomment.

Data Types :-

  • Data types are templates for creating data objects.
  • A data types defines the technical attributes ( types and length ) of data objects.
  • Data types do not use any memory space.
  • Data types can be defined independently in the ABAP program or in ABAP Dictionary.

Data Objects :-

  • A data object is an instance of a data type.
  • A data objects holds the content or data.
  • It occupies the memory space based upon the data type specified.
*******************************
*Example:-
DATA lv_empid(20) type n,
lv_empid = 10.
*******************************
  • In the above example, DATA = keyword, lv_empid is the name of the data object, TYPE = keyword, n(numeric) = is a data type of that data object.

Categories of data types :-

  • There are three categories of data types :-

    • Elementary types
    • Complex types
    • Reference types


1. Elementary Types :-

  • They are predefined data types
  • They are not composed of other data types.

Elementary Datatypes are of 2 types :-

  1. Fixed Length data types - C(character), N(numeric), I(Integer), P(packed number), F(floating point), D(date), T(time), X(hexadecimal)
  2. Variable length data types - String, Xstring

2. Complex Data Types :-

  • There is no pre-defined complex data type in ABAP.
  • They are the combination of elementary data types.

There are 2 types of complex data types :-

  1. Structure Type
  2. Table Type

3. Reference Data Types :-

  • There is no-predefined reference data type.
  • It describes data objects that contain references to other objects.

There are two types of reference data types :-

  1. Data reference
  2. Object reference
*********************************
*Example:-
lo_object type ref to ZCLASS.
**********************************
  • In the above syntax - lo_object = Name of the data object, TYPE REF TO = keyword, ZCLASS = name of already existing class.

Types of Data Objects :-

  • The Data objects are of 2 types
    1. Literals(unnamed data objects )
    2. Named data objects

1. Literals(Unnamed Data Objects )

  • Literals don’t have any name that’s why they are called as unnamed data object.
  • They are fully defined by their value.
  • There are 2 types of literals :-
    • Numeric Literals :- Numeric Literals have sequence of numbers. Examples - 123, -4567 etc.
    • Character Literals :- Character Literals are sequences of alphanumeric characters in single quotation marks. Examples :- ‘Test 123’, ‘SAP ABAP’ etc.

2. Named Data Objects :-

  • Data objects that have a name are called as named data objects.
  • The various types of named data objects are as follows :-
    1. Variable
    2. Constants
    3. Text Symbols.

Variables :-

  • Variables are data objects whose contents can be changed.
  • Variables are declared using the DATA, CLASS-DATA, STATICS, PARAMETERS, SELECT-OPTIONS, and RANGES statements.
***************************
*Example :-
DATA lv_empid(20) type n.
lv_empid = 10.
lv_empid = 20.
****************************

Constants :-

  • Constants are data objects whose contents can not be changed.
  • Constants are declared using the CONSTANTS keyword.
********************************
*Example
CONSTANTS lc_pi type p decimals 3 value '3.141'.
*********************************

Text Symbols :-

  • A text symbol is data object that is not declared in the program itself.
  • It is defined as a part of the text elements of the program.

Note :- Text symbols are not written inside the code.






So, that’s enough for today. I think we have cover almost each and every introduction part of ABAP programming. So, from next blog we will write our first program.

Thanx alot for being a part of this wonderful journey.

Comments

Popular posts from this blog

Understanding Different Types of SAP Function Modules: Normal, RFC, and Update

Unlocking SAP ABAP Secrets: Interactive Classical Reports with GET CURSOR, At User Command, and a Comparison of HIDE Statements

Mastering ABAP: A Step-by-Step Guide to Function Modules and Groups for Modularized Programming