0% found this document useful (0 votes)
39 views

Debugging

This document outlines the debugging process in SAP ABAP programming, detailing methods to identify data sources for fields in SAP tables and the use of breakpoints and watchpoints for effective debugging. It explains the differences between session and external breakpoints, the advantages of debugging, and best practices for using breakpoints. Additionally, it covers real-time debugging techniques, error message analysis, and performance considerations when working with internal tables.

Uploaded by

yamini14166
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
39 views

Debugging

This document outlines the debugging process in SAP ABAP programming, detailing methods to identify data sources for fields in SAP tables and the use of breakpoints and watchpoints for effective debugging. It explains the differences between session and external breakpoints, the advantages of debugging, and best practices for using breakpoints. Additionally, it covers real-time debugging techniques, error message analysis, and performance considerations when working with internal tables.

Uploaded by

yamini14166
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 172

Debugging:

Value Table in SAP:

In SAP Tables, for some fields data we can see in different color (Green) as shown below.
Ex:
 Table: VBAK
 Fields: Sales Type, Sales Org, Division, Distribution Channel

If we see any fields information appearing


in different color, that means these fields
are getting filled from some other Table.

Method 1:
Steps:
 Put a Cursor on that field and Press F1 ( Fn + F1 )
 Click on Technical Information

 Double click on Data Element ( in this case it is VKORG )


 Double Click on DOMAIN (in this case it is VKORG)
 Go to Value Range Tab

 Below we can see the Option called – Value Table

For Sales Org field in VBAK table, we are getting data from TVK0
If we go go TVK0 we can see the information about Sales Org

Method 2:

Go To SE11 – provide the table VBAK and find the filed VKORG

 Double Click on Data Element – VKROG


 Double Click on DOMAIN
 Go To Value Range Tab

 Below we can see the Value Table


And sometimes filed is not appearing in Green
Color but for that field Key and Text both are
maintained.

For example in VBAK we have Document Category (VBTYP ) field and for this value information
is maintained
 GO TO SE11 – VBAK Table – SEARCH FOR VBTYP Filed and double click
on Data element

 Double Click on Domain - VBTYP


 Under Single Values section we can see the data maintained for each
value.

Requirement:-Suppose if we need to find, How many programs are using a custom table,
generally we use Where used button and find the list.

So in my current scenario this table is using in 2 places


We can also find this through Table – D010TAB and pass Z*/Y* in Master Field and table name
in TABNAME field – Execute

Output:-

Certainly! This solution can help many SAP consultants and fresher’s who are working where
used list for a table.
Purpose of this document:
This document will detail the process of debugging in SAP ABAP programming.

What is Debugging?
Debugging entails analyzing a program's flow to identify and rectify defects or
bugs. SAP distinguishes itself from other programming languages by involving the
analysis of various objects during the debugging process. Consequently, diverse
techniques are employed for debugging different object types.

Why do we need a Debug:


In the SAP environment, debugging is facilitated through the ABAP Debugger, a
programming tool capable of scrutinizing an ABAP program or object on a line-by-line
or section basis. It also allows for the dynamic alteration of object values during
runtime.
There exist two varieties of SAP ABAP Debuggers: The Classical Debugger, applicable to
releases up to 6.40, and the New ABAP Debugger, designed for all releases from 6.40
onwards.

Advantages of Debugging:
1) Pinpointing the exact cause of an issue
2) Efficient use of resources
3) Enhanced program logic
4) Improved code quality
5) Better collaboration among
teams 6)
Types of Debugging techniques:
1) Classic Debugging
2) New ABAP Debugger

Classical Debugger:
The predominant debugging method in SAP ABAP is the classic debugging technique,
widely employed by developers. This approach includes the placement of breakpoints
within the code, which halts program execution. This interruption provides developers
with the opportunity to scrutinize the values of variables, tables, and other data
objects.

New ABAP Debugger:


The New ABAP Debugger represents an upgraded iteration of the traditional debugger
in SAP ABAP, incorporating supplementary features and enhanced functionality for
program debugging. Notable aspects of the new debugger encompass the ability to
debug multiple sessions concurrently, conduct code coverage analysis, perform code
profiling, and benefit from an improved user interface, among others.
MILLU138@GMAIL.COM
ABAP/Webdynpro/CDS/ODATA/SAP UI5/FIORI

Difference between Session and external breakpoints:


Session Breakpoint:
Set within the ABAP program code, affecting only the user's session. When the
program execution reaches the line of code where the session breakpoint is set, it
interrupts the execution, allowing the programmer to analyze and debug the program
at that point.

External Breakpoint
Set outside the program code, often in the ABAP Editor or Debugger, with a
broader scope that can affect multiple users working on the same program.

How to Set the session breakpoint:


Step1: Open the Program in SE38

Step2: Set the breakpoint


 We can click over the line and set the breakpoint

https://www.linkedin.com/in/milan-victor-xavier-
1713b3192
Milan Victor – SAP
MILLU138@GMAIL.COM
ABAP/Webdynpro/CDS/ODATA/SAP UI5/FIORI

 Place the cursor over the line and press the session breakpoint button.

How to set the user ID for this external breakpoint.

UtilitiesSettingABAP EditorDebuggingUser ID

https://www.linkedin.com/in/milan-victor-xavier-
1713b3192
Milan Victor – SAP
MILLU138@GMAIL.COM
ABAP/Webdynpro/CDS/ODATA/SAP UI5/FIORI

How to debug based on the message, Function


module, class, method, etc.
Step1: Find the message class and message number from the error
message

https:// kedin.com/in/milan-victor-xavier-
www.lin 1713b3192
Milan Victor – SAP
MILLU138@GMAIL.COM
ABAP/Webdynpro/CDS/ODATA/SAP UI5/FIORI

Click over the error message and that will open the one window where we can see the
message number and class.

Message Number:
FR180 Message Class:
FR Message Number:
180

Step2: Put a dynamic breakpoint


Execute the tcode, put /H into the comment box and press enter.

Then press the execute button. After that dynamic breakpoint will be triggered.

https://www.linkedin.com/in/milan-victor-xavier-
1713b3192
Milan Victor – SAP
MILLU138@GMAIL.COM
ABAP/Webdynpro/CDS/ODATA/SAP UI5/FIORI

Step3: Set the breakpoint at the message:


BreakpointBreakpoint atBreakpoint at message

Here we can see all possible ways to set the breakpoints. But here we are going to use
breakpoint at message option.

https://www.linkedin.com/in/milan-victor-xavier-
1713b3192
Milan Victor – SAP
MILLU138@GMAIL.COM
ABAP/Webdynpro/CDS/ODATA/SAP UI5/FIORI

Next, give the Message ID and Number in the correct fields and click the ok button to set the
breakpoint based on the message ID and number.

Then, u will see the message like this,

Then Press F8 to navigate the exact place for the error,

Next cursor will stop to the exact place,

These are the steps to set the breakpoint based on the message, like the same we can set it for
Function module, class methods, perform, etc.

https://www.linkedin.com/in/milan-victor-xavier-
1713b3192
Milan Victor – SAP
MILLU138@GMAIL.COM
ABAP/Webdynpro/CDS/ODATA/SAP UI5/FIORI

Watch Points:
Watchpoints are breakpoints with a specific purpose – monitoring the values of variables or
expressions at runtime. While traditional breakpoints pause program execution to allow you to
inspect the code, watchpoints take it a step further by actively tracking the changes in variable
values. This can be immensely helpful in locating the source of a bug or understanding the flow
of your program.

Benefits of Watchpoints:
 Dynamic Monitoring
 Reduced Breakpoints
 Efficient Issue Identification
 Enhanced Debugging Experience

How to set the Watchpoint:


Step1: Put the session or external breakpoint in the program

Step2: Give the Inputs and execute the Tcode:

Step3: Set the watchpoint

Click Create Watchpoint button to create the watchpoint

https://www.linkedin.com/in/milan-victor-xavier-
1713b3192
Milan Victor – SAP
MILLU138@GMAIL.COM
ABAP/Webdynpro/CDS/ODATA/SAP UI5/FIORI

Then, a new popup will come up like the following screenshot

Here you have to give the variable and Condition to set the watch point. I will set the
watchpoint for the currency field with a value of USD. That means if the currency field is USD
means then only watchpoint will be triggered.

After giving the variable name and condition we need to press the ‘OK’ button, then we will
receive the message below.

Then we have to press F8, whenever the currency is USD that time watchpoint will be triggered.

https://www.linkedin.com/in/milan-victor-xavier-
1713b3192
Milan Victor – SAP
MILLU138@GMAIL.COM
ABAP/Webdynpro/CDS/ODATA/SAP UI5/FIORI

Best Practices for Using Breakpoints


To harness the full power of breakpoints, consider these best practices:

1) Strategic placements
Place breakpoints where they matter the most. Focus on critical decision
points, loops, and areas where you suspect issues might arise.

2) Temporary vs. permanent Breakpoints


Use temporary breakpoints during initial debugging sessions. If the issue
is persistent, consider converting them into permanent breakpoints for future
reference

3) Conditional Breakpoints
Enhance your debugging efficiency by setting conditions for breakpoints. Pause
execution only when specific criteria are met, reducing unnecessary
interruptions

4) Deactivation after Use


Once you've identified and resolved an issue using breakpoints, deactivate or
remove them. Leaving inactive breakpoints in your code can lead to confusion
and unnecessary pauses

5) Documentation
https://www.linkedin.com/in/milan-victor-xavier-
Consider adding comments or documentation explaining the purpose of
1713b3192
breakpoints. This can be especially helpful when revisiting code or when
collaborating with other developers
Conclusion:
Breakpoints in SAP ABAP are more than just tools for finding and fixing bugs;
they are your allies in understanding, optimizing, and mastering your code. By
strategically placing breakpoints, utilizing different types, and following best
practices, you can streamline your debugging process and become a more
proficient ABAP developer.

Remember, breakpoints are not just for troubleshooting errors; they are
essential for gaining deep insights into your code's execution. So, embrace
breakpoints, use them wisely, and let them guide you through the intricate paths
of SAP ABAP development. Happy coding and debugging.
Scenario 1: in our custom program we want to see the behavior of one particular variable we
will ask SAP to stop the program when it reaches this variable for achieve our goal we will use
watchpoints let’s see how
Go to se38 and open your program in debug mode
Create watchpoint
Put the name of variable you want to check and click on the green button

You will get this message

You can also check in watchpoints tab


And execute the program (F8)

And finally you will get this confirmation message

Scenario 2: For example, there are 386 entries in the internal table. Let's see how to analyse the
227th record, i.e. the PO number "4500001592".
Go to se38 and open your program in debug mode
Create watchpoint

Because we want to see a particular value, we will create a watchpoint but this time our
variable will be a 'work area' with the field corresponding to our value.
You will get this message

You can also check in watchpoints tab


And execute the program (F8)
And finally you will get this confirmation message

1.Changing Variable Values:


