Saturday, May 31, 2025

๐Ÿ“„ Types of Internal Tables

 There are three types of Internal Table in ABAP Programming :- '

 1. Standard Internal Table

 2. Sorted Internal Table

 3. Hashed Internal Table

 

1. Standard Internal Table 
1. They are the default internal tables.

TYPES : BEGIN OF ty_employee, 

               emp_id TYPE zar_emp_id,

               emp_name TYPE zar_emp_name,

               END OF ty_employee.

DATA : lt_employee TYPE TABLE OF ty_employee,

             ls_employee TYPE ty_employee.

 OR

          DATA : lt_employee type standard table of ty_employee. 

2. They are the index based internal tables ( i.e. in the debugging we can check each and every record has a index ).

3. Records can be inserted or appended.
Append :- Append statement inserts the record at the last of the internal table.
Insert :- Insert statement inserts the records anywhere in the internal table. 

4. Data is not sorted by default, We can use SORT statement to sort the internal table.
                        SORT lt_employee BY emp_id.

5. For standard internal table we can read a record based on key and based on index too.

Based on key

READ TABLE lt_employee INTO ls_employee WITH KEY emp_id = '10

IF sy-subrc EQ 0.

WRITE :/ ls_employee-emp_id, ls_employee-emp_name.

ENDIF.

Based on index

READ TABLE lt_employee INTO ls_employee index 1.

 IF sy-subrc EQ 0.

WRITE :/ ls_employee-emp_id, ls_employee-emp_name.

 ENDIF. 

6. For standard internal tables either we can use the linear search ( sequential search ) or we can use the binary search to search a record. 
Note :- You can use binary search if your internal table has been sorted.

READ TABLE lt_employee INTO ls_employee with key emp_id = '010' Binary Search.

IF sy-subrc EQ 0.

 WRITE :/ ls_employee-emp_id, ls_employee-emp_name. 

ENDIF.

Or else if it is not sorted you can go for linear search.

READ TABLE lt_employee INTO ls_employee with key emp_id = '010'.

IF sy-subrc EQ 0.

 WRITE :/ ls_employee-emp_id, ls_employee-emp_name.

ENDIF.

 7. Response time depends upon the number of entries in the internal table. 

2. Sorted Internal Table

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

TYPES : BEGIN OF ty_employee,

              emp_id TYPE zar_emp_id,

              emp_name TYPE zar_emp_name,

              END OF ty_employee.

DATA : lt_employee TYPE SORTED TABLE OF ty_employee WITH UNIQ

             ls_employee TYPE ty_employee.

2. They are also indexed based internal table, i.e. data will be stored indexed wise.

3. We should not used append statement for sorted internal table and we should only go for insert statement.  
                   ls_employee-emp_id = '101'.
                   ls_employee-emp_name = 'Yuvraj Singh'.
                   insert ls_employee into table lt_employee.
                   CLEAR ls_employee.

                   ls_employee-emp_id = '102'.
                   ls_employee-emp_name = 'Virat Kohli'.
                   insert ls_employee into table lt_employee.
                   CLEAR ls_employee.

                   ls_employee-emp_id = '104'.
                   ls_employee-emp_name = 'K.L Rahul'.
                   insert ls_employee into table lt_employee.
                   CLEAR ls_employee.

                   ls_employee-emp_id = '103'.
                   ls_employee-emp_name = 'Rohit Sharma'.
                   insert ls_employee into table lt_employee.
                   CLEAR ls_employee.

Q. Why we should not use append statement in sorted internal table ?

Suppose, first three records that we have stored was employee id 101, 102 and 104 and then the fourth record we want to store is 103. So, if you will try to store this as a fourth record and our internal table is sorted by employee so logically 103 should be stored as third row, therefore in this situation it will generate a runtime error. And if we will use the insert operation, it will automatically add the record at its suitable position. 

4. Data is already sorted, there is no need to use SORT statement. 

5. We read a record using key or index. 

6. Since, data is already sorted we can use binary search to search a record. 

7. Response time of a sorted internal table is very fast as compared to standard internal table.  


