You are on page 1of 3

Quick Reference

Data Type Initial field length Valid field length Initial value

ABAP
Numeric types I 4 F 8 P 8 Character types C D N T 1 8 1 6

http://help.sap.com Ver. 1.2 goudden@gmail.com

BASIC ABAP Languaje Statements


MOVE gv_var1 TO gv_var2. | gv_var1 = gv_var2.

BASIC ABAP Languaje Statements


Command

TRANSACCION Object Navigator Repository Infor. System Function Builder ABAP Editor Business Object Repository Abap Dictionary Data Browser Code Inspector User Overview AS Abap Instances Overview Work Process RFC Connectors Scheduling Background Lock Entries List of Spool Requests Define Background Job RFC Connections Function Builder Data Browser Maintain Table Views GUI Painter Class Builder ABAP Splitscreen Editor Shared Objects Cusrtomizing Project Manag. Enhancements BAdI Builder BAdI Implementations Modification Browser Trasport Message Class

Command

DESCRIPTION
Call transaction in a new session Call a transaction in the same session

Predefined Elementary ABAP Types


Meaning

PARAMETERS pa_mun TYPE i. ADD 1 TO gv_counter. (suma 1 a la variable) CLEAR gv_var1, Gv_var2. => reset de contents of a data object to initial type

SE80 SE84 SE37 SE38 BAPI SE11 SE16 SCID SM04 SM51 SM50 SM59 SM36 SM12 SP02 SM36 SM59 SE37 SE16 SM30 SE41 SE24 SE39 SHMA SPRO CMOD SE18 SE19 SE95 SE91

/oXXX /nXXX /o /nend /nex /: /ns000

Overview of sessions End logon session End logo session without save Delete current session
To end the current transaction and return to the starting menu

4 8 1 - 16 1 - 65535 8 1 - 65535 6 1 - 65535

0 0 0 ''

Integer (whole number) Floating point number Packed number

Adition

Division

Text field (alphanumeric characters) Date field '00000000' (Format: YYYYMMDD) Numeric text field '0 0' (numeric characters) Time field '000000' (format: HHMMSS) X'0 0' Hexadecimal field

* Multiplication ** Exponentiation - Substraction


IF gv_var > 0. statements ELSEIF gv_var = 0. statements ELSE. statements ENDIF.

DIV Integral Division without Remainder MOD Remainder after integral division

System Fields
System Field

Hexadecimal type X 1

IF result > 0. WRITE / 'Result greater than zero.'. ELSE. WRITE / 'Result less or equal zero.'. ENDIF. IF result IS NOT INITIAL. IF NOT (a=1 OR b=2) AND c = 3

Meaning

sy-subrc sy-mandt sy-uname sy-langu sy-datum sy-uzeit sy-tcode sy-repid sy-index sy-tabix sy-listi sy-lsind

Return Code 0 = OK Logon Client Logon Name user Logon Language user Local Date ABAP System Local Time ABAP System Current Transaction Code Name Current Program Loop Counter DO & WHILE used for record count of internal tables List processing, index of current list List processing, details list index

TYPES <Type> [ <length> ] <Type>[ <decimals> ]. DATA <campo> [ (<longitud>)] <tipo> [ <valor> ] [ <decimales> ] DATA: BEGIN OF PERSON, NAME(20), AGE TYPE I, END OF PERSON. TYPES TYPE_PERSONS LIKE PERSON OCCURS 20. DATA PERSONS TYPE TYPE_PERSONS. PERSON-NAME = 'Michael'. PERSON-AGE = 25. APPEND PERSON TO PERSONS.

CASE gv_var. WHEN AA . statements WHEN BB . statements WHEN OTHERS . statements ENDCASE.

CASE result. WHEN AA .

WRITE / 'Result AA'. WRITE / 'Result BB'.

WHEN BB . WHEN OTHERS . ENDCASE.


WRITE / 'Result Others'.

