Data Types

Embed Size (px)

DESCRIPTION

abap data types-hands on

Citation preview

2.DATA TYPES========================================1.ELEMENTARY DATA TYPES 1.PRE-DEFINED DATA TYPES : N,C,I,P,F,X,D,T,STRING 2.USER-DEFINED DATA TYPES : TYPES (KEYWORD)2.STRUCTURED DATA TYPES 1.PRE-DEFINED DATA TYPES: TABLES (KEYWORD) 2.USER-DEFINED DATA TYPE: INTERNAL TABLESDATA OBJECTS : VARIABLES: THEY CHANGE THEIR VALUE DURING RUNTIME/EXECUTION TIME. EX: A A IS ONE CHARACTER BY DEFAULT.DATA TYPE: WHAT TYPE OF DATA, DATA OBJECT IS GOING TO STORE IN IT IS KNOWN AS DATA TYPE A I (INTEGER IS DATA TYPE)DATA: KEYWORD TO DEFINE DATA OBJECTS SYNTAX: DATA TYPE . DATA: LIKE . EX: DATA: A TYPE I. DATA: B LIKE A. EX: DATA: CNO LIKE KNA1-KUNNR. KNA1: CUSTOMER TABLE, KUNNR : CUSTOMER NUMBERCONSTANTS: HAS FIXED VALUE EX: CONSTANTS : A = 20.=======================================================1.ELEMENTARY DATA TYPES 1.PRE-DEFINED DATA TYPES : N,C,I,P,F,X,D,T,STRING================================================================n: numeric : (0-9) digits. it is not used for calculations. it is used to represent sequence of numbers such as empno, vendno, matno etc., ex: '1000', 1000.c: character (a-z, alphanumeric a333) default data type is allways a character 'ravi'.i: integer (-3,-2,-1,0,1,2,3,,,) no-decimals. it is used for calculations.p: packed decimals : keyword : decimals . max decimals : 14 data: numb type p decimals 2.f: float : exponential result is displayed with the float. '0.0000000000000000+e01' it is not used to give input to any programx: hexa decimals: binary nos, system nosd: date : yyyy mm dd ( 8chars)t: time: hh mm ssstring : ' '==========================================================================*n,c data typesdata : numb type n, name type c.numb = '1000'.name = 'ravi krishna'.write:/ numb, name.=================================result: 0 r=====================================*n,c data typesdata : numb(4) type n, name(30) type c.numb = '1000'.name = 'ravi krishna'.write:/ numb, name.result: 1000 ravi krishna==========================================*n,c data typesdata : numb(4) type n, name(30) type c.move '1000' to numb.move 'ravi krishna' to name.write:/ numb, name.result: 1000 ravi krishna==========================================*prg for i data typedata: a type i, b type i, c type i.a = 60.b = 70.c = a + b.write:/ c.===========================================parameters : is a keyword to give input values at the runtime*prg using i data typeparameters: a type i, b type i.data: c type i.c = a + b.write:/ c.======================================================*prg using packed decimalsdata: num type p decimals 2 value '4.11', den type p decimals 2 value '1.11', res type p decimals 14 . res = num / den. write:/ res. "it gives exact division res = num div den. write:/ res. "it gives quantant res = num mod den. write:/ res. "it gives reminder============================================================*prg using packed decimalsdata: num type p decimals 2 value '4.11', den type p decimals 2 value '1.11', res type p decimals 14 . res = num / den. write:/ res. "it gives exact division res = num div den. write:/ res. "it gives quantant res = num mod den. write:/ res. "it gives reminder===============================================assignment1.create a program using parameters and using packed decimals2.suppose the result of a program is 5.7896 make the result in 2 decimals 5.79 (rouding the result) 5.78 which is correct result==================================================================next class: structure data objects, types, type-pools==================================================================