One of the important features of the SAP debugger is the ability to change the values of
variables "on the fly".
Sometimes, when we debug for testing purposes, we need to change the values of variables
in order to test several scenarios or to see the behavior of the program.
And even during troubleshooting, changing the value of a particular variable can help solve
the problem.
However, it is important to ensure that you have permission to do so, otherwise the system
will not allow you to change a field. You should therefore contact the SAP security team to
obtain the necessary permissions.
Let’s see how we can change the value
For the testing purpose we will change the PO number (from: 4500001592 to:
4500001630) to see the behavior of the program

Click to pencil icon to make the field editable

Now we can change the PO number easily


2.Real time Debbuging:

a) Debbuging pop up screen:


In SAP we encounter pop-up screens every day, but there are scenarios where a pop-up
screen needs to be debugged to find the exact cause of the error.
One of the most important difficulties is that command line debugging is not possible if pop-
up screens appear: because you cannot edit /h
What you need to do is save the line of codes below to a text file on your laptop or desktop.
And when it's time to debug, just drag and drop the text file you saved on your desktop or
laptop onto the pop-up screens.
Let’s take an example

During a transaction, we get this pop up screen here below

Our task now is to find out exactly which line of the ABAP code contains this error by
debugging.

Just drag and drop the text file you saved on your desktop or laptop onto the pop- up screens.
You will get this message

And click on the green button

The program will stop exactly at the point where this error occurs.
b) Debugging of Enhancement
Before we talk about debugging enhancement let’s see first what is enhancement and what is
the purpose of enhancement?
Enhancements: enables customers/clients to add custom business functionality to sap
standard software without changing at all the sap standard functionality (which is supposed
to be unchanged).
But to better manage the enhancements in the program and also to be sure not to change
the standard functionality of the sap, the best thing to do is to copy a standard program and
make the enhancements you want.
Now let’s see how we can debugging enhancement

Two things you should keep in your mind before starting debugging
enhancement:

 Icon snail :
 And(the F5 key) button remember (The F5 key): Allows you
to execute the code line by line

Go to se38 and open your program in debug mode


Identify the snail icon in the program as shown below
With the (F5 key) you can start debbuging your enhancement step by step
c) Debugging an error message
As I explained earlier, in some cases SAP error messages are not useful, which means that we
don't know what caused the error. In such a situation we have no choice, the only method of
troubleshooting is debugging.
Let’s see how we can debug error message A user
sends you this screenshot by email:

Our task now is to find out exactly which line of the ABAP code contains this error by
debugging.
Open the program in debugging mode
Go to breakpoint at message
Enter the information contained in the error message

And execute
As you can see above the program ABAP
Debug ing: Analyzing Memory Usage of Your
Programs
Like SQL statements, one of the most-notorious causes of ABAP performance problems is internal tables with many entries. Large
internal tables consume massive amounts of memory and CPU, for example, during copy, sort, or search operations.

You can use the ABAP debugger to create an overview of all internal tables of a program. The ABAP debugger is a tool for
performing functional troubleshooting in programs. You can find more detailed descriptions of the debugger in SAP literature under
ABAP programming. Youʼll find information on main memory usage both in the classic and the new debugger. You can set the
debugger in the ABAP Editor (Transaction SE38) via Utilities > Settings > Debugging.

Performance analysis using the ABAP debugger isnʼt a standard procedure and is best performed by an ABAP developer.
Rules When Debugging
Take the following advice into account when working with the ABAP debugger. During the debugging process, the ABAP
program may terminate and display the error message Invalid interruption of a database selection, or the system may
automatically trigger a database commit.

In either case, an SAP œṙ ḅ ḙǜǀ ḵĮ ṎḙẤṙ Ḃť ṙ ẃḮ ᾨœĮ ť ᾩhas been interrupted, and this may lead to
inconsistencies in the application tables. Therefore, you should only debug on a test system or in the presence of someone
who is very familiar with the program being analyzed and who can manually correct inconsistencies in the database tables if
necessary. See “Debugging Programs in the Production Client” in SAP Online Help for the ABAP debugger.

You perform a performance analysis with the debugger as follows:

. Start the program to be analyzed. Then open a second session. Here you can monitor the program to be analyzed in the
work process overview (Transaction SM50). Enter the debugger from the work process overview by selecting the
Debugging function. By using the debugger several times in succession, you can identify the parts of the program that
cause high CPU consumption. Often, these sections consist of LOOP ... ENDLOOP statements that affect large internal
tables.
. To display the current memory requirements (in the “classic” debugger), select Goto > Other Screens > Memory
Use.
. Check for cases of unnecessary memory consumption that may have been caused by a nonoptimal program or inefficient
use of a program. As a guideline, bear in mind that a program being used by several users in dialog mode should not
allocate more than 100MB.
. As of SAP NetWeaver AS ABAP 6.20, you can use the classic debugger to create a list of program objects located in the
memory by selecting Goto > Status Display > Memory Use. Under Memory Consumption, the Ranking Lists tab contains
a list of objects and their memory consumption.

In SAP NetWeaver AS ABAP versions 4.6 und 6.10, you can obtain a memory consumption list by choosing Goto > System
> System Areas. Enter “ITAB-TOP25” in the Area field. This way, youʼll obtain a list of the 25 largest internal tables.
5. In the “new” debugger, you first display the memory analysis tool by clicking the button for the new tool and then
selecting Memory Analysis from the tools on offer in the Memory Management folder. The initial screen then displays
how much memory is allocated or used by the analyzed internal session. Click the Memory Objects button to go to the
list of the largest memory objects, which can be the internal tables, objects, anonymous data objects, or strings.

Memory Extracts
Moreover, you can create and then analyze a memory extract, that is, an overview of the objects that occupy memory space. You
can create a memory extract in any transaction by selecting System > Utilities > Memory Analysis> Create Memory Extract or
simply enter function code “/HMUSA”. The third option is to create a memory extract from program coding. Refer to SAP Help
for a description of the system class CL_ABAP_MEMORY_UTILITIES.

To evaluate the memory extract, start the Memory Inspector by selecting System _ Utilities > Memory Analysis > Compare
Memory Extracts in any transaction or via Transaction S_MEMORY_INSPECTOR. The Memory Inspector lists all memory extracts
in the upper part of the screen. In the lower part of the screen, you can find details about the individual memory extract.

Here, a distinction is made among the object types, programs, classes, dynamic memory request of a class, table bodies,
strings, and types of anonymous data objects. Youʼre provided with different ranking lists, according to which you can sort
the objects. For each memory object, youʼre provided with the values of bound allocated, bound used, referenced allocated,
and referenced used memories. You can find a detailed description of the ranking lists and the displayed values in SAP Help.

Memory Inspector
The Memory Inspector is particularly useful for examining transactions over a long period of time, as is the case in a customer
interaction center. Here, users frequently enter a transaction at the beginning of their workday and exit it when they go home.
In these “long-term” transactions, data often remains, and therefore memory consumption continuously increases.
The figure below shows an example of a memory extract. The dominator tree shows the hierarchical program structure
and the memory used by the program parts. With a size of 494MB, table LT_MEM is conspicuous. The next largest
object is the CL_GUI_ALV_GRID class with a size of 250 KB. Below this class, 130 KB are used by table MT_ATA.

Conclusion
In order to find potential performance bottlenecks, itʼs important to take a look at historical culprits such as SQL
and ABAP code. With tools such as the ABAP debugger and Memory Inspector, analyzing the memory usage in
your program becomes quite easy.

has stopped exactly at the point where this error occurs.


1) What is debugging?
2) Why do we use debugging?
3) How to achieve debugging?

What is debugging?
Debugging is a vital aspect of software development as it involves employing techniques to
locate, rectify, and resolve errors. This process enables developers to navigate through their
code, examine variable values, and pinpoint the underlying cause of issues.

Why do we use debugging?

 The SAP Debugger is a valuable tool utilized for


performing meticulous analysis and troubleshooting of
ABAP code in a systematic manner.

 Debugging serves as a means to detect performance


bottlenecks within ABAP programs. Through careful
examination of the execution flow, developers can
accurately identify sections that excessively consume time
or resources, enabling optimization for enhanced overall
performance.

 This technique proves particularly beneficial when


attempting to identify the underlying cause of an issue or
when devising necessary functionality to bridge any gaps in
requirements.

Debugging Technique/Modes
Start the ABAP Debugger: There are multiple ways to start the ABAP Debugger, depending on the
scenario:
1. Transaction Code: Enter the transaction code "/h” in the Search bar and press Enter. This
will activate the debugger for the current session.

After entering ‘/h’, press enter and the below message will be displayed.

Upon execution, the commencement of debugging triggers the display of the subsequent window
Commonly used debug keys:

F5: When we press F5 in debugging, you will go to the next step means your program
control goes to the next line.
F6: When you press F6 in debugging, it will execute the module without going into it. F6 works
for performs (subroutines), Function modules, Class methods, etc.
F7: When you press F7 in debugging, it will complete the current module/program in a single
step.
F8: When you press F8 in debugging, control will go to the next breakpoint if any, or completes
the program execution.

After displaying the above window, it is essential to establish a breakpoint before proceeding
to it. Prior to delving into the breakpoint concept, it is crucial to address the term 'BREAK-
POINT'.

 A breakpoint is a method employed to halt the execution of


code at a specific line, thereby facilitating the initiation of the
debugging process.
 Breakpoints can be set directly within the code, with the
commonly utilized window being Desktop3.
To set a breakpoint, position the cursor on the desired line and press F6 or click on the left
margin of the code editor.
To view the content of the internal table, go to the tables tab on the Debug window and
double-click on the internal table. It displays the content of the Internal table

Entering the name of the internal table/variable directly at the bottom of the window
allows for the immediate display of its values upon pressing enter.
The internal tables are displayed as strings as shown above it_ekpo. If one wants to see it as
fields, then double click on the internal table name in the below window then the internal table
is displayed as fields as below:

Once the program executes all breakpoints, pressing F8 will cause the execution to pause,
simultaneously deactivating the debugger and providing the desired output.
Co In concluding a blog post on debugging, it is crucial to
highlight the importance of debugging in the software
ncl
development process.
usi
Furthermore, it should be emphasized that debugging
on: can effectively save time and resources by identifying
and resolving issues early in the development cycle.
1. Difference between Standard and Customized Objects?
Standard Objects: are the objects which are provided by SAP itself, and these are non-
changeable objects. if we want to change then we require the Access Key.

C2
General

Custom Objects: are the objects which will be developed by ABAPer as


per the Business custom requirement.

2. What is a Client?
Client is a 3-digit unique number which is used to identify the Development, Quality, and
Production
systems. And the Range is from ‘000’ to ‘999’

3. Default Login Language?


English is the Default Language.

if want we can change to native language also.


4. What is the Initial Screen we get once we login to the system?
SAP Access Key is the Initial Screen.

5. What are the Different Bars, we


have in SAP system? Menu Bar

Standard Tools Bar:

As part of this Bar, we have Command Field where we enter the Transaction Code.

Title Bar:

Application Tool Bar:

Status Bar:
6. Which tool is used to develop the Executable Programs?

ABAP Editor and the T-Code is SE38