3. Hashed Internal Table
1. Hashed internal tables are the special type of internal table which works on HASH algorithms. 

TYPES : BEGIN OF ty_employee, 

               emp_id TYPE zar_emp_id, 

              emp_name TYPE zar_emp_name, 

              END OF ty_employee.

 DATA : lt_employee TYPE HASHED TABLE OF ty_employee WITH UNIQ

              ls_employee TYPE ty_employee.


Hashing :-
Hashing is a technique which returns the address of the record based upon the search key without index. Example: if we will go for order number 10, hashing will directly go for address of order number 10. 

2. Hashed internal tables do not support the concept of index i.e. why they are not the index based internal table. 

3. We use the insert operation, append statement is not supported here, if you will use append statement, it will give a compile time error. 

4. There is no impact of SORT, as we read the record based upon the hashed algorithm.

5. We Read a record using key, index is not applicable.

READ TABLE lt_employee INTO ls_employee index 1.

IF sy-subrc EQ 0.

 WRITE :/ ls_employee-emp_id, ls_employee-emp_name.

ENDIF.


The above line will give syntax error 

6. Hashed algorithm is used to search a record.

7. Response time is faster as compared to standard and sorted internal table, as response time is independent of number of entries. It is well suited for tables, where a table has huge number of records and we want to search based upon unique key.


4. Comparing Standard vs Sorted vs Hashed Internal Tables

1. Index :- 

  • Standard Internal tables are the index based internal tables. 
  • Sorted Internal tables are also the index based internal tables. 
  • Hashed internal tables are not the index based internal tables.

2. Insertion Of Records:-

  • Both append and insert operations can be used to insert the records to standard internal tables. 
  • Only insert operation can be used to insert the records to sorted internal tables. 
  • Only insert operation can be used to insert the records to hashed internal tables.

3. Sorting :- 

  • Data is not sorted by default in standard internal table.SORT operation is used sort the data to standard internal table. 
  • Data is sorted by default. There is no need for SORT operation. 
  • SORT does not have any impact on the performance of HASHED internal table.

4. Read :- 

  • The record can be read from standard internal table using KEY or Index. 
  • They record can be read from sorted internal table using KEY or Index. 
  • The record can be read from hashed internal table using KEY only. 

5. Search :-

  • Linear or Binary Search 
  • Binary Search 
  • Hashed algorithm

6. Response Time :- 

  • Response time of standard internal table is less as compared to sorted and hashed internal tables as it uses linear search by default. The response time of standard internal tables depends upon the number of entries. The response time of standard internal table can be improved by using binary search.
  •  Response time of sorted internal table is fast as compared to standard internal table as it uses binary search.
  •  Response time of hashed internal table is fast as compared to standard and sorted internal tables. The response time of hashed internal tables does not depend upon the number of Types of Internal Tables in ABAP Programming 10 entries. It is well suited for tables, where a table has huge number of records and we want to search based upon unique key. 

Some Important Questions:
1. Which of the internal tables are indexed based internal tables ? 
Ans :- Standard, Sorted

 2. Is standard internal table only uses linear search ? 
Ans :- By default, standard internal table uses linear search, We can use binary search also.

 3. Can we use append to insert a record to sorted internal table ?
 Ans :- No, append is never preferred , as it will result in to runtime error, if we insert a record that is not in sorted order. 

4. Which internal table has highest performance when there is large amount of data and search is based upon unique key ? 
Ans :- Hash internal Table 

5. What is the difference between append and insert ? 
Ans :- Append inserts the record at the last of the internal whereas Insert inserts the record at anywhere in the internal table.

Thursday, May 29, 2025

๐Ÿ” Internal Tables - READ

 READ:

It reads a single record from Body to Header Line (or) Work Area

Syntax:

READ TABLE it[INTO wa]

[INDEX n][WITH KEY keyexpression]

[TRANSPORTING fieldname]

[Binary Serach]

 

READ TABLE it:

           Reads a single record from Body to Header Line

           Ex: READ TABLE it INTO it.

