0% found this document useful (0 votes)
28 views13 pages

1.basic Programming Material

Uploaded by

Mulla Javeed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views13 pages

1.basic Programming Material

Uploaded by

Mulla Javeed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 13

CORE ABAP FROM GENSOFT TECHNOLOGIES

POWERED BY Mr. Sridhar Sunkari

c/c++/java for variable declaration:

int x=10;

char y;

float z;

int x,y,z;

c/c++/java for reading user input:

scanf, cin,System.in.read

c/c++/java for displaying output:

printf,cout,System.out.println

ABAP statements / keywords:

1. Data: used for declaring variables

Syntax:

data [:] <variable name> <type/like> <data type>


[value <initial value>]

[decimals <no.of
decimals>]....

[ ] --> optional (may / may not be used)

< > --> mandatory / obligatory

Eg: data x type i.

data x type i value 10.

data abc type c.


CORE ABAP FROM GENSOFT TECHNOLOGIES
POWERED BY Mr. Sridhar Sunkari

2. Parameters: generates selection screen for reading user input

Syntax:

parameters [:] <variable name> <type/like> <data type> [default


<default value>] [obligatory] [lower case].....

3. Write: generates List processing screen(output screen) for


displaying the result

Syntax:

write [:] <variable> ...........

4. Constants: used for declaring fixed value variables. It must


be initialized at the time of initialization itself.

Syntax:

constant [:] <variable> type <datatype>


value <fixed value>.

Conditional statements:

1. if-else

Syntax:

if <condition 1>.

statements.

elseif <condition 2>.

statements.

----

elseif <condition n>.


CORE ABAP FROM GENSOFT TECHNOLOGIES
POWERED BY Mr. Sridhar Sunkari

statements.

else.

statements.

endif.

2. Case-endcase (similar to switch statement in 'C'


lang)

Syntax:

case <variable>.

when <value 1>.

statements.

when <value 2>.

statements.

----

when others.

statements.

endcase.

3. Check:

Syntax:

check <condition>.

statements.
CORE ABAP FROM GENSOFT TECHNOLOGIES
POWERED BY Mr. Sridhar Sunkari

Looping statements:

1. While-endwhile

Syntax:

while <condition>.

statements.

endwhile.

2. Do-enddo

Syntax 1:

do.

statements.

<Exit condition>.

enddo.

Syntax 2:

do <n> times.

statements.

enddo.

3. Loop-endloop - internal tables

syntax:

loop at <int.table> [condition].

statements.
CORE ABAP FROM GENSOFT TECHNOLOGIES
POWERED BY Mr. Sridhar Sunkari

endloop.

4. Select-endselect  database programming

Syntax:

select <query>.

statements.

endselect.

Operators in ABAP:

Arithmetic Operators:

+, -, *, / (quotient), mod (remainder)

Logical Operators:

AND, OR

Relational Operators:

Symbolic Format (or) Character Format

< lt (less than)

> gt (greater than)

<= le (less than or equal to)

>= ge (greater than or equal to)

= eq (assignment / equal to)

< > ne (not equal to)

?= Type casting symbol


CORE ABAP FROM GENSOFT TECHNOLOGIES
POWERED BY Mr. Sridhar Sunkari

Standard objects --> are provided by SAP

--> Starts with other than 'Z' /


'Y'

--> read and execute

--> for modification --> need to provide


access key

Access key --> 16 digit secured password used for modifying


standard objects --> will be provided by SAP itself (if
required)

Custom objects / zee objects --> developed by ABAP consultants


on behalf of customer --> Starts with
'Z' / 'Y'

--> do not require access key for development/modification

Developer access key --> needs to be provided when we are trying


to develop first object in the registered user (one time task)

--> used for authenticating (checking) the user as a


registered developer

Package --> it is like a directory / folder which is a


collection of objects

--> A object stored in $tmp (local object) cannot be


transported

--> A object must be stored in transportable package so that


it can be assigned to a change/transportable request which can
be transported from one client to other

