Showing posts with label SAP ABAP Key words. Show all posts
Showing posts with label SAP ABAP Key words. Show all posts

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.



Friday, April 26, 2013

0 Difference between TYPE and LIKE in ABAP


Difference between TYPE and LIKE in SAP ABAP :


TYPE : It will allocate memory during execution (object type).
       TYPE will improve performance.
       It is used when userdefined object link with SAP system data type.
       TYPE refers to the user defined data types
       TYPE,assign datatype directly to the data object while declaring.
     
LIKE :  Tt will allocate memory immediatly.
        It is when data object link with the other data object.
        LIKE refers to existing data type of data object
        LIKE,you assign the datatype of another object to the declaring data object. The datatype is referenced indirectly.

Thursday, April 25, 2013

0 Variables in SAP ABAP

Variables in  SAP ABAP :



Variables are named data objects, you can declare variables statically using declarative statements, or dynamically while a program is running. They allow you to store changeable data under a particular name within the memory area of a program.


DATA is a keyword which is used to declare the variables in SAP ABAP

Syntax :
DATA < Variable Name> Type <Data Type>
                           (Or)
DATA <Variable Name> Like <Data Type>
Ex: DATA V1 Type I.
       DATA V2 Like I.

Type is abap keyword for reference
Fields :
         Elementary
        DATA vendor_code(10) TYPE C.
         Reference to Non Elementary
        TYPES vend_code(10)  TYPE C,
        DATA  vendor_code TYPE vend_code.
         Reference to existing fields
        DATA : vend_code(10) TYPE C,
                                   vendor_code LIKE Vend_code.



Tuesday, March 19, 2013

0 What is a difference between - RETURN, EXIT, CHECK, STOP & REJECT - To leave the processing blocks



STOP: This terminates the block and executes end-of selection.
EXIT: It terminates the loop processing and process the next
statements.
CHECK: It evaluates the subsequent logical expression if it
is true the processing continue with the next statement.
CONTINUE terminates the current loop pass, returns the
processing to the beginning of the loop and starts the next
loop pass,
REJECT: it terminates the current event, even from loops or
subroutines.

Monday, June 11, 2012

0 Move ,Compute & Move-Corresponding in ABAP


Move & Compute:
MOVE source TO target.
COMPUTE target = source.
DATA : d1(4),
             d2 TYPE I VALUE 75,
             d3 TYPE I.
    MOVE ‘SAP’ TO d1.
   COMPUTE d3 = d2 + 125.                                                                         
If source & target fields have different type then source is converted in the format of target.
Basic Assignment Operations
Assigning values with Offset specifications
Copying values between components of Field Strings
Basic Assignment Operations
Syntax:    MOVE <f1> TO  <f2>
The MOVE statement transports the contents of the source field <f1>, which can be any data object, to the target field <f2>
The MOVE statement and the assignment operator have the same function. The above statement when written with assignment                                                                                 operator (=) has the form:
f2 = f1.
Example:
DATA: T(10),
           NUMBER TYPE P DECIMALS 1,
            COUNT TYPE P DECIMALS 1.
T  =  1111.
MOVE  ‘ 5.3 ‘  TO  NUMBER.
COUNT  =  NUMBER.
The result of this assignment is that fields T, NUMBER, and COUNT contain the values ‘ 1111 ’, ‘ 5.3 ‘, and ‘ 5.3 ‘.
Assigning values with Offset specifications
You can Specify offsets and lengths for elementary data objects in every ABAP/4 statement.
Syntax:                                                                                                             
MOVE <f1> [+<p1>][(<l1>)] TO <f2> [+<p2>][(<l2>)].
The contents of the section of field <f1>, which begins at the position <p1>+1 and has a length of <l1>, are assigned to field <f2> where they overwrite the section which begins at the position <p2>+1 and has a length of <l2>.
In the MOVE statement, all offset and length specifications can be variables.
Example:
DATA:F1(8) VALUE  ‘ABCDEFGH’,
          F2(8).
DATA:O TYPE I VALUE 2,
L TYPE I VALUE 4.
MOVE  F1  TO  F2.             
Write / F2.
MOVE  F1+O(L)  TO  F2.     
Write / F2.
MOVE  F1  TO  F2 +O(L).   
 Write / F2.
CLEAR F2.
MOVE  F1  TO  F2 +O(L).
 Write / F2.
MOVE  F1+O(L)  TO  F2+O(L).
 Write / F2.
The above example produces the following output:
ABCDEFGH
CDEF
CDABCD
CDEF
Copying values between components of Field Strings
Syntax:
MOVE-CORRESPONDING <STRING1>  TO <STRING2>.
This statement assigns the contents of the components of field string <string1> to those components of field string <string2> which have the same names.
The system executes a MOVE statement for each name pair as follows:
MOVE STRING1- <component> TO STRING2- <component>
 

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