READ TABLE it INTO wa INDEX n:

           It reads a specific record (Line Number) from Body to Work Area

           Ex: READ TABLE it INTO wa INDEX 5.

READ TABLE it INTO wa WITH KEY keyexpression:

       It reads a specific record which matches a given condition in Work Area

        Ex: READ TABLE it INTO wa WITH KEY customer=wa1-customer

 READ TABLE it INTO wa WITH KEY keyexpression TRANSPORTING <field1> <field2>……….:

Ex: READ TABLE it INTO wa WITH KEY customer=wa1-customer TRANSPORTING city (it will shows only city field)

Binary Search:

It reads data from Body to Work Area based on binary search algorithm

Note:

1. Use binary search if Internal table is large

2. Data should be sorted before applying binary search algorithm

3. There should be no duplicate records in Internal Table

4. Binary search algorithm improves performance of programming.

๐Ÿ” Internal Tables- LOOP

Internal Tables

  • Internal table is a temporary table created in RAM in Application Server
  • It is created & filled with data during run time (execution time)
  • Once execution is performed it is rolled out (or) discarded

Note:We Use Internal table for storing multiple records during run time 

Difference between Database table & Internal table:

Database Table                                              Internal Table

1. It is created in Database Server                  1. It is created in Application Server

2. It holds data permanently                           2. It holds data temporarily

3. It holds only specific type of data              3. It holds data of different tables of at one place


Question: What is exact purpose of Internal table. Do you think should be created in ABAP

programming?

Answer: In real time we are creating Internal table for storing different types of application data

from different tables at one place.

Every Internal table is having 2 parts

They are:

1. Internal Table Body

2. Header Line

1. Internal Table Body:

The name Internal table itself specifies body of Internal table & it holds multiple records

2. Header Line:

It is a default Work Area & holds single record


Note: Header Line is system defined Work Area & Work Area is user defined Header Line

Syntax:

DATA: BEGIN OF it_kna1 OCCURS 0,

customer(20) TYPE C,

name(20) TYPE C,

city(20) TYPE C,

END OF it_kna1.

Note:

1. With above syntax an Internal table it_kna1 is crated in Application Server

2. You can provide any name. But in real time Internal table should always begins with it_ (or) i_ followed by table name

3. With BEGIN option Header Line is created & OCCURS option Body is created

4. 0, 1, 2, 3, …..9 is called Size Category

5. Both Header Line & Body name is same (it_kna1)


Flow of Data in Internal Table:

1. Database Table ----> Body---> Header Line--->Virtual Page --->Presentation Server

2. Database Table ---> Body---> Presentation Server 

Reading Data from Body to Work Area (or) Header Line:

1. LOOP ……….. ENDLOOP

2. READ keywords

1. LOOP ……… ENDLOOP:

It reads multiple records (record by record) from Body to Header Line (or) Work Area

Syntax:

LOOP AT it[INTO wa]

[FROM m][TO n]

[where condition].

…………

…………

ENDLOOP.

LOOP AT it: Reads multiple records (record by record) from Body to Header Line

Note:Internally system converts LOOP AT it as LOOP AT it INTO it.

Working:

  • Go to SE38
  • Program: ZSD_LOOPENDLOOP
  • Select Create option
  • Title; Internal Table
  • Type: Executable Program
  • Select Save option
  • Leave Package:__________ blank
  • Select Local Object option

Program: REPORT ZSD_LOOPENDLOOP.

* provide internal table

DATA: BEGIN OF it_kna1 OCCURS 0,

customer(20) TYPE C,

name(20) TYPE C,

city(20) TYPE C,

END OF it_kna1.

* provide extraction logic

SELECT kunnr name1 ort01 FROM kna1 INTO TABLE it_kna1.

* Appling processing logic

LOOP AT it_kna1 INTO it_kna1.

WRITE:/10 it_kna1-customer,

30 it_kna1-name,

60 it_kna1-city.