7. Executable Programs start with Keyword?

Executable Programs start with keyword – REPORT

8. What is a Package?
Package is like a container which is used to transport all the developed objects from one
system to another system. The Transaction is for creating package is SE80 (Object
Navigator)

NOTE: To Transport any objects, then that object should be in ACTIVE STATUS

9. What is Local Object?


If we want to Transport objects from one system to another system, then that objects should
be saved under transportable (like ZABC), but sometimes we develop objects just to test , in
that case we will not transport them to next level systems. These objects we will save it under
Local Objects and SAP has given a package for all the Local Objects (Function Key – F7) that is
$TMP
10. Every Statement must END with?

In SAP ABAP, every statement must end with Period “ . ” , otherwise we will get this syntax
error.

11 What is Variable?
Variable is User Defined object which is used to store the

Values. We use DATA keyword to declare the Variable in SAP

ABAP. data v_x type i. (Declared one Variable )

To declare the multiple variables.

data v_x type i. data


v_y type i. data: v_z
type i.

12. What is CHAIN Operator?

data v_x type i.


data v_y type i.
data v_z type i.
in the above statement to declare the 3 variable we have used DATA keyword 3 times but if want
to declare them by using DATA key word only once then we use chain operator (:)
data : v_x type i,
v_y type i,
v_z type i.
13. What is Comment?
In the written ABAP code, if we don’t want to execute any statement then we will comment that
statement.
To COMMENT single line , we put (*) at the starting of that line –
*data : v_x type i.

To COMMENT multiple lines, then select the block of line and use CTRL + <
To UNCOMMENT multiple lines, then select the block of line and use CTRL + >

*data : v_x type i,


* v_y type i,
* v_z type i.

If we want to comment from the middle of the line then use “ (Double Quotes symbol)

data : v_x type i. "VARIABLE DECLARATION

14. Keyword to display of the Variable values in SAP ABAP?


WRITE is the keyword is used to display the variable values on LPS(List Processing Screen)

15. Steps to perform before executing the program?


SAVE – CTRS + S
Check for Syntax Error – CTRL +

F2 Activate the Object – CTRL +

F3
Execute – F8 (Direct Processing on the Application Bar )
16. Reason for below Syntax Error?
The Reason for this syntax error is ABAP is SPACE SENSITIVE so we should maintain at
least one space between operator and values.
V_X=10. "Syntax Error
V_X = 10. "No Syntax Error

17. How to Display the value in the next line?


To Display the value in the next line we use this symbol “ / ”

WRITE: / V_Z.

18. Types of Justifications in SAP ABAP?


By default, Numeric Data Types are RIGHT JUSTFIED and Character Data Types

are LEFT JUSTIFIED. In SAP ABAP, we have 3 types of Justfication.


1. LEFT JUSTIFIED
2. RIGHT JUSTIFIED
3. CENTERED

WRITE: / V_Z RIGHT-


JUSTIFIED. WRITE: /
V_Z LEFT-JUSTIFIED.
WRITE: / V_Z CENTERED.

19. How to Initialize the variable at the time of declaration?


We use VALUE keyword to initialize the variable at the time of declaration itself.
data x type i VALUE 100. "Declaration &
Initialization
20. By
default Numeric and Character datatypes occupied,
how many bytes of memory?
Numeric Datatype: ONE BYTE and it is

initialized to ZERO. Character Datatype:

FOUR BYTE and it is initialized to SPACE.


Obligatory- which means whichever the field will be mandatory that time we will use
this.
Text-001 which means?
MEMORY ID?
S_ which means selection screen
SELECTION-SCREEN BEGIN OF LINE
SELECTION-SCREEN END OF LINE
CALL FUNCTION – which means function module will call
IMPORTING
EXPORTING
CHECK 1=2
CALL METHOD
How to find the fields names based on the description
FUNCNAME

If we want to delete any line, then will put ‘*’.


How to create a Package?
Step 2: Open SE80 (Object Navigator)
1. In the SAP Easy Access screen, enter SE80 in the transaction code field.
2. Press Enter. This will open the Object Navigator.
<!--Screenshot link example-->
Step 3: Choose Package from the Dropdown
1. In the Object Navigator, select Package from the drop-down list.
2. Enter the name of the new package you want to create (e.g., Z_MY_PACKAGE).
<!--Screenshot link example-->
Step 4: Click Create
1. Once the name is entered, press the Enter key.
2. A pop-up will appear asking for further details. Click on the Create Object
button.
<!--Screenshot link example-->
Step 5: Fill in the Package Details
1. Short Description: Enter a brief description of your package (e.g., "My Custom
Development Package").
2. Application Component: Assign the package to an appropriate component (if
known). You can use the search button to find relevant components.
3. Software Component: Select the correct software component. For custom
developments, this is usually HOME or ZLOCAL for local objects.
4. Click Save.
<!--Screenshot link example-->
Step 6: Assign a Transport Request
1. You will now be prompted to assign the package to a transport request.
o If you already have a transport request, select it.

o If you do not have one, click Create Request, and provide a description
for it.
<!--Screenshot link example-->
2. Click Continue to complete the process.
Step 7: Check the Created Package
1. The package will now be visible in the Object Navigator under the Package
section.
2. You can now use this package to store your development objects (programs,
function modules, classes, etc.).
What is the purpose of TOC?

Table maintenance in SAP ABAP refers to creating a maintenance interface (a


maintenance view) for a database table so that you can manage table entries
(create, update, delete) through a user-friendly interface. Here's a step-by-step
guide to creating and generating a table maintenance generator in SAP ABAP:
Step-by-Step Guide to Create Table Maintenance in SAP ABAP:
Step 1: Create or Select the Table
1. Create a Table in the Data Dictionary (Transaction Code SE11).
2. After defining all fields, save and activate the table.
3. If the table already exists, skip this step.
Step 2: Open Table in SE11
1. Open SE11 (Data Dictionary).
2. Enter your table name (e.g., Z_MYTABLE) and click on Display.
Step 3: Go to Utilities > Table Maintenance Generator
1. In the SE11 screen, after displaying your table, click on Utilities in the menu
bar.
2. Select Table Maintenance Generator from the dropdown.
<!-- Example screenshot -->
Step 4: Define Maintenance Attributes
1. In the Table Maintenance Generator screen, fill in the following fields:
o Authorization Group: Leave it blank or enter a relevant authorization
group.
o Function Group: Create or select a function group. If it's your first time
creating it, enter a new name (e.g., Z_MYFUNCGRP), and the system will
create a new one for you.
o Maintenance Type: Choose either One Step or Two Step. For simple
table maintenance, choose One Step.
<!-- Example screenshot -->
2. After filling in the details, click Create.
Step 5: Generate the Maintenance View
1. Click Save and Generate. This will create the table maintenance program
under the assigned function group.
2. If prompted for a transport request, assign the appropriate one.
<!-- Example screenshot -->
Step 6: Test Table Maintenance
1. You can now test the table maintenance functionality by going to SM30.
2. Enter the table name (e.g., Z_MYTABLE) and click Maintain.
3. This will open the user-friendly interface where you can add, change, or delete
entries from the table.
Functional Specification Document:
What is Transport Request (TR) in
SAP
Transport Request is container of changes which is made in SAP Development system as per
Customer requirement.

Using TR we can transport or move all changes/ Customize setting from DEV to QA to
Production System.

TR Naming Convention:
SID<K>90003

SID - System Name


K- Co file created in Data base

90003 - Number can be anything from starting with 9xxx

Ex: If TR DEVK90003 generated in development system then as per naming convention Here SID
is DEV

Types of Transport Request


1.Workbench Request : Workbench requests are cross-client. Changes done in
one client are automatically reflected in all other clients. If we use ABAP Logic
during changes then use Workbench Request.

2.Customizing Request : Customizing requests are client specific. The


changes will not be reflected in other clients. for Example if we made
changes in DEV-100 system then this will not reflected in DEV-200 system
we need to do copy client by TR (T code ; SCC1)

we use this customizing request if not using ABAP Logic during changes in
system.
How to Release TR
T code: SE01

If you know TR number then go to Display tab -> Put TR No. -> Click on Display Push Button.

1. Select Sub TR EH7K900456 --> Click on truck Icon Button so that Sub TR
will be release.

2. Again Select Main EH7K900455 --> TR Click on Truck Icon Button so that

Main TR will be release Note: System not allow you release first MAIN TR

before release Sub TR.

VISHAL JAIN
Once you Release TR then Right Check mark will be visible next to TR

VISHAL JAIN
How To Revert SAP Released Transport Request
To Unreleased Status

If You want change Status of TR from Released to Unreleased then follow


below Process.

1. Run T code SE38 /SA38

2. Enter Program RDDIT076 in SE38/SA38 & Execute

3. In the Selection screen Enter Main TR number which you want to change
status.

VISHAL JAIN
4. Select TR and Click on binoculars

5. Click on Pencil Button for Change Mode.

VISHAL JAIN
System Allow you change status From "R to D'" & SAVE it

Now TR status Changed as D- Modifiable

VISHAL JAIN
For Information Purpose ;

Types of TR Status

Request

Type of Request

Varun N
ST01 = System Trace
1) Access the ST01 Transaction: -
 Go to the SAP Easy access screen.
 Enter the transaction code ST01 in the command field and press
Enter.

2) Select Trace Components: -


 In the initial screen, you will see options to select the
type of trace you want to activate. Common options
include:
 Authorization Check = > To monitor authorization checks.
 SQL Trace = > To log database queries.
 Buffer Trace = > To monitor buffer activities.
 Check the boxes for the components you want to trace.

Varun N
Varun N
3) Set Trace Options (Optional): -
 You can set filters in the down what all are the trace records,
such as:
 User IDs = > Specify particular users to trace.
 Transaction Codes = > Focus on specific transactions.
 Programs = > Monitor specific programs.

4) Activate the Trace: -


 Click on the "Trace on" button. The system will start
recording activities based on your selected components
and filters.

5) Perform the Activities to be Traced: -


 While the trace is active, login to that User id and perform the
actions or
processes you want to analyze.

6) Deactivate the Trace: -


 Once you have captured the necessary information,

Varun N
return to the ST01 screen, and click "Trace off" to stop
recording.
7) Display and Analyze Trace Results: -

Varun N
 Click on "Analysis" in ST01 screen and specify the user,
date, and time to view the recorded data. Then execute
to see the Trace.

8) Troubleshoot and Analyze:

 Use the trace data to identify issues, such as


unauthorized access attempts, slow-performing SQL

Varun N
queries, or other system problems.

Varun N
 Based on that the security consultants give the
authorization, if fails by identify by using the return
codes in red color.
Note = > It is important to deactivate the trace when not in use.

Return Codes
 RC = > 0 --- Authorization is successful.
 RC = > 4 --- User has required authorization object, but
different
authorization Values.
 RC = > 8 --- User does not have required authorization
values in the user buffer.
 RC = > 12 --- User does not have access to authorization
object.

If any 0 Records found


means if no trace display.

 Incorrect input values.


 User present in different application server.

