Structure Data Objects, Types, Type-pools

Embed Size (px)

DESCRIPTION

Structure Data Objects, Types, Type-pools-hands on

Citation preview

3.STRUCTURE DATA OBJECTS==============================OBJECTS IN RELATIONSHIP ARE KNOWN AS STRUCTURE DATA OBJECTSCUST {CNO,CNAME,CITY,PIN}SYNTAX:DATA: BEGIN OF , , END OF .==============================================*PRG USING STRUCTURE DATA OBJECTSdata: begin of str1, no(4) type n, name(30) type c, city(30) type c, end of str1.data: cust like str1.data: vend like cust. str1-no = '1000'. str1-name = 'raj'. str1-city = 'hyd'. write:/5 str1-no, 10 str1-name, 20 str1-city. uline. cust-no = '2000'. cust-name = 'ravi'. cust-city = 'chennai'. write:/5 cust-no, 10 cust-name, 20 cust-city. uline. vend-no = '3000'. vend-name = 'hari'. vend-city = 'delhi'. write:/5 vend-no, 10 vend-name, 20 vend-city. uline.=================================================type-pools : contains structure data objects that are used in several programs.str1 str1 str1 : type-poolsprg1 prg2 prg3step1: we define the structure data object in type-poolsgo to t-code se11: data dictionaryselect option type-group: zshan createshort text: my type-poolssave as local objecttypes: begin of zshan_str1, no(4) type n, name(30) type c, city(30) type c, end of zshan_str1.types: begin of zshan_cust, cno(4) type n, cname(30) type c, end of zshan_cust.types: begin of zshan_vend, vno(4) type n, vname(30) type c, end of zshan_vend.save-check-activate=========================================step2: calling is done in any executable program in abap editorgo to se38: abap editorprogram: zshancalltyp createtitle: calling program for type-poolstype: executable program save as local objectREPORT ZSHANCALLTYP.type-pools: zshan.data: emp type zshan_str1.data: cust type zshan_cust.data: vend type zshan_vend.emp-no = '1000'.emp-name = 'raj'.emp-city = 'hyd'.write:/5 emp-no, 10 emp-name, 20 emp-city.uline.cust-cno = '2000'.cust-cname = 'ravi'.write:/5 cust-cno, 10 cust-cname.uline.vend-vno = '3000'.vend-vname = 'hari'.write:/5 vend-vno, 10 vend-vname.uline.save-check-activate-test=====================================standard type-pool: SLIS (it is used in ALV REPORTING) SAP LIST VIEWER/ ABAP LIST VIEWER=========================================================types: is a reserved word to define user-defined objects.DATA TYPES: ELEMENTARY DATA TYPES 1.PRE-DEFINED 2.USER-DEFINED : TYPES (KEYWORD)CORRECT USAGE IS TYPE-POOLS .WRONG USAGE OF TYPES KEYWORD===================================================*WRONG USAGE OF TYPES KEYWORDTYPES: NUM TYPE NUMB, NAM TYPE NAME.DATA: NUMB(4) TYPE N, NAME(30) TYPE C.NUMB = 1000.NAME = 'RAVI'.WRITE:/ NUMB, NAME.=======================================================NUMB, NAME ARE RESERVED WORDS IN SAP=====================================================*WRONG USAGE OF TYPESTYPES: CNO TYPE A, CNAME TYPE B, PIN TYPE C.DATA: A(4) TYPE N, "CNO B(30) TYPE C, "CNAME C(6) TYPE N. "PIN.A = '3000'.B = 'HARI'.C = '500035'.WRITE:/ A, B, C.===================================================