SAP ABAP Technical Interview Questions
SAP ABAP Technical Interview Questions
Table of Contents
1. ABAP Dictionary
2. Modularization Techniques
3. Debugging Concepts
4. Internal Tables
5. Database Updates and Open SQL
6. String Operation / System Variables / Formatting Data
7. Transaction Code (Technical & Functional)
8. Background Jobs
9. Module Pool Programming
10. ABAP OOPS
11. Batch Data Communication (BDC)
12. Business Application Programming (BAPI)
13. Legacy System Migration Workbench (LSMW)
14. File Handling
15. Business Add in (BADI )
16. Enhancement Framework
17. Field symbols and Data Reference
18. SAP and ABAP Memory
19. Standard Text (SO10)
20. Excel Upload
21. Performance Tuning
22. Classical Reports and Interactive Reports
23. OOPS ALV Reports
24. ALV with IDA
25. Message Class
26. SAP Tranports Organizer
27. SMARTFORMS
28. ADOBE Forms
29. ABAP on HANA ( ABAP 7.4)
30. ABAP On HANA ( Core Data Service )
31. ABAP On HANA ( AMDP )
32. Intermeditae Document ( IDOCS)
33. ODATA
34. Business Process
35. General Topics
Data Dictionary
2. How many types of tables exist and What are they in Data Dictionary?
There are 4 Types of Tables in ABAP dictionary -
Transparent tables - Exists with the same structure both in dictionary as well as in database
exactly with the same data and fields. Both Open SQL and Native SQL can be used.
Pool tables - Pooled tables in the dictionary has a many-to-one relation with the table in
database. Table in the database has the different name as in the dictionary. Pooled table are
stored in table pool at the database level.
Cluster tables - These are logical tables that are arranged as records of transparent tables. One
cannot use Native SQL on these tables (only Open SQL). They are not manageable directly using
database system tools.
3. What Is the Step-by-step Process to Create A Table in Data Dictionary?
Steps to create a table –
Creating domains (data type, field length, Range).
Creating data elements (properties and type for a table field).
Creating tables (SE11).
4. Can a transparent table exist in Data Dictionary but not in the Database physically?
No, Transparent table do exist with the same structure both in the dictionary as well as in the
database. And also exactly with the same data and fields.
5. How can we set the tablespaces and extent sizes?
We can specify the extent sizes and the tablespace (physical storage area in the database) for a
transparent table by setting the size category and data class.
10. How many types of size categories and data classes are there?
There are five size categories (0-4) and 11 data classes only three of which are appropriate for
application tables:
• APPL0- Master data (data frequently accessed but rarely updated).
• APPL1- Transaction data (data that is changed frequently).
• APPL2- Organizational data (customizing data that is entered when the system is configured and
then rarely changed).
The other two types are:
• USR
• USR1 – Intended for customer's own developments.
17. In the ABAP/4 Dictionary Tables can be defined independent of the underlying database (T/F).
True.
18. A field containing currency amounts (data type CURR) must be assigned to a reference table and
a reference field. Explain.
As a reference table, a system containing all the valid currencies is assigned or any other table,
which contains a field with the currency key format. This field is called as reference field.
The assignment of the field containing currency amounts to the reference field is made at
runtime. The value in the reference field determines the currency of the amount.
19. A field containing quantity amounts (data type QUAN) must be assigned to a reference table and
a reference field. Explain?
As a reference table, a system table containing all the valid quantity units is assigned or any
other table, which contains a field with the format or quantity units (data type UNIT). This field is
called as reference field.
The assignment of the field containing quantity amounts to the reference field is made at
runtime. The value in the reference field determines the quantity unit of the amount.
20. What is the significance of Technical settings (specified while creating a table in the data
dictionary)?
By specifying technical settings we can control how database tables are created in the database. The
technical settings allows us to
• Optimize storage space requirements.
• Table access behavior.
• Buffering required.
• Changes to entries logged.
23. What is the max. no. Of structures that can be included in a table or structure.
Nine.
27. If a table that is to be extended contains a long field, we cannot use append structures why?
Long fields in a table must always be located in the end, as the last field of the table. If a table has an
append structure the append line must also be on the last field of the table.
28. Can we include customizing include or an append structure with Pooled or Cluster tables?
No.
29. What are the two ways for restricting the value range for a domain?
• By specifying fixed values.
• By stipulating a value table.
30. Structures can contain data only during the runtime of a program (T/F)
True.
31. The data of a view is not physically stored, but derived from one or more tables (t/f)
True.
34. Can you delete a domain, which is being used by data elements?
No.
38. Can you delete data element, which is being used by table fields.
No.
Value Table : The value table is maintained at domain level, it is also called as domain level
validation.
(or)
It is a table which contains all valid entries of a domain, this domain can be reused in multiple
tables.
54. what are lock objects and what FM will generate during lock object creations ?
A lock object is a feature of the ABAP Dictionary that is used to synchronize access to the same
data by more than one program123. A lock object defines the tables and key fields that need to
be locked when data is inserted or changed in the database13. A lock object can be created and
administered using the t-code SM124. When a user tries to access a locked record, SAP will
either block the access or provide a message indicating that the record is already locked
FM – ENQUEUE and DEQUEUE Function module will auto generate when the lock object in
activated.
The SAP system offers two primary methods (SESSION METHOD, CALL TRANSACTION METHOD) for
transferring data from other Non-SAP systems to SAP system. These two methods are collectively called
as 'BATCH INPUT' or 'Batch Data Communication' (BDC).
There are mainly three steps in BDC session processing. Those are -
Identify the screens of the transaction that the program is going to process.
Write a program to build the BDC table that uses to submit the data to SAP.
Submit the BDC table to the system in the batch mode or as a single transaction by the CALL
TRANSACTION command.
Transaction Method -
It is faster than session method.
While executing, it starts from starting.
Session Method -
It is slower than transaction method.
While executing, it does not start from starting.
These are the 3 functional modules that are used in a sequence to perform a data transfer successfully
using BDC programming -
BDC_OPEN_GROUP - Parameters like Name of the client, sessions and username are specified in
these functional modules.
BDC_INSERT - It is used to insert the data for one transaction into a session.
BDC_CLOSE_GROUP - This is used to close the batch input session.
Call transaction Method and Call dialog, Direct Input Method are alternatives to Batch Input session.
What do you do when the system crashes in the middle of a BDC batch session?
Check number of records already updated and delete them from input file and run BDC again.
Analyze, correct input file format and entries in internal table BDCDATA.
First, we need to investigate the list of the incorrect sessions to do the processing new. Now, to correct
the faulty session, we need to spot which value and which screen are causing the error. Minor or small
errors may solve away in an interactive way; however, in the order resolve major errors, one may require
modifying the batch input program. In those cases, it is required to modify the data file to set things
right.
What is the structure of the BDC table?
FVAL CHAR 132 Actual value to be filled into the specified screen field
How do you find the transaction number, program number and field names?
What are the available OK Codes that can be utilized during batch input processing?
/n – Terminates current batch input transaction and marks as incorrect.
/bdel – Delete current batch input transaction from session.
/bend – Terminate batch input processing and mark session as incorrect.
/bda – Change display mode to process the session on screen instead of displaying only errors.
/bde – Change display mode to display only errors instead of processing the session on the screen.
What is the effect of the BDC_CURSOR field name in the BDC table?
The cursor can be positioned by setting the cursor on the field name and enter the corresponding field
value.
Call transaction is used to update the database using a single transaction in asynchronous mode. Call
transaction used to update the data that is relatively small. If the call transaction used to update the
large amount of data, there might be a problem of getting TIME_OUT.
The session method is used to perform huge database updates using more than one transaction and
executes for a long time. Session method used to update the data that is relatively huge.
The errors occurred during the database updation using call transaction are trapped using a structure
bdcmsgcall. If the error occurred in the above process, structure bdcmsgcall field msgtyp becomes ‘e’.
The error records are formatted calling format_message function to convert them into the desired
format and stored in an internal table for listing all the error in the single shot.
In the context of session method, the updating method is “Batch Input”. We required to code a program
to complete the operation.
In the context of LSMW method, the updating methods is “Batch Input/Direction Input” from an IDOC,
BAPI structure. No source code is required, the complete operation is performed in 16 steps.
We need to use the BDC_OKCODE '=P+' while doing the BDC for table control.
It is the BCD_OKCODE for Page down that can be used for scrolling down in table control.
After running a BDC program in background, next day morning when you see the results, few records are
not updated (error records). What will you do then?
We need to investigate incorrect session, analyze the error screen, reprocess the session after correcting
the data.
You are given functional specs for a BDC program and you need to decide whether to write a method call
transaction or a session. How u will decide?
Based on the amount of data (number of records to update), we can decide what method to use. For
example - If data is less the 5000, we can use call transaction. If data is more than 5000 records, we can
use session method.
In all BDC tables, the field name BDC_OKCODE and a field value of ‘/11’ is the last entry used to save BDC
table.
What are the problems in processing batch input sessions? How is batch input process different from
processing online?
The below are two major drawbacks of processing batch input sessions -
Sessions cannot run in parallel.
The processing is slow.
The data in BDC tables is saved by using the field name ‘BDC_OKCODE’ and field value of ‘/11’.
Does the CALL TRANSACTION method allow multiple transactions to be processed by SAP?
Yes.
CALL TRANSACTION trans [ using bdctab MODE mode ]. Three possible entries are there for MODE -
A - show all screens
E - show only screens with errors
N - show no screens
Can we use call transaction and session method in the same program? explain?
Yes, we can call "call transaction" and "session method" in same program. Generally, we use call
transaction for updating and session method for logging errors in the same program.
What are the different types of mode (run Code) in Call Transaction Method?
In contrast to LEAVE TRANSACTION, the CALL TRANSACTION statement causes the system to start a new
SAP LUW. This second SAP LUW runs parallel to the SAP LUW for the calling transaction.
BDC_OPEN_GROUP - Parameters like Name of the client, sessions and username are specified in
these functional modules.
BDC_INSERT - It is used to insert the data for one transaction into a session.
BDC_CLOSE_GROUP - This is used to close the batch input session.
No transaction is stored until the previous transaction has been written to the Database during the
processing. This is called Synchronous Database update.
What is BDC_OKCODE?
The BDC_OKCODE is a command field identified in batch input. This name is constant and always
identifies the command field.
How can we position the cursor on a field?
BDCDATA-FNAM = ‘BDC_CURSOR’
S - Synchronous
A - Asynchronous
L - Local
The message parameter specifies that all system messages issued during a CALL TRANSACTION are
written into the internal table. The internal table must have the structure of BDCMSGCOLL.
To enhance the batch input procedure, the SAP system offers the direct input technique for transferring
large amount of data. This technique does not create sessions but stores the data directly. The direct
input programs should be executed in the background only. To maintain and start these programs, use
program RBMVSHOW or the transaction BMVO.
What is the ABAP program name to process the batch input session automatically?
RSBDCSUB
Parameters Purpose
CLIENT Client in which session to be processed
GROUP Name of the session
HOLDDATE Lock date
KEEP Keep session even after successful processing
This is used to check the user authorizations to run
USER the transactions
Conversions – LSMW
1. What is LSMW ?
The LSMW (Legacy System Migration Workbench) is a tool based on SAP software that
supports single or periodic data transfer from non-SAP to SAP systems (and with
restriction from SAP to SAP system). Its core functions are: Importing legacy data from
PC spreadsheet tables or sequential files.
2. Difference between LSMW and BDC
The differences between LSMW and BDC are stated as below :
1.lsmw is basically for standard sap application.BDC is basically for customized
applications.
2. In lsmw mapping is take care by sap.In bdc we have to give mapping concept explicitly.
3. LSMW offers different techniques for migrating data say : Direct input , Batch input
recording , BAPI , IDOC.
4. BDC basically uses recording. There are two methods to implement BDC : (a) Call
Transaction Method(b) Session Method.
5. LSMW is basically designed for Functional consultants who do no coding .BDC is used
by technical consultants , who do coding.
6. In LSMW , Coding cannot be done flexibily as BDC.On the other hand in BDC ,Coding
can be done flexibly to customize applications.
7. In LSMW, we do the recording through LSMW only. However, in case of BDC we do the
recording through transaction SHDB.
8. LSMW is more preferable method as it uses the standard programs for data upload. In
case of BDC, if screen design changes tomorrow, program will not work(need to do the
recording again).
Project : Specifies the name of the data transfer project. More than one subproject can be
assigned to project.
Subproject : Specifies the name of the subproject. A subproject can have an unlimited
number of objects.
Object : Object name. An object corresponds to a business object.
7. Events in LSMW ?
The events of LSMW are.
BEGIN_OF_PROCESSING - Before the beginning of data processing
BEGIN_OF_TRANSACTION - Before the beginning of transaction data processing
BEGIN_OF_RECORD - Before applying the conversion rules for a source structure
END_OF_RECORD - After applying the conversion rules for a source structure.
END_OF_TRANSACTION - After finishing transaction processing.
END_OF_PROCESSING__ After finishing data processing.
8. Can I build periodic interfaces using LSMW?
No. The LSM Workbench is available free of charge to SAP’s customers and partners
10. Is there a way to define GLOBAL data in LSMW for use in the conversion rules?
Goto the MENU EXTRAS->LAYOUT
Choose Global Data Definition. You will get this.
Field Mapping and Rule
__GLOBAL_DATA__ Global Data Definitions and Declarations
If you double click on that in change mode , you can define the global data for the
conversion program.
Using change request options - Go to LSMW (Give your project, subproject and object) -
> Extras > Create change request.
Conversions – BAPI
1. What is BAPI ?
BAPIs are defined as API methods of SAP business object types but implemented as remote
enabled Function modules . These business object types and their BAPIs are described and
stored in the Business Object Repository (BOR).
An External Application System (May be as SAP system or any other system uses
programming language like Java Or Visual Basic Or C++ ) can make a call to BAPI.
SAP Business Objects: Real time objects, such as a sales order/billing doc can be
represented as business objects in business application systems ( R/3).
SAP Business Objects can be created with Tcode- SWO1 called as Business Object Repository.
This BO Repository allows to define Business Object, their interfaces and BAPIs(API
Methods).
The BAPI FM interface supports standard fields but there can be cases where the
customer adds some Z-fields to the DB table / some other business function is activated
in the system which in turn adds some fields to the DB tables. In either of the cases the
standard BAPI interface won’t be able to update these addon fields. SAP provides a way
to update these addon fields in terms of BAPI Extension technique.
The BAPI extension structure allows to pass the structure name ( name of the structure
that contains addon fields) and values. Once this is done, the BAPI takes care of
updating the fields.
8. Is BAPI being always a RFC Function Module?
Yes
9. BAPI Names should always starts with the name ‘BAPI ‘
Yes
ABAP Debugging
7. What is watchpoint ?
Watchpoints are like "stop signs" for the ABAP Debugger. Sometimes we debug and look
for a specific value on an internal table that has more than 1,000 records. Debugging the
table on record at a time can be exhaustive and time consuming. To solve this, we can
place a watchpoint. Run the debugger, and it will stop at the watchpoint's given value.
/H
Internal Tables
Internal table is a temporary table that is created, used during the program execution, and
deleted before the program terminated. Internal tables used to store the dynamic data sets
from a fixed structure in the main/working memory in ABAP. The lifetime of the table is until
end of the program execution. Internal tables fulfill the function of arrays in ABAP.
SY-TABIX is a system variable that stores the index current processing record of an internal
table.
SY-INDEX is a system variable that acts as a loop iteration counter, it stores loop iteration
number.
We can sort internal table without using SORT statement by declaring sorted internal table. For
ex - DATA <new-sort-table> TYPE SORTED TABLE OF <input-table>.
AT FIRST / ENDAT
AT LAST / ENDAT
AT NEW / ENDAT
AT END OF / ENDAT
SUM
ON CHANGE OF / ENDON
The code between AT NEW and ENDAT is executed only during the first loop pass. So it is used to
write the headers or some other initialization processing.
The code between AT LAST and ENDAT is executed only during the last loop pass. So it is used to
write the totals or some report footers.
Between AT FIRST and ENDAT the work area will not contain any data. The default key fields
are filled with asterisks(*) and the numeric fields are filled with zeros. The ENDAT restores the
contents to the values they had prior to entering the AT FIRST. Changes to the work area within
AT FIRST and ENDAT are lost. The same applies for AT LAST and ENDAT.
AT NEW and ENDAT is used to detect a change in the value of the field between the loop passes.
The field that is specified in AT NEW is called control level. The code between AT NEW and
ENDAT will be executed during the first loop pass and every time the value of the control level
changes or any other field left to the control level changes. Between AT NEW and ENDAT all the
fields in the work area that are right to the control level are filled with zeros and asterisks.
Similarly The code between AT END OF and ENDAT will be executed during the last loop pass and
every time the value of the control level changes or any other field left to the control level
changes.
internal table is used to hold data. and table types are used for refernce of a table. Difference
is that internal tables are specific to a particular program and need to be defined every time.
where as Table types are defined globally and can be used in n number of programs
The objective of this document is aimed at explaining the concept of logical unit of work in SAP. I
assume that this will be a good read for my fellow readers.
gv_x = 1.
gv_x = 2.
gv_x = 3.
COMMIT WORK.
What will be the value of gv_x at the COMMIT WORK?
No, the value of gv_x will not be 3; when commit is executed by the system the value of gv_x that will be
passed is dependent at the point of function call therefore during the first call the value of gv_x will be 1
& during the second call the value of gv_x will be 2.
1. Difference between select single and select single upto 1 Rows ?
Select single statement only selects the first record of any series of records from a database
table. That means this statement can read a single record from a database table. It keeps the
data into a work area or header line. This work area is generally a line type of internal table.
In below example we are fetching records of PO no, item no, material, plant & storage location
from table EKPO where the PO no is 3000000232. The database contains only 3 items for this
PO.
REPORT zabap_gui.
TABLES: ekpo.
* Creating a custom structure of Item Table
TYPES:
BEGIN OF ty_ekpo,
ebeln TYPE ekpo-ebeln,
ebelp TYPE ekpo-ebelp,
matnr TYPE ekpo-matnr,
werks TYPE ekpo-werks,
lgort TYPE ekpo-lgort,
END OF ty_ekpo.
WRITE:/ wa_ekpo-ebeln,
15 wa_ekpo-ebelp,
28 wa_ekpo-matnr,
48 wa_ekpo-werks,
55 wa_ekpo-lgort.
Output of this:
The database contains 3 records here. But select single statement fetches only single record
from database. Here the first record is always fetched by this statement.
Select up to statement is used to mention the rows need to be selected from the database table.
If the database contains that number of rows then it will display accordingly. Here we are
declaring an internal table to store the multiple row records and print the output as well.
REPORT zabap_gui.
TABLES: ekpo.
Output of this:
Since there are only three records in database, the system shows only 3 records in spite of being
mentioned “UP TO 5 ROWS”.
Inner join is used to join two or more than two tables which are having common fields. Inner join
actually joins with the data which are common in both table. In the following example one
purchase order is having the unique entry in EKKO table and it has 24 items in the EKPO table
based on the different items. Since we have selected EKPO table as INNER JOIN we are having all
records of that PO in item table EKPO. In this way we have joined further two tables MAKT &
MARA.
This join will select all records from the first table based on the where condition and then it will
join the second table with matching condition. Here if it doesn't find any record on the second
table, then also it will create single line (blank line) for the join. Left outer join always creates
one line of the right table based on the left table.
Check for all entries internal table is not initial before passing in the select query
String Operation / System Variables / Formatting Data
String Operations
Strings, which are widely used in ABAP programming, are a sequence of characters.We use data type C
variables for holding alphanumeric characters, with a minimum of 1 character and a maximum of 65,535
characters. By default, these are aligned to the left.
Creating Strings
The following declaration and initialization creates a string consisting of the word 'Hello'. The size of the
string is exactly the number of characters in the word 'Hello'.
REPORT YT_SEP_15.
DATA my_Char(5) VALUE 'Hello'.
Write my_Char.
Hello
String Length
In order to find the length of character strings, we can use STRLEN statement. The STRLEN () function
returns the number of characters contained in the string.
Example
REPORT YT_SEP_15.
DATA: title_1(10) VALUE 'Tutorials',
length_1 TYPE I.
1 CONCATENATE
Two strings are joined to form a third string.
2 CONDENSE
This statement deletes the space characters.
3 STRLEN
Used to find the length of a field.
4 REPLACE
Used to make replacements in characters.
5 SEARCH
To run searches in character strings.
6 SHIFT
Used to move the contents of a string left or right.
7 SPLIT
Used to split the contents of a field into two or more fields.
The following example makes use of some of the above mentioned statements −
Example
REPORT YT_SEP_15.
DATA: title_1(10) VALUE 'Tutorials',
title_2(10) VALUE 'Point',
spaced_title(30) VALUE 'Tutorials Point Limited',
sep,
dest1(30),
dest2(30).
CONDENSE spaced_title.
Write: / 'Condense with Gaps:', spaced_title.
Formatting
ABAP offers various types of formatting options to format the output of programs. For example, you can
create a list that includes various items in different colors or formatting styles.
The WRITE statement is a formatting statement used to display data on a screen. There are different
formatting options for the WRITE statement. The syntax of the WRITE statement is −
LEFT-JUSTIFIED
1
Specifies that the output is left-justified.
CENTERED
2
Denotes that the output is centered.
RIGHT-JUSTIFIED
3
Specifies that the output is right-justified.
UNDER <g>
4
The output starts directly under the field <g>.
NO-GAP
5
Specifies that the blank after field <f> is rejected.
7 NO-ZERO
If a field contains only zeroes, then they are replaced by blanks.
Following are the formatting options for Numeric Type fields −
NO-SIGN
1
Specifies that no leading sign is displayed on the screen.
EXPONENT <e>
2 Specifies that in type F (the floating point fields), the exponent is defined in
<e>.
ROUND <r>
3 The type P fields (packed numeric data types) are first multiplied by 10**(-r)
and then rounded off to an integer value.
CURRENCY <c>
4 Denotes that the formatting is done according to the currency <c> value that
is stored in the TCURX database table.
UNIT <u>
5 Specifies that the number of decimal places is fixed according to the <u>
unit as specified in the T006 database table for type P.
DECIMALS <d>
6 Specifies that the number of digits <d> must be displayed after the decimal
point.
For instance, the following table shows different formatting options for the date fields −
DD/MM/YY 13/01/15
MM/DD/YY 01/13/15
DD/MM/YYYY 13/01/2015
MM/DD/YYYY 01/13/2015
DDMMYY 130115
MMDDYY 011315
YYMMDD 150113
Here, DD stands for the date in two figures, MM stands for the month in two figures, YY stands for the
year in two figures, and YYYY stands for the year in four figures.
Let’s take a look at an example of ABAP code that implements some of the above formatting options −
REPORT ZTest123_01.
WRITE: n, m.
WRITE: / n,
/ m UNDER n.
WRITE: / n NO-GAP, m.
DATA time TYPE T VALUE '112538'.
WRITE: / time,
/(8) time Using EDIT MASK '__:__:__'.
Tutorials Point
Tutorials
Point
TutorialsPoint
112538
11:25:38
Print Page
System Variables
AL08 List of all Users Logged ON (about all Instances/Servers of the System)
SP00 Spool
NACE conditions of output control (to create a link between forms and driver programs)
SE64 Terminology
smartforms Smartforms
Modularization Technique
In a function module, passing data using call by reference. In particular, the tables
parameter should call using "call by reference" by passing memory address.
In an RFC, passing data is by value. The reason behind this is, it’s going to access other
system while doing the above by reference wouldn't work as we are into another system
whose memory id will not match.
A BAPI are standard SAP function modules provided by SAP for remote access. Also, they
are part of Business Object Repository (BOR).
RFC is the protocol used to call functions in an R/3 system by a caller external to R/3 or
to call programs external to R/3 from an R/3 system. BAPI are RFC enabled function
modules. The difference between RFC and BAPI are business objects. We create business
objects and those are then registered in our BOR (Business Object Repository) that can
be accessed outside the SAP system by using some other applications (Non-SAP) such as
VB or JAVA.
Calling by reference: During a subroutine call, only the address of the actual parameter is
transferred to the formal parameters. The formal parameter has no memory of its own,
and we work with the field of the calling program within the subroutine. If we change
the formal parameter, the field contents in the calling program also change.
Calling by value: During a subroutine call, the formal parameters are created as copies of
the actual parameters. The formal parameters have memory of their own. Changes to
the formal parameters have no effect on the actual parameters.
Calling by value and result: During a subroutine call, the formal parameters are created
as copies of the actual parameters. The formal parameters have their own memory
space. Changes to the formal parameters are copied to the actual parameters at the end
of the subroutine.
BACKGROUND JOBS
Procedure 1:
Below is a sample code for the same. Note the ZTEMP2 is the program i am
scheduling with 15mins frequency.
1. Singleton Class
Ensures that the class has only one instance and provides global point of access to this object/instance.
Instance - requires instance, pass by value, defined using “METHODS, Involves declaration of reference variable,
instantiating the class and then calling the class, itt can access all attributes of a class, Can be redefined in
sub classes.
5. Narrow casting / Widening Casting in OOPS ABAP –
Both the Narrow casting and Wide casting is related to Inheritance concept,
Narrowcasting - In Narrow casting, an instance of the subclass is assigned to the reference.
of the superclass.
Widening Caste - An instance of the superclass is assigned to the instance of the subclass
Inheritance - Derive code functionality from one class to another, promotes reusability of classes,
Encapsulation - we can do encapsulation via access methods – public, private, protected.
Polymorphism - Polymorphism means redefining methods to either overload them or override them,
Abstraction - A class which contains at least one Abstract method is called Abstract class.
A class which contains methods with implementation and without implementation is called Abstract Class.
* We can't create 'objects' to Abstract Class because they are not fully Classes or Fully Implemented.
Final Class - creating a class as a final means you can stop polymorphism. A class that is defined as final
class can not be inherited further. All Methods of a final class are inherently final and must not be declared
as final in the class definition. Also, a final method can not be redefined further.
BADI follows the Object-Oriented approach to make them reusable. A BADI can be used any
number of times whereas standard enhancement techniques can be used only once.
To define a BADI use Sap Menu -> Tools -> ABAP Workbench -> Utilities -> Business Ad-Ins ->
- When a BADI is created, BADI class gets automatically created with the suffix 'CL_EX_'
after the first character of the BADI name.
- Package: Specifies the Package in which this BADI resides.
- Multiple uses: With this option, you can have multiple implementations for the same
BADI.
SE18, When you create a BAdI definition, a class interface will be automatically created and you
can define your methods in the interface. The implementation of the methods can be done in
the SE19 transaction.
An adapter class with 'CL_EX_' inserted between the first and second characters of the BADI
name.
An interface with 'IF_EX_' inserted between the first and second characters of the BADI name
Method 1:
Method 2:
Go to transaction SE84 and click on Enhancements. Then double click on Business Add-Ins.
3) Now Press F8, and a list of BADI names will be displayed as shown below. Select the
appropriate BADI name and implement it based on the business requirement using the
transaction SE19.
Method 3:
1) Multi-use BADI:With this option, any number of active implementations can be assigned to
the same definition BADI. By default, this option is checked.
If you have multiple-use BADI definitions, the sequence must not play any role.
2) Filter-dependent BADI:
Using this option we can define the BADI according to the filter values to control the add-in
implementation on specific criteria.
The normal customer enhancement is a BAdI without a filter which is called once. No state has
to be kept, so you can use static methods. Such a BAdI is defined in the core or an industry
solution and is implemented by a customer.
If the BAdI is a single-use BAdI, that is, it requires exactly one implementation, a default class
must be provided by SAP. Otherwise, the GET BADI will raise an exception if this statement is
executed before the customer has inserted his or her implementation.
You use a multiple-use BAdI with static methods if no data is kept and many implementations
make sense. For example, you can write defined results specified in the interface to different
destinations.
13. How can you implement particular implementations for multiple implementations Badi?
Business Add-Ins may be implemented on the basis of a filter value. If an enhancement for
country-specific versions is provided in the standard version, it is likely that different partners
will want to implement this enhancement. The individual countries can create and activate their
own implementation.
Business Add-Ins may be implemented on the basis of a filter value. If an enhancement for
country-specific versions is provided in the standard version, it is likely that different partners
will want to implement this enhancement. The individual countries can create and activate their
own implementation.
We can define multiple BADI definitions under a single Enhancement Spot and also we can
define multiple BADI implementations under a single Enhancement implementation.
16. What are the Differences Between Classic and New BAdI's in SAP
Classic and new BAdIs differ in a number of features important for migration:
BADI object:
a. In the case of classic BAdIs, you create a BAdI object by calling a factory method and reference
it by means of a reference variable of the type of the BAdI interface.
b. In the case of new BadIs, you create a BAdI object with the ABAP statement GET BADI as a
handle for the calls of BAdI methods and you reference it with a reference variable of the type of
the BAdI. A BADI object is an instance of an internal BAdI class that is invisible to the outside
world.
a. In the case of classic BAdIs, the filter values are stored in a structure and passed with the call
of the BAdI methods.
b. In the case of new BAdIs, the comparison values for the filters used to search for
implementations are passed when the BAdI object is created with the GET BADI statement.
In the case of the static variant, addition TYPE is not declared. The static type of the reference
variable BADI must be a BADI. This determines which BADI will be used.
The Fallback option is used if no BAdI implementation with suitable filter conditions and no
standard implementation is found.
Many a times we need to call the Multiple Badi implementations, in a sequential manner as per
the sort technique because by default the multiple Badi implementations are called randomly by
the run time environment. To achieve this SAP provides sort technique.
1.No Sort
2. Standard Sort
3. Special Sort
To deactivate a BADI implementation in SAP, you can go to Transaction Code SE19 and select the
implementation you want to deactivate. Then, you can choose the ‘Implementation’ menu
option and select ‘Deactivate’ to deactivate the implementation. Once deactivated, the BADI
implementation will no longer be active in the system.
Enhancement Framework
There are two types of explicit enhancement options: Source code enhancements with source
code plug-ins and BAdIs:
Explicit enhancement options of the source code enhancement type allow you to insert source
code plug-ins. These are lines of code that are executed if the source code enhancement option
is inserted in the code with the Enhancement Point command.
Source code enhancement options with the Enhancement Section command behave the same,
except that the source code plug-in replaces the section in the original code. Therefore, you are
not only able to enhance the original code, but can also flag specific code sections (as
enhancement sections) so that other developers can replace these sections with other code
without making modifications.
Customer exits are provided to the customer in the form of Function Module which holds the
include in the customer namespace.The user can add own source code in it.This is technically an
enhancement.Eg for customer exits are Function module exits,Menu Exits,Screen Exits.BADI.
User exists are empty subroutines that the SAP Developers have provided for you that u can fill
with your own source code.This is technically a modification since the object in the SAP name
space is modified. This is SD module. Sample program name is MV45AFZZ.
Field Symbols and Data Reference
Field symbol is a placeholder for data object, which points to the value present at the memory address
of a data object. It does not reserve any physical memory space when we declare them. It only points to
a data object at run time. Field symbols are of two types:
NOTE:
Typed field symbols can point to the data objects of specified type only.
After assigning a data object to a field symbol, if we make any changes to the field symbol value,
then the value of corresponding data object is also updated.
Modifying internal table records - We can declare a field symbol of type any structure, which we can use
while looping through an internal table.
NOTE:
If we change any field of structure in field symbol, the corresponding field in internal will get
updated. We don’t need to write the MODIFY statement which we would have written if we had
used work area. This is because work area stores a copy of the internal table row, whereas field
symbol directly references the internal table row.
Hence processing of internal table with field symbol is faster than the processing of internal
table with work area.
Appending to internal table - Now suppose we want to append some values to one internal table, then
we can use field symbol as below:
After executing this, the internal table will hold two rows.
NOTE:
Always perform a check on field symbol that if it is assigned before doing any operation to avoid
short dump. Also after doing the operation, unassign the field symbol.
Reading internal table – We can read a record of internal table using field symbol as below:
Dynamic programming is actually implemented using generic field symbols. The most commonly used
generic types are TYPE ANY and TYPE ANY TABLE.
Here we can assign any data object to TYPE ANY field symbol whereas TYPE ANY TABLE field symbol is
used for assigning any internal table.
TYPE ANY:
Let us assign a work area of type MARA to a TYPE ANY field symbol and then populate the work area
using field symbol.
NOTE:
After assigning lw_mara to <fs_str>, we cannot directly use the ‘-‘ operator on field symbol to
access the fields of MARA structure i.e. <fs_str>-matnr would produce syntax error. This is
because the field symbol type is declared only at runtime not at compile time.
So to access the matnr field with field symbol, first we need to assign that field component to a
different field symbol and then use the new field symbol to update the matnr field as show in
above code snippet.
After execution of above code snippet, the value of lw_mara-matnr would be MAT001.
TYPE ANY TABLE:
We can assign any internal table to this field symbol. Let us analyze the below code snippet to
understand how we could use such field symbol.
NOTE:
Since <fs_tab> is a generic field symbol, its type will be known only at runtime, hence we cannot
directly write the fields of MARA structure after WITH KEY, instead we have to write the field
name within parenthesis as shown above.
In ABAP, this parenthesis indicates the compiler that the value of the operand will be decided at
runtime, hence we don’t get any compilation error.
Field symbol is a placeholder for data object to which it is assigned and points to the content of data
object hence it can be used at any operand position (no need to dereference it) and works with the
content of the referenced memory area (value semantics).
Data references are pointers to data objects and it contains the memory address of data object
(reference semantics). Data reference cannot be used at operand position directly; it should be
dereferenced first.
Here first statement declares a reference variable lr_num which can point to any data object of type “i”.
And second statement creates an anonymous data object of type “i” and assigns the reference of this
data object to lr_num. Now if we want to change the value of data object, then it can be done by
dereferencing lr_num by using dereference operator ->* as shown below:
lr_num->* = 2.
WRITE: / lr_num->*.
NOTE:
With ABAP 7.40, instead of CREATE DATA, the NEW operator can also be used to create an
anonymous data object and assigns its reference to a data reference variable.
If you want to assign the reference of an existing data object to a data reference, you can use GET
REFERENCE statement.
Here lv_num is an existing data object (not anonymous data object). The output would be 4.
NOTE:
With ABAP 7.40, instead of GET REFERENCE, the REF operator also can be used to assign the
reference of an existing data object to a data reference.
Here individual components of the structure can be accessed with -> operator on data reference
variable.
While processing internal table row, we can use REFERENCE INTO statement to set references to table
rows as shown below:
DATA: lr_mara TYPE REF TO mara.
DATA: lt_mara TYPE TABLE OF mara.
Here first statement declares a generic data reference lr_num which can point to any data object. And
second statement creates an anonymous data object of type “i” and assigns its reference to lr_num.
Now since lr_num is generic, lr_num->* cannot be directly used at operand position. Hence the below
statement would not be allowed.
lr_num->* = 2.
So in case of generic data reference, it can only be dereferenced using a field symbol, and this field
symbol can be used at any operand position to manipulate the value of data object as shown below:
<num> = 3.
NOTE:
After ASSIGN statement you should check sy-subrc If field symbol assignment is successful, sy-
subrc will be 0 otherwise it will be 4.
Here CREATE DATA statement creates an anonymous data object (MARA structure) and assigns its
reference to the generic data reference lr_str, which then can be dereferenced into a generic field
symbol <str>. Now, to access individual component of MARA structure, ASSIGN COMPONENT statement
can be used.
Requirement: Selection screen parameter “Table Name” will take a table name as input and display the
corresponding table entries as output.
Solution:
PARAMETERS: p_tname TYPE tabname.
DATA: lr_tab TYPE REF TO data.
FIELD-SYMBOLS: <tab> TYPE ANY TABLE.
Explanation:
Here lr_tab is a generic data reference and <tab> is a generic field symbol for internal table. In CREATE
DATA statement, the type of data object is mentioned in parenthesis which means that the type will be
determined at runtime based on the value of parameter p_tname. After that we have dereferenced the
data reference lr_tab into a generic field symbol <tab>. Now this field symbol can be used to do any valid
operation on the internal table.
Object reference
Data reference variable can store the reference to any data object (variable, structures, internal tables
etc.) whereas Object reference variable can store the reference to any class object.
For data reference variables, either the generic data type or a completely specified data type can be
specified. For object reference variables, either a class or an interface can be specified.
SAP and ABAP Memory
SAP memory is avaialble to all external sessions,i.e, it is not specific to a single session ,it belongs to all
sessions.SAP memory is commited after all the dialogs ar e commited,
Whereas ABAP memory is specific to one session of SAP and is normally used for passing data between
programs. In ABAP memory you can store from simple variables to complex structures and even objects,
where as in sap memory you can only store single values.ABAP memory is for induvidual screens.
Within a main session, when ever you start an application program, it opens up an internal sessions with
in the main session. The internal session has a memory area that contains the ABAP program and its
associated data. So when ever you want to pass data between two internal sessions, then you can use
ABAP Memory (i.e import, export).
When comes to SAP memory (also known as global memory), if the data has to be passed b/w two main
sessions, we can use SAP Memory(SPA/GPA Parameters). SAP Memory can also be used to pass data b/w
internal sessions.
SAP Memory
SAP memory is a memory area to which all main sessions within a SAPgui have access. You can use SAP
memory either to pass data from one program to another within a session, or to pass data from one
session to another. Application programs that use SAP memory must do so using SPA/GPA parameters
(also known as SET/GET parameters). These parameters can be set either for a particular user or for a
particular program using the SET PARAMETER statement. Other ABAP programs can then retrieve the set
parameters using the GET PARAMETER statement. The most frequent use of SPA/GPA parameters is to fill
input fields on screens.
REPORT YSP_0138 .
*************************************************
REPORT YSP_0139 .
WRITE : / TEXT2.
ABAP memory is a memory area that all ABAP programs within the same internal session can access
using the EXPORT and IMPORT statements. Data within this area remains intact during a whole sequence
of program calls. To pass data
to a program which you are calling, the data needs to be placed in ABAP memory before the call is made.
The internal session of the called program then replaces that of the calling program. The program called
can then read from the ABAP memory. If control is then returned to the program which made the initial
call, the same process operates in reverse.
report zrich_0002 .
Standard Text
You can read the standard text from your own ABAP code by calling function module
READ_TEXT
CLEAR wa.
wa-count = '1'.
wa-name = 'Name1'.
APPEND wa TO itab.
CLEAR wa.
wa-count = '2'.
wa-name = 'Name2'.
APPEND wa TO itab.
CLEAR wa.
wa-count = '3'.
wa-name = 'Name3'.
APPEND wa TO itab.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
filename = 'D:Wencesdown.xls'
i_begin_col =1
i_begin_row =1
i_end_col = 200
i_end_row = 200
TABLES
intern = it_upload
.
*******************************************************
BREAK-POINT.
REFRESH itab.
*******************************************************
LOOP AT it_upload.
AT NEW row.
CLEAR itab.
ENDAT.
CASE it_upload-col.
WHEN '0001'.
itab-count = it_upload-value.
WHEN '0002'.
itab-name = it_upload-value.
AT END OF row.
APPEND itab.
ENDAT.
ENDCASE.
ENDLOOP.
Performance Tuning
1. What tools used to help performance tuning ?
ST05 is the SQL trace used to measure the performance for the select statement of the program
SE30 is the run time analysis transaction and can be used to measure the application
performance
One of the best tool for static performance analyzing is code inspector ( SCI )
During DB fetch, I prefer to use the CDS view instead of OPEN SQL query
During the data load, I will try to use the parallel processing
Use the ABAP 7.5 coding instead of classical way of coding
In short, Get the avaialble work process and split the records and call the wrapper function
module starting new task.
1. What is report ?
Report is a program used to fetch data from the database tables and display it on the screen. It
has 2 screens selection screen(optional) and list or output screen.
SKIP provides empty space between lines, while RESERVE executes a page break on the current
page if the number of lines between current line and the page footer is less than the number
specified in RESERVE statement.
SKIP generates a blank line, while the NEW-LINE causes the control to move to next line.
5. What is hotspot?
Hotspot is an area on the list where the mouse pointer turns into an upright hand symbol. A
single click on the hotspot does the same thing as a double-click.
The HIDE statement hides the contents of the line along with the line numbers in a system
defined HIDE area. This is used in interactive reporting.
INITIALIZATION
AT SELECTION-SCREEN
START-OF-SELECTION
END-OF-SELECTION
TOP-OF-PAGE
END-OF-PAGE
20
9. What is the name of the system variable that holds the contents of the selected line in
interactive reporting?
SY-LISEL
11. what are the events in SAP ABAP reports and its order of execution?
Intialization: Before the standard selection screen is displayed.
at selection-screen: After user input on a selection screen has been processed, but while the
selection screen is still active
Start-of-selection
end-of-selection
top-of-page
end-of-page
at line selection
at pf status
at user command
An output list that displays the basic details and allow user to interact, so that a new list is
populated based on user-selection. With interactive list, the user can actively control data
retrieval and display during the session.
At PF
At line-selection
At user-command
AT SELECTION-SCREEN event is triggered in the PAI of the selection screen once the ABAP
runtime environment has passed all the input data from the selection screen to the ABAP
program.
AT SELECTION-SCREEN OUTPUT event block allows you to modify the selection screen directly
before it is displayed.
17. I have 1 basic list and 15 secondary list in interactive report. If I am in 9th list, how can I come
directly to the basic list?
System variable SY-LSIND stores the list number, by using this we can go to basic list.
REPORT zvenkat_alv_grid.
TABLES:t001.
"Types
TYPES:
BEGIN OF t_1001,
bukrs TYPE t001-bukrs,
butxt TYPE t001-butxt,
ort01 TYPE t001-ort01,
land1 TYPE t001-land1,
END OF t_1001.
"Work area
DATA:
w_t001 TYPE t_1001.
"Internal table
DATA:
i_t001 TYPE STANDARD TABLE OF t_1001.
*&---------------------------------------------------------------------*
* ALV Declarations
*----------------------------------------------------------------------*
* Types Pools
TYPE-POOLS:
slis.
* Types
TYPES:
t_fieldcat TYPE slis_fieldcat_alv,
t_events TYPE slis_alv_event,
t_layout TYPE slis_layout_alv.
* Workareas
DATA:
w_fieldcat TYPE t_fieldcat,
w_events TYPE t_events,
w_layout TYPE t_layout.
* Internal Tables
DATA:
i_fieldcat TYPE STANDARD TABLE OF t_fieldcat,
i_events TYPE STANDARD TABLE OF t_events.
*&---------------------------------------------------------------------*
*& start of selection
*&---------------------------------------------------------------------*
START-OF-SELECTION.
PERFORM get_data.
*&---------------------------------------------------------------------*
*& end-of-selection.
*&---------------------------------------------------------------------*
END-OF-SELECTION.
PERFORM build_fieldcatlog.
PERFORM build_events.
PERFORM build_layout.
PERFORM list_display.
*&---------------------------------------------------------------------*
*& Form get_data
*&---------------------------------------------------------------------*
FORM get_data .
SELECT bukrs
butxt
ort01
land1
FROM t001
INTO TABLE i_t001
UP TO 30 ROWS.
ENDFORM. "BUILD_FIELDCATLOG
*&---------------------------------------------------------------------*
*& Form BUILD_FCATALOG
*&---------------------------------------------------------------------*
FORM build_fcatalog USING l_field l_tab l_text.
w_fieldcat-fieldname = l_field.
w_fieldcat-tabname = l_tab.
w_fieldcat-seltext_m = l_text.
ENDFORM. "build_events
*&---------------------------------------------------------------------*
*& Form build_layout
*&---------------------------------------------------------------------*
FORM build_layout .
w_layout-colwidth_optimize = 'X'.
w_layout-zebra = 'X'.
w_header-typ = 'S'.
w_header-info = sy-title.
APPEND w_header TO li_header.
CLEAR w_header.
w_header-typ = 'A'.
w_header-info = sy-uname.
APPEND w_header TO li_header.
CLEAR w_header.
ENDFORM. "top_of_page
TYPE-POOLS: SLIS.
*type declaration for values from ekko
TYPES: BEGIN OF I_EKKO,
EBELN LIKE EKKO-EBELN,
AEDAT LIKE EKKO-AEDAT,
BUKRS LIKE EKKO-BUKRS,
BSART LIKE EKKO-BSART,
LIFNR LIKE EKKO-LIFNR,
END OF I_EKKO.
* declaration for events table where user comand or set PF status will
* be defined
DATA: V_EVENTS TYPE SLIS_T_EVENT,
WA_EVENT TYPE SLIS_ALV_EVENT.
INITIALIZATION.
V_REPID = SY-REPID.
PERFORM BUILD_FIELDCATLOG.
PERFORM EVENT_CALL.
PERFORM POPULATE_EVENT.
START-OF-SELECTION.
PERFORM DATA_RETRIEVAL.
PERFORM BUILD_LISTHEADER USING IT_LISTHEADER.
PERFORM DISPLAY_ALV_REPORT.
*&--------------------------------------------------------------------*
*& Form BUILD_FIELDCATLOG
*&--------------------------------------------------------------------*
* Fieldcatalog has all the field details from ekko
*---------------------------------------------------------------------*
FORM BUILD_FIELDCATLOG.
WA_FIELDCAT-TABNAME = 'IT_EKKO'.
WA_FIELDCAT-FIELDNAME = 'EBELN'.
WA_FIELDCAT-SELTEXT_M = 'PO NO.'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_EKKO'.
WA_FIELDCAT-FIELDNAME = 'AEDAT'.
WA_FIELDCAT-SELTEXT_M = 'DATE.'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_EKKO'.
WA_FIELDCAT-FIELDNAME = 'BUKRS'.
WA_FIELDCAT-SELTEXT_M = 'COMPANY CODE'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_EKKO'.
WA_FIELDCAT-FIELDNAME = 'BUKRS'.
WA_FIELDCAT-SELTEXT_M = 'DOCMENT TYPE'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_EKKO'.
WA_FIELDCAT-FIELDNAME = 'LIFNR'.
WA_FIELDCAT-NO_OUT = 'X'.
WA_FIELDCAT-SELTEXT_M = 'VENDOR CODE'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
ENDFORM. "BUILD_FIELDCATLOG
*&--------------------------------------------------------------------*
*& Form EVENT_CALL
*&--------------------------------------------------------------------*
* we get all events - TOP OF PAGE or USER COMMAND in table v_events
*---------------------------------------------------------------------*
FORM EVENT_CALL.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE =0
IMPORTING
ET_EVENTS = V_EVENTS
* EXCEPTIONS
* LIST_TYPE_WRONG =1
* OTHERS =2
.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. "EVENT_CALL
*&--------------------------------------------------------------------*
*& Form POPULATE_EVENT
*&--------------------------------------------------------------------*
* Events populated for TOP OF PAGE & USER COMAND
*---------------------------------------------------------------------*
FORM POPULATE_EVENT.
READ TABLE V_EVENTS INTO WA_EVENT WITH KEY NAME = 'TOP_OF_PAGE'.
IF SY-SUBRC EQ 0.
WA_EVENT-FORM = 'TOP_OF_PAGE'.
MODIFY V_EVENTS FROM WA_EVENT TRANSPORTING FORM WHERE NAME =
WA_EVENT-FORM.
ENDIF.
*&--------------------------------------------------------------------*
*& Form data_retrieval
*&--------------------------------------------------------------------*
* retreiving values from the database table ekko
*---------------------------------------------------------------------*
FORM DATA_RETRIEVAL.
SELECT EBELN AEDAT BUKRS BSART LIFNR FROM EKKO INTO TABLE IT_EKKO.
ENDFORM. "data_retrieval
*&--------------------------------------------------------------------*
*& Form bUild_listheader
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
* -->I_LISTHEADEtext
*---------------------------------------------------------------------*
FORM BUILD_LISTHEADER USING I_LISTHEADER TYPE SLIS_T_LISTHEADER.
DATA HLINE TYPE SLIS_LISTHEADER.
HLINE-INFO = 'this is my first alv pgm'.
HLINE-TYP = 'H'.
ENDFORM. "build_listheader
*&--------------------------------------------------------------------*
*& Form display_alv_report
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
FORM DISPLAY_ALV_REPORT.
V_REPID = SY-REPID.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = V_REPID
* I_CALLBACK_PF_STATUS_SET =''
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'
I_GRID_TITLE = I_TITLE_EKKO
* I_GRID_SETTINGS =
* IS_LAYOUT = ALV_LAYOUT
IT_FIELDCAT = I_FIELDCAT[]
* IT_EXCLUDING =
* IT_SPECIAL_GROUPS =
* IT_SORT =
* IT_FILTER =
* IS_SEL_HIDE =
* i_default = 'ZLAY1'
I_SAVE = 'A'
* is_variant = i_variant
IT_EVENTS = V_EVENTS
TABLES
T_OUTTAB = IT_EKKO
* EXCEPTIONS
* PROGRAM_ERROR =1
* OTHERS =2
.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. "display_alv_report
*&--------------------------------------------------------------------*
*& Form TOP_OF_PAGE
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
FORM TOP_OF_PAGE.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = IT_LISTHEADER
* i_logo =
* I_END_OF_LIST_GRID =
.
ENDFORM. "TOP_OF_PAGE
*&--------------------------------------------------------------------*
*& Form USER_COMMAND
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
* -->R_UCOMM text
* -->, text
* -->RS_SLEFIELDtext
*---------------------------------------------------------------------*
FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
RS_SELFIELD TYPE SLIS_SELFIELD.
CASE R_UCOMM.
WHEN '&IC1'.
READ TABLE IT_EKKO INTO WA_EKKO INDEX RS_SELFIELD-TABINDEX.
PERFORM BUILD_FIELDCATLOG_EKPO.
PERFORM EVENT_CALL_EKPO.
PERFORM POPULATE_EVENT_EKPO.
PERFORM DATA_RETRIEVAL_EKPO.
PERFORM BUILD_LISTHEADER_EKPO USING IT_LISTHEADER.
PERFORM DISPLAY_ALV_EKPO.
ENDCASE.
ENDFORM. "user_command
*&--------------------------------------------------------------------*
*& Form BUILD_FIELDCATLOG_EKPO
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
FORM BUILD_FIELDCATLOG_EKPO.
WA_FIELDCAT-TABNAME = 'IT_EKPO'.
WA_FIELDCAT-FIELDNAME = 'EBELN'.
WA_FIELDCAT-SELTEXT_M = 'PO NO.'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_EKPO'.
WA_FIELDCAT-FIELDNAME = 'EBELP'.
WA_FIELDCAT-SELTEXT_M = 'LINE NO'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'I_EKPO'.
WA_FIELDCAT-FIELDNAME = 'MATNR'.
WA_FIELDCAT-SELTEXT_M = 'MATERIAL NO.'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'I_EKPO'.
WA_FIELDCAT-FIELDNAME = 'MENGE'.
WA_FIELDCAT-SELTEXT_M = 'QUANTITY'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'I_EKPO'.
WA_FIELDCAT-FIELDNAME = 'MEINS'.
WA_FIELDCAT-SELTEXT_M = 'UOM'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'I_EKPO'.
WA_FIELDCAT-FIELDNAME = 'NETPR'.
WA_FIELDCAT-SELTEXT_M = 'PRICE'.
APPEND WA_FIELDCAT TO I_FIELDCAT.
CLEAR WA_FIELDCAT.
ENDFORM. "BUILD_FIELDCATLOG_EKPO
*&--------------------------------------------------------------------*
*& Form event_call_ekpo
*&--------------------------------------------------------------------*
* we get all events - TOP OF PAGE or USER COMMAND in table v_events
*---------------------------------------------------------------------*
FORM EVENT_CALL_EKPO.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE =0
IMPORTING
ET_EVENTS = V_EVENTS
* EXCEPTIONS
* LIST_TYPE_WRONG =1
* OTHERS =2
.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. "event_call_ekpo
*&--------------------------------------------------------------------*
*& Form POPULATE_EVENT
*&--------------------------------------------------------------------*
* Events populated for TOP OF PAGE & USER COMAND
*---------------------------------------------------------------------*
FORM POPULATE_EVENT_EKPO.
READ TABLE V_EVENTS INTO WA_EVENT WITH KEY NAME = 'TOP_OF_PAGE'.
IF SY-SUBRC EQ 0.
WA_EVENT-FORM = 'TOP_OF_PAGE'.
MODIFY V_EVENTS FROM WA_EVENT TRANSPORTING FORM WHERE NAME =
WA_EVENT-FORM.
ENDIF.
ENDFORM. "POPULATE_EVENT
*&--------------------------------------------------------------------*
*& Form TOP_OF_PAGE
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
FORM F_TOP_OF_PAGE.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = IT_LISTHEADER
* i_logo =
* I_END_OF_LIST_GRID =
.
ENDFORM. "TOP_OF_PAGE
*&--------------------------------------------------------------------*
*& Form USER_COMMAND
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
* -->R_UCOMM text
* -->, text
* -->RS_SLEFIELDtext
*---------------------------------------------------------------------*
FORM DISPLAY_ALV_EKPO.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
* I_INTERFACE_CHECK =''
* I_BYPASSING_BUFFER =''
* I_BUFFER_ACTIVE =''
I_CALLBACK_PROGRAM = V_REPID
* I_CALLBACK_PF_STATUS_SET =''
* I_CALLBACK_USER_COMMAND = 'F_USER_COMMAND'
I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'
* I_CALLBACK_HTML_TOP_OF_PAGE =''
* I_CALLBACK_HTML_END_OF_LIST =''
* I_STRUCTURE_NAME =
* I_BACKGROUND_ID =''
I_GRID_TITLE = I_TITLE_EKPO
* I_GRID_SETTINGS =
* IS_LAYOUT =
IT_FIELDCAT = I_FIELDCAT[]
* IT_EXCLUDING =
* IT_SPECIAL_GROUPS =
* IT_SORT =
* IT_FILTER =
* IS_SEL_HIDE =
* I_DEFAULT =
I_SAVE = 'A'
* IS_VARIANT =
IT_EVENTS = V_EVENTS
TABLES
T_OUTTAB = IT_EKPO
EXCEPTIONS
PROGRAM_ERROR =1
OTHERS =2
.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM.
Basics
"Instantiation
cl_salv_table=>factory(
IMPORTING
r_salv_table = DATA(lo_alv)
CHANGING
t_table = mt_data ).
"Do stuff
"...
Column settings
Change header text
Sort columns
"Sort a column up
lo_alv->get_sorts( )->add_sort( 'COLUMNNAME' ).
Hotspots
About
Hotspots are special cells of an ALV list that can be compared to hyperlinks or buttons on web
pages/apps. If a user clicks once onto a hotspot field an event is triggered. For fields that are not defined
as hotspots, the user must double-click the field or use a function key to trigger an event.
DATA(lo_events) = lo_alv->get_event( ).
SET HANDLER lcl_application->on_link_click FOR lo_events.
Handler implementation
Aggregations
Class CL_SALV_AGGREGATIONS can be used to display basic statistical facts for a given column. Options
include displaying the total, minimum or maximum, and average value.
List selections
DATA(lo_selections) = lo_alv->get_selections( ).
"allow single line selection
lo_selections->set_selection_mode( if_salv_c_selection_mode=>single ).
DATA(lo_selections) = lo_alv->get_selections( ).
DATA(lt_selected_row_indices) = lo_selections->get_selected_rows( ).
IF lines( lt_selected_row_indices ) NE 1.
"Select one row for this function
MESSAGE s022(upp_pp_k) DISPLAY LIKE 'W'.
RETURN.
ENDIF.
Variants
DATA(lo_layout) = lo_alv->get_layout( ).
"set layout key for identifying the particular ALV list
lo_layout->set_key( VALUE #( report = sy-repid ) ).
METHODS set_layout
IMPORTING io_alv TYPE REF TO cl_salv_table
RAISING cx_salv_error.
METHOD set_layout.
DATA(lo_layout) = io_alv->get_layout( ).
"set layout key for identifying the particular ALV list
lo_layout->set_key( VALUE #( report = sy-repid ) ).
"remove restriction on saving layouts
lo_layout->set_save_restriction( if_salv_c_layout=>restrict_none ).
"allow setting layouts as default layouts
lo_layout->set_default( abap_true ).
ENDMETHOD.
Default functions
First go to t-code SE91 i.e. Message Maintenance, enter the name of the message class
and click on create button.
Maintain the required message texts with message numbers. Then save the entries and
assign it to proper development class and transport request. Once the message class is
saved we can use it in our ABAP programs.
MESSAGE s000(ztest).
Output
In the above code, the message number, message class and message type are specified in the
MESSAGE statement. We can also specify the message class in the REPORT statement as shown
below, so that we can skip the message class in the MESSAGE statements of the program.
REPORT zmessages
MESSAGE-ID ztest.
MESSAGE s000.
In the above message “&” is the placeholder. At runtime the placeholders (&) will be
replaced by the variable values specified in the MESSAGE statement.
REPORT zmessages MESSAGE-ID ztest.
MESSAGE s001
WITH ‘XYZ’ ‘1000’.
Output
The values “XYZ” and “1000” replaces the placeholders in the actual message.
SAP Transport Orgainiser
1. How to move the client dependent objects from one client to another client ?
Using SCC1 transaction code we can move the client dependent objects from one client to
another client.
SE01 is the main screen of the Change and transport Organizer. From here the administrator can
acheive all tasks related to transport requests - such as create, change, view logs, display
client/delivery transports, etc. SE09 and SE10 can also be accessed from here. However, not all
developers might be granted access to this transaction.
In the latest version of SAP NetWeaver, both the Transactions are same.
Workbench request
Customizing request
ToC – Transport of Copies
Relocation
Using RDDIT076
SMARTFORMS