Sei sulla pagina 1di 11

Report on the things I have covered in ABAP

Advanced Business Application Programming


-Abap is a programming language used in SAP, which enables you to: CREATE/ MODIFY
PROGRAMS.
-Each Abap program consists: Program name (starts with Z/Y).
Program attributes (with data types).

Data Dictionary:
-DD is a central repository of data definition in SAP system.
-Used to store the data definitions, create and maintain user defined types.
-When we are looking at DD these are: DB tables, Views, Domain.

Tables(SE11):
-Tables are objects that stores data.
-When creating a table: you start with a Z or Y (naming conversion).
-When creating tables, it should have:
Field name: name of your variable e. g Name (it doesn’t have to start with Z/Y).
Data Elements: used to display the field label.
: describes the meaning of the domain.
Domain:
-When you double click on the data element (ZCustomer Name) you are able to create the
DT.
-Currency field(CURR): used to record amount, when defining it currency you only enter
field name(currency), Data element(WRBTR).
-Quantity () is already defined in SAP.
-SE14 allows you to alter a table.

Data Types:
-Data Types are objects that allows you to define variables.
-Data types arrange/puts info in a structured way.
-Strings(C): these data type is used to define character variables(name).
-Integer(I): these data types are used to define numeric variables (25).
-Date (D/ Dats /Datum) and time(T): used to define date and time.
: ABAP always saves time as 24hr format.
: Timestamp (P) – format YYYYMMDD.

Variables:
-These are named data objects used to stored data/values.
e. g DATA <f> type
-Types of variables: Static variables-These variables are declared in the function modules-
subroutines
Reference Variables-These are used to declare a referenced variable.
System Variable-These variables are already defined by the system.
-Ways of naming a variable:
Cannot use special characters when naming a variable.
Name of the variable cannot be the sane as Abap keyword.

The _ is used to separate words.

-Like keyword-used to refer an existing variable when defining additional variables.

e. g DATA gv_var2 like gv_var1.

-Parameter: defines an input field on selection screen that is also a variable whose value can be
accessed in a program.

-Data: defines a variable that is accessible and will be used internally in the program.

-Value is used to pre-assign a value to a variable. E. g DATA gc_text string value ‘ABC’.

-Literals: are strings of char without a name, their values cannot be changed, they are essentially
hard coded values.

Numeric Literals: continuous sequence of numbers, can be specified without quotes.

Text Literals: character strings, must be enclosed in single quotes.

-System variables: these variables are already defined by the system, SY-DATUM (current date), SY-
UZEIT (Current time), SY-UNAME (user name of the person logged in).
Operators:
-Arithmetic Operators: +, -, *, /, %.
-Comparison Operators: these operators compare between values: =, >, <, <>.
-Character String Operator: Contain Only(CO), Not contain only(CN), Contain Any(CA),
Not contain any(NA), Contain string(CS), Not contain string(NS),
Contain pattern(CP), Not contain pattern(NP).
-Statements used to manipulates strings:
Concatenate-joining two strings. e. g
Report YT_sep_15
DATA: name_1(10) value ‘Amanda’.
name_2(10) values ‘Mhlongo’.
Concatenate name_1, name_2 into name_3
Write:/ Concatenation: ‘in full’.
Condense-delete a character.
Strlen-used to find a length.
Search-used to run a search.
Shift-used to move content left/right.
Split-used to split a field.

Views(SE11):
-A view is created by joining data from one/more tables that contain information about on
application object. *****
-Acts as DB table only.
-It is similar to a virtual table (A table that doesn’t have any physical existence).
Transports:
-A transport is an object that is created to move your data from one place to the other.
-There is local object: this is used only when you want to save your data locally; you don’t
want to transfer to other system it should remain on dev.

Structures:
-Structure are similar to tables except they don’t have PK and technical characteristics.
-Structures are re-usable.
-They are two options that you can choose from when adding a structure to a table
Include: Only used in custom tables.
They are re-usable by multiple tables.
Syntax Yname (field name). Include and data element***
Append (Also to append is to add a new record in a program):
Only used in SAP Tables.
Cannot be re-used.

Programs(SE38):
-They are two types of programs:
Reports: These are programs that generates lists of data (to the front end/interface).
Dynpros: Dynamic programs.
Allow users to intervene in the execution of a program.
-Programs consists of individual statements.
-Each statement end with a (.).
-Two words must be separated by a (_).
-Abap is not case sensitive.
-When declaring multiple attributes, you can use (:) then list the attributes instead of writing
“DATA” multiple times (chained statements).
-Once a statement begins with ** it is ignored because it is indicated as a comment.
Structure of an ABAP program
1.Declaration Section: This is where your global/ non global variables, data types, tables are
defined/declared.
2.Processing Block: This is where you write the logic of what you want the program to do.

-To DEBUG: is to check line by line why is your program not working, by stepping inside the
program.
-Breakpoint: is used when you know which line you want to debug.
-Watch point: (similar to a breakpoint) used to specify where the debugger should start
And stop. Can only be set when you are in the debugger.

IF…ENDIF Conditional Statements (used within a program)


-Consists of conditions.
-Every if statement must end with an endif.
-IF: mandatory
Code
ELSEIF: optional, can occur multiple times
Code
ELSE: optional, occurs once before endif.
ENDIF: mandatory (close if)

AND IN AN IF:
-This logical expression is only true when all logical expressions that comprise are true, if
one expression is false the whole operation is false.

