3

Click here to load reader

-Abap Quick Reference

Embed Size (px)

Citation preview

Page 1: -Abap Quick Reference

ABAPQuick Reference

Predefined Elementary ABAP Types

Data Type Initialfield length

Validfield length

Validfield length

Initial value Meaning

Numeric types Numeric types Numeric types Numeric types Numeric types Numeric typesI 44 4 0 Integer (whole number)F 88 8 0 Floating point numberP 88 1 - 16 0 Packed number

Character types Character types Character types Character types Character types Character typesC 11 1 - 65535 '   …   ' Text field

(alphanumeric characters)D 88 8 '00000000' Date field

(Format: YYYYMMDD)N 11 1 - 65535 '0 … 0' Numeric text field

(numeric characters)T 66 6 '000000' Time field

(format: HHMMSS) Hexadecimal type Hexadecimal type Hexadecimal type Hexadecimal type Hexadecimal type Hexadecimal type

X 11 1 - 65535 X'0 … 0' Hexadecimal field

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.

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.

BASIC ABAP Languaje Statements Ver. 1.2

[email protected] MOVE gv_var1 TO gv_var2. | gv_var1 = gv_var2.

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

+ Adition / Division

* Multiplication DIV Integral Division without Remainder

** Exponentiation MOD Remainder after integral division

- Substraction

IF result > 0. WRITE / 'Result greater than zero.'.ELSE. WRITE / 'Result less or equal zero.'.ENDIF.

IF gv_var > 0. statementsELSEIF gv_var = 0. statementsELSE. statementsENDIF. —— IF result IS NOT INITIAL.

—— IF NOT (a=1 OR b=2) AND c = 3

CASE gv_var. WHEN ’AA’ . statements WHEN ’BB’ . statementsWHEN OTHERS . statementsENDCASE.

CASE result. WHEN ’AA’ . WRITE / 'Result AA'. WHEN ’BB’ . WRITE / 'Result BB'. WHEN OTHERS . WRITE / 'Result Others'.ENDCASE.

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> ... StatementsENDLOOP .

BASIC ABAP Languaje Statements

WHILE <condition> . Statements ENDWHILE .

Command TRANSACCIONSE80 Object Navigator

SE84 Repository Infor. System

SE37 Function Builder

SE38 ABAP Editor

BAPI Business Object Repository

SE11 Abap Dictionary

SE16 Data Browser

SCID Code Inspector

SM04 User Overview

SM51 AS Abap Instances

SM50 Overview Work Process

SM59 RFC Connectors

SM36 Scheduling Background

SM12 Lock Entries

SP02 List of Spool Requests

SM36 Define Background Job

SM59 RFC Connections

SE37 Function Builder

SE16 Data Browser

SM30 Maintain Table Views

SE41 GUI Painter

SE24 Class Builder

SE39 ABAP Splitscreen Editor

SHMA Shared Objects

SPRO Cusrtomizing

CMOD Project Manag. Enhancements

SE18 BAdI Builder

SE19 BAdI Implementations

SE95 Modification Browser Trasport

SE91 Message Class

Command DESCRIPTION

/oXXX Call transaction in a new session

/nXXX Call a transaction in the same session

/o Overview of sessions

/nend End logon session

/nex End logo session without save

/: Delete current session

/ns000 To end the current transaction and return to the starting menu

System Field Meaning

sy-subrc Return Code 0 = OKsy-mandt Logon Clientsy-uname Logon Name usersy-langu Logon Language usersy-datum Local Date ABAP Systemsy-uzeit Local Time ABAP Systemsy-tcode Current Transaction Codesy-repid Name Current Program

sy-index Loop Counter DO & WHILE

sy-tabix used for record count of internal tables

sy-listi List processing, index of current list

sy-lsind List processing, details list index

System Fields

More click here: http://help.sap.com/

http://abap4.tripod.com/Transaction_Codes.html

http://help.sap.com

A Visual Explanation of SQL Joins

Page 2: -Abap Quick Reference

Subroutines

Sintaxis de declaración: (igual para subrutinas internas y externas) FORM nombre [ parámetros ]. statements. ENDFORM.

Llamada a una subrutina interna: PERFORM nombre [ parámetros ]. Llamada a una subrutina externa: PERFORM name (programa) [ paráms ] [ 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.

CALL BY REFERENCEEl parámetro formal y el actual ocupan la misma posición de memoria, con lo que su valor puede ser modificado por la subrutina. Se pasa la dirección del parámetro, no una copia. Se puede usar en TABLES, USING y CHANGING.

FORM nombre [ parámetros ]. USING Value(pv_act) TYPE I Value(pv_max) TYPE I CHANGING Value(cv_pc) TYPE gty_perc.

statements.

ENDFORM.

Llamada a una subrutina by reference

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

Internal tables

[ Declaring New]

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

[ Assigning ]

MOVE <itab1> TO <itab2>.or

<itab2> = <itab1>.

[ Initializing ]

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

[ Comparing Internal Tables]

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

<operator> Meaning <operator> MeaningEQ equal to < less than= equal to LE less than or equal to

NE not equal to <= less than or equal to<> not equal to GT greater than>< not equal to > greater thanLT less than GE greater than or equal to

>= greater than or equal to

[ 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 2>] INTO TABLE <itab2>.

[ Reading Lines of Tables ]

READ TABLE <itab> <key> <result>.

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

[ Processing Table Entries in Loops ]

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

[ Changing Lines - Deleting Lines]

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

DELETE TABLE <itab> FROM <wa>.

Function Group ALV (SALV)

[ Most used types of ALV]

- REUSE_ALV_GRID_DISPLAY- REUSE_ALV_HIERSEQ_LIST_DISPLAY - REUSE_ALV_LIST_DISPLAY

[ + System Fields]

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

MESSAGE[identify the message in table T100]

[Message Maintenance - SE91]

Type Meaning Behavior Message appears in

s Status message Program continues without interruption Status line in next screen

i Information Program continues after interruption Modal dialog boxw Warning Context dependent Status bare Error Context dependent Status bara Termination Program Aborted Modal dialog box

x Short dump Runtime error MESSAGE_TYPE_X is triggered

Short dump

Messages on help.sap.com

[Message Types - SE91]

[ First Declare Class ]REPORT <name> MESSAGE-ID <class>.

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

[ 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>.

[ Messages and Exceptions ]MESSAGE..... RAISING <exc>.

Page 3: -Abap Quick Reference

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.

[ 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. MOVE-CORRESPONDING wa_sflight TO wa_focc.

ScreensThe 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.

User Dialogs Help.sap.com

[ Definición de una tabla de control en "Module Pool" ]

CONTROLS ctrl TYPE TABLEVIEW USING SCREEN scr.

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 .

[ 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 screensSELECTION-SCREEN BEGIN OF SCREEN <numb><title>] [AS WINDOW].</title> [TITLE

...

SELECTION-SCREEN END OF SCREEN <numb>.

[ Calling ABAP Dialog Modules ]

MODULE <mod> OUTPUT. ... ENDMODULE.

SAP ABAP Program Types

Type MeaningType 1 Executable programsType M Module pools (Dialog Programs)Type F Function groupsType K Class poolsType J Interface poolsType S Subroutine poolsgroups Type groups or pools are introduced with the TYPE-POOL statement.Type I Include programs

Program Types and Execution help.sap.com

User Dialogs abap.es