Vous êtes sur la page 1sur 4

Programming Techniques

 The R/3 Basis System is the platform for all applications (logistics, FI, HR
etc) in R/3 System
 There are 3 parts :
A. Position of Basis System within R/3 System
• Logical View
• Software Oriented view
• User Oriented view
B. Application Server
• Structure of application server
• Dispatching dialog steps
• Dispatching and Programming models
C. Work Processes
• Structure of Work Processes
• Types of Work Processes

Data objects:
A data object is a part of the repository whose content can be addressed and interpreted by
the program
Physical units with which ABAP statements work at runtime.
Contents occupy memory space in a program
ABAP Statements access the contents by addressing the name of the data object
ABAP Statements can write the contents of Data object in report or in the database and also
pass/receive from routines and can be changed by assigning new values
Declare objects statically or dynamically
ABAP Data object has a set of technical attributes, defined at all times when the ABAP
program is running

Data Types
Data Types can be defined independently,
The definition of a user-defined data type is based on a set of predefined elementary data
types.
Define data types either locally in the declaration part of a program using TYPES Statement
or globally in the ABAP Dictionary.
Use own data types to declare data objects or to check the types of parameters in generic
operations.
Data types can be divided into Elementary, Reference and Complex types.
Elementary Types: are fixed or variable length that are not made up of other types.
The difference between variable length data types and fixed length data types is that the
length and the memory space required by data objects of variable length data types can
change dynamically during runtime, and that these data types cannot be defined irreversibly
while the data object is being declared

Control statements
1. Flow Control
2. Logical Expressions
3. Conditional Statements

Flow of Control
1. External Flow: Events triggered by user or the system
2. Internal Flow :Control of processing sequentially within a program at one event,
Logical conditions and loops

Case Distinction : IF ……ENDIF and CASE ……ENDCASE


Loops : Do….. ENDDO and WHILE ….. ENDWHILE
Control Statements: CONTINUE, CHECK, EXIT.
Logical Expressions: EQ, NE, GT, GE, LT,LE, BETWEEN f1 and F2, IS INITIAL

• Internal control is processing guided by branching (like IF and CASE) and Looping
(DO and WHILE) in a program.
• External control is processing guided by events such as user input.
• Logical Expressions include using NOT, AND, and OR Operators.
• Logical Expressions are similar to those in other computer languages and can be
specified by either alphabetic or symbolic relation operators such as EQ or =, NE or
<>, LT or <, LE or <=, GT or >, GE or >= etc.,
• IF/ELSEIF/ELSE/ENDIF Implement conditional logic for arbitrary conditions.
• CASE/WHEN/ENDCASE implement conditional logic according to fixed set of possible
values.
• A DO loop repeats processing either a fixed number of time or until an EXIT condition
is encountered.
• A WHILE Loop Repeats processing as long as a logic expression is true or until an
EXIT condition is encountered.
• An EXIT Statement is used to leave a loop or a current subroutine.
• Logical Expressions include using NOT, AND, and OR Operators.
• Logical Expressions are similar to those in other computer languages and can be
specified by either alphabetic or symbolic relation operators such as EQ or =, NE or
<>, LT or <, LE or <=, GT or >, GE or >= etc.,
• IF/ELSEIF/ELSE/ENDIF Implement conditional logic for arbitrary conditions.
• CASE/WHEN/ENDCASE implements conditional logic according to fixed set of possible
values.
• A DO loop repeats processing either a fixed number of time or until an EXIT condition
is encountered.

Internal Tables
• Internal table is a very important concept in ABAP/4 programming
• Internal Tables are local tables within a program containing a series of lines having
same data type
• ABAP Open SQL allows single field, range of fields, entire database table or view into
an Internal table
• Internal table is a dynamic sequential dataset in which all records have the same
data structure and a key
• Internal tables are used for fetching large volume of data from the database, storing
in ABAP working memory line-by-line and processing within a program
• Although Internal tables are declared with the other data objects, at runtime they
behave as dynamic objects
• Internal tables provide a means of taking data from a fixed structure and storing it in
working memory in ABAP
• Data is stored line by line in memory, and each line has the same structure
• A particularly important use for internal tables is for storing and formatting data from
a database table within a program
• The number of internal tables in a program must be kept minimum as possible .
• Creating an internal of standard type and going to process small amount of data its
better to declare a internal table directly using DATA statement
• Try to avoid using internal table with header line; declare a separate work area
compatible to the internal table line type .
• Always try to use the system fields when you processing the internal table entries
within the loop
• APPEND statement always adds to the last line of the internal table whereas MODIFY
changes entry that is already in the table.
• Using internal table within a loop that behaves differently at each pass make sure
that you have cleared the header line or work area
• Use the appropriate statements for Standard, Sorted and Hashed Tables
• SY-SUBRC – This is common to all the statements in ABAP. This system field is set to
0 when the statement is executed successfully else it is set to 4.
• SY-TABIX – This system field contain the current line of an internal table. The
internal table must of either Standard or Sorted table. For Hashed table this field is
not set. As this field is set only for Index tables SY-TABIX is set to the index for the
following operations- Append, Collect, loop at and Read.
• SY-TFILL – contains the number of lines in the internal table
• SY-TLENG – contains the length of the lines in the internal table
• SY-TOCCU – contains the initial amount of memory allocated to the internal table.

Modularization:
• improve program structure
• make the program easier to maintain and update
• improve readability
• reduce redundancy
• allow for component reuse
• event processing
ABAP is an event driven language. The processing associated with each event is
written in a program module
• Types of modules in an ABAP program
Subroutines : internal subroutines - source code is in the same ABAP program as
the calling procedure
External subroutines - source code of external subroutines is in an ABAP program
other than the calling procedure
Functions: stored in central library
offer a defined interface
Event handling code blocks

Difference between FM and Form:


• Main difference between subroutines and functions is a clearly defined interface for
passing data between program and function
• Function modules must belong to a pool called a function group.
• They possess a fixed interface for data exchange. This makes it easier for you to
pass input and output parameters to and from the function module.
For example, you can assign default values to the input parameters. The interface
also supports exception handling. This allows you to catch errors and pass them back
to the calling program for handling.
• They use their own memory area. The calling program and the function module
cannot exchange data using a shared memory area - they must use the function
module interface. This avoids unpleasant side effects such as accidentally overwriting
data.
• You call a function module by its name (which must be unique) in a CALL FUNCTION
statement
Calling Programs:
• To develop an extensive application, one program can become very complex.
• To make the program easier to read, divide the required functions among several
programs.
• Using external modularization, in which store the procedures in special non-
executable ABAP Programs like function groups,
• ABAP Statements allows to start executable program or transaction.
• Exit the calling program or have the system return to it when the called program
finishes running
• Call a transaction whose initial screen is filled with data from the selected list line
• The event LOAD-OF-PROGRAM is triggered each time a program is called
• Each execution of an executable program actually has a SUBMIT statement as its
source
• Enter the program name in a transaction like SE38 or SA38 and choose Execute, a
SUBMIT statement occurs in the transaction.
• Therefore, executable programs have the attribute of being able to be called using
SUBMIT, although their principal characteristic from a user’s point of view is that
they are started in the foreground
• The following ABAP Statements allows to start executable program or transaction
• Call with return
• Executable program – SUBMIT AND RETRUN
• Transaction – CALL TRANSACTION
• Call without return
• Executable Program - SUBMIT
• Transaction - LEAVE TO TRANSACTION

• There are two ways of passing data to a called program


• Passing Data Using Internal Memory Areas
• SAP MEMORY
• ABAP MEMORY
• Filling Input Fields on an Initial Screen
• Filling the selection screen of a called program
• Filling Initial Screens using SPA/GPA parameters

Vous aimerez peut-être aussi