Varun N
Note = > ST01 trace should be applied in the local server
only. Hence before applying ST01 trace, ensure that user and
you are in the same system.
AL08 = > Users in each server.

SM51 = > List of application servers.

Varun N
STAUTHTRACE
 Exclusive authorization Trace.
 Trace is applied across all application servers.
Note = > This T code is available in the updated version of SAP.

How to Use STAUTHTRACE:


 Access the Transaction:

o Enter STAUTHTRACE in the SAP command field and press Enter.

 Start the Trace:


o Specify the Username and Click on "Start Trace" to begin
recording
authorization checks.

 Perform Activities:
Varun N
o Inform the user to perform the actions that are causing
access issues, such as trying to execute a transaction
they cannot access.

Varun N
 Stop the Trace:
o Once the activities are completed, go back to the
STAUTHTRACE screen, and click "Deactivate Trace".

 View and analyze results:


o Click on "Display Trace" to see the results. and review the
authorization.

It displays the details about the authorization objects, field


values, program name and the return codes.
Note = > Click on System Wide Trace to view the trace for
each application server. Apply the necessary filters, then click on
Execute.

Varun N
PFU
D
Mass User Comparison

 For a single role we can do user comparison in PFCG ->


User comparison Tab.

 If there is a requirement to perform User comparison for 100


Roles
(Multiple roles), then we go to a T code called PFUD, to perform that.

 Click from multiple role selection and copy from clipboard.

Varun N
 Then, click on execute.

What all important actions are performed in PFUD?


1) Profile matchup
 It ensures profile get assigned to user and the role status is green under
SU01.

2) Composite role reconciliation


 Whenever composite role is modified, the role is added or
removed from composite role, should reflect to user as well.

3) HR organizational management: reconciliation


 It ensures that role assigned to position or org unit of the user.

4) Cleanups
 It ensures that expired roles are removed from SU01, record of users.
Program related to PFUD = > PFCG_TIME_DEPENDENCY SM01
= > Lock T code

EWZ5 = > Mass User Lock


SU10 = > SU12 Varun N
1. REPORTS

Reports are custom programs or scripts designed to extract and display data from the SAP system in a specified
format. They are used to provide insights and analytics on various business processes.

Types of Reports:

Standard Reports: Delivered by SAP and can be


customized minimally.
Custom Reports: Developed from scratch to meet
specific requirements.

Tools and Technologies:

ABAP (Advanced Business Application


Programming): The primary programming language
used to create reports in SAP.
ALV (ABAP List Viewer): A tool for developing
interactive and user-friendly reports.

Examples:
Sales analysis report Inventory stock report Financial
statement report

Varun N
2.INTERFACES

Interfaces are mechanisms that enable data exchange between SAP and external systems. They ensure seamless
integration and communication across different platforms and applications.

Types of Interfaces:

Inbound Interfaces: Data is received into SAP from


external systems.
Outbound Interfaces: Data is sent from SAP to
external systems.

Tools and Technologies:

IDocs (Intermediate Documents): Standard SAP format


for data exchange.
BAPIs (Business Application Programming Interfaces):
Standardized programming interfaces for integrating
SAP with external systems.
RFCs (Remote Function Calls): Methods for
communication between SAP systems or between an
SAP system and an external system.
SOAP/REST Web Services: Protocols for web-based
data exchange.
Examples:
Varun N
Integration with third-party logistics providers Data exchange with a CRM
synchronization with external financial systems
3. CONVERSIONS

Conversions refer to the data migration processes required when transferring data from legacy systems to SAP. This
step is critical during SAP implementation projects.

Phases of Data Conversion:

Data Extraction: Extracting data from legacy


systems. Data Transformation: Transforming the data
to fit the SAP data structures.
Data Loading: Loading the transformed data into SAP.
Data Validation: Ensuring the accuracy and
completeness of the loaded data.

Tools and Technologies:

LSMW (Legacy System Migration Workbench): A tool for


migrating data from legacy systems to SAP.
BDC (Batch Data Communication): A method for
automating data entry in SAP.
SAP Data Services: An ETL tool for data migration and
integration.

Examples:
Varun N
Migrating customer master data from a legacy CRM system Transferring historical sales data to SAP

Importing financial data into SAP FI


4. ENHANCEMENTS

Enhancements are modifications made to standard SAP functionality to meet specific business requirements
without affecting the integrity of the original SAP code. These modifications are usually implemented in a way that
preserves the ability to upgrade the SAP system.

Types of Enhancements:
User Exits: Predefined places in standard SAP programs where custom code can be inserted.
Customer Exits: Similar to user exits but typically more extensive and customizable.

BAdIs (Business Add-Ins): More flexible and robust


enhancement techniques.
Enhancement Framework: A collection of tools and
techniques for enhancing SAP applications.

Examples:
Custom validations during sales order creation Enhancing the functionality of standard reports
Adding custom fields to standard SAP screens

Varun N
5. FORMS

Forms are used to generate formatted documents from SAP data. These documents can be printed, emailed, or
faxed and are typically used for business transactions.

Tools and Technologies:


SAPscript: The older technology for designing and printing forms.
Smart Forms: A more advanced tool for designing forms with better flexibility and functionality.
Adobe Forms: The most modern tool, offering rich interactive form design and integration capabilities.

Examples:
Invoice forms
Purchase order forms
Delivery notes

Varun N
6. WORKFLOWS

Workflows automate business processes in SAP by defining a sequence of steps that involve multiple users or
systems. They ensure that tasks are completed in a predefined order and help in managing approvals and
notifications.

Components of a Workflow:
Tasks: Individual units of work assigned to users or systems.

Events: Triggers that start or end workflows.


Agents: Users or user groups responsible for executing tasks.

Tools and Technologies:

SAP Business Workflow: The primary tool for


designing and managing workflows.
Workflow Builder: A graphical tool for creating and
maintaining workflows.

Examples:
Purchase requisition approval workflow Leave request approval
workflow Invoice processing workflow

Varun N
1. Introduction to ABAP Editor
▪ ABAP editor is a tool for ABAP coding.
▪ It is one of the main tools of the ABAP workbench.
▪ The transaction code for ABAP editor is SE38.
▪ Any customized program must start with Z or
Y as first alphabet.
▪ A statement is a sequence of words that
ends with a period.
▪ In the ABAP editor, the keywords appear in blue color.

2.Functionalities of ABAP Editor


▪ Save - Ctrl + S
▪ Syntax check - Ctrl + F2
▪ Activation - Ctrl + F3
▪ Execute - F8
▪ Display/change - Ctrl+ F1
▪ Display object list - Ctrl + Shift + F5
3.Pretty Printer
▪ The use of pretty printer is used to format the
ABAP code. It makes the code more readable.
▪ The shortcut of pretty printer is Shift + F1.
▪ The various functionalities of pretty printer are as follows:
▪ Indentation

Varun N
▪ Convert uppercase/lowercase
4.Comments
▪ 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 a comment.
▪ The " character, which can be entered at any
position in the line, indicates that the remaining
content in the line is a comment.
▪ Shortcut to comment out lines - Ctrl +, ( , )
▪ Shortcut to uncomment lines - Ctrl +. ( . )

5.Data Types
▪ Data types are templates for creating data objects.
▪ A data type defines the technical attributes
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.

Varun N
▪ Data Objects
▪ A data object is an instance of a data type.
▪ A data object holds the contents 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

Varun N
There are three categories of data types.

Elementary Types

▪ They are predefined data types.


▪ They are single data types. They are not
composed of other data types.
▪ Elementary datatypes are of 2 types:
▪ Fixed length data types - C(character) ,
N(numeric) , I(Integer) , P(packed number) ,
F(floating point) , D(date), T(time) ,
X(hexadecimal).

Varun N
▪ Variable length data types - String , Xstring.
▪ 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.
▪ Structure type
▪ Table type
▪ Reference Data Types
▪ There is no pre-defined reference data type.
▪ It describes data objects that contain references
to other objects.
▪ They are of 2 types of reference data type.
▪ Data reference
▪ Object reference
▪ Example : DATA lo_object TYPE REF TO zclass.
▪ In the above syntax - DATA = keyword ,
lo_object = name of data object, TYPE REF TO =
keyword , zclass = name of already existing
class.
▪ Types of Data Objects
The Data objects are of 2 types.

▪ Literals(unnamed data objects)


▪ Named data objects

Varun N
▪ Literals (Unnamed Data Objects)
▪ Literals don’t have any name that’s why they are
called as unnamed data objects.
▪ 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.
▪ 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 :
▪ Variables
▪ Constants
▪ 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
keyword.

Varun N
▪ Example

Varun N
DATA lv_empid(20) TYPE n. lv_empid = 10.
lv_empid = 20.

Constants

▪ Constants are data objects whose contents


cannot 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 a data object that is not
declared in the program itself.
▪ It is defined as a part of the text elements of the program.
▪ Character and Numeric Data Types
▪ The C(character) , N(numeric), D(date), T(time)
are considered as character(non-numeric)
data types.
▪ The I(Integer) , P(packed decimal), F(floating point)
are considered as numeric data types.
Write Statement

▪ The basic ABAP statement for displaying


data on the screen is write.
▪ Example

Varun N
DATA: number TYPE i VALUE 1,
name(25) TYPE c VALUE 'Leena'.

WRITE: 'The Number is', number.


WRITE: / 'The Name is ', name.
▪ We can use ‘ /’ in write statement to denotes a new line.
▪ Chain Operator
▪ The chain operator is ‘:’.
▪ It is used to combine the statements.
▪ Statement sequence -
WRITE var1.
WRITE var2.
WRITE var3.
CHAIN statement: WRITE: var1 , var2 , var3.

Conditional Statements

▪ Conditional statements allow us to execute a


block of code if a certain condition is met.
▪ The various conditional statements are as follows:
▪ IF statement
▪ CASE statement
▪ IF Statement
▪ It is a conditional statement.
▪ Every if statement ends with endif.
▪ We provide multiple conditions using elseif.

Varun N
▪ Multiple statements blocks are there, depends
upon the condition one block executes.
▪ If none of the If and elseif conditions are
satisfied, it goes to else part.

CASE Statement

▪ It is a conditional statement.
▪ Every case statement ends with endcase.
▪ Multiple statements blocks are there, depends
upon the condition one block executes.
▪ If none of the conditions are satisfied, it goes
to others part.

Varun N
Difference between Case C IF

▪ If we have multiple IF conditions , IF check all the


conditions, until it gets a true condition whereas in CASE , it directly jumps to the true condition.

▪ Case is performance effective as compared to IF.


▪ Loop
▪ Loop allows us to execute a group of statements
multiple times.
▪ The various loops are as follows:
▪ Do loop
▪ While loop.
▪ Loop at <itab> where itab stands for Internal table.
▪ Do Loop

Varun N
▪ Do loop is called as a unconditional loop.
▪ Every do loop ends with enddo.
▪ Syntax: Do <n> TIMES.
<statement block>. ENDDO.
While Loop

▪ While loop is called as a conditional loop.