ENDLOOP. 

 Note; Activate the program then select F8 to execute the program

  • Debugging: Internal Table
  • Go to SE38
  • Program: ______ which you want to debug
  • Select Debugging button
  • Select Tables tab (starting from 6th option)
  • Table: it_kna1 & press Enter

Note:

You will find a Cap symbol which indicates Header Line (holds only single record)

Select F5 for single step debugging

Note:

1. Table keyword will transfer the data directly to Internal Table to Body

2. Always use Table keyword in select statement if you are working with Internal Tables

3. As long as you are in loop system will read next record in-line in an Internal Table. Once the loop is terminated again the loop starts reading from 1st line

LOOP AT it INTO wa:

Reads multiple records (record by record) from Body to Work Area

Working:

  • Go to SE38
  •  Program: ZSD_INTERNAL_WORKAREA
  •  Select Create option
  •  Title: Internal Table & Work Area
  •  Type: Executable Program
  •  Select Save option
  •  Leave Package:__________ blank
  •  Select Local Object option


Program: REPORT ZSD_ INTERNAL_WORKAREA.

* provide internal table & work area

TYPES: BEGIN OF ty_kna1,

customer (20) TYPE C,

name(20) TYPE C,

city(20) TYPE C,

END OF ty_kna1.

DATA: wa_kna1 TYPE ty_kna1,

it_kna1 TYPE TABLE OF ty_kna1.

* provide extraction logic

SELECT kunnr name1 ort01 FROM kna1 INTO TABLE it_kna1.

* Appling processing logic

LOOP AT it_kna1 INTO wa_kna1.

WRITE:/10 wa_kna1-customer,

30 wa_kna1-name,

60 wa_kna1-city.

ENDLOOP.

Note:

1. Using TABLE OF you can create your own body

2. Using TYPES keyword Structures are created in ABAP programming

3. In ABAP programming always create Object (Work Area & Body) based on Structures

4. Avoid creating Internal Table with OCCURS clause


LOOP AT it INTO wa FROM m TO n:

Reads multiple records from Body to Work Area based on given condition

Example:

1. LOOP AT it INTO wa FROM 100.

2. LOOP AT it INTO wa FROM TO 50.

3. LOOP AT it INTO wa FROM 100 TO 200. 

Thursday, May 22, 2025

๐Ÿ”ค ABAP/4

 ABAP/4

Advanced Business Application Programming 4th Generation Language

All SAP applications are designed & developed using ABAP Language

It is a high level language


Features of ABAP:

1. It was designed based on ‘C’ language

2. It is a platform independent language

3. It is a case insensitive language

4. It is database independent

5. It is truly business oriented language

6. It is rich in data types

7. It was designed based on Object Oriented Programming

8. It is an event driven programming language

9. It is highly user friendly

10. It supports web based applications also

 

ABAP Work Bench:

In real time as a Technical Consultant have to work with ABAP Work Bench tools

ABAP Work Bench Tools:

1. ABAP Dictionary:

 It works with Transaction Code (OR) T Code SE11 (System Engineering)

 Here we can create & store Tables (or) Data

2. ABAP Editor:

It works with Transaction Code (OR) T Code SE38 (System Engineering)

Here we can create & execute Programs

3. Screen Painter:

 It works with Transaction Code (OR) T Code SE51 (System Engineering)

 Here we can design Applications (OR) Screens

4. Class Builder:

 It works with Transaction Code (OR) T Code SE24 (System Engineering)

 It is for Object Oriented ABAP

5. Function Builder:

It works with Transaction Code (OR) T Code SE37 (System Engineering)

Here we can work with Function Modules

6. Object Navigator:

It works with Transaction Code (OR) T Code SE80 (System Engineering)

Here we can create & modify the Objects & store the Objects


Note:

  • In Object Navigator you can develop all Objects in SAP.
  • It is also known as a True ABAP Development Work Bench


Requirements for Installing SAP:

1. 4GB RAM

2. 500GB Hard Disk

3. Core 2 Duo Processor

๐Ÿข SAP R/3

 SAP R/3:

Systems, Applications, Products in data processing

R/3------ Real time 3 tier architecture

History:

SAP AG---- developed by 5 IBM employees in 1973----in woldoff (Germany)

SAP R/1(Finance)------1973

SAP R/2 (Mainframes)------1978

SAP R/3 (Client Server Technology)----1992

Systems:

These are basic resources for implementing a project

Examples: Servers, Hardware, Soft ware, Systems, Network, Database………etc

 

 Features of SAP:

1. Designed based on RDBMS

2. Designed based on R/3 Architecture

3. Database independent

4. Supports all types of industry specific solutions

5. International package available in 40 languages

6. It can be customized using ABAP language

7. Best ERP for FI, SD, MM, PP, HR, CR

8. Supports Client-Server Technology

9. Highly versatile (Operating System independent)

10. Supports web based application softwares 

 

ABAP Consultant (or) Abapar (or) Technical Consultant:

Roles:

1. Creates Technical Documents (brief logic)

2. Creates an Object from scratch implementation project

3. Modifies existing objects to support project

 

BASIS Consultant:

Roles:

1. Installation

2. Maintenance

3. Configuration

4. Customization (or) Administration

Applications:

  •  These are collection of Screens
  •  Each Screen is a collection of Fields

 

Use---Applications are used by Clients (or) End Users

Create---Applications are created by Abapars (or) Technical Consultant (or) ABAP Consultant

Customized Data----Applications data customized by Functional Consultant

Functional Consultant:

Roles:

1. Customization of Data

2. Getting requirements from Clients

3. Preparing Functional Documents

4. Preparing End User Manuals (or) Snapshots

5. Providing end user Training

Products:

  • These are called Objects 

  • These are created by Programming

 

SAP R/3 Architecture



Services in R/3 Architecture:

1. Dialog Service:

It provides interface between Presentation Server & Application Server

2. Update Service:

It provides interface between Application Server & Database Server

3. Spool Service:

It provides interface between SAP R/3 & External Systems (Printers, Fax….etc)

4. Background Service:

It is for background scheduling

Note: In real time once report is created, then it is scheduled in background by BASIS Consultants, they will set time & event related to it

5. En-queue Service:

It maintains data integrity (locking mechanism) in SAP

6. Message Service:

It is for Error & Exception handling

7. Gateway Service:

It is for distributed environment

Note: The above 7 services are part of Application Server

8. SAP GUI Front End Service:

It handles all SAP GUI Operations in SAP Presentation Server

9. Database Service:

It Maintains & Manages data operations in Database Server


Softwares in SAP:

1. Production Software

2. IDES Software (or) Training Software

1. Production Software:

  1. It is Real time
  2. Every company should purchase this software from SAP
  3. Here you will find only live data.
  4.  Clients (End Users) are works with Production Software

2. IDES Software:

    1. International Demonstration & Education System Software
    2. It is also known as Training Software
    3. Here you can find data for practice & examples for practice






 

๐Ÿ“ฆ ERP: Enterprise Resource Planning

 ERP: Enterprise Resource Planning

ERP is a package under which all the business resources are integrated in one system.

          Enterprise-------organization

Resource--------FICO, HR, MM, PP, SD, CRM

 

Types of ERP:

1. High End ERP

2. Mid Range ERP

 

1. High End ERP:

  •  These ERPs are implemented in large scale industries
  •  In these ERPs all the tables, programs & applications are predefined

Example:

1. SAP R/3 (60000+ applications, 400000+ tables, 55+ modules)

2. Oracle Apps (for Finance)

2.1. Oracle Finance

2.2. Oracle Manufactures

2.3. Oracle HRMS

3. SIEBEL (for CRM)

4. People Soft (for HR)


2. Mid Range ERP:

These ERPs are implemented in small scale & medium scale industries

Example:

1. Baan (for Finance)

2. JD Ed Wards (for logistics)

3. Ramco (for Cement)

4. Microsoft ERP (for Finance)

 

Need for ERP:

1. Large Organization

2. Centralized Database

3. User Friendly

4. Speed

5. Security

6. Competitive Advantage

7. Reduced Errors