0% found this document useful (0 votes)
338 views117 pages

SAP ABAP Technical Interview Questions

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)
338 views117 pages

SAP ABAP Technical Interview Questions

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/ 117

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

1. The different types of data dictionary objects are -Tables,Views,Domain,Data Element,Type


Groups,Search Helps/Match code Objects,Lock Objects,Structures,Table Types

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.

6. What is the significance of Delivery Class?


Delivery class to control the transport of table data for an installation, upgrade, or client copy
and transports between customer systems. The delivery class is also used in the extended table
maintenance.
7. What are domains and data element?
Domain - Domain is a central object for explaining the technical characteristics of an attribute of a
business objects. It describes the value range of the field.
Data Element – Data element is used to describe the semantic definition of the table fields like
description the field. Data element describes how a field can be displayed to end-user.

8. What is a Data Class?


The Data class determines in which table space the table is stored when it is created in the
database.

9. What is a Size Category?


The Size category describes the probable space requirement of the table in the database.

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.

11. What is a table pool?


A table pool (or pool) is used to combine several logical tables in the ABAP/4 Dictionary. The
definition of a pool consists of at least two key fields and a long argument field (VARDATA).

12. What are pooled tables?


These are logical tables, which must be assigned to a table pool when they are defined. Pooled
tables can be used to store control data (such as screen sequences or program parameters).

13. What is a table cluster?


A table cluster combines several logical tables in the ABAP/4 Dictionary. Several logical rows from
different cluster tables are brought together in a single physical record. The records from the cluster
tables assigned to a cluster are thus stored in a single common table in the database.
14. How can we set the table spaces and extent sizes?
You can specify the extent sizes and the table space (physical storage area in the database) in which
a transparent table is to be stored by setting the size category and data class.

15. What are local objects?


Local objects (Dev class$TMP) are independent of correction and transport system.

16. What is a data dictionary?


Data Dictionary is a central source of data in a data management system. Its main function is to
support the creation and management of data definitions. It has details about

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.

21. What is a Table attribute?


The table's attributes determine who is responsible for maintaining a table and which types of access
are allowed for the table. The most important table attributes are:
• Delivery class.
• Table maintenance allowed.
• Activation type.
22. What is the significance of Delivery Class?
The delivery class controls the degree to which the SAP or the customer is responsible for table
maintenance.
• Whether SAP provides the table with or without contents.
• Determines the table type.
• Determines how the table behaves when it is first installed, at upgrade, when it is transported, and
when a client copy is performed.

23. What is the max. no. Of structures that can be included in a table or structure.
Nine.

24. What are two methods of modifying SAP standard tables?


• Append Structures and
• Customizing Includes.

25. What is the difference between a Substructure and an Append Structure?


• In case of a substructure, the reference originates in the table itself, in the form of a statement
include….
• In case of an append structure, the table itself remains unchanged and the reference originates in
the append structure.

26. To how many tables can an append structure be assigned.


One.

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.

32. What is a Match Code?


Match code is a tool to help us to search for data records in the system. Match Codes are an efficient
and user-friendly search aid where key of a record is unknown.
33. What is the function of a Domain?
• A domain describes the technical settings of a table field.
• A domain defines a value range, which sets the permissible data values for the fields, which refers
to this domain.
• A single domain can be used as basis for any number of fields that are identical in structure.

34. Can you delete a domain, which is being used by data elements?
No.

35. What are conversion routines?


• Non-standard conversions from display format to sap internal format and vice-versa are
implemented with so called conversion routines.

36. What is the function of a data element?


A data element describes the role played by a domain in a technical context. A data element contains
semantic information.

37. Can a domain, assigned to a data element be changed?


Yes. We can do so by just overwriting the entry in the field domain.

38. Can you delete data element, which is being used by table fields.
No.

39. Can you define a field without a data element?


Yes. If you want to specify no data element and therefore no domain for a field, you can enter data
type and field length and a short text directly in the table maintenance.

40. What are null values?


If the value of a field in a table is undefined or unknown, it is called a null value.

41. What is the difference between a structure and a table?


Structures are constructed the almost the same way as tables, the only difference using that no
database table is generated from them.

42. What is a view?


A view is a logical view on one or more tables. A view on one or more tables i.e., the data from a
view is not actually physically stored instead being derived from one or more tables.

43. How many types of Views are there?


• Database View
• Help View
• Projection View
• Maintenance View
44. what is Locking?
When two users simultaneously attempt to access the same data record, this is synchronized by a
lock mechanism.

45. What is database utility and T code?


Database utility is the interface between the ABAP/4 Dictionary and the underlying the SAP system.

46. What are the basic functions of Database utility?


The basic functions of database utility are:
• Create database objects.
• Delete database objects.
• Adjust database objects to changed ABAP/4 dictionary definition.

47. How to regenerate TMG ?


How to Regenerate SAP Table Maintenance Generator? - SAPHub

48. How to transport the the TMG data ?

49. What is TMG Events and Types.


The events allow developers to access and modify predefined positions in the maintenance dialog1.
Some of the events include:
1. Before saving the data in the database
2. After saving the data in the database
3. Before deleting the data displayed
4. After deleting the data displayed
5. Creating a new entry

50. Can we add the authorization objects in TMG ?


Yes

51. T code for the TMG?


SM30

52. What is foregin key relationship


In SAP ABAP, a foreign key relationship is defined as follows:
A foreign key links two tables, with fields of one table assigned to the primary key fields of
another table.
The table with the assigned fields is called the foreign key table (dependent table), and the other
table is the check table (referenced table).
The pair of fields for the two tables must have the same data type and length

53. Difference between value table and check table ?


Check Table : It is nothing but table it contains all valid entries of a particular foreign key table
field. Basically the check table is used for field level validation (it restricts the field value).
(or)
The check table is the table used by system to check whether the data exist or not in foreign key
table field. When ever you are trying to create the table, if you are sure the field contains some
values that values only you can use in another foreign key Data Base Table.

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.

55. Types of buffereing in Dictioanry ?


There are three buffering types that can be configured for a database table or database view in
the ABAP Dictionary: Single record buffering, Generic buffering, and Full buffering

56. Single record Buffering ?


With single-record buffering, only the records that are actually read are loaded into the buffer.
Single-record buffering therefore requires less storage space in the buffer than generic and full
buffering. The administrative costs in the buffer, however, are greater than for generic or full
buffering. Considerably more database accesses are necessary to load the records than for the
other buffering types.
Single-record buffering should be used particularly for large tables where only a few records are
accessed with SELECT SINGLE. The size of the records being accessed should be between 100
and 200 KB.

57. What is full buffering ?


With full buffering, either the entire table is in the buffer or the table is not in the buffer at all.
All the records of the table are loaded into the buffer when one record of the table is read.
58. Generic Buffering ?
With generic buffering, all the records in the buffer whose generic key fields match this record
are loaded when one record of the table is accessed. The generic key is a part of the primary key
of the table that is left-justified.

59. What is primary index and secoundray index ?


The difference between primary and secondary index is..
The primary index is generated when you activate the table.
The primary index is generated based on the primary key combination.
The secondary index is generated when you try to create secondary index on table.
If you create secondary index then you should explicitly use that in your select query when you
want to use it.
Index is nothing but the table arranged the data in some specific order, when ever you use select
query where class it fetches data based on this key.
Conversions - BDC
What is ‘BDC'?

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).

What are the advantages in Batch Input?

Below are the major advantages of batch input -


 Ensures Data integrity.
 No manual interaction is required during Data transfer.

What are the steps in a BDC session?

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.

How to write a BDC - How do you go about it?

Steps for writing BDC -


 /nSE38
 Declare Tables, Data (for ITAB) and Data (for BDCITAB)
 Call function ‘Upload’.
 Write code for the First Screen, Radio Button, Filename, Change Button, Second Screen, Utilities
(Create Entries), Third Screen and Save.
 Call transaction ‘SE11’ using BDCITAB mode 'A'.
 Save, Check Errors, Activate and Execute.
What are the types of BDC’s?

There are two types of BDC’s -


1. Transaction Method
2. Session Method