OR IN AN IF:
-This logical expression is used when join multiple expression. at least one expression has to
be true. If all are false, then the operands evaluate are false.
Rational and Boolean Operators:
EQ =
NE <>
GT >
GE >=
LT <
LE <=

Case…endcase statements:
-Used to differentiate cases.
Case gv_var1—Variable you want to work with.
When ‘A’---condition
Write: ‘Successful’---Do something(action).
When ‘B’.
Write: ’Unsuccessful’---Do something else
When others---none of the above condition.
‘Logic if none of the above is executed’.
Endcase—closing/ending of the case statement.

Function Modules(SE37)
-Function modules are programs that contain set of standard function code (From SAP).
-These programs can be run independently.

Form Painter(SE71)
-This is a tool that is used to manipulate forms and also provides graphical layout of SAP
script forms.

SQL Statements
-These are statements that are used access data from the DB.
-These statements can also be used to access DB tables that are declared in the Abap
dictionary.
-Insert statements
DATA wa_customer1(table name) LIKE ZCustomers1(program name).
wa_customer1-name=’Amanda’.
Insert ZCustomer1 from wa_customer1.
-Check statements (This code checks if the data was inserted and correctly)
If sy-subrc = 0.
Write ‘Record inserted successfully’.
Else.
Write ‘The return code is’, sy-subrc.
Endif.
-Clear statements (these statements allow a field to be cleared out for insertion of new
data)
-Update/ Modify statement (these statements are used to update existing data)
Update zcustomer1 from wa_customers1.
Where customer = wa_customer1_name
-Move: statements used to transfer the content of one variable to another.
e. g Move gv_num To gv_num2.
-Clear: statements used to reset the contents of a variable to the type-related to the initial
Value.

Internal Tables:
-These are temporally tables that contains the record of programs that are executed.
-These tables only exist during run time.
-They are used to process large data.
-Data is stored in rows and columns.
-They hold temporally data.
-All records have the same structure and key.
-Once a program is terminated, the records in the internal table are discarded.
-DATA statements are used to declare them followed by Begin of:
DATA: BEGIN OF itab01(internal table name) occurs (this tells SAP that an internal table is
Being created).
0 (number of records contained initially).
Name like Zcustomer1-name,
DOB like Zcustomer1-dob.
END OF itab01.
Populating internal table:
Populating includes-selection, insertion, append.
Insert <work-area-itab> into <internal _tab>
Index<index_num> - add a new line to the internal table

Loops:
-They are situation where you want your program to process the same process multiple
times, a loop makes it easier to do that instead of writing the same thing multiple times.
-Loops allows code to be executed repeatedly.
-Loops are used when a block of code need to be used several times.
-A loop statement allows us to execute a statement/statements multiple times.
Types of loops: While loop-repeats statements when the given condition is true.
Do loop-they are used for repeating particular task a specific number.
Nested loop-this loop is inside a while/do loop.
-Loop control statements; change execution from its normal sequence.
1.Continue: used when you want to skip a remainder and start the next loop.
2.Check: checks if the condition is true/false. If true it executes else if false, the
Remaining statement after the check is ignored then SY starts the next loop.
3.Exit: immediately terminates / end the loop, the skip to the statement after the loop.

Screen Painter (SE38(display object list) /SE80):


-SP allows you to design and maintain the screen and elements.
-Allows you to create GUI screen.
-Once you have created your screen (code/flow logic)
1.Process Before Output(PBO): code that will be executed before the screen is shown to
The user.
2.Process After Input(PAI): code that will happen once the user triggers something, e. g
Clicking a display button.

Selection screen (similar to search):


-Selection screens are used to capture user input.
-Enables to display particular output using particular search values.
-

Transaction Code(SE93)

Validation:
-Validation function allow you to check entered values.
-VF allows you to check the range of values entered.
-We use validation to create a user defined Boolean (true/false statements) statement to
validate an entry.
Prerequisite statement: checks entered values if false {invalid} continue.
Check statement: checks if entered value is valid if true {valid} continue.
Else false {display message}.
-If a statement check is not met a validation message can be created.
//CHECK
e. g – if the account is a revenue account
if you guys master faster {

Then only sales centre can be posted.


}
Types of messages in Abap:
-Type E(Error): when something wrong has been done, program doesn’t execute.
-Type I(Information): messages that informs a user about something.
-Type A (Abnormal end task): this normally happens when a program is terminated, user
cannot make further entries, the program goes to high level menu.
-Type S(Status/success)-these are messages that give information about the execution of a
program. They only display the status of the program.
-Type W(warning)-his displays information to warn the user of possible problems, but
doesn’t stop the programs.
-Types X(exit)-this is when a program terminates and details of why it was terminated are
found on ST22.
**Syntax MESSAGE <’message you want to display’> TYPE <message type>
MESSAGE < ‘Record captured’ > TYPE S.

Runtime Errors
-These are dumps that are thrown once a program has been executed.
-I f the runtime environment encounters a statement/ line if code that cannot be executed,
the program terminates and that triggers a runtime error.
-Each runtime error is identified by a name and assigned to a specific error situation.
-A short dump indicates: name of the runtime error, description of the error, the content of
any variable where the error has occurred.

Call functions:
-Call functions are like methods.
-Exports statements: assigns actual parameter into input parameter.
-Imports statements: assigns actual parameter to the output parameter.
Search helps(SE11):
-Search helps are objects that are created for searching.
-se11-search help-elementary-short description-table name-select the field that you want to
use for searching.
-When you want to add the search help on your form you add the name of your search help
on the screen painter(fields).

Potrebbero piacerti anche