Note: Executable programs starts with 'Report' keyword

Execution of objects:
CORE ABAP FROM GENSOFT TECHNOLOGIES
POWERED BY Mr. Sridhar Sunkari

1. Save (ctrl + s)

2. Check for syntax errors (ctrl + f2)

3. Activate the object (ctrl + f3)

4. Execute the object (f8)

Notes:

1. Parameter variable names should not exceed 8 characters and


should not contain special characters.
2. Parameters / Parameter is the statement used for generating
selection screen for reading the input values
3. Default is the option/addition used as part of parameters
statement to provide default values for selection screen
fields
4. Obligatory is the option used as part of parameters
statement to make a selection screen field as mandatory
5. By default, numeric data types (integer(i), packed(p),
float(f)) are right-justified and character data types
(character( c ), date (d), time (t) are left-justified).
6. We use : (colon chain operator) as part of ABAP statements
whenever we perform multiple operations using single
keyword.
7. To check the DOCUMENTATION (for understanding the syntax of
statement and its related options), put the cursor on the
relevant abap statement and press ‘F1’ key
8. No standard page heading is the option used as part of
report statement to suppress (remove) the default title
display in the list processing screen.
9. To generate selection text for a parameter variable, follow
the path given below.
10. To change the Date and time formats display, we can
use the addition ‘EDIT MASK’ as part of write statement.
11. Integers cannot store decimal values, if any decimal
value is stored in integer variable; it will round off to
nearest integer. To store the decimal values, we can use
CORE ABAP FROM GENSOFT TECHNOLOGIES
POWERED BY Mr. Sridhar Sunkari

packed data type and use the addition ‘decimals’ to specify


the no. of decimal positions.

Selection-texts for the selection screen parameter


variables:

Develop and activate the program first, choose the menu ‘go
to’  text elements  selection texts  under selection
texts tab, provide meaningful text for the parameter
variables, activate.

Reference:
CORE ABAP FROM GENSOFT TECHNOLOGIES
POWERED BY Mr. Sridhar Sunkari

ABAP System Fields:

These are provided by SAP itself and they start with ‘SY-…..’.
The Values for these System fields are assigned by SAP itself.

Sy-datum  Current application server date

Sy-uzeit  Current Application server time

Sy-repid  Current Program name

Sy-uname  Login user name

Sy-dynnr  current screen no.

Note: By default, selection-screen number is always 1000.

Numeric Values:

By default, Integers cannot store decimal values. If any


Decimal value is assigned to integer variable in single
quotes, then the value will be rounded off to the nearest
integer and stored in the integer variable. To store
decimal values, we can use ‘P’ (Packed) data type and while
declaring packed variables, we need to use decimals
addition to specify number of decimal places.

Character Fields:

A variable declared as ‘C’ (character) can store only


single character by default, to store more number of
characters declare the variable as array of characters or
as a string data type.

Continue Statement:

Whenever continue statement is executed inside a loop, the


statements after the continue statement will be skipped i.e. the
rest of the statements will not be executed for the current
CORE ABAP FROM GENSOFT TECHNOLOGIES
POWERED BY Mr. Sridhar Sunkari

iteration and the control jumps to next iteration for condition


check. Before the continue statement is executed, the iteration
variable needs to be incremented / decremented otherwise it
leads to infinite execution.

Exit Statement:

Whenever the exit statement is executed inside a loop the


control jumps out of the current loop, if the exit statement is
executed independently outside the loop, the control comes out
of the program execution i.e rest of the statements after exit
statement will not be executed.

The Difference between While-Endwhile and Do-Enddo is in case of


While-endwhile, the condition is checked first and if it is
true, the control enters the while loop and then executes the
statements. In case of Do-endo, the control first enters the do
loop, executes the statements at-least once and then check the
condition for continuing the iteration of loop or to exit the
loop.

Check statement is used for condition check. If the check


condition is true, it executes the statements after check
otherwise ignores it.

String Functions:

1. Strlen  Returns Length of string


2. Translate  Converts a given string to upper case/lower
case
3. Concatenate  Combines multiple strings into single string
4. Split  Splits the given string into multiple substrings
based on the delimiter
5. Condense  Removes the blank spaces of a string
6. Replace  Replaces the source pattern of a string with the
given target pattern
7. Overlay  Replaces the blank spaces of the source string
with the corresponding positioned character in the target
string
CORE ABAP FROM GENSOFT TECHNOLOGIES
POWERED BY Mr. Sridhar Sunkari

8. Shift  shifts the contents of the string to the specified


direction and no.of places
9. Unpack  It prefixes the character field containing numeric
values with the appropriate no. of zero’s depending on the
field width.
10. Pack It removes the leading zero’s from the character
field containing numeric values

Note: Off-set logic is used for extracting the portion of the


string.

Submit, Export and Import keywords:

1. Submit keyword is used for calling a program from another


program
2. The addition ‘and return’ as part of submit statement
returns the control back to calling program otherwise the
control remains in called program
3. To exchange data between 2 programs we need to use export
and import statements along with submit statement
4. Export statement writes a variable value to ABAP memory
referring to a memory id.
5. Import statement reads the value from ABAP memory by
referring to a memory id
6. The life time of ABAP memory is within the session. i.e
once the user log off of the session, the variable
values maintained in ABAP memory for that particular
session will be destroyed.

Field-symbols are a special data structure used for holding any


kind of data. i.e it is capable of storing any kind of data.
Field-symbol variable must be enclosed between ‘<’ and ‘>’. We
use the keyword ‘assign’ to assign a variable value to the
field-symbol. Once a variable is assigned to the field-symbol,
there will be a pointer link between the variable and field-
symbol, so any changes made to the data of the variable will
automatically reflect the value of field-symbol and vice versa.

Exception Handling:
CORE ABAP FROM GENSOFT TECHNOLOGIES
POWERED BY Mr. Sridhar Sunkari

- An exception is a runtime error which is raised during the


program execution. If the exception is not handled, the
program execution will be terminated.

- Exception handling is a process of handling the Runtime


Error’s and continue the program execution without
termination.

- The exceptions which are raised by SAP are called as


Standard Exceptions.

- These standard exceptions are raised from standard


exception classes which start with Naming convention
“CX___”.

- We can handle these exceptions by using “TRY” and “CATCH”


blocks.

- Inside the “TRY” Block we need to keep those statements


where the possible exceptions might occur.

- The ‘CATCH’ block is placed immediately after the Try


Block; it is responsible for handling the exceptions by
providing appropriate exception handling statements which
can be system defined exception message / user-defined
exception message.

- “CX_ROOT” is common for any exceptions i.e it is super


class(parent class) for all exception classes.

- As part of the catch block we need to provide the exception


class name which is responsible for raising the exception.

- If we are not sure about the exception class, we can give


the exception class name as “CX_ROOT”.

- “CX_ROOT” is super class for all the exception classes.

Syntax for Selection Screen Radio buttons:

Parameters <radio button name> radiobutton group <group


name> [user-command <function code>].
CORE ABAP FROM GENSOFT TECHNOLOGIES
POWERED BY Mr. Sridhar Sunkari

Eg: Parameters p_r1 radiobutton group grp1.

Note: In a group of radiobuttons, only one radiobutton can


be selected.

A Radiobutton will contain either ‘X’ (or) ‘‘ as values

‘X’ indicates  Selected, ‘‘ indicates  Not selected

By Default, First radiobutton in the group will be


selected.

Syntax for Selection screen Checkboxes:

Parameters <Checkbox name> as checkbox [user-command


<function code>].

Note: In case of checkboxes on selection-screen, we can


select any no. of checkboxes.

A checkbox can contain either ‘X’ (or) ‘ ‘ as values

‘X’  selected, ‘ ‘  not selected

By Default, None of the checkboxes will be selected.

You might also like