Scrol

SAP Trainings contact sap.sreeram@gmail.com or 091-9916083157, 001-210-399-8414

SAP ABAP Internal tables


STANDARD table

Key access to a standard table uses a linear search. This means that the time required for a search is in linear relation to the number of table entries.

You should use index operations to access standard tables.

SORTED table

Defines the table as one that is always saved correctly sorted.

Key access to a sorted table uses a binary key. If the key is not unique, the system takes the entry with the lowest index. The runtime required for key access is logarithmically related to the number of table entries.


HASHED table

Defines the table as one that is managed with an internal hash procedure

You can only access a hashed table using the generic key operations or other generic operations ( SORT, LOOP, and so on). Explicit or implicit index operations (such as LOOP ... FROM oe INSERT itab within a LOOP) are not allowed.


INDEX table

A table that can be accessed using an index.

Index table is only used to specify the type of generic parameters in a FORM or FUNCTION. That means that you can't create a table of type INDEX.

Standard tables and sorted tables are index tables.

Syntax :
DATA itab TYPE table type of line type [WITH UNIQUE/NON-UNIQUE KEY <key>] [Iinitial size n]  [WITH HEADER LINE]


What are DATA CLUSTERS ?
You can group any complex internal data objects of an ABAP/4 program together in data clusters and store them temporarily in ABAP/4 memory or for longer periods in databases. You can store data clusters in special databases of the ABAP/4 Dictionary. These databases are known as ABAP/4 cluster databases and have a predefined structure.Storing a data cluster is specific to ABAP/4. Although you can also access cluster databases using SQL statements, only ABAP/4 statements are able to decode the structure of the stored data cluster.

SAP ABAP General Reporting



What are reports? and how do you set up reports?
A report program reads and analyzes data from one or more database tables without modifying the database. Usually, the result of such a report program is in the form of a list which is output to the screen or sent to a printer.

What are the different types of programs?
I           Include Program
M         Module Pool
F          Function Modules
S          External Subroutines
1          Online program


Events in Reporting ? Explain ?

The following events occur at runtime of a typical report program which uses logical databases:

Event keyword                                        Event
--------------------------------------------------------------------------------------------------
INITIALIZATION                                                        Point before the selection screen
                                                                                    is displayed

When you start a program in which a selection screen is defined (either in the program itself or in the linked logical database program), the system normally processes this selection screen first. If you want to execute a processing block before the selection screen is processed, you can assign it to the event keyword INITIALIZATION.




AT SELECTION-SCREEN                                                   Point after processing user
input on the selection screen while the selection screen is still active

The event keyword AT SELECTION-SCREEN provides you with several possibilities to carry out processing blocks while the system is processing the selection screen.

START-OF-SELECTION                                          Point after processing the selection screen

The event START-OF-SELECTION gives you the possibility of creating a processing block after processing the selection screen and before accessing database tables using a logical database. You can use this processing block, for example, to set the values of internal fields or to write informational statements onto the output screen.

At the START-OF-SELECTION event, also all statements are processed that are not attached to an event keyword except those that are written behind a FORM-ENDFORM block

GET <table>                                                  Point at which the logical database
offers a line of the database table                  <table>.

The most important event for report programs with an attached logical database is the moment at which the logical database program has read a line from a database table (see Accessing Data Using Logical Databases ). To start a processing block at this event, use the GET statement as follows:

Syntax
GET <table> [FIELDS <list>].
After this statement, you can work with the current line of the database table <table>. The data is provided in the table work area <table>.


GET <table> LATE                                       Point after processing all tables which
are hierarchically subordinate to the database table <table> in the structure  of the logical database.

To start a processing block at the moment after the system has processed all database tables of a logical database that are hierarchically inferior to a specific database table, use the event keyword GET as follows:

Syntax
GET <table> LATE [FIELDS <list>].

In analogy to report programs that use only SELECT statements (see table in Comparison of Access Methods ), the processing block of a GET <table> LATE statement would appear directly before the ENDSELECT statement in the SELECT loop for the database table <table>.


END-OF-SELECTION                                   Point after processing all lines offered
by the logical database.

To define a processing block after the system has read and processed all database tables of a logical database, use the keyword END-OF-SELECTION.