▪ Every while loop ends with endwhile.
▪ Syntax : WHILE<condition>.
<statement block>. ENDWHILE.
Loop Statements

▪ Exit - is used to exit from the loop.


▪ Continue - skip the current processing of the
record and then process the next record in the
loop statement.
▪ Check - if the check condition is not true, loop
will skip the current loop pass and move to
next loop pass.
▪ System Variables
▪ System variables are pre-defined variables in SAP.
▪ SYST is the structure for the system fields.
▪ All system fields are addressed using SY field name.
▪ The various system variables are as follows :

Varun N
▪ SY-SUBRC - System variable for return code
(successful = 0, not successful = other than 0).
SY-TABIX - It returns the current line index inside a loop.

 SY-INDEX - It returns the current line index inside


do and while Loop.
 SY-DATUM - System variable for current date
(internal format - yyyymmdd).
 SY-UNAME - It returns the logon name of the user.
 SY-UZEIT - It returns the current system
time(internal format - hhmmss)
 SY-UCOMM - System variable for user command.
 String
 A string is a collection of characters.
 String is an elementary data type of variable length.
 Imp point : String operations are applicable to data
objects having C(character),N(numeric),D(date),T(time) and string data types.

 String Operations - Concatenate


 The purpose of concatenate is to combine the
strings. Syntax:
CONCATENATE <c1> <cn> INTO <c> SEPARATED BY BY <s>.

In the above syntax: CONCATENATE = keyword , <c1>-----


--<cn> = individual strings , INTO = keyword , <c> = final result string , SEPERATED BY = keyword,
<s> = separator.

Varun N
DATA: lv_1(10) type c VALUE 'NEC',
lv_2(10) type c VALUE 'Software',
lv_3(10) type c VALUE 'Solutions',

lv_output type string.

CONCATENATE lv_1 lv_2 lv_3 INTO lv_output S EPARATED BY ' '.

WRITE: 'The result is : ' ,lv_output.

output :- The result is : NEC Software Solutions

Split

▪ The purpose of split is to divide the strings.


▪ For split, separator is compulsory.
▪ Syntax :
SPLIT <string> AT <separator> INTO <f1> < f2> <f3>….

▪ In the above syntax: SPLIT = keyword , <string>


= string which we need to split, AT = keyword,
<separator> = any delimiter , INTO = keyword ,
<f1> <f2><f3>---------------------------------=
individual
strings.

DATA : lv_1(3) type c ,


lv_2(10) type c ,
lv_3(10) type c .
DATA : lv_5 type string VALUE 'NEC/Software/ Solutions',

Varun N
lv_out type string.

SPLIT lv_5 AT '/' INTO lv_1 lv_2 lv_3 .

WRITE : 'After Split is :', lv_1, lv_2 ,lv_3


.
output :- After Split is : NEC Software Solutions

Condense

▪ The purpose of condense is to remove the


leading and trailing spaces and convert a
sequence of spaces into a single space.
▪ Synta CONDENSE <c>.
x:
▪ In the above syntax: CONDENSE = keyword ,
<c> = string which we want to condense.
DATA : lv_5 type string VALUE ' NEC Soft
ware Solutions '.
CONDENSE lv_5. WRITE
lv_5.
output:- NEC Software Solutions

- Condense No-gaps
▪ To remove the entire spaces the addition no-
gaps is used with condense.
▪ Syntax : CONDENSE <c> NO-GAPS.
▪ In the above syntax : CONDENSE = keyword ,
<c> = string which we want to condense , NO-
GAPS = keyword.

Varun N
DATA : lv_5 type string VALUE ' NEC Soft
ware Solutions '.
CONDENSE lv_5 NO-GAPS. WRITE
lv_5.
output:- NECSoftwareSolutions

Strlen

▪ The purpose of strlen is to provide the string length.


▪ Syntax : len = strlen( string ).
In the above syntax : len = variable name which returns the length of the string, strlen =
pre-defined operation , string = string whose length needs to be calculated.
DATA : lv_5 type string VALUE 'NEC Software Solutions',
lv_length(2) type n.
lv_length = STRLEN( lv_5 ). WRITE
lv_length.
output:- 22

Find

▪ The purpose of find is to find a particular


pattern in a string.
▪ Syntax : FIND <pattern> IN <str> .
▪ In the above syntax : FIND = keyword , <pattern> = is the
sequence of characters we are looking for , IN = keyword ,
<str> = is the string that is being searched.
DATA : lv_5 type string VALUE 'NEC Softwa re Solutions'.

Varun N
FIND 'NEC' IN lv_5.
IF sy-subrc = 0. WRITE 'Found'.
else.
WRITE 'Not Found'.
ENDIF.
Output: - Found

Translate

▪ The purpose of translate is to convert the string


to upper case or lower case.
▪ Syntax :
TRANSLATE <string> TO UPPER CASE / LOWER CASE.

▪ In the above syntax : TRANSLATE = keyword ,


<string> = the string which needs to be
converted , TO = keyword , UPPER
CASE/LOWER CASE = keyword.

DATA : lv_5 type string VALUE 'NEC Softwa re Solutions'.

TRANSLATE lv_5 TO LOWER CASE.


WRITE : / lv_5.
TRANSLATE lv_5 to UPPER CASE.
WRITE : / lv_5.
Output :- nec software solutions
NEC SOFTWARE SOLUTIONS

Translate Using Pattern

Varun N
▪ We can translate a text based upon specific pattern also.
▪ Syntax : TRANSLATE <string> USING <pattern> .
▪ In the above syntax : TRANSLATE = keyword ,
<string> = the string which needs to be
converted , USING = keyword, pattern =
contains letter pairs.
DATA : lv_5 type string VALUE 'nEC software
company',
lv_pattern(10) type c VALUE 'nNsScC'.

TRANSLATE lv_5 USING lv_pattern. WRITE lv_5.


Output :- NEC Software CompaNy

Shift

▪ The purpose of shift is to shift the contents of a string.


▪ It shifts the string by a number of places.
▪ Syntax : SHIFT <string> BY n PLACES <mode>.
(by default mode is left)
▪ In the above syntax : SHIFT = keyword , string
= string which needs to be shifted, BY =
keyword , n = number , PLACES = keyword ,
<mode> = left/right/circular.
DATA : lv_1(10) TYPE c VALUE '0123456789'
,
lv_2(10) TYPE c VALUE '0123456789'
,
lv_3(10) TYPE c VALUE '0123456789'
.

SHIFT lv_1 BY 4 PLACES LEFT.

Varun N
WRITE : / 'Left - ', lv_1.

SHIFT lv_2 BY 4 PLACES RIGHT.


WRITE : / 'Right - ', lv_2.

SHIFT lv_3 BY 4 PLACES CIRCULAR.


WRITE : / 'Circular - ', lv_3. Output :- Left -
456789

Right - 012345
Circular - 4567890123

DATA : lv_1(10) TYPE c VALUE '200000000',


lv_2(10) TYPE c VALUE '000000002'.

SHIFT lv_1 RIGHT DELETING TRAILING '0'.


WRITE : / 'Right - ' , lv_1.

SHIFT lv_2 LEFT DELETING LEADING '0'.


WRITE : / 'Left - ' , lv_2.

Substring Processing

▪ Substring is a part of the string or small set of


characters from the string.
▪ Depends upon the requirement we need to
process the substring.
▪ Syntax : Target variable = Source variable[+]
[starting position of substring](length of the
substring).

Varun N
DATA : lv_value(30) type c VALUE '91-040- 6789990004',

lv_county(2) type c,
lv_city(3) type c,
lv_number(10) type c.
lv_county = lv_value+0(2).
WRITE : /'The Country Code - ' , lv_county.

lv_city = lv_value+3(3).
WRITE : / 'The City Code - ', lv_city.

lv_number = lv_value+7(10).
WRITE : / 'The Phone Number - ', lv_number.

Output :- The Country Code - 91


The City Code - 040
The Phone Number - 6789990004

▪ String Comparison Operators


▪ String comparison operators are used to
compare the strings.
▪ String comparison operators are applicable to data
objects having C(character),N(numeric),D(date),T(time) and string data types.

▪ The system variable SY-FDPOS plays an


important role in string comparison.

Varun N
The various string comparison operators are as follows: CO (contains only)

DATA : lv_1(20) type c VALUE 'Sathish',


lv_2(20) type c VALUE 'Sathish Derangula'
.

IF lv_1 co lv_2.
WRITE : 'TRUE' , Sy-fdpos.
else.
WRITE : 'FALSE' , Sy-fdpos. ENDIF.
Output :- TRUE 20

CN (contains not only)

DATA : lv_1(20) type c VALUE 'Sathish',


lv_2(20) type c VALUE 'Sathish Derangula'
.

Varun N
IF lv_1 CN lv_2.
WRITE : 'TRUE' , Sy-fdpos.
else.
WRITE : 'FALSE' , Sy-fdpos. ENDIF.

Output:- FALSE 20

CA (contains any)
DATA : lv_1(20) TYPE c VALUE 'Sathi@1234',
lv_2(20) TYPE c VALUE '0123456789'.

IF lv_1 CA lv_2.
WRITE : sy-fdpos.
ELSE.
WRITE : sy-fdpos.
ENDIF.
Output:- 6
NA (contains not any)

DATA : lv_1(20) TYPE c VALUE 'Sathi@1234',


lv_2(20) TYPE c VALUE '0123456789'.
IF lv_1 NA lv_2.
WRITE : 'TRUE', sy-fdpos. ELSE.
WRITE : 'FALSE' , sy-fdpos. ENDIF.
Output: - FALSE 6

Varun N
CS(contains string)
ATA : lv1(30) TYPE c VALUE 'Sathish Derangula',
lv2(20) TYPE c VALUE 'Sathish'.

IF lv1 CS lv2.
WRITE : 'True' , sy-fdpos. ELSE.
WRITE : 'False', sy-fdpos. ENDIF.
Output :- TRUE 0

NS(contains no string)

DATA : lv1(30) TYPE c VALUE 'Sathish Derangula',


lv2(20) TYPE c VALUE 'Manoj'.

IF lv1 NS lv2.
WRITE : 'True' , sy-fdpos. ELSE.
WRITE : 'False', sy-fdpos. ENDIF.

Output :- TRUE 30

CP (contains pattern)

Varun N
DATA : lv1(30) TYPE c VALUE 'Sathish Derangula',
lv2(20) TYPE c VALUE '*Dera*'.

IF lv1 CP lv2.
WRITE : 'True' , sy-fdpos. ELSE.
WRITE : 'False', sy-fdpos. ENDIF.

Output :- TRUE 8

NP(contains no pattern)

DATA : lv1(30) TYPE c VALUE 'Sathish Derangula',


lv2(20) TYPE c VALUE 'Dera*'.

IF lv1 NP lv2.
WRITE : 'True' , sy-fdpos. ELSE.
WRITE : 'False', sy-fdpos. ENDIF.
Output :- TRUE 30