Reporting Commands
(imprime valor en pantalla) write:/10(45) 'Total No of Employees entered:', gd_records, "/10 indents 10 chars /10(45) 'Number of Employees processed successfully:'. "(45) sets field lenth new-line. "moves to a new line describe table it_error lines gd_lines. "gets number of records in a table skip 2. "skips 2 lines write:/10 sy-vline, "sy-vline creates a vertical line (10) 'Employee' COLOR COL_HEADING, sy-vline, "COLOR changes background colour (50) 'Description' COLOR COL_HEADING, sy-vline.

DO. Statements [sy-index > Loop Counter] IF <abort_condition> . EXIT. ENDIF. ENDDO. DO n TIMES. Statements [sy-index a Loop Counter] IF <abort_condition> . EXIT. ENDIF. ENDDO.

[ Recorre filas de tabla interna ] LOOP AT <internal table> ... Statements ENDLOOP . WHILE <condition> . Statements
http://abap4.tripod.com/ Transaction_Codes.html

More click here: http://help.sap.com/ A Visual Explanation of SQL Joins

ENDWHILE .

Subroutines
Sintaxis de declaracin: (igual para subrutinas internas y externas) FORM nombre [ parmetros ]. statements. ENDFORM. Llamada a una subrutina interna: PERFORM nombre [ parmetros ]. Llamada a una subrutina externa: PERFORM name (programa) [ parms ] [ IF FOUND ].
En este caso se debe indicar el programa en el cual se encuentra la subrutina llamada. Con IF FOUND, si la subrutina no existe, la sentencia PERFORM es ignorada y no se genera error.

Internal tables
[ Declaring New]
DATA <itab> TYPE|LIKE <tabkind> OF <linetype> WITH <key> [INITIAL SIZE <n>] [WITH HEADER LINE].

Function Group ALV (SALV)


[ Most used types of ALV]
- REUSE_ALV_GRID_DISPLAY - REUSE_ALV_HIERSEQ_LIST_DISPLAY - REUSE_ALV_LIST_DISPLAY

[ Assigning ]

[ Initializing ]

[ + System Fields]
- sy-lisel : contains data of the selected line. - sy-lsind : contains the level of report (from 0 to 21)

MOVE <itab1> TO <itab2>. or <itab2> = <itab1>.

CLEAR <itab>. REFRESH <itab>. FREE <itab>.

[ Comparing Internal Tables]


.... <itab1> <operator> <itab2> ...
<operator>

CALL BY REFERENCE El parmetro formal y el actual ocupan la misma posicin de memoria, con lo que su valor puede ser modificado por la subrutina. Se pasa la direccin del parmetro, no una copia. Se puede usar en TABLES, USING y CHANGING. FORM nombre [ parmetros ]. USING Value(pv_act) TYPE I Value(pv_max) TYPE I CHANGING Value(cv_pc) TYPE gty_perc.
statements.

EQ = NE <> >< LT

Meaning equal to equal to not equal to not equal to not equal to less than

<operator>

< LE <= GT > GE >=

Meaning less than less than or equal to less than or equal to greater than greater than greater than or equal to greater than or equal to Type s i

MESSAGE
[identify the message in table T100] [Message Maintenance - SE91] [Message Types - SE91]
Meaning Behavior Message appears in Status message Program continues without interruption Status line in next screen Information Warning Error Termination Short dump Program continues after interruption Context dependent Context dependent Program Aborted Runtime error MESSAGE_TYPE_X is triggered Modal dialog box Status bar Status bar Modal dialog box Short dump

[ Sorting Internal Tables ]


SORT <itab> [ASCENDING|DESCENDING] [AS TEXT] [STABLE]. NO sort a sorted table using the SORT statement.

[ Inserting Lines into Tables ]


INSERT <line> INTO TABLE <itab>. INSERT LINES OF <itab1> [FROM <n1>] [TO <n TABLE <itab2>.
2>]

w e a INTO x

