Thursday, May 2, 2013

0 Constants in SAP ABAP

Constants in SAP ABAP :


Constants refers to the fixed values that do not change during the execution of a program. A "constant" is a number, character, or character string that can be used as a value in a program.
A constant can be

a number, like 58 or 1.9

a character, like S or @

a character string, like "this is a SAP"


Using "CONSTANTS" keyword we can declare Constants

Syntax :

CONSTANTS : <Name> TYPE <Data Type> VALUE <' number/character/character string'>


EX :

 *&---------------------------------------------------------------------*
*& Report  ZCONSTANTS
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT  zconstants NO STANDARD PAGE HEADING.

* Declaration Of Constants. *
* Constants: - We can n't change value at run time. *
* Keyword for Constant is 'CONSTANT'. *

** Program Starts *

* Declaring and Assigning values to Constants. *

CONSTANTS : name    TYPE char10  VALUE 'vishnu'.
CONSTANTS : number  TYPE i      VALUE 10.

* Displaying output. *

WRITE : name,
        number.



 

SAP-ABAP Copyright © 2011 - |- Template created by Vishnu - |- Powered by Blogger Templates