Advantages and Disadvantages of different types of BDC’s?

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.

What are the functional modules used in sequence in BDC?

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.

What should be the approach for writing a BDC program?

Below are the steps to writing a BDC program -


 Analyze the Data from the local file.
 Analyze transaction.
 Generate SAP structure like local file and BDCDATA.
 Develop transfer program for transferring data from local file to internal table.
 Create a sequential file.
 Write a batch input program.
 Process batch input data BDCDATA using call transaction/session method.

What is the alternative to 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.

What do you do with errors in BDC batch session?

Analyze, correct input file format and entries in internal table BDCDATA.

How can you handle errors in the BDC batch sessions?

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?

The BDCDATA table structure consists of the following fields -

FIELD TYPE LENGTH DESCRIPTION

PROGRAM CHAR 40 Online program name of transaction

DYNPRO NUMC 4 Screen number of transactions

DYNBEGIN CHAR 1 Indicator to specify the start of a new screen

FNAM CHAR 132 Field names of a screen to be filled with data

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?

Go to SE38, then choose the menu path like shown below -


Transaction number, program number – System -> status
Field names - F1 Technical help

What are the processing modes for Batch Input?

The three modes for processing batch input session are -


 Background
 Display Errors Only
 Foreground

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.

Why you choose Call transaction and/or session method?

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.

How you trap errors in call Transaction?

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.

What are different types of update modes?


BDC have two types of updating modes –
 Synchronous
 Asynchronous

What is main difference between session method and LSMW?

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.

Differences between LSMW and BDC?

 LSMW is for standard sap application. BDC is for customized applications.


 Mapping is taken care by SAP in LSMW whereas we need to specify the mapping explicitly in
BDC.
 LSMW offers different techniques like Direct input, Batch input recording, BAPI, IDOC for
migrating data. BDC uses recording and have two methods to implement - Call Transaction
Method, Session Method.
 LSMW is a Non-SAP to SAP communication tool, while BDC is an SAP to SAP communication
utility.
 LSMW used by Functional consultants. BDC is used by technical consultants.
 In LSMW, coding is not flexible. BDC coding is flexible for customize applications.
 In LSMW, recording performed through LSMW only. However, in BDC recording performed
through transaction SHDB.
 LSMW is preferable method as it uses the standard programs for data upload. In BDC if screen
design changes tomorrow, program will not work and need to do the recording again to make it
work.
 LSMW is recommended for large amount of data.
How do you do BDC for a table control?

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.

What is the last entry in all BDC tables?

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 is the transaction for Recording BDC?

Transaction Code for recording is SHDB.


What are the different modes of processing batch input sessions?

The three modes for processing batch input session -


 Foreground
 Display Errors Only
 Background

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.

How do you save data in BDC tables?

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?

No. The CALL TRANSACTION method process only single transaction.

Does the BDC_INSERT function allow multiple transactions to be processed by SAP?

Yes.

What is the syntax for ‘CALL TRANSACTION'?

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?

There are three modes in Call Transaction -


 A – Displays All Screen
 E – Display Errors
 N – Background Processing

What is the difference between Leave Transaction and Call Transaction?

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.

Can you set up background processing using CALL TRANSACTION?

Yes, using “No Screen Mode” in 'CALL TRANSACTION'.

Which mode of ‘CALL TRANSACTION’ method allows background processing?

N is the only mode that allows background processing in CALL TRANSACTION.


What are the function modules called from BDC program to submit the transactions for processing?
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.

How many sessions will be opened using BDC_OPEN_GROUP?

Only one session can be created.

What is Synchronous Database update?

No transaction is stored until the previous transaction has been written to the Database during the
processing. This is called Synchronous Database update.

What are the types of Batch Input?

 Classical Batch Input


 Call Transaction
 Call Dialog

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’

What is the use of BDC_INSERT?

A transaction can be added to a Batch Input Session by using this function.


What are the update modes in CALL TRANSACTION?

 S - Synchronous
 A - Asynchronous
 L - Local

What does the message parameter indicate?

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.

What is Direct Input?

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

What are the parameters in BDC_OPEN_GROUP?

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).

3. Import methods available in BDC?


LSMW tool provides 4 different methods for upload: Direct input method, Batch input
recording, BAPI, IDOC
4. LSMW Steps ?

5. What is Project ,subproject and objects?

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.

6. Can we write the ABAP program in LSMW ?


Yes

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?

Yes. It is possible to build periodic interfaces using the frame program


/SAPDMC/SAP_LSMW_INTERFACE

9. Is there an extra charge for the LSM Workbench?

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.

11. LSMW Upload and Download


Here are the steps for LSMW to Download & Upload.
Go to LSMW
Open Yr LSMW
Then goto Menu item ' Extras -> Export Project
It will ask U project name ( Give yr LSMW Project name)
Then on next screen U can Select/Deselect Yr Subproject and Object.
Then click Export(F8)....Green errow (->)
Then save it on Local system
In case of Upload , used the Menu item ' Extras -> Import Project

12. How to transport LSMW


Using Export and Import options

Using change request options - Go to LSMW (Give your project, subproject and object) -
> Extras > Create change request.
Conversions – BAPI

1. What is BAPI ?

BAPI(Business Application Programming Interface ) : is defined as an interface providing


access to business processes and data in R/3 business application systems. Or BAPI is a set
of interfaces to object-oriented programming methods that enable a programmer to
integrate third-party software into R/3 product from SAP.

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).

BAPIs can be located in the Transaaction: BAPI.(BAPI Explorer).

2. What is the difference between RFC and BAPI?


BAPI:
 BAPI is a library of function modules released by SAP to the public so that they can
interface with SAP.
 There is a Business Object Associated with a BAPI. So a BAPI has an Interface, Key Field,
Attributes, Methods, and Events.
 Outside world (JAVA, VB, .Net or any Non SAP system) can connect to SAP using a BAPI.
 Error or Success messages are returned in a RETURN table.
RFC
 RFC is nothing but a remote enabled function module. So if there is a Function Module
in SAP system 1 on server X , it can be called from a SAP system 2 residing on server Y.
 No Business Object is associated with a RFC.
 Non–SAP world cannot connect to SAP using RFC.
 RFC does not have a return table.
3. What are the steps for creating a BAPI?
Stage1: Creating a structure in SE11.
Stage2: Creating the function module in SE37.
Stage 3: Creating the business object in SWO1.
Stage 4: Viewing the created BAPI in BAPI Explorer

4. What is t code for BAPI?


BAPI

5. Provide some standard BAPI available in SAP.

BAPI_SALESORDER_CREATEFROMDATA – Create sales order.


BAPI_GOODSMVT_CREATE for Goods Receipt

6. Is it mandatory to call BAPI_TRANSACTION_COMMIT after calling the Create BAPI?


Yes, for database commit.

7. What is BAPI Extension?

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

1. How do I debug background processes ?

2. How do I debug completed background process?

3. How do I debug remote function calls?

4. How do I debug updates/system code?


5. Why does it give dump when I put a break-point in between SELECT and ENDSELECT ?

6. How do I set breakpoints in modal dialog box ?

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.

8. What is command used for debugging ?

/H
Internal Tables

1. What is 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.

2. What types of Internal tables exist?

Standard Internal Tables -


This table type is particularly appropriate if we want to address individual table entries using
the index. This is the quickest way to access table entries. To fill a standard table, append lines
using the (APPEND) statement. Standard tables have a linear index. We can access them using
either the index or the key. If we use the key, the response time is in linear relationship to the
number of table entries. The key of a standard table is always non-unique, and we may not
include any specification for the uniqueness in the table definition.

Sorted Internal Tables -


Sorted tables are always saved sorted by key. They also have a linear key. Like standard tables,
we can access them using either the table index or the key. The key of a sorted table can be
either unique, or non-unique, and we should specify either UNIQUE or NON-UNIQUE in the
table definition. Standard tables and sorted tables both belong to the generic group index
tables. This table type is particularly suitable if we want the table to be sorted while we are
still adding entries to it.

Hashed Internal Tables -