ENDFORM. Llamada a una subrutina by reference


PERFORM nombre [(prog)] [ USING lista_var ][ CHANGING lista_var ]

[ Reading Lines of Tables ]


READ TABLE <itab> <key> <result>. INSERT LINES OF <itab1> [FROM <n1>] [TO <n TABLE <itab2>.
2>]

Messages on help.sap.com [ First Declare Class ]


REPORT <name> MESSAGE-ID <class>. INTO

[ Specifying the Message Statically ]


MESSAGE <t><nnn>(<id>) [WITH <f1> ... <f4>] [RAISING <exc>].

[ Changing Lines - Deleting Lines]


MODIFY TABLE <itab> FROM <wa> [TRANSPORTING <f1> <f 2> ...]. DELETE TABLE <itab> FROM <wa>.

[ Specifying the Message Dynamically ] MESSAGE ID <id> TYPE <t> NUMBER <n> [WITH <f1> ... <f4>] [RAISING <exc>]. [ Filling Message Texts Dynamically ]
MESSAGE ... WITH <f1> ... <f 4>.

[ Processing Table Entries in Loops ]


LOOP AT <itab> <result> <condition>. <statement block> ENDLOOP.

[ Messages and Exceptions ]


MESSAGE..... RAISING <exc>.

Working with Structures


[ Defining Structures with Local Types ]
TYPES: BEGIN OF st_flightinfo, carrid TYPE s_carr_id, connid TYPE s_conn_id, fldate TYPE s_date, END OF wa_flightinfo TYPE st_flightinfo. DATA wa_flightinfo TYPE st_flightinfo.

Screens
The screens in a single ABAP program can be combined to form screen sequences. You can call single screens or screen sequences either using a transaction code from outside the ABAP program, or by using the CALL SCREEN statement in the corresponding ABAP program. When you call a screen or screen sequence, the screen flow logic takes control of the ABAP program execution. You can define screen sequences dynamically by setting the next screen attribute for a screen dynamically in the ABAP program. Selection screens are one of the three types of screen in the R/3 System, along with dialog screens and lists. You use them whenever you want the user to enter either a single value for a field or fields, or to enter selection criteria. Las listas no definen botones y recursos con nombres que luego se utilizan en ABAP en este caso se utilizan areas de trabajo libres y las sentencias WRITE, ULINE; and SKIP .

[ Access to Structure Components ] structure_name-component_name.


DATA: wa_scarr TYPE scarr. wa_scarr-carrid = LH. SELECT SINGLE * FROM scarr INTO wa_scarr WHERE carrid = wa_scarr-carrid. WRITE:/ wa_scarr-carrid, wa_scarr-carrname, wa_scarr-url. [ Copying Structure Components with the Same Name ] DATA: wa-sflight TYPE sflight, wa_focc TYPE sbc400focc.

[ Calling ABAP Dialog Modules ] MODULE <mod> OUTPUT. ... ENDMODULE. [ SELECT SCREEN ] Tres sentencias para manejar las select screen. PARAMETERS for single fields SELECT-OPTIONS for complex selections SELECTION-SCREEN for formatting the selection screen and defining user-specific selection screens
SELECTION-SCREEN BEGIN OF SCREEN <numb><title>] [AS WINDOW].</title> [TITLE ... SELECTION-SCREEN END OF SCREEN <numb>.

MOVE-CORRESPONDING wa_sflight TO wa_focc.

SAP ABAP Program Types


Type

[ Definicin de una tabla de control en "Module Pool" ] CONTROLS ctrl TYPE TABLEVIEW USING SCREEN scr.

Meaning Executable programs Module pools (Dialog Programs) Function groups Class pools Interface pools Subroutine pools Type groups or pools are introduced with the TYPE-POOL statement. Include programs

Type 1 Type M Type F Type K Type J Type S groups Type I

Program Types and Execution help.sap.com

User Dialogs abap.es

User Dialogs Help.sap.com