Wednesday, December 17, 2008

ABAP Program

ABAP Program

-> ABAP programs are made up of individual statements.
-> Each statement ends with a period.
-> The first word in the statement is a keyword.
-> Words must be seperated by atleast one space.
-> Statements can be intented.
-> Statements can take up more than one line.
-> You can have multiple statements in one line.
Programming Convention
-> Consecutive statements with identical keywords can be condensed into one chained statement
-> In chained statements,initial part of the statement containing the keyword must be followed by a colon.
-> Individual elements that come after the colon must be seperated by comma.

Chain Operator ‘:’ is a chain operator.
  • It combines lines of code beginning with same word.
  • Places common part at the beginning
  • Reduces redundancy of code.
Comments
  • ‘*’ in the first column is used to comment an entire line
  • ‘“’ used t command remaining part of the line.

Data Declaration

-> The TABLES keyword refers to a golbal type flat structure that is defined in the ABAP dictionary.

-> The DATA keyword is used to define local data objects.

-> The data object type is defined using TYPES.

-> PARAMETERS not only defines an elementary data object but also allows the user to input a data.

Data Types

C -> Character
N-> Numeric Text
D ->Date(YYYYMMDD)
T ->Time(HHMMSS)
X ->Byte(Hexadecimal)
I ->Integer
P ->Packed Number
F ->Floating Point Number
STRING -> Character String
XSTRING-> String of Bytes

ABAP supports three numeric data types - I, P and F. Type N is a text type, not a numeric data type (although its values are strings of digits), because the strings are not used for calculation purposes. Typical examples of type N fields are account and article numbers (provided they contain only digits), as well as the sub-fields of date and time fields.

Rules for naming data objects:

  • A name can consist of maximum 30 characters.
  • These symbols are not allowed : ( )+:.,
  • SPACE is a predefined field.
  • With data types P,N,C,X you need to enter the length in parentheses.
  • WIth P type you can specify the DECIMALS to determine no. of decimal places.
  • If no type is specified default type is C.

Conditional statements
If .
stmts.
Elseif .
stmts.

Else.
stmts.
Endif.

Case

Case var.
When val1
stmts.
When val2
stmts.

When others
stmts.
Endcase.

Do loop
Do times.
stmts.
Enddo.

While
While .
stmts.
Endwhile.









No comments:

Post a Comment