Hashes tables have no internal linear index. We can only access hashed tables by specifying
the key. The response time is constant, regardless of the number of table entries, since the
search uses a hash algorithm. The key of a hashed table must be unique, and we must specify
UNIQUE in the table definition. This table type is particularly suitable if we want mainly to use
key access for table entries. We cannot access hashed tables using the index.
3. Explain the use of insert and append statement in SAP ABAP?
Append statement used to add a record at the end of internal table in work area.
Insert statement used to add a record at specified location of internal table in work area.

4. What is the difference between SY-INDEX and SY-TABIX?

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.

So, when we are looping over an internal table, we use SY-TABIX.


LOOP AT ITAB INTO WA. **SY-TABIX stores index number of internal table record
ENDLOOP.
When we use DO ENDDO / WHILE for looping, there is no table involved. So, we use SY-INDEX.
DO 10 times. **SY-INDEX stores number of iterations of loop
ENDDO.

5. Can we sort internal table without using SORT statement? Explain?

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>.

6. What will happen if I sort a sorted internal table?

Nothing will happen because the table is already sorted.

7. How to eliminate duplicate entries in internal table?


SORT the Internal table first and use the syntax
DELETE ADJACENET DUPLICATES COMPARING <Field1> <field2>

8. What is control break statement


Control break processing is used to execute a piece of code whenever a specific condition in the
data is detected during the processing of internal table loop.
The following control break statements are available with in LOOP and ENDLOOP.

 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.

9. What is the difference between internal table and table type ?

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

Internal table declaration DATA: itab TYPE TABLE OF vbak.

Table type Declaration TYPES : tab TYPE TABLE OF vbak.


Database updates and Open SQL

Logical Unit Of Work ( LUW )

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.

Why logical units of work?


The main purpose of the logical unit of work is to ensure data consistency in the R/3 systems. Let
us consider that there is a complex R/3 transaction that involves a series of dialog steps; during
the execution of one such dialog step at the middle of the transaction the data involved will lack
completeness & will therefore be inconsistent. When talking about of logical unit of work we
must note the following points initially.
1. Database LUW also known as DB LUW, each dialog step has its own DB LUW that is used to
ensure data consistency.
2. SAP LUW consists of several dialog steps and all the changes to database are written in a
single DB LUW. We must note that the database changes are always written in the final
database LUW.
3. Therefore to summarize a complex R/3 transaction may span across several dialog steps
each having its own DB LUW, however all the changes are written to the database in the final
DB LUW of the SAP LUW after a commit work is executed by the system or rolled back with
no changes written to the database due to errors.

What is a database LUW?


A database LUW is work unit consisting of database operations (INSERT, UPDATE, MODIFY &
DELETE) that it used to make the database changes. The final database LUW of a SAP LUW is
used to make the changes to the database, the changes to the database is not made until after
the database commit. The database LUW is executed in a special kind of work process called the
update work process.

What is a SAP LUW?


A SAP LUW is a logical unit work that spans over several dialog steps. Let us consider a complex
R/3 transaction of n screens; where each screen has its own DB LUW involving database
operations and are logically related to each other. It is important that the changes to the
database for this complex transaction must be made all at once or it must be rolled back all for
the data consistency; that is where the SAP LUW becomes critical in maintaining a logical
relationship between several DB LUWs (dialog phases) & making all the changes to the database
in the final DB LUW. SAP LUW uses the bundling technique to achieve the same. There are
several possibilities of bundling technique and one of them is bundling the database changes
using a function module call in the UPDATE TASK.
Bundling in SAP LUW:
A CALL FUNCTION…IN UPDATE TASK is one of the bundling techniques to achieve all the
database changes in the last DB LUW of the SAP LUW. The open SQL statements for database
changes are placed in the function module instead of placing them in the code, using the
addition UPDATE TASK ensures that the function module is not executed until COMMIT WORK is
found in the program. At COMMIT WORK the function module calls with UPDATE TASK are
executed in a special work process called update work process and the changes to the database
is executed in the final DB LUW of the SAP LUW.

R/3 transactions using update function modules.


Let us consider there is one R/3 transaction calling another R/3 transaction and as well as calling
some update function module. There is some typical behavior that can be noted for this
particular scenario.
 (a) The called transaction begins in a new SAP LUW in comparison to the calling
transaction. It implies that there are two different SAP LUWs now.
 (b) A new update key is generated for the new SAP LUW that is used to identify all the
update function modules.
 (c) If the called R/3 transaction does not have a COMMIT WORK then the update function
modules will not be executed i.e. both the calling transaction & the called transaction must
have their own COMMIT WORK.
 (d) The update function modules are called only after the system has executed a COMMIT
WORK.
 (e) Let us consider there is an importing parameter -IM_X for the update function module;
now the same function module is called at several places in the program like shown below –

DATA: gv_x TYPE i.

gv_x = 1.

CALL FUNCTION UPD_FUNC IN UPDATE TASK


EXPORTING
IM_X = gv_x.

gv_x = 2.

CALL FUNCTION UPD_FUNC IN UPDATE TASK


EXPORTING
IM_X = gv_x.

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.

* Creating a line type of predefined structure


DATA:
wa_ekpo TYPE ty_ekpo.

* Select single will fetch only the First record


* from the PO Item table
SELECT SINGLE ebeln ebelp matnr werks lgort
FROM ekpo INTO wa_ekpo
WHERE ebeln = '3000000232'.

WRITE:/ 'PO No.',


15 'Item No',
28 'Material',
48 'Plant',
55 'Storage'.
ULINE.
SKIP.

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.

* 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.

* Creating a line type of predefined structure


DATA:
wa_ekpo TYPE ty_ekpo,
it_ekpo TYPE STANDARD TABLE OF ty_ekpo.

* Select up to n rows fetches n rows


* from the PO Item table
SELECT ebeln ebelp matnr werks lgort
UP TO 5 ROWS
FROM ekpo INTO TABLE it_ekpo
WHERE ebeln = '3000000232'.

WRITE:/ 'PO No.',


15 'Item No',
28 'Material',
48 'Plant',
55 'Storage'.
ULINE.
SKIP.

LOOP AT it_ekpo INTO wa_ekpo.


WRITE:/ wa_ekpo-ebeln,
15 wa_ekpo-ebelp,
28 wa_ekpo-matnr,
48 wa_ekpo-werks,
55 wa_ekpo-lgort.
ENDLOOP.

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”.

2. What is inner join , left outer join ?

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.

3. Prerequesties of using for all entries ?

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'.

Data my_Char(5) VALUE 'Hello'.

Following program is an example of creating strings.

REPORT YT_SEP_15.
DATA my_Char(5) VALUE 'Hello'.
Write my_Char.

The above code produces the following output −

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.

length_1 = STRLEN( title_1 ).


Write: / 'The Length of the Title is:', length_1.

The above code produces the following output −

The Length of the Title is: 9


ABAP supports a wide range of statements that manipulate strings.
S.No. Statement & Purpose

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).

CONCATENATE title_1 title_2 INTO dest1.


Write: / 'Concatenation:', dest1.

CONCATENATE title_1 title_2 INTO dest2 SEPARATED BY sep.


Write: / 'Concatenation with Space:', dest2.

CONDENSE spaced_title.
Write: / 'Condense with Gaps:', spaced_title.

CONDENSE spaced_title NO-GAPS.


Write: / 'Condense with No Gaps:', spaced_title.

The above code produces the following output −


Concatenation: TutorialsPoint
Concatenation with Space: Tutorials Point
Condense with Gaps: Tutorials Point Limited
Condense with No Gaps: TutorialsPointLimited

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 −

WRITE <format> <f> <options>.


In this syntax, <format> represents the output format specification, which can be a forward slash (/) that
indicates the display of the output starting from a new line. In addition to the forward slash, the format
specification includes a column number and column length. For example, the WRITE/04 (6) statement
shows that a new line begins with column 4 and the column length is 6, whereas the WRITE 20
statement shows the current line with column 20. The parameter <f> represents a data variable or
numbered text.

The following table describes various clauses used for formatting −

S.No. Clause & Description

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.

USING EDIT MASK <m>


Denotes the specification of the format template <m>. Using No EDIT Mask:
6
This specifies that the format template specified in the ABAP Dictionary is
deactivated.