Varun N
▪ Internal Tables
▪ Internal table is a temporary storage of
data on application layer.
▪ Internal table stores any number of records at run time.
▪ A very important use of internal tables is for
storing and formatting data from a database
table within a program.
▪ Work Area in Internal Tables
▪ Work area is also a temporary storage of
data on application layer.
▪ Work area are single rows of data.
It is used to process the data in an internal table, one line at a time. Internal Table Operations

1. Append  It is used to insert the data at the last of the internal table.
SYNTAX:- APPEND ls_emp to lt_emp.

2. Loop  It is used to read the records one by one from the internal
table.
SYNTAX:-LOOP AT lt_emp INTO ls_emp.

ENDLOOP.

3. Delete  It is used to delete the records from the internal table.


DELETE lt_emp WHERE emp_name = 'H'.
DELETE lt_emp INDEX 3.

4. Modify  It is used to modify the records of the internal table.

Varun N
SYNTAX:-
MODIFY lt_emp FROM ls_emp TRANSPORTING emp_na me.

5. Sort  It is used to sort the internal table. By default, in Ascending


order will sort the data
SYNTAX :- SORT lt_emp BY emp_id .

6. Read table  It is used to read the first matching record from the
internal table.
SYNTAX:-
READ TABLE lt_emp INTO ls_emp WITH KEY emp_id
= 9.

READ TABLE lt_emp INTO ls_emp INDE X 5.

7. Clear, Refresh  It is used to clear the contents of the internal table.


SYNTAX:-CLEAR lt_emp.
REFRESH lt_emp.

8. Describe Table  It returns the number of records in the internal


table.
SYNTAX:-
DESCRIBE TABLE lt_emp LINES DATA(LV_LINES).

In the above syntax : DESCRIBE TABLE = keyword, <itab> = name


of the internal table ,
LINES = keyword, <lv_lines> = local variable which returns the
number of records.

Varun N
9.Collect - It is used to make sum of numeric field values based
upon unique character (non-numeric) field values. The C(character)
, N(numeric), D(date), T(time) are considered as character(non- numeric) data types. The I(Integer) ,
P(packed

Types of Internal Tables Internal table is of 3


types.

A. Standard internal table


1) They are the default internal tables.
2) They are the index based Internal tables.
3) Records can be inserted or appended.
4) Data is not sorted by default, We can use SORT
statement to sort the Internal table.
5) We read a record using KEY or Index.
6) Either Linear search(Sequential) or Binary search
is used to search a record.
7) Response time depends upon the number of
entries in the internal table. Response time of a
standard internal table is improved by using Binary
Search.
TYPES: BEGIN OF lty_data,
ono TYPE zdeono_28,
pm TYPE zdepm_28,
END OF lty_data.

DATA : lt_data TYPE TABLE OF lty_data.


DATA : lt_data TYPE STANDARD TABLE OF lty_data.

Varun N
Append Inserts the record at the last of the internal table whereas Insert inserts the record at
anywhere in the internal table.

B. Sorted internal table


1)They are the special type of internal tables in
which data is automatically sorted.
We need to specify the key while declaring the sorted internal table.

2) They are also the index based Internal tables.


3) Records can be inserted.
4) Data already sorted, there is no need to use SORT statement.
5) We read a record using KEY or Index.
6) Binary search is used to search a record.
7) Response time of a sorted internal table is fast as
compared to Standard Internal table.
TYPES: BEGIN OF lty_data,
ono TYPE zdeono_28,
pm TYPE zdepm_28,
END OF lty_data.

DATA : lt_data TYPE SORTED TABLE OF lty_data WIT H UNIQUE KEY


ONO PM.
DATA : lt_data TYPE SORTED TABLE OF lty_data WIT H NON-UNIQUE
KEY ONO PM.

Varun N
C. Hashed internal table
Hashing - It is a technique which directly returns the address of the record based upon the
search key without using the index.

1) They are the special type of internal table which


works on HASH algorithms. We need to specify the
unique key while declaring the internal table.
2) They are not the index based Internal tables.
3) Records can be inserted.
4) There is no impact of SORT, as we read the record
based upon the hashed algorithm.
5) We Read a Record using Key, index is not applicable.
6) Hashed algorithm is used to search a record.
7) Response time is faster as compared to
Standard and sorted internal tables, as responsetime is
independent of number of entries. It is well
suited for tables, where a table has huge
number of records and we want to search based upon
unique key.

TYPES: BEGIN OF lty_data,


ono TYPE zdeono_28,
pm TYPE zdepm_28,
END OF lty_data.

DATA : lt_data TYPE HASHED TABLE OF lty_data WIT H UNIQUE KEY


ONO

Varun N
Varun N
DATABASE OPERATIONS

Database operations deal with the database tables. The various database operations are as
follows:

1. Select  Select is used to fetch data from database tables.


2. Insert  Insert is used to insert the records to database tables.
3. Update  Update is used to update the existing
records in the database tables.
4. Delete  Delete is used to delete the existing records
from the database tables.
5. Modify  It works for both Insert + Update. For existing
records – It acts as update, for non- existing records –
it acts as Insert.

Selection Screen

▪ Selection screen is also called as Input screen.


▪ With the help of selection screen user provides a
input to the program.
▪ There are 2 ways to provide the input to the program.
▪ Parameters
▪ Select-options

Parameters

▪ Parameters are used to pass the single input.


▪ The various parameters variations are as follows:

Varun N
▪ PARAMETERS <p> ...... DEFAULT <f> ......
▪ PARAMETERS <p> ...... OBLIGATORY ......
▪ PARAMETERS <p> ...... AS CHECKBOX ......
▪ PARAMETERS <p> ...... RADIOBUTTON GROUP <radi>......
▪ Select-Options
▪ Select-options are used to pass a range of inputs.
▪ The various Select-options variations are as
follows: SELECT-OPTIONS <seltab> FOR <f> ...
DEFAULT <g> [TO
<h>]

SELECT-OPTIONS <seltab> FOR <f> ... NO-EXTENSION


Hiding Multiple selections

SELECT-OPTIONS <seltab> FOR <f> ... NO INTERVALS


Hiding High values

SELECT-OPTIONS <seltab> FOR <f> ... OBLIGATORY

A select-option has 4 parts.

▪ Sign - I/E(include/exclude)
▪ Option - Relational operator (EQ, BT, LT etc.)
▪ Low - Low value
▪ High - High value

Varun N
Selection Screen Block

LINE COMMENT - Starting position of the comment + length

DATA : lv_one TYPE ebeln.

SELECTION-
SCREEN : BEGIN OF BLOCK b1 WITH FRAME TITLE TEXT
-001.

SELECT-OPTIONS : s_one FOR lv_one NO INTERVALS.


PARAMETERS p_lv_one TYPE ebeln OBLIGATORY.

SELECTION-SCREEN : BEGIN OF LINE.

PARAMETERS : p_r1 TYPE c RADIOBUTTON GROUP r1. SELECTION-


SCREEN : COMMENT 3(8) TEXT-002.

PARAMETERS : p_r2 TYPE c RADIOBUTTON GROUP r1. SELECTION-


SCREEN : COMMENT 14(8) TEXT-003.

PARAMETERS : p_r3 TYPE c RADIOBUTTON GROUP r1. SELECTION-


SCREEN : COMMENT 27(8) TEXT-004.

SELECTION-SCREEN : END OF LINE.

SELECTION-SCREEN : BEGIN OF LINE.

PARAMETERS : p_check1 AS CHECKBOX. SELECTION-SCREEN :


COMMENT 3(8) TEXT-005.

PARAMETERS : p_check2 AS CHECKBOX. SELECTION-SCREEN :


COMMENT 15(8) TEXT-006.

Varun N
SELECTION-SCREEN : END OF LINE.

SELECTION-SCREEN : END OF BLOCK b1.

Varun N
ABAP Learning:

Pre-defined ABAP types:

* Data Objects with Built-in Types


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

" comment/uncomment the following declarations and check the output


DATA variable TYPE string.
* DATA variable TYPE i.
* DATA variable TYPE d.
* DATA variable TYPE c LENGTH 10.
* DATA variable TYPE n LENGTH 10.
* DATA variable TYPE p LENGTH 8 DECIMALS 2.

* Output
**********************************************************************

out->write( 'Result with Initial Value)' ).


out->write( variable ).
out->write( '---------' ).

variable = '19891109'.

out->write( 'Result with Value 19891109' ).


out->write( variable ).
out->write( '---------' ).

Varun N
Data Object:

* Example 1: Local Types


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

* Comment/Uncomment the following lines to change the type of my_var


TYPES my_type TYPE p LENGTH 3 DECIMALS 2.
* TYPES my_type TYPE i .
* TYPES my_type TYPE string.
* TYPES my_type TYPE n length 10.

* Variable based on local type


DATA my_variable TYPE my_type.

out->write( `my_variable (TYPE MY_TYPE)` ).


out->write( my_variable ).

* Example 2: Global Types


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

* Variable based on global type .


" Place cursor on variable and press F2 or F3
DATA airport TYPE /dmo/airport_id VALUE 'FRA'.

out->write( `airport (TYPE /DMO/AIRPORT_ID )` ).


out->write( airport ).

* Example 3: Constants
**********************************************************************

CONSTANTS c_text TYPE string VALUE `Hello World`.


CONSTANTS c_number TYPE i VALUE 12345.

"Uncomment this line to see syntax error ( VALUE is mandatory)


* constants c_text2 type string.

Varun N
out->write( `c_text (TYPE STRING)` ).
out->write( c_text ).
out->write( '---------' ).

out->write( `c_number (TYPE I )` ).


out->write( c_number ).
out->write( `---------` ).

* Example 4: Literals
**********************************************************************

out->write( '12345 ' ). "Text Literal (Type C)


out->write( `12345 ` ). "String Literal (Type STRING)
out->write( 12345 ). "Number Literal (Type I)

"uncomment this line to see syntax error (no number literal with digits)
* out->write( 12345.67 ).

Varun N
Arithmetic Calculations:

* Declarations
**********************************************************************

" comment/uncomment these line for different result types


TYPES t_result TYPE p LENGTH 8 DECIMALS 2.
* TYPES t_result TYPE p LENGTH 8 DECIMALS 0.
* TYPES t_result TYPE i.

DATA result TYPE t_result.

* Calculations
**********************************************************************
" comment/uncomment these lines for different calculations

result = 2 + 3.
* result = 2 - 3.
* result = 2 * 3.
* result = 2 / 3.
*
* result = sqrt( 2 ).
* result = ipow( base = 2 exp = 3 ).
*
* result = ( 8 * 7 - 6 ) / ( 5 + 4 ).
* result = 8 * 7 - 6 / 5 + 4.

* Output
**********************************************************************

out->write( result ).

Varun N
Varun N
String Processing:

METHOD if_oo_adt_classrun~main.

* Declarations
**********************************************************************
TYPES t_amount TYPE p LENGTH 8 DECIMALS 2.

DATA amount TYPE t_amount VALUE '3.30'.


DATA amount1 TYPE t_amount VALUE '1.20'.
DATA amount2 TYPE t_amount VALUE '2.10'.

DATA the_date TYPE d VALUE '19891109'.