The following events occur during the processing of the output list of a report program:
Event keyword                                                            Event
--------------------------------------------------------------------------------------------------

TOP-OF-PAGE                                              Point during list processing when
a new page is started
END-OF-PAGE                                              Point during list processing when a page
is ended

The following events occur during the display of the output list of a report program:
Event keyword                                                            Event
----------------------------------------------------------------------------------------------------

AT LINE-SELECTION                                  Point at which the user selects a line

AT USER-COMMAND                                  Point at which the user presses a
function key or enters a command in the       command field.

AT PF<nn>                                                    Point at which the user presses the
function key with the function code                PF<n>


With the selection screen, ABAP/4 offers an interactive element also for report programs. You can define a selection screen without having to bother about all the details required in dialog programming.
The selection screen is always processed directly after a report program is started. The user can enter field values and selection criteria on this screen.

The main purpose of the selection screen is to enable the user to control the database selections of the report program. If a report program is started from another ABAP/4 program with the SUBMIT statement (see Calling Reports), the selection screen objects also serve as a data interface,
With a selection screen defined in the report program, you can enable the user to

·           assign values to variables with the PARAMETERS statement
·           determine selection criteria with the SELECT-OPTIONS statement

How do you read selected lines of database table into an internal table in packages of predefined size.
·         SELECT * FROM  <SPFLI>  INTO TABLE  <ITAB>  PACKAGE SIZE <N>.
                                                                                    where   'n'   is  variable.

Name the WILDCARD characters which are used for comparisons with character strings & numeric strings.
·         '%'       and       '_'.


How to specify a client for database table processing.
    TABLES SPFLI.
SELECT * FROM SPFLI CLIENT SPECIFIED
         WHERE MANDT BETWEEN '001' AND '003'.
  ...
ENDSELECT.


Activation – During activation, the runtime object of aggregate object or tables is created. The runtime object is buffered so that the application program can access it quickly. Runtime object has information about the following objects of table

- domain – data elements – field definition – table definition


Lock Mechanism – prevents a new database operation being started an existing one has been correctly completed. When conversion is done, lock is created automatically and released only when conversion is successful.

Clearing of locks
·         restart adjustment – attempt is made to continue conversion at the point of termination 
Cancel adjustment – lock entry is simply deleted from table


Version  Management functions –

·         Canceling changes – reset revised version to active version
·         Storing changes – active version will be temporarily stored in version
Switching changes – switch between active and revised versions

Version catalog – list of all existing versions of an object

·         Revised version – produced when we edit an existing object
·         Active version – produced when we activate an object
·         Temporary version – produced when we copy the active version temporarily to the database with store version functions
·         Historical versions – created when 1. Correction is created 2 correction is 
      released


Table Buffering : Possible buffering types

·         full buffering – either, whole table or none of the table is located in the buffer (Tables up to 30 kb done in client dependent fully buffered tables)
·         Generic buffering – generic areas of the table are fully buffered.
·         Generic key – left justified section of primary key of a table.
·         generic area – all records for which fields of generic key correspond
·         Single record buffering – records actually being accessed are loaded to buffers,   large records where few records are accessed.

SAP ABAP Reporting Formatting


In order to suppress the leading zeros of a number field the keywords used are :
NO-ZERO.

The  Command that allows for vertical alignment of fields one below the other.
UNDER.

In order to concatenate strings only for output purposes the command _________ can be used in conjunction with the 'Write' statement.
NO-GAP.

Data can be moved from one field to another using a 'Write:' Statement and stored in the desired format.
TRUE. Write : Date_1 to Date_2 format DD/MM/YY.

In order to have boldfaced text as output the command used is
Write : <f> INTENSIFIED.

Background and foreground colors can be interchanged using the command
Format inverse.

Which datatype cannot be used to define parameters.
Type F.

For each new event, the system resets all formatting options to their default values. TRUE.


The processing block following END-OF-PAGE  is processed only if you reserve lines for the footer in the LINE-COUNT option of the REPORT statement.              

To execute a page break under the condition that less than a certain number of lines is left on a page is achieved by ________________________.
RESERVE n lines.



What is the limit for the length of a page if the page length is not specified in the report statement.
60,000 Lines.

How can Symbols or R/3 icons be output on the screen?
WRITE <symbol-name> AS SYMBOL.
WRITE <icon-name>   AS ICON.

ABAP Modularization


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

How can we create callable modules of program code within one ABAP/4 Program?
A.  By defining macros.
B.      By creating include programs in the library.

What are subroutines?
Subroutines are program modules which can be called from other ABAP/4 programs or within the same program.

What are the types of Subroutines?

A.    Internal Subroutines:  The source code of the internal subroutines will be in the      same ABAP/4 program as the calling procedure (internal call).
B.      External Subroutines:  The source code of the external subroutines will be in an ABAP/4 program other than the calling procedure.

What are the different types of  parameters?

Formal parameters: Parameters which 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.

How can one distinguish between different kinds of parameters?
A.  Input parameters are used to pass data to subroutines.
B.      Output parameters are used to pass data from subroutines.

What are the different methods of passing data?

A.    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.
B.      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.
C.     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.
The method by which internal tables are passed is By Reference.



What is the difference between the function module and a normal ABAP/4 subroutine?
In contrast to normal subroutines function modules have uniquely defined interface.
Sub routines do not return values.
Sub routines do not return exceptions.
Sub routines cannot be tested independently.
Declaring data as common parts is not possible for function modules. Function modules are stored in a central library.

What is a function group?
A function group is a collection of logically related modules that share global data with each other. All the modules in the group are included in the same main program. When an ABAP/4 program contains a CALL FUNCTION statement, the system loads the entire function group in with the program code at runtime. Every function module belongs to a function group.

What is the difference between internal tables and extract datasets?

A.    The lines of an internal table always have the same structure. By using extract datasets, you can handle groups of data with different structure and get statistical figures from the grouped data.
B.      You have to define the structure of the internal table at the begining. You need not define the structure of the extract dataset.
C.     In contrast to internal tables, the system partly compresses extract datasets when storing them. This reduces the storage space required.
D.    Internal tables require special work area for interface whereas extract datasets do not need a special work area for interface.

Logical Database Step by step Creation


Step-by-Step Procedure to create the logical data base(LDB):

  1. Enter the transaction code SE36.

 














  1. Enter the LDB name starting with Y or Z and click on create.















  1.  Enter the short description click on “Create”


 
  1. Enter the package name and click on “Save”.


 
  1. Enter the root table name and short description and click on create. NOTE:: Node name and DB table name must be same.



  1. Then you will see the following screen layout. To insert other nodes select the node first and right click then select “Insert node”.

 
  1. Provide the DB table name, short text and then click on “Create New Node”. Then click on “Save”.

 
  1. You will see the following screen. From the application tool bar click on “Selections”.



  1. Then it will ask whether the LDB is generated from the structure? Click “Yes”.
  2. Then again it will ask whether you want to define the “search help”? click “no”. then you will see the following screen. Select the database tables for which free selections are to be generated. Click on “Transfer”.


 
  1. Un comment the select-options and replace “?” with the suitable database table name. Then Save and activate. Then click on “back”(F3).


 
  1. Click on “ Source code” button from the application tool bar


 
  1. Then you will see the following screen


 
  1.  Double click on TOP include. Save and active and then come back(F3).

 

  1. Double click on next include. Then you will see the following screen.


 
  1. if you are created the LDB using n number of database tables then you will get n number of includes(DB<p_name>N001, DB<p_name>N002 ,…….. DB<p_name>N00n).
  2. Double Click the first node. And insert the following code before the PUT statement .

Select * from zsemp where eno in eno.
            Put zsemp.
                        Endselect.
           
                        Then Save and activate.


  1. Then double click on second node and enter the following code before the put statement.

Select * from zsdept where edept = zsdept-edept and edept in edept.
            Put zsdept.
Endselect.



  1.  That’s completes the creation of Logical Data Base.
  2. Now using this LDB we have to write the program.
  3. For that create any program of Type 1/E (Report Program).
  4. Enter the transaction code SE38. Provide the program name and then click on “Create”. Then Enter the short description, select the type of the program, Logical database table name and then click on “Save”.



  1.  Enter the following code.

nodes: zsemp, zsdept.

get: zsemp, zsdept.

write: / zsemp-eno, zsemp-ename, zsemp-esal, zsemp-edept, zsdept-edes,
         zsdept-epf.

  1.  Save, Check, activate and execute the program.