7 NO-ZERO
If a field contains only zeroes, then they are replaced by blanks.
Following are the formatting options for Numeric Type fields −

S.No. Clause & Description

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 −

Formatting Option Example

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.

DATA: n(9) TYPE C VALUE 'Tutorials',


m(5) TYPE C VALUE 'Point'.

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 '__:__:__'.

The above code produces the following output −

Tutorials Point
Tutorials
Point
TutorialsPoint
112538
11:25:38
Print Page

System Variables

1. SY-CPAGE – Holds Current Page Number


2. SY-CPROG – Contains Program Name
3. SY-CUCOL – Cursor Position ( Column)
4. SY-CUROW – Cursor Position (Line)
5. SY-DATLO – Local Date for User
6. SY-DATUM – System Date
7. SY-DATUD – Global Date Related To UTC ( GMT )
8. SY-DBCNT – Number of entries read by DB Operation
9. SY-DBNAM- Logical DB for ABAP/4 Program
10. SY-DBSYS – System DB System
11. SY-DYNNR- Number of Current Screen
12. SY-INDEX – Number Of Loop passes
13. SY-LANGU- SAP Log on Language Key
14. SY-LILLI – Number Of Current List Line
15. SY-LINCT – Number Of List Lines
16. SY-LINNO – Current Line for List Creation
17. SY-LINSZ – Line Size of List
18. SY-LISEL – Selected Line For Interactive List
19. SY-LSIND – Number Of Secondary List
20. SY-MANDT – Client Number For SAP Log On
21. 21.SY-MSGID – Message ID

22. SY-MSGTY – Message Type


23. SY-MSGNO – Message Number
24. SY-MSGV1 – Message Variable1
25. SY-MSGV2 – Message Variable2
26. SY-MSGV3 – Message Variable3
27. SY-MSGV4 – Message Variable4
28. SY-OPSYS – Operating System
29. SY-PAART – Print Format
30. SY-PAGCT – Page Size of List in Report Program
31. SY-PAGNO – Current Page in the List
32. SY-PDEST – Print Output Device
33. SY-PFKEY – Run time Current F key Status
34. SY-REPID – Report Name in ABAP
35. SY-SAPRL – SAP Release
36. SY-SUBRC – Return Value after specific ABAP Statement
37. SY-SYSID – SAP system ID
38. SY-TABIX – Current line of Internal Table
39. SY-TCODE – Current Transaction Code
40. SY-TIMLO – Local Time Of User
41. SY-TITLE – Title of ABAP Program
42. SY-TMAXL – Maximum entries in a Internal Table
43. SY-TNAME – Name Of Internal Table after first Access
44. SY-UCOMM -Interact : Command field Function entry / Function code
45. SY-ULINE – Underline
46. SY-UNAME – Session : SAP user from Log On
47. SY-UZEIT – System Time
48. SY-VLINE – Vertical Bar

ABAP Transaction Codes

ABAPDOCU Example Library

ABAPHELP Keyword Documentation


AL03 Operating system Alert Monitor

AL05 Workload Alert Monitor

AL08 List of all Users Logged ON (about all Instances/Servers of the System)

DB01 Exclusive waits in Oracle database

DB02 Database performance ; tables and index

DB03 Parameter changes in database

DB05 Analysis of table with respect to indexed fields

DB12 Backup logs

DB13 DBA planning calendar

PFCG Role Maintenance

RZ06 Maintain alert threshold

RZ08 CCMS Alert Monitor

RZ10 Maintain system profiles

RZ20 Alert Monitor 4.0

RZ21 Maintain settings for Alert Monitor 4.0

RZ11 Profile Parameter Maintenance

SA38 ABAP Reporting

SCAM CATT Management

SCAT Computer Aided Test Tool

SCC1 Client copy transport


SCC3 Client copy log

SCC4 Client copy administration

SCC5 Delete Clients

SCC6 Client import

SCC7 Client import— post processing

SCC8 Client export

SCC9 Remote client copy

SCCL Local client copy

SCDO Change Document Object

SCMP Table comparison

SCU3 Table History

SCI Code Inspector

SE01 Transport Organizer(Extended View)

SE06 Set up workbench organizer

SE09 Transport organizer

SE10 Customizing organizer

SE11 Data dictionary maintenance`

SE12 Data dictionary display

SE15 Repository Info System

SE16 Display table content

SE17 General table display


SE37 ABAP Function Modules

SE38 ABAP Editor

SE41 Menu Painter

SE51 Screen Painter

SE71 Form Painter

SE80 Object Navigator

SE93 Maintain Transaction

SFT2 Maintain public holiday calendar

SFT3 Maintain factory calendar

SHDB Transaction Recorder

SICK Installation check

SLIN Extended Check

SM01 Lock Transactions

SM04 Overview of users

SM13 Update terminates

SM21 System Log

SM30 Maintain tables(not all tables can use SM30)

SM31 Maintain tables

SM35 Batch Input Monitoring

SM37 Overview of background jobs

SM39 Job analysis


SM49 External operating system commands, execute

SM50 Work process overview

SM51 Instance overview

SM58 Error log for asynchronous RFC

SM59 RFC connection, maintain

SM63 Operations mode, maintain

SM66 Global work process overview

SM69 External operating system commands, maintain

SP00 Spool

SP01 Spool control

SP02 Display output requests

SP11 TemSe(temporary sequential objects) contents

SP12 TemSe administration

SPAD Spool administration (printer setup)

SPAM SAP Patch Manager

SPAU Intersection SAP Transport/customer modifications

SPIC Spool; installation check

ST01 SAP system trace

ST06 Operating system monitor

ST07 Application Monitor

ST09 Table call statistics


ST11 Display developer trace

ST12 Application monitor

ST22 Dump Analysis

STAT Local Transaction statistics

STUN Performance monitoring

SU01 User maintenance

SU02 Maintain authorization profiles

SU03 Maintain authorizations

SU10 Maintain change to user records

SU12 Delete all users

SU2 Maintain user parameters

SU53 Display authorization checked values

SM12 To unlock the locked entries

SAAB Checkpoints that Can Be Activated

SALE ALE customizing transaction

CG3Y Transfer file from application server to front end.

CG3Z transfer file from front end to application server

NACE conditions of output control (to create a link between forms and driver programs)

ST05 SQL tracer (for performance tunning)

SE30 ABAP runtime analysis(Performance tuning)

SE61 SAP Documentation


SE62 Industry Utilities

SE63 Translation: Initial Screen ( to Translate Short / Long Text )

SE64 Terminology

SE72 SAPscript Styles

SE73 SAPscript Font Maintenance

SE74 SAPscript format conversion

SE75 SAPscript Settings

SE76 SAPscript: Form Translation

SE77 SAPscript Styles Translation

smartforms Smartforms

Wedi IDOC and EDI basis

we31 Segment creation

we30 Idoc Type creation

we81 Creation and assigning of Message type

Modularization Technique

1. What is modularization technique ?


If the program contains the same or similar blocks of statements or required to process
the same function several times, we can avoid redundancy by using modularization
techniques. By using modularizing, we can make the ABAP/4 programs easy to read and
improve their structure. Modularized programs are also easier to maintain and to
update.

2. Difference between function group and Function modules ?


Function Group and Function Module are logically belonging together. Function groups
are considered as containers of the Function Modules. The differences between
Function Groups and Function Modules are as follows -
 Function Groups need not be defined in Function Module however, the function
modules must be defined in Function Groups.
 Function Modules can be called from various kinds of programs. Function Groups
cannot be called.
 Function Groups acts as Function Module's containers, but the function modules
don’t act as containers.

3. What are the function modules used in F4 Help?

There are two types of function modules used in F4 help -


 F4IF_FIELD_VALUE_REQUEST
 F4IF_INT_TABLE_VALUE_REQUEST

4. Type of parameters to pass to RFC pass by value or pass by reference?

Always Pass by Value.


RFC is Remote Function call cannot access the values with Pass by reference.

5. What is difference between Function module and RFC?

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.

6. How to debug RFC Function module?


SE38 -> Utilities -> Settings -> ABAP Editor -> Debugging.
The above path activates the external debugging and choose the New Debugger option
in ABAP debugger. Go to the place in the code and put break point, popup appear then
choose the HTTP break point. If we are triggering the RFC from SAP portal make sure
that both the user ID should be same. If the users are different then provide the
XI/Portal User ID in the user’s field.

7. What is the difference between BAPI and RFC?

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.

8. Type of function modules in SAPABAP


 Normal Function Module
 Remote Enabled Function Module ( RFC )
 Update Function Module

9. How do you call RFC function Module ?


CALL FUNCTION ‘XXX’ DESTINATION ‘DEST”
EXPORTING
F1 =
IMPORTING
F2 =

10. Types of RFC available in SAP ?


Synchronous RFC
Asynchronous RFC
Transactional RFC
Queued qRFC

11. How to call RFC function module locally ?


CALL FUNCTION ‘XXX’ DESTINATION ‘NONE”

12. How to call update function modules ?


CALL FUNCTION ‘XXX’ IN UPDATE TASK

13. What is update function module ?


An update function module performs database modifications and registers itself for later
execution with CALL FUNCTION in UPDATE TASK. It will only commit changes to the
database if the calling program explicitly issues a COMMIT WORK, so any errors after the
function module is called will not save data. Update function modules are assigned a
priority level and execute pending changes when the calling transaction commits.

14. Types of update function modules ?


 Update with immediate start
 Update with delayed

15. Types of modularzation technique ?


 Function Modules
 Include Program
 Subroutines
16. Types of subroutines ?
Internal Subroutines: The source code of the internal subroutines will be in the same
ABAP/4 program as the calling procedure (internal call).
External Subroutines: The source code of the external subroutines will be in an ABAP/4
program other than the calling procedure.

17. What are the different types of parameters?


Formal parameters: Parameters that are defined during the definition of subroutine with
the FORM statement.
Actual parameters: Parameters which are specified during the call of a subroutine with
the PERFORM statement.

18. What are the different methods of passing data?

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.

19. Subroutine can be terminated unconditionally using EXIT. (TRUE / FALSE)


True.
20. What is the disadvantage of a call by reference?
During a call by reference damage or loss of data is not restricted to the subroutine, but
will instantly lead to changes to the original data objects.

BACKGROUND JOBS

1. What is the transaction code for background job ?


SM36 – For Scheduling and SM37 – For Monitor

2. How to schedule a backgroup jobs ?

There are two ways for you to handle,


one manually setting up the job through SM36 which is better and convinient,
secondly through program using FM's JOB_OPEN, SUBMIT, JOB_CLOSE.

Find below steps in doing both:

Procedure 1:

1. Goto Trans -> SM36


2. Define a job with the program and variant if any
3. Click on start condition in application tool bar
4. In the pop-up window, click on Date/Time
5. Below you can see a check box "Periodic Job"
6. Next click on Period Values
7. Select "Other Period"
8. Now give '15' for Minutes
9. Save the job

Procedure 2 via Program:

Below is a sample code for the same. Note the ZTEMP2 is the program i am
scheduling with 15mins frequency.

DATA: P_JOBCNT LIKE TBTCJOB-JOBCOUNT,


L_RELEASE(1) TYPE c.

CALL FUNCTION 'JOB_OPEN'


EXPORTING
JOBNAME = 'ZTEMP2'
IMPORTING
JOBCOUNT = P_JOBCNT
EXCEPTIONS
CANT_CREATE_JOB = 1
INVALID_JOB_DATA = 2
JOBNAME_MISSING = 3
OTHERS = 4.
IF SY-SUBRC 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

SUBMIT ZTEMP2 VIA JOB 'ZTEMP2' NUMBER P_JOBCNT


TO SAP-SPOOL WITHOUT SPOOL DYNPRO
WITH DESTINATION = 'HPMISPRT'
WITH IMMEDIATELY = SPACE
WITH KEEP_IN_SPOOL = 'X' AND RETURN.

CALL FUNCTION 'JOB_CLOSE'


EXPORTING
JOBCOUNT = P_JOBCNT
JOBNAME = 'ZTEMP2'
STRTIMMED = 'X'
PRDMINS = 15
IMPORTING
JOB_WAS_RELEASED = L_RELEASE
EXCEPTIONS
CANT_START_IMMEDIATE = 1
INVALID_STARTDATE = 2
JOBNAME_MISSING = 3
JOB_CLOSE_FAILED = 4
JOB_NOSTEPS = 5
JOB_NOTEX = 6
LOCK_FAILED = 7
INVALID_TARGET = 8
OTHERS = 9.
IF SY-SUBRC 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Module Pool Programming

1. What are the events in Module Pool Programming?


PAI, PBO, POH, POV

2. What is AT EXIT COMMAND?


To bypass the mandatory required fields, we use at exit command.
Function Type should be E.
Syntax: MODULE XXX AT EXIT COMMAND

3. What is CALL SCREEN and SET SCREEN?


CALL SCREEN - Add new screen to the stack, all the screen is alive.
SET SCREEN - kill the current screen, don’t keep alive, will not come back, No stack.
LEAVE TO SCREEN - Replace the last stacked screen with the new screen.

4. What is ON CHAIN COMMAND?


It is used the validate the field input. Remain enabled after giving the error message.

5. SUBSCREEN - 100(Normal Screen, Sub Screen Area), 200( Sub Screen ).


CALL SUBSCREEN SUB INCLUDING SY-REPID '0101'

6. What is ON INPUT AND ON REQIUEST FIELD Statement?


On Input - Need input to trigger and will not trigger when change happen (single time)
On request - When changed also will trigger (multiple times)

7. What is SUPPRESS DIALOG?


Screen will be suppressed. LEAVE TO LIST PROCESSING - Screen to reports

8. Tab strips Controls - CONTROLS : tab_strip TYPE TABSTRIP.

9. Table Control - CONTROLS: tbl_ctrl TYPE TABLEVIEW USING SCREEN 0001.

10. Changing screen field properties –


Using Loop at screen. If screen-field = 'xxxx'. Screen-input = 0. MODIFY SCREEN. End loop.
ABAP OOPS – Object Oriented Programming

1. Singleton Class

Ensures that the class has only one instance and provides global point of access to this object/instance.

2. Difference between Abstract class and Interface -


Abstract - can’t be instantiated,at least contain one abstract method, Methods don’t have implementation
Interface - can’t have implementation.

3. What is the constructor and class constructor ?


The instance constructor is executed each time you create an object (instance) with the
CREATE OBJECT statement,
while the class constructor is executed exactly once before you first access a class.

4. What is static and Instance Method / Attributes –


Static -doesn’t require instance, pass by reference, CLASS-METHODS, It can access only static attribute of a class,
Cannot be redefined in sub classes

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

6. Abstraction, Encapsulation, Polymorphism, Inheritance –

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.

7. Friend Class / Final Class –


Friend class - A class can grant friendship to other classes and interfaces.
(And thus, to all classes that implement this interface). This relationship is created using the FRIENDS.
additions of the statement CLASS ... DEFINITION by specifying all classes and interfaces to which friendship
is to be granted. These friends are granted access to all components of the class offering the friendship,
regardless of their visibility section or the addition READ-ONLY and can always create instances of this.
class regardless of the addition CREATE of the statement CLASS.

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.

8. Method overloading and Method Overriding –


ABAP doesn’t Support method Overloading. The Process of overriding the super class method inside the
Subclass is called as Method Overriding.

9. Concept of ‘SUPER’ and ‘ME’ in SAP ABAP Class? –


ME - By using ME, we access the instance attribute.
SUPER - Super Keyword is used to call super class methods

10. Deferred Keyword in OOPS ABAP.


One class can be referred within another class definition with defining the class. But that class must be defined.
Later.
File Handling in SAP ABAP

1. How to read the data from the ALL1 directory?

OPEN DATASET file FOR INPUT IN TEXT MODE ENCODING DEFAULT.


DO.
READ DATASET file INTO ls_data.
IF sy-subrc EQ 0.
APPEND ls_data TO it_data.
ELSE.
EXIT.
ENDIF.
ENDDO.
CLOSE DATASET file.

2. How to transfer data to AL11 directory ?

OPEN DATASET file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.

LOOP AT it_data INTO ls_data.

TRANSFER ls_data TO file.


ENDLOOP.

CLOSE DATASET file.

3. T code to AL11 directory ?


AL11

4. T code to upload the data in AL11 directory ?


Go to Transaction CG3Z for uploading a file in the AL11 directory.

5. T code to download the data from AL11 directory ?


Go to Transaction CG3Y for downloading a file in the AL11 directory.

6. F4 HELP for AL11 directory ?


We use the FM /SAPDMC/LSM_F4_SERVER_FILE in the event AT SELECTION SCREEN ON
VALUE REQUEST

Business Add in (BADI )

1. What is a BADI in SAP?


BADI (Business Add-In) is a new SAP Object Oriented enhancement technique that is used to add
our own business functionality to the existing SAP standard functionality.

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.

2. What are the steps to Developing BADI in SAP?

Enter a BADI name. Click on CREATE SE18.

To define a BADI use Sap Menu -> Tools -> ABAP Workbench -> Utilities -> Business Ad-Ins ->

Defining BADIs - Attributes

- Enter a short text

- BADI class is automatically created

- 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.

3. What are the transaction codes used for 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.

4. What is the class name for BADI in SAP?

An adapter class with 'CL_EX_' inserted between the first and second characters of the BADI
name.

5. What is an Interface name for BADI in SAP?

An interface with 'IF_EX_' inserted between the first and second characters of the BADI name

6. How can find the implementations for the BADIs?


How many ways you can find a BADI?

Method 1:

1. Go to SE 24 transaction, type CL_EXITHANDLER, and then click on display.

2. Double click on the GET_INSTANCE method.

3. Put a break-point on class method CL_EXITHANDLER=>GET_CLASS_NAME_BY_INTERFACE.

4. Run any transaction on which we won't find the BADI's

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:

Finding the BADI names using the SE18 transaction

7. How many types of BADI's in SAP?

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 we want the BADI for multiple uses,

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.

8. What is a Single Implementation for a BADI?

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.

9. What are the multiple Implementations for a BADI?

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.

10. What is CL_EXITHANDLER in BADI?

CL_EXITHANDLER is a class using which, we can find the BADI's.

11. What is Get_Instance in BADI?

Get_instance is a method in which BADI's are found.

12. How to Implement a BAdI ?


To implement the BADI, we have transaction SE19.

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.

14. What is filter Dependent 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.

15. What is Kernel BADI in SAP?

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.

Passing comparison values for the filter.

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.

17. What is the GET BADI statement?


This statement generates a new BADI object and sets the BADI reference to the object in a BAdI
reference variable BADI.

This statement has a static and dynamic variant.

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.

18. What is a Fallback Class?

The Fallback option is used if no BAdI implementation with suitable filter conditions and no
standard implementation is found.

19. What is BADI sorting ?

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.

20. Types of BADI sorting ?

Different Sorting Types:

1.No Sort

2. Standard Sort

3. Special Sort

21. How do you deactivate a BADI implementation in SAP?

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

1. What is Enhancement spots?


Enhancement spots are containers for explicit enhancement options and carry information
about the positions at which enhancement options were created.

2. What is explicit Enhancement ?

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.

3. What is enhancement points and Enhancement section ?


Enhancement Point and Enhancement Section are used during explicit enhacement. If you have
written code using enhacement point your custom code will be executed along with the
standard code. If you have written code using enhancement section, only your custom code will
be executed replacing standard code.

4. What is Implicit enhancement ?


Implicit enhancement points: These are basically points within ABAP code where an
enhancement point is implied, and in which case can be created. Examples of implicit
enhancement points are at the beginning and end of FORM, at the end of a program, include or
function module etc.

5. What is enhancement and modifications ?


Enhancements are hooks provided by SAP for extending the business logic without hampering
the standard code. Modifications are incorporating the changes in Standard SAP Program by
taking access key to suite the particular business requirement.

6. What is user exits and customer exits ?

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:

 Typed Field Symbol


 Generic Field Symbol

Typed Field Symbol – Typed field symbol can be declared as:

DATA: var TYPE i VALUE 2.


FIELD-SYMBOLS: <fs_num> TYPE i.
ASSIGN var TO <fs_num>.
WRITE: / <fs_num>.
<fs_num> = 4.
WRITE: / var.

The output will be 2 and 4.

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.

Field symbol as a replacement of Work area:

Modifying internal table records - We can declare a field symbol of type any structure, which we can use
while looping through an internal table.

DATA: lt_mara TYPE STANDARD TABLE OF mara.


FIELD-SYMBOLS: <fs_mara> TYPE mara.
SELECT * FROM mara INTO TABLE lt_mara UP TO 10 ROWS.
LOOP AT lt_mara ASSIGNING <fs_mara>.
<fs_mara>-matkl = 'DEMO'.
ENDLOOP.

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:

DATA: lt_mara TYPE STANDARD TABLE OF mara.


FIELD-SYMBOLS: <fs_mara> TYPE mara.

APPEND INITIAL LINE TO lt_mara ASSIGNING <fs_mara>.


IF <fs_mara> IS ASSIGNED.
<fs_mara>-matnr = 'MAT1'.
<fs_mara>-matkl = '001'.
UNASSIGN <fs_mara>.
ENDIF.

APPEND INITIAL LINE TO lt_mara ASSIGNING <fs_mara>.


IF <fs_mara> IS ASSIGNED.
<fs_mara>-matnr = 'MAT2'.
<fs_mara>-matkl = '001'.
UNASSIGN <fs_mara>.
ENDIF.

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:

READ TABLE lt_mara ASSIGNING <fs_mara> WITH KEY matnr = 'MAT1'.

Generic Field Symbol:

Dynamic programming is actually implemented using generic field symbols. The most commonly used
generic types are TYPE ANY and TYPE ANY TABLE.

FIELD-SYMBOLS: <fs_str> TYPE ANY.


FIELD-SYMBOLS: <fs_tab> 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.

FIELD-SYMBOLS: <fs_str> TYPE ANY.


FIELD-SYMBOLS: <fs_data> TYPE ANY.
DATA: lw_mara TYPE mara.

ASSIGN lw_mara TO <fs_str>.


IF <fs_str> IS ASSIGNED.
ASSIGN COMPONENT 'MATNR' OF STRUCTURE <fs_str> TO <fs_data>.
IF <fs_data> IS ASSIGNED.
<fs_data> = 'MAT001'.
UNASSIGN <fs_data>.
ENDIF.
UNASSIGN <fs_str>.
ENDIF.

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.

FIELD-SYMBOLS: <fs_tab> TYPE ANY TABLE.


FIELD-SYMBOLS: <fs_str> TYPE any.
FIELD-SYMBOLS: <fs_data> TYPE any.
DATA: lt_mara TYPE STANDARD TABLE OF mara.
DATA: lw_mara TYPE mara.

ASSIGN lt_mara TO <fs_tab>.


SELECT * FROM mara INTO TABLE lt_mara UP TO 10 ROWS.

LOOP AT <fs_tab> ASSIGNING <fs_str>.


IF <fs_str> IS ASSIGNED.
ASSIGN COMPONENT 'MATKL' OF STRUCTURE <fs_str> TO <fs_data>.
IF <fs_data> IS ASSIGNED.
IF <fs_data> EQ '01'.
*********** Do some processing *********
ENDIF.
UNASSIGN <fs_data>.
ENDIF.
ENDIF.
ENDLOOP.

Reading internal table using generic field symbol:

FIELD-SYMBOLS: <fs_tab> TYPE ANY TABLE.


FIELD-SYMBOLS: <fs_str> TYPE any.
DATA: lt_mara TYPE STANDARD TABLE OF mara.
ASSIGN lt_mara TO <fs_tab>.
SELECT * FROM mara INTO TABLE lt_mara UP TO 10 ROWS.

READ TABLE <fs_tab> ASSIGNING <fs_str> WITH KEY ('MATNR') = 'MAT001'.

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.

Difference between field symbol and data reference:

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.

Working with data reference:


There can be two types of data references:

 Typed Data Reference


 Generic Data Reference

Typed Data Reference:

Typed data reference variable can be declared as:

DATA lr_num TYPE REF TO i.


CREATE DATA lr_num.

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:

DATA lr_num TYPE REF TO i.


CREATE DATA lr_num.

lr_num->* = 2.
WRITE: / lr_num->*.

The output will be 2.

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.

DATA lr_num TYPE REF TO i.


lr_num = NEW #( ).
Assigning existing data object to data reference:

If you want to assign the reference of an existing data object to a data reference, you can use GET
REFERENCE statement.

DATA: lv_num TYPE i VALUE 2.


DATA: lr_num TYPE REF TO i.

GET REFERENCE OF lv_num INTO lr_num.


lr_num->* = 4.
WRITE: / lv_num.

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.

Working with structures:

DATA: lr_mara TYPE REF TO mara.

CREATE DATA lr_mara.


lr_mara->matnr = '1111'.
lr_mara->matkl = '03'.

Here individual components of the structure can be accessed with -> operator on data reference
variable.

Working with internal tables:

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.

SELECT * FROM mara INTO TABLE lt_mara UP TO 10 ROWS.

LOOP AT lt_mara REFERENCE INTO lr_mara.


WRITE: / lr_mara->matnr.
ENDLOOP.

Generic Data Reference:

Generic data reference can be declared as:

DATA: lr_num TYPE REF TO data.


CREATE DATA lr_num TYPE i.

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.

‘data’ in ABAP is a generic data type.

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:

DATA: lr_num TYPE REF TO data.


FIELD-SYMBOLS: <num> TYPE any.
CREATE DATA lr_num TYPE i.
ASSIGN lr_num->* TO <num>.

<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.

Working with structures:

DATA: lr_str TYPE REF TO data.


FIELD-SYMBOLS: <str> TYPE any.
FIELD-SYMBOLS: <data> TYPE any.
CREATE DATA lr_str TYPE mara.

ASSIGN lr_str->* TO <str>.


ASSIGN COMPONENT 'MATNR' OF STRUCTURE <str> TO <data>.
<data> = '112'.

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.

Dynamically create data objects:

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.

CREATE DATA lr_tab TYPE TABLE OF (p_tname).


ASSIGN lr_tab->* TO <tab>.
IF sy-subrc EQ 0.
SELECT * FROM (p_tname) INTO TABLE <tab> UP TO 10 ROWS.
cl_demo_output=>display( <tab> ).
ENDIF.

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.

Difference between data reference and object reference:

There are two types of reference variable:

 Data reference and

 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 .

DATA TEXT1(30) TYPE C VALUE 'SET AND GET PARAMETER'.

SET PARAMETER ID 'MEM' FIELD TEXT1.

WRITE : 'SET PARAMETER'.

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

REPORT YSP_0139 .

DATA TEXT2(30) TYPE C .

GET PARAMETER ID 'MEM' FIELD TEXT2.

WRITE : / TEXT2.

WRITE : 'GET PARAMETER'.


ABAP/4 Memory

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 .

data: it001 type table of t001 with header line.


select * into table it001 from t001.
export it001 = it001 to memory id 'ZRICH_TEST'.
clear it001. refresh it001.
import it001 = it001 from memory id 'ZRICH_TEST'.
loop at it001.
write:/ it001-bukrs, it001-butxt.
endloop

Standard Text

1. What is standard text ?


With transaction SO10 you can maintain standard texts. These texts can be used in
SapScript, SmartForms and your own ABAP code.

2. How to transport the SO3. 10 text ?


After saving the standard text the tool just saves the text without prompting for
transport. This is as designed. The text can be maintained directly in production this way.
Either by IT or even by business users.
If you do want to transport the standard texts, use program RSTXTRAN to add the
standard text to the transport:

3. How to read the standard text in program?

You can read the standard text from your own ABAP code by calling function module
READ_TEXT

EXCEL Upload / Download

TYPES: BEGIN OF ty_table,


count TYPE i,
name(12) TYPE c,
END OF ty_table.

DATA itab TYPE TABLE OF ty_table WITH HEADER LINE.


DATA wa LIKE LINE OF itab.
DATA it_upload TYPE TABLE OF alsmex_tabline WITH HEADER LINE.

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.

CALL FUNCTION 'SAP_CONVERT_TO_XLS_FORMAT'


EXPORTING
i_filename = 'D:Wencesdown.xls'
TABLES
i_tab_sap_data = 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 )

2. Extended program check ?


Extended program check: is maintly to check the syntax, like obselete statements. For example if
you don't mention type in subroutine EPC will thrown a warning. Or if you use "tables"
statement in subroutines/FMs, EPC will through a warning message as using tables is obselete.

3. Code Inspector ( SCI )


It is mainly checks the quality (performance, security..etc) of the code.

4. How to improve the performance ?

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

5. What is parallel processing in SAP ABAP ?

In short, Get the avaialble work process and split the records and call the wrapper function
module starting new task.

Classical and Interactive Reports Interview Questions

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.

2. When the TOP-OF-PAGE event does get triggered?


TOP-OF-PAGE event will be triggered when the first ULINE, WRITE or SKIP statement occurs in a
program.

3. What is the difference between SKIP and RESERVE?

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.

4. What is the difference between SKIP and NEW-LINE?

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.

6. What does HIDE statement do?

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.

7. What are the events in classical reports?

 INITIALIZATION
 AT SELECTION-SCREEN
 START-OF-SELECTION
 END-OF-SELECTION
 TOP-OF-PAGE
 END-OF-PAGE

8. How many detail lists can be created in interactive reporting?

20

9. What is the name of the system variable that holds the contents of the selected line in
interactive reporting?

SY-LISEL

10. Can we set page headers to details lists?

Yes. Use TOP-OF-PAGE DURING LINE-SELECTION event.

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

at selection screen on value request

at selection screen in help request

at selection screen on field

Start-of-selection

end-of-selection

top-of-page

end-of-page

at line selection

at pf status

at user command

12. Explain what are interactive reports?

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.

13. What are the events in interactive reporting?

There are three events of Interactive Reports -

At PF

At line-selection
At user-command

14. What is the difference between AT SELECTION-SCREEN and AT SELECTION-SCREEN OUTPUT?

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.

15. Which event is executed first at-selection-screen or at-selection-screen-output in sap ABAP?

Before screen display - AT SELECTION-SCREEN OUTPUT will trigger first.


After screen is displayed - AT SELECTION-SCREEN will trigger first.

16. How many lists can be displayed through an interactive report?

Maximum 21 lists can be displayed (1 basic list 20 secondary lists).

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.

ALV Reports and ALV Interactive Reports

Sample ALV program using REUSE_ALV_GRID_DISPLAY

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. " get_data


*&---------------------------------------------------------------------*
*& Form build_fieldcatlog
*&---------------------------------------------------------------------*
FORM build_fieldcatlog .
CLEAR:w_fieldcat,i_fieldcat[].

PERFORM build_fcatalog USING:


'BUKRS' 'I_T001' 'BUKRS',
'BUTXT' 'I_T001' 'BUTXT',
'ORT01' 'I_T001' 'ORT01',
'LAND1' 'I_T001' 'LAND1'.

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.

APPEND w_fieldcat TO i_fieldcat.


CLEAR w_fieldcat.

ENDFORM. " build_fieldcatlog


*&---------------------------------------------------------------------*
*& Form build_events
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM build_events.
CLEAR :
w_events, i_events[].
w_events-name = 'TOP_OF_PAGE'."Event Name
w_events-form = 'TOP_OF_PAGE'."Callback event subroutine
APPEND w_events TO i_events.
CLEAR w_events.

ENDFORM. "build_events
*&---------------------------------------------------------------------*
*& Form build_layout
*&---------------------------------------------------------------------*
FORM build_layout .

w_layout-colwidth_optimize = 'X'.
w_layout-zebra = 'X'.

ENDFORM. " build_layout


*&---------------------------------------------------------------------*
*& Form list_display
*&---------------------------------------------------------------------*
FORM list_display .
DATA:
l_program TYPE sy-repid.
l_program = sy-repid.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'


EXPORTING
i_callback_program = l_program
is_layout = w_layout
it_fieldcat = i_fieldcat
it_events = i_events
TABLES
t_outtab = i_t001
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. " list_display
*&---------------------------------------------------------------------*
*& Form top_of_page
*&---------------------------------------------------------------------*
FORM top_of_page.
DATA :
li_header TYPE slis_t_listheader,
w_header LIKE LINE OF li_header.
DATA:
l_date TYPE char10.
WRITE sy-datum TO l_date.
w_header-typ = 'H'.
CONCATENATE sy-repid ':' 'From Date' l_date INTO w_header-info SEPARATED BY space.
APPEND w_header TO li_header.
CLEAR w_header.

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.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'


EXPORTING
it_list_commentary = li_header.

ENDFORM. "top_of_page

Sample ALV interactive reports

REPORT YMS_ALVINTERSAMPLE NO STANDARD PAGE HEADING LINE-SIZE 650


MESSAGE-ID ZZ_9838.

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.

DATA: IT_EKKO TYPE STANDARD TABLE OF I_EKKO INITIAL SIZE 0,


WA_EKKO TYPE I_EKKO.

*type declaration for values from ekpo


TYPES: BEGIN OF I_EKPO,
EBELN LIKE EKPO-EBELN,
EBELP LIKE EKPO-EBELP,
MATNR LIKE EKPO-MATNR,
MENGE LIKE EKPO-MENGE,
MEINS LIKE EKPO-MEINS,
NETPR LIKE EKPO-NETPR,
END OF I_EKPO.

DATA: IT_EKPO TYPE STANDARD TABLE OF I_EKPO INITIAL SIZE 0,


WA_EKPO TYPE I_EKPO .

*variable for Report ID


DATA: V_REPID LIKE SY-REPID .

*declaration for fieldcatalog


DATA: I_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
WA_FIELDCAT TYPE SLIS_FIELDCAT_ALV.

DATA: IT_LISTHEADER TYPE SLIS_T_LISTHEADER.

* 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.

* declartion for layout


DATA: ALV_LAYOUT TYPE SLIS_LAYOUT_ALV.

* declaration for variant(type of display we want)


DATA: I_VARIANT TYPE DISVARIANT,
I_VARIANT1 TYPE DISVARIANT,
I_SAVE(1) TYPE C.
*PARAMETERS : p_var TYPE disvariant-variant.

*Title displayed when the alv list is displayed


DATA: I_TITLE_EKKO TYPE LVC_TITLE VALUE 'FIRST LIST DISPLAYED'.
DATA: I_TITLE_EKPO TYPE LVC_TITLE VALUE 'SECONDRY LIST DISPLAYED'.

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.

READ TABLE V_EVENTS INTO WA_EVENT WITH KEY NAME = 'USER_COMMAND'.


IF SY-SUBRC EQ 0.
WA_EVENT-FORM = 'USER_COMMAND'.
MODIFY V_EVENTS FROM WA_EVENT TRANSPORTING FORM WHERE NAME =
WA_EVENT-NAME.
ENDIF.
ENDFORM. "POPULATE_EVENT

*&--------------------------------------------------------------------*
*& 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
*---------------------------------------------------------------------*

*retreiving values from the database table ekko


FORM DATA_RETRIEVAL_EKPO.
SELECT EBELN EBELP MATNR MENGE MEINS NETPR FROM EKPO INTO TABLE IT_EKPO.
ENDFORM.

FORM BUILD_LISTHEADER_EKPO USING I_LISTHEADER TYPE SLIS_T_LISTHEADER.


DATA: HLINE1 TYPE SLIS_LISTHEADER.
HLINE1-TYP = 'H'.
HLINE1-INFO = 'CHECKING PGM'.
ENDFORM.

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.

SALV: ALV Quickstart Snippets

Basics

"Instantiation
cl_salv_table=>factory(
IMPORTING
r_salv_table = DATA(lo_alv)
CHANGING
t_table = mt_data ).

"Do stuff
"...

"Display the ALV Grid


lo_alv->display( ).

Column settings
Change header text

DATA(lo_column) = lo_alv->get_columns( )->get_column( 'COLUMNNAME' ).


lo_column->set_long_text( 'LONG_HEADER' ).
lo_column->set_medium_text( 'MEDIUM_HEADER' ).
lo_column->set_short_text( 'SHORT_HEADER' ).

Optimize column width

lo_alv->get_columns( )->set_optimize( abap_true ).

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.

Register hotspot columns

DATA(lo_column_tab) = CAST cl_salv_column_table(


lo_alv->get_columns( )->get_column( 'COLUMNNAME' ) ).
lo_column_tab->set_cell_type( if_salv_c_cell_type=>hotspot ).

Register hotspot click handler

DATA(lo_events) = lo_alv->get_event( ).
SET HANDLER lcl_application->on_link_click FOR lo_events.

Handler implementation

CLASS lcl_application DEFINITION.


PRIVATE SECTION.
METHODS on_link_click
FOR EVENT link_click OF cl_salv_events_table
IMPORTING
row
column.
"...
ENDCLASS.

CLASS lcl_application IMPLEMENTATION.


METHOD on_link_click.
"Handle hotspot click
ENDMETHOD.
ENDCLASS.

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.

"Show total for column 'COLUMNNAME'


DATA(lo_aggregations) = lo_alv->get_aggregations( ).
lo_aggregations->add_aggregation(
columnname = 'COLUMNNAME'
aggregation = if_salv_c_aggregation=>total ).

List selections

Set selection mode

DATA(lo_selections) = lo_alv->get_selections( ).
"allow single line selection
lo_selections->set_selection_mode( if_salv_c_selection_mode=>single ).

Get selected lines

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.

READ TABLE lt_selected_row_indices INDEX 1 INTO DATA(lv_selected_row_index).


READ TABLE mt_data
INDEX lv_selected_row_index
ASSIGNING FIELD-SYMBOL(<s_selected_row>).
IF sy-subrc NE 0.
"Select one row for this function
MESSAGE s022(upp_pp_k) DISPLAY LIKE 'W'.
RETURN.
ENDIF.

"Handle user action


"...

Variants

Initialize: set layout key

DATA(lo_layout) = lo_alv->get_layout( ).
"set layout key for identifying the particular ALV list
lo_layout->set_key( VALUE #( report = sy-repid ) ).

Allow variant saving

"remove restriction on saving layouts


lo_alv->get_layout( )->set_save_restriction( if_salv_c_layout=>restrict_none ).

Set initial variant

"set initial layout


lo_alv->get_layout( )->set_initial_layout( 'VARIANT_NAME' ).

Allow default variants


"allow setting layouts as default layouts
lo_alv->get_layout( )->set_default( abap_true ).

Example: setting up ALV variants

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.

Handling ALV toolbar functions

Default functions

"Enable default ALV toolbar functions


lo_alv->get_functions( )->set_default( abap_true ).
Message Class

1. What is message class?


Message Class is a like a container which holds a number of different messages. Each
message in the message class is identified with unique message number. So when you
call a message in a ABAP program, you need to specify the message class and message
number.

2. How to create the message class ?

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.

Messages can be issued as follows.

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.

We can also maintain placeholders for variables in messages.

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.

2. Difference between SE01 , SE09, & SE10 ?

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.

SE09 This was used for development of transports


SE10 – This was used for customizing the transports request. When you run SE10 in SAP ERP, you
will get the same screen as in T-Code SE09 of Transport Organizer.

In the latest version of SAP NetWeaver, both the Transactions are same.

3. Types of transport request ?

 Workbench request
 Customizing request
 ToC – Transport of Copies
 Relocation

4. Status of Transport request?

Modifiable and released.

5. What is version management?


Version Management. Version management allows you to compare two versions of a Repository
object, and also to display old versions. You call version management in the maintenance
transaction of the respective object by choosing Utilities → Version Management.

6. Changing the status of the request from release to modifiable?

Using RDDIT076

SMARTFORMS

You might also like