DATA my_number TYPE p LENGTH 3 DECIMALS 2 VALUE '-273.15'.

DATA part1 TYPE string VALUE `Hello`.


DATA part2 TYPE string VALUE `World`.

* String Templates
**********************************************************************

" comment/uncomment the following lines for different examples


DATA(text) = |Hello World|.
* DATA(text) = |Total: { amount } EUR|.
* DATA(text) = |Total: { amount1 + amount2 } EUR|.

* Format Options
**********************************************************************

"Date
* DATA(text) = |Raw Date: { the_date }|.
* DATA(text) = |ISO Date: { the_date Date = ISO }|.
* DATA(text) = |USER Date:{ the_date Date = USER }|.

"Number
* DATA(text) = |Raw Number { my_number }|.
* DATA(text) = |User Format{ my_number NUMBER = USER }|.
Varun N
* DATA(text) = |Sign Right { my_number SIGN = RIGHT }|.
* DATA(text) = |Scientific { my_number STYLE = SCIENTIFIC }|.

* String expression (concatenation Operator)


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

* DATA(text) = part1 && part2.


* DATA(text) = part1 && | | && part2.
* DATA(text) = |{ amount1 } + { amount2 }| &&
* | = | &&
* |{ amount1 + amount2 }|.

* Output
**********************************************************************

out->write( text ).

METHOD if_oo_adt_classrun~main.

* Declarations
**************************

DATA number1 TYPE i.


DATA number2 TYPE i.

DATA result TYPE p LENGTH 8 DECIMALS 2.

* Input Values
**************************

number1 = -8.
number2 = 3.

* Calculation
**************************

* DATA(result) = number1 / number2. "with inline declaration

result = number1 / number2.

DATA(output) = |{ number1 } / { number2 } = { result }|.

* Output
**************************

out->write( output ).

ENDMETHOD.

Varun N
Varun N
Conditional Branching:

* Declarations
**********************************************************************

CONSTANTS c_number TYPE i VALUE 0.


* CONSTANTS c_number TYPE i VALUE 1.
* CONSTANTS c_number TYPE i VALUE 2.
* CONSTANTS c_number TYPE i VALUE -1.
* CONSTANTS c_number TYPE i VALUE -2.

* Example 1: Simple IF ... ENDIF.


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

out->write( `--------------------------------` ).
out->write( `Example 1: Simple IF ... ENDIF.` ).
out->write( `-------------------------------` ).

IF c_number = 0.
out->write( `The value of C_NUMBER equals zero` ).
ELSE.
out->write( `The value of C_NUMBER is NOT zero` ).
ENDIF.

* Example 2: Optional Branches ELSEIF and ELSE


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

out->write( `--------------------------------------------` ).
out->write( `Example 2: Optional Branches ELSEIF and ELSE` ).
out->write( `--------------------------------------------` ).

IF c_number = 0.
out->write( `The value of C_NUMBER equals zero` ).
ELSEIF c_number > 0.
out->write( `The value of C_NUMBER is greater than zero` ).
ELSE.
out->write( `The value of C_NUMBER is less than zero` ).
ENDIF.
Varun N
* Example 3: CASE ... ENDCASE
**********************************************************************

out->write( `---------------------------` ).
out->write( `Example 3: CASE ... ENDCASE` ).
out->write( `---------------------------` ).

CASE c_number.
WHEN 0.
out->write( `The value of C_NUMBER equals zero` ).
WHEN 1.
out->write( `The value of C_NUMBER equals one` ).
WHEN 2.
out->write( `The value of C_NUMBER equals two` ).
WHEN OTHERS.
out->write( `The value of C_NUMBER equals non of the above` ).
ENDCASE.

Exception Handling:

* Declarations
**********************************************************************
DATA result TYPE i.

DATA numbers TYPE TABLE OF i.

* Preparation
**********************************************************************

APPEND 123 TO numbers.

* Example 1: Conversion Error (no Number)


**********************************************************************
Varun N
CONSTANTS c_text TYPE string VALUE 'ABC'.
* CONSTANTS c_text TYPE string VALUE '123'.

out->write( `---------------------------` ).
out->write( `Example 1: Conversion Error` ).
out->write( `---------------------------` ).

TRY.
result = c_text.
out->write( |Converted content is { result }| ).
CATCH cx_sy_conversion_no_number.
out->write( |Error: { c_text } is not a number!| ).
ENDTRY.

* Example 2: Division by Zero


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

CONSTANTS c_number TYPE i VALUE 0.


* CONSTANTS c_number TYPE i VALUE 7.

out->write( `---------------------------` ).
out->write( `Example 2: Division by Zero` ).
out->write( `---------------------------` ).

TRY.
result = 100 / c_number.
out->write( |100 divided by { c_number } equals { result }| ).
CATCH cx_sy_zerodivide.
out->write( `Error: Division by zero is not defined!` ).
ENDTRY.

* Example 3: Itab Error (Line Not Found)


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

CONSTANTS c_index TYPE i VALUE 2.


* CONSTANTS c_index TYPE i VALUE 1.

out->write( `-------------------------` ).
out->write( `Example 3: Line Not Found` ).
out->write( `-------------------------` ).

TRY.
result = numbers[ c_index ].
out->write( |Content of row { c_index } equals { result }| ).
CATCH cx_sy_itab_line_not_found.
out->write( `Error: Itab has less than { c_index } rows!` ).
ENDTRY.

* Example 4: Combination of Different Exceptions


**********************************************************************
* CONSTANTS c_char TYPE c LENGTH 1 VALUE 'X'.
* CONSTANTS c_char TYPE c length 1 value '0'.
CONSTANTS c_char TYPE c LENGTH 1 VALUE '1'.
* CONSTANTS c_char TYPE c length 1 value '2'.

out->write( `----------------------` ).
Varun N
out->write( `Example 4: Combination` ).
out->write( `----------------------` ).

TRY.
result = numbers[ 2 / c_char ].
out->write( |Result: { result } | ).
CATCH cx_sy_zerodivide.
out->write( `Error: Division by zero is not defined` ).
CATCH cx_sy_conversion_no_number.
out->write( |Error: { c_char } is not a number! | ).
CATCH cx_sy_itab_line_not_found.
out->write( |Error: Itab contains less than { 2 / c_char } rows| ).
ENDTRY.

 Change the values of constants c_number, c_text, c_index, and c_charin a way
that no exceptions are raised.

* Declarations
**********************************************************************

CONSTANTS c_number TYPE i VALUE 3.


* CONSTANTS c_number TYPE i VALUE 5.
* CONSTANTS c_number TYPE i VALUE 10.

DATA number TYPE i.

* Example 1: DO ... ENDDO with TIMES


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

out->write( `----------------------------------` ).
out->write( `Example 1: DO ... ENDDO with TIMES` ).
out->write( `----------------------------------` ).

Varun N
DO c_number TIMES.
out->write( `Hello World` ).
ENDDO.

* Example 2: DO ... ENDDO with Abort Condition


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

out->write( `-------------------------------` ).
out->write( `Example 2: With Abort Condition` ).
out->write( `-------------------------------` ).

number = c_number * c_number.

" count backwards from number to c_number.


DO.

out->write( |{ sy-index }: Value of number: { number }| ).


number = number - 1.

"abort condition
IF number <= c_number.
EXIT.
ENDIF.

ENDDO.

Analyze the console output. Play around with the source code to get familiar with the
concepts; Uncomment different declarations of constant c_number to see how the different
values affect the result

* Declarations Varun N
**********************************************************************

" Internal tables


DATA numbers TYPE TABLE OF i.

"Table type (local)


TYPES tt_strings TYPE TABLE OF string.
DATA texts1 TYPE tt_strings.

" Table type (global)


DATA texts2 TYPE string_table.

" work areas


DATA number TYPE i VALUE 1234.
DATA text TYPE string.

* Example 1: APPEND
**********************************************************************

APPEND 4711 TO numbers.


APPEND number TO numbers.
APPEND 2 * number TO numbers.

out->write( `-----------------` ).
out->write( `Example 1: APPEND` ).
out->write( `-----------------` ).

out->write( numbers ).

* Example 2: CLEAR
**********************************************************************

CLEAR numbers.

out->write( `----------------` ).
out->write( `Example 2: CLEAR` ).
out->write( `----------------` ).

out->write( numbers ).

* Example 3: table expression


**********************************************************************
APPEND 4711 TO numbers.
APPEND number TO numbers.
APPEND 2 * number TO numbers.

out->write( `---------------------------` ).
out->write( `Example 3: Table Expression` ).
out->write( `---------------------------` ).

number = numbers[ 2 ] .

out->write( |Content of row 2: { number }| ).


"Direct use of expression in string template
out->write( |Content of row 1: { numbers[ 1 ] }| ).

* Example 4: LOOP ... ENDLOOP


**********************************************************************
Varun N
out->write( `---------------------------` ).
out->write( `Example 4: LOOP ... ENDLOOP` ).
out->write( `---------------------------` ).

LOOP AT numbers INTO number.

out->write( |Row: { sy-tabix } Content { number }| ).

ENDLOOP.

* Example 5: Inline declaration in LOOP ... ENDLOOP


**********************************************************************
out->write( `-----------------------------` ).
out->write( `Example 5: Inline Declaration` ).
out->write( `-----------------------------` ).

LOOP AT numbers INTO DATA(number_inline).


out->write( |Row: { sy-tabix } Content { number_inline }| ).
ENDLOOP.

Local Class:

*"* use this source file for the definition and implementation of
*"* local helper classes, interface definitions and type
*"* declarations

CLASS lcl_connection DEFINITION.

PUBLIC SECTION.

DATA carrier_id TYPE /dmo/carrier_id.


DATA connection_id TYPE /dmo/connection_id.

CLASS-DATA conn_counter TYPE i.

PROTECTED SECTION.
PRIVATE SECTION.

ENDCLASS.

CLASS lcl_connection IMPLEMENTATION.

ENDCLASS.

Icon Strip

Desktop Strip:

Varun N
Loop At

Varun N
DEBUGGIN
G

1. Debugging

▪ Debugging is a technique by which we can find the error, correct the error
and detect the error.

▪ SAP debugger is a part of ABAP workbench only.

2.Ways of Debugging
There are 2 ways of debugging.
▪ Set the breakpoint on any executable statement and program stops
automatically at that point.

▪ We can debug the code with the help of transaction code /h.

3. Execution Keys
There are 4 execution keys in debugging mode.
▪ F5 - Step by step execution

▪ F6- Line by line execution

▪ F7 - Return

▪ F8 - Continuous execution or exit

4.System Variables in Debugging Mode


There are 2 default system variables available in the debugging mode.
▪ SY-SUBRC - System variable for return code (successful = 0, not
Varun N
successful = other than 0). To check whether the above statement,
function, or select query is
executed or not.
▪ SY-TABIX - It returns the current line index inside

a loop. Below are the important system variables

1. SY-DATE: Current date

2. SY-UZEIT: Current time

3. SY-UNAME: Username

4. SY-TCODE: Transaction code

5. SY-REPID: Report or program name

