ABAP/4 Elementary Data Types

C: Character Text N: Numeric Text

I: Integer P: Packed # F: Floating Point #

D: Date T: Time X: Hexadecimal #

L&T Information Technology Limited - Confidential

ACQUIRED TYPE D. L&T Information Technology Limited . STARTER. NICKNAME(35). VALUE „10‟.Declaring Variables DATA: PLAYER(35) TYPE C.Confidential . GAMES TYPE I AVERAGE(5) TYPE P. POINTS TYPE I.

Initial Values C: (blank) I: zero P: zero F: zeroes N: zeroes D: 00000000 T: 000000 X: 00 The “CLEAR” statement sets a field back to its initial value. not its default value. L&T Information Technology Limited .Confidential .

Confidential .Assigning Default Values DATA: PLAYER(35) TYPE C. VALUE „19760610‟. VALUE „25.5‟. J‟. VALUE 10. NICKNAME(35) POINTS TYPE I GAMES TYPE I AVERAGE(5) TYPE P STARTER ACQUIRED TYPE D VALUE „Dr. L&T Information Technology Limited . VALUE „255‟. VALUE „Yes‟.

ACQUIRED LIKE SY-DATUM. NICKNAME LIKE PLAYER. Use the “LIKE” addition to declare fields with the same format (i.Declaring “Like” Fields DATA: PLAYER(35) TYPE C VALUE „Julius Erving‟. L&T Information Technology Limited .Confidential . data type and length) DATA: PLAYER(35) TYPE C VALUE „Julius Erving‟. ACQUIRED TYPE D. NICKNAME(35).e.

Declaring Constants The “VALUE” addition is required. If you attempt to change the value of a constant. TEAM2 LIKE TEAM1 VALUE „Celtics‟. L&T Information Technology Limited . TOT_GAMES TYPE I VALUE 82. a syntax error will occur. CONSTANTS: TEAM1(20) TYPE C VALUE „76ers‟.Confidential .

CONSTANTS: TEAM1 TYPE TEAMS VALUE „76ers‟. NICKNAME LIKE PLAYER. L&T Information Technology Limited . TEAMS(20) TYPE C.Confidential . TEAM2 LIKE TEAM1 VALUE „Celtics‟. A user-defined data type created with the “TYPES” statement is used to specify a field‟s data type in the “TYPE” addition of the “DATA” or “CONSTANTS” statements. DATA: PLAYER TYPE NAME VALUE „Julius Erving‟.User-Defined Data Types TYPES: NAME(35) TYPE C.

Confidential .Type-Specific Output Data Type Standard Output Length = defined length = defined length 10 8 12 Output Justification Left-Justified Left-Justified Left-Justified Left-Justified Right-Justified C N D T I P F 2X the defined length + 1 22 2X the defined length Right-Justified Right-Justified Left-Justified X L&T Information Technology Limited .

/ TEST EXPONENT 0 DECIMALS 2. 8765432100000000e+03 876.Confidential . / TEST EXPONENT 1 DECIMALS 3.4321E+01 8765.Output with Floating Point Numbers DATA: TEST TYPE F VALUE „98.7654321E2‟ WRITE: / TEST.43 L&T Information Technology Limited .

MOVE 5 TO GRID_LEVEL. MOVE „President‟ TO TITLE.Value Assignment DATA: TITLE(25). L&T Information Technology Limited . SORT_NAME(10). CNVSALARY = SALARY * 3. SALARY(10) TYPE N. CNVSALARY(10) TYPE N.Confidential . ADD 1000 TO SALARY. COMPUTE SALARY = 5000000. GRID_LEVEL TYPE I.

Examples Source Field Type Length Value C C C 1 4 7 3 A ABCD 47110 Target Field Type Length Value C C P 8 2 4 A____ AB 47110 P 12345- C 7 12345- L&T Information Technology Limited .Confidential .Type Conversions .

L&T Information Technology Limited . EXP. /. STRLEN. LOG. COS.. * DIV and MOD Functions Include: SQRT. SIN. and more.Confidential .. -.Arithmetic Expressions Operators Include: +.

ABAP/4 System Fields L&T Information Technology Limited .Confidential .

„xx‟. CUSTOMER+6 = „1111‟. WRITE: CUSTOMER+8(2).1996 L&T Information Technology Limited . * Start of Month INV_DATE+6(2) = „01‟. INV_DATE.01.Confidential . CUSTOMER = „9999999999‟. „------‟. WRITE: / CUSTOMER. 9999999999 xx 1996 9999991111 ----.Sub-Fields in ABAP/4 DATA: CUSTOMER(10) TYPE C.06. INV_DATE = „19960626‟. INV_DATE(4). INV_DATE LIKE SY-DATUM.

TODAY LIKE SY-DATUM. DAYSOLD. TODAY = SY-DATUM.DOB. DAYSOLD = TODAY .”.Date Calculations in ABAP/4 DATA: DAYSOLD TYPE P.Confidential . L&T Information Technology Limited . You are 12410 days old. WRITE: “You are‟. “days old. DOB = „19621230‟. DOB TYPE D.

Declaring Fields with PARAMETERS L&T Information Technology Limited .Confidential .

Confidential . not the value in the field. the field-symbol assumes the field address. L&T Information Technology Limited .Working with Field-Symbols in ABAP/4 Important: When a field is assigned to a field-symbol.

TEXT_LINE. * this assigns 5 characters of text_line starting at * position 3 to the field string. ASSIGN TEXT_LINE+2(5) TO <FSTRING>. <FSTRING> = „1234567890‟.Confidential . FIELD-SYMBOLS <FSTRING>. TEXT_LINE. ULINE. L&T Information Technology Limited .Dynamic Assignment of Partial Character Strings DATA: TEXT_LINE(30) VALUE „ABCDEFGHIJK‟. <FSTRING>. <FSTRING>. ULINE. WRITE: / „text line =„. ULINE. WRITE: / „field symbol=„. WRITE: / „field symbol =„. WRITE: / „text line =„.

Dynamic Field Assignment SY-FIELD sy-datum PARAMETERS: SY_FIELD(8) DEFAULT „SY-UZEIT‟. SY_FIELD.Confidential . ENDIF. The contents of system field SY-UZEIT 12:30:02 L&T Information Technology Limited . FIELD-SYMBOLS <FIELD>. IF SY-SUBRC = 0. 45 <field>. WRITE: / „The contents of system field‟. ASSIGN SY_FIELD TO <field>.

Sign up to vote on this title
UsefulNot useful