You are on page 1of 13

7/11/2017

Dynamic ABAP
Coding
Concepts

Presented By
Venkata Sudheer D
1 Teklink International Inc.
2 7/11/2017

Ways of Writing Program in ABAP:

Static Programming
Dynamic Programming

Teklink International Inc.


3 7/11/2017

Important Steps during Program Execution:

Compilation
Here system will convert Logic from Higher level
language to intermediate language which will
be understood by system.

Execution
Here system executes the interpreted logic with
the help of input provided by user.

Teklink International Inc.


4 7/11/2017

Different ways in writing dynamic


programming in ABAP

DATA Declaration
SELECT
WHERE Clause
SORT
READ
SUBROUTINE

Teklink International Inc.


5 7/11/2017

DATA Declaration
STATIC Way:
DATA: LT_MAKT TYPE STANDARD TABLE OF TY_MAKT,
LWA_MAKT TYPE TY_MAKT.

Dynamic Way:
FIELD-SYMBOLS: <F_MAKT> TYPE STANDARD TABLE.
DATA: LO_MAKT TYPE REF TO DATA.
CREATE DATA LO_MAKT TYPE TABLE OF (LV_TAB).
ASSIGN LO_MAKT ->* TO <F_MAKT>.

LV_TAB is a variable which holds the


Structure name.

Teklink International Inc.


6 7/11/2017

SELECT
STATIC Way:
SELECT M ATNR
M AKTX
SPRAS
FROM M AKT
INTO TABLE LT_MAKT
WHERE SPRAS EQ SY-LANGU.

Dynamic Way:
SELECT (LT_FIELDS)
FROM (LV_TAB)
INTO TABLE <F_M AKT>
WHERE SPRAS EQ SY-LANGU.

Here LT_FIELDS is an internal table which contains list of fields


need to fetch from a DB Table.
LV_TAB is a variable which holds DB Table name.
Teklink International Inc.
7 7/11/2017

WHERE Clause
STATIC Way:
SELECT MATNR
MAKTX
SPRAS
FROM MAKT
INTO TABLE LT_MAKT
WHERE SPRAS EQ SY-LANGU.

Dynamic Way:
SELECT (LT_FIELDS)
FROM (LV_TAB)
INTO TABLE <F_MAKT>
WHERE (LV_CONDITION).

Here LV_CONDITION is a variable which contains Where


clause condition.
Teklink International Inc.
8 7/11/2017

SORT
STATIC Way:

SORT LT_MAKT BY MATNR SPRAS.

Dynamic Way:

SORT <F_MAKT> BY (LT_SORT).


Here LT_SORT is an internal table which contains list
of fields based on which SORT operation will be
performed.

Teklink International Inc.


9 7/11/2017

READ
STATIC Way:
READ LT_MAKT INTO LWA_MAKT WITH KEY M ATNR = COM PUTER.

Dynamic Way:
LOOP AT <F_M AKT> INTO <FWA_MAKT>.
ASSIGN COM PONENT LV_MATNR of STRUCTURE <FWA_MAKT>
TO <FV_MAT_VAL>.
IF <FV_MAT_VAL> EQ COM PUTER.
EXIT.
ENDIF.
ENDLOOP.

Here LV_MATNR is variable which holds field name i.e. M ATNR.


<FWA_MAKT> is Structure which hold single line of internal
table.

Teklink International Inc.


10 7/11/2017

Modularization Techniques:
These Techniques are used to:
Avoid Repetitive Coding.
Organizing ABAP Code in Neat Manner.
Limit Maintenance Cost by coding everything only
once.
Easier to understand.

Types of Techniques:
INCLUDES.
SUB ROUTINES.
MACROS.
FUNCTION MODULES.
METHODS.

Teklink International Inc.


11 7/11/2017

SUB ROUTINE
STATIC Way:
PERFORM READ_MATNR.

FORM READ_MATNR.
-------
ENDFORM.
Dynamic Way:

GENERATE SUBROUTINE POOL LT_CODE NAME LV _PROG MESSAGE LV _MSG


SHORTDUMP-ID LV _SID.

PERFORM (LV _SUBROUTINE) in program (LV _PROG).

Here LT_CODE is an internal table which contains SUB ROUTINE DEFINITION


Lines.
LV_PROG is variable which holds dynamic program name generated by
system.
LV_MSG which hold Message Triggered while generating dynamic
program.
LV_SID is variable which holds Short dump id generated during dynamic
program creation.
LV_SUBROUTINE is a variable which hold dynamic subroutine name
which generated in dynamic sub routine pool.

Teklink International Inc.


12 7/11/2017

Teklink International Inc.


13 7/11/2017

Teklink International Inc.

You might also like