6. SY-DATUM: System date

Varun N
7. SY-LANGU: Logon language
8. SY-MANDT: Client (system identifier)

5.Static Breakpoints

▪ Static breakpoints are also called as user independent breakpoints.

▪ The syntax to set a static breakpoint is BREAK-POINT.

6. Dynamic Breakpoints

▪ Dynamic breakpoints are also called as user dependent breakpoints.

▪ The syntax to set a dynamic breakpoint is BREAK

username. Example: - BREAK Sathish (Username).

7.Various Operations on Internal Table in Debugging Mode

The various operations on internal table in the debugging mode are as follows:
▪ Deleting a row from an internal table.

▪ Editing a row of an internal table.

▪ Adding a row to an internal table.

▪ Saving internal table to a local file.

▪ Delete complete table.

Click on the LT_USER

Varun N
Click on the Services of the tool symbol after we can find the Change table content where we
perform the internal table operations.

8.Jump to a Particular Statement in Debugging Mode

▪ We can jump to a particular statement in debugging mode by using

the path: Debugger-Go to statement.

▪ We can also jump to a particular statement by using the shortcut ‘Shift +


F12’.

Varun N
9. Features - Setting Breakpoint at Keywords, FM’s and Messages

▪ We can set the breakpoints at keywords in debugging mode like -


SELECT, CALL FUNCTION, MESSAGE etc.

▪ We can also set breakpoints on specific function modules or


subroutines or messages etc.

Varun N
10. Features - Deleting and Deactivating the Breakpoints

▪ Deleting breakpoints - Permanently deleting the breakpoints in that


particular session.

▪ Deactivating breakpoints - Temporary deleting the breakpoints in that


particular session. When we run the program again, the breakpoint
resumes.

Varun N
11. Features - Find

▪ In the debugging mode, we can find the specific records of internal table.

▪ We need to do CTRL + F for the internal table data, one pop-up appears
to pass the column values, pass the input and it point to the records
having matching values.

12. Features - Source Code Display

▪ In the debugging mode, we can open the code in a new session without
closing the debugging session.

▪ We need to click on to program/include/line icon as per the


screenshot(highlighted).

Varun N
13. Features - Save Parameters as Test Data (SE37)

▪ We can save the function module parameter values in the debugging mode.

▪ The path to save function module parameters values as test data is


as follows: Services of the Tool - Save Parameters as Test Data(SE37)

14. Features - SAP Memory and ABAP Memory Values

▪ We can check the values of SAP memory and ABAP memory in the
debugging mode.

▪ The path to check the memory id values in the debugging mode is

as follows: New Tool - Special Tools - System Areas (Internal

Only)

Varun N
15.Watchpoints

Watchpoints are used to monitor the values of variables, work areas and internal tables.

Varun N
16. Breakpoints and Watchpoints Comparison

▪ Breakpoints are for executable statements whereas watchpoints are


used to monitor the values of variables, work areas and internal
tables.

▪ A user can set a maximum of 30 breakpoints whereas a user can set a


maximum of
10 watchpoints.
17. Comparison of Session Breakpoint and External Breakpoint

▪ A session breakpoint is attached to user session and exists until the


user closes the last session, whereas external breakpoint has a validity of
2 hours.

▪ The session breakpoint is used to debug the ABAP code internally


whereas the external breakpoint is used to debug the ABAP code from
an external process like Web Dynpro applications, BSP (Business
Server Pages) etc.

18. User Specific Desktop

▪ Desktop 1, Desktop 2 and Desktop 3 are considered as user specific


desktop in the debugging mode.

The layouts are different and in desktop 2 we can see the ABAP STACK (It is based on the LIFO).
But in Standard desktop we can see both normal and ABAP STACK and Desktop 3 is just most
preferable one to debug.
Varun N
19.Way to Debug a Dialog Screen or Pop-Up Screen

▪ Firstly, we need to create a text document using the below

mentioned code. [Function]

Command=/H
Type=SystemCommand
▪ Then drag and drop this text document on the required dialog screen
or pop-up screen.

20. Update Debugging

▪ Update debugging is used to debug the code which is written in the


update task as we cannot debug the update task code using normal
debugging.

▪ Example - Function module called in the update task.

▪ The path to on the update debugging is as follows:

Settings - Change Debugger Profile/Settings - Update Debugging

21. Script Tab

▪ We can use the script tab to stop the debugger on the selection of
specific tables and update of tables.

▪ We need to go to script tab, click on to load script and pass the name of
the script as per the requirement.

Varun N
 After click on the Start Script and enter the table like MARA, MAKT, MARD.

Varun N
The various scripts for selection and updating of tables are as follows:

▪ Script for selection of tables - RSTPDA_SCRIPT_BP_SELECT_TAB

▪ Script for updating of tables - RSTPDA_SCRIPT_BP_CHANGE_TAB

Note: To check the inserting and updating fields into DB tables in the debugging you should
change the normal debugging mode to update mode.

Breakpoint - Breakpoint at statement - INSERT DBTAB or MODIFY DBTAB

Adding Custom Fields in SAP

Varun N
Interview Questions for SAP SD Prepared by Balachandra
Marri

1. Adding Custom Fields in the Sales Order


Item Level in SAP

Step 1: Append Custom Fields to the Structure

1. Enhance the Standard Structure:


o Go to transaction SE11.
o Identify the structure that corresponds to the item level of the
sales order (e.g., VBAP).
o Append your custom fields to the structure. This could be done
by creating an append structure.

2. Structures for Item Level:


o For sales order item level, you can add custom fields to the
VBAP table (sales document: item data).
o Append the custom field in this structure (use a
meaningful name, like ZZFIELD).

Step 2: Adjust the Screen Layout (Optional)

If you want to make the custom field visible on the sales order item screen:
1. Go to transaction SE51 for screen enhancement.
2. Identify the screen number for sales order items (e.g., SAPMV45A -
screen number 4900).
3. Add the custom field to the layout using the screen painter tool.

Step 3: Populate Custom Fields

To populate the custom fields, you need to enhance the logic in the user exits or BAdIs.

1. Using User Exits:


o Go to transaction SMOD and locate the relevant exits (e.g.,
MV45AFZZ).
o Implement the logic inside the exit, such as
USEREXIT_MOVE_FIELD_TO_VBAP, to populate your
Varun N
custom fields.

Example code in MV45AFZZ:


IF VBAK-AUART = 'Z001'. " Custom sales
document type VBAP-ZZFIELD =
<your_logic>.

ENDIF.

Varun N
Interview Questions for SAP SD Prepared by Balachandra
Marri

2. Using BAdIs (Business Add-Ins):

o Use transaction SE18 to find a relevant BAdI. For sales orders,


you might use BADI_SALES_ITEM.
o Implement the necessary logic in the BAdI method to populate
the custom field.

Step 4: Update Data in Custom Fields

You need to ensure that the custom fields are correctly populated during order processing
(create/change/display).
1. Transaction VA01/VA02/VA03:
o When the sales order is created or updated, make sure the
custom field logic is executed in the corresponding user exit or
BAdI to populate the field.
2. Saving the Data:
o During save operations (VA01, VA02), the custom fields should
be correctly stored in the database table (e.g., VBAP) based on
your logic.

Step 5: Extend the Pricing/Conditions or Other Functionalities (If Required)

 If the custom fields are used in pricing, output determination, or


other processes, you might need to enhance the field catalog for
those functionalities and adjust the required routines or exits.

Step 6: Testing and Validation

 Test the configuration by creating, updating, and displaying sales


orders to ensure the custom fields are functioning as expected.

2. Adding Custom Fields in the Pricing Field


Catalog in SAP

To add custom fields to the pricing field catalog in SAP, you need to follow a structured
Varun N
process involving enhancements of SAP structures and writing code in user exits to
ensure the custom fields are available during pricing determination. Below are the steps
to do this:

Step 1: Append Custom Fields to the Pricing


Communication Structures

Varun N
Interview Questions for SAP SD Prepared by Balachandra
Marri

Pricing in SAP uses communication structures to pass data between various


components during pricing determination. These structures include:

 KOMK (Header communication structure)

 KOMP (Item communication structure)

1. Go to Transaction SE11:
o Identify whether the field should be added to the header
(KOMK) or item (KOMP) communication structure.

o Create an append structure for KOMKAZ (for header) or KOMPAZ


(for item).

o Add the custom field to this append structure (e.g., ZZFIELD).

Step 2: Populate Custom Fields in User Exits

After appending the fields to the communication structures, you need to ensure that these
fields are filled with the correct data during pricing.

1. User Exits for Pricing:


o You need to use the relevant user exits to move data from the
sales document to the pricing structures. The following are
the most commonly used user exits for pricing:
o For Header Fields: Use the exit
USEREXIT_PRICING_PREPARE_TKOMK in program MV45AFZZ.
o For Item Fields: Use the exit
USEREXIT_PRICING_PREPARE_TKOMP in program
MV45AFZZ.

Example code for header and item fields:

* Example for Header (KOMK) Custom

Field FORM

USEREXIT_PRICING_PREPARE_TKOMK.

MOVE VBKD-ZZPAYEE TO TKOMK-

ZZPAYEE. ENDFORM.

* Example for Item (KOMP) Custom Varun N


Field FORM USEREXIT_PRICING_PREPARE_TKOMP.

MOVE VBAP-ZZFIELD TO TKOMP-ZZFIELD.

ENDFORM.

Varun N
Interview Questions for SAP SD Prepared by Balachandra
Marri

Step 3: Add Custom Fields to the Pricing Field Catalog

After adding the custom fields to the communication structures and populating them
through the user exits, the next step is to add them to the pricing field catalog. The field
catalog determines which fields are available for use in pricing conditions.

o This transaction allows you to maintain the pricing field catalog.

o Add the custom field (e.g., ZZFIELD) to the pricing field


catalog so it can be used in pricing conditions.

Step 4: Adjust the Access Sequence and Condition


Tables (If Required)

If your custom field is used for determining pricing conditions, you may need to update the
access sequence and condition tables.

Varun N
1. Go to Transaction V/07:
o Modify the access sequence to include the new custom field.

2. Go to Transaction V/03:

Varun N
Interview Questions for SAP SD Prepared by Balachandra
Marri

o Update or create a condition table that includes the custom


field for your pricing strategy.

Step 5: Testing the Custom Fields in Pricing

Once the custom fields are added to the pricing field catalog and the necessary coding is
done, you can test the implementation:

1. Create or Change Sales Orders using transaction VA01 or VA02.

2. Check the pricing calculation and verify that the custom fields are
being used in the pricing conditions.

3. Analyze the output and make sure the field is properly flowing
into the pricing communication structure and that the condition
records are being accessed correctly.

Additional Considerations:
 If you want to display the custom field in pricing analysis, you may
need to modify the pricing analysis layout.

 Ensure all configuration changes and code adjustments are thoroughly


tested in the quality or test environment before moving to production.

By following these steps, you can successfully add custom fields into the pricing field
catalog in SAP, and the fields will be available for use in pricing conditions and routines.

Varun N
Varun N

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy