You are on page 1of 3

3.

STRUCTURE DATA OBJECTS


==============================
OBJECTS IN RELATIONSHIP ARE KNOWN AS STRUCTURE DATA OBJECTS
CUST {CNO,CNAME,CITY,PIN}
SYNTAX:
DATA: BEGIN OF <STRUCTURE DATA OBJECT NAME>,
<FIELDS>,
END OF <STRUCTURE DATA OBJECT NAME>.
==============================================
*PRG USING STRUCTURE DATA OBJECTS
data: 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-pools
prg1 prg2 prg3
step1: we define the structure data object in type-pools
go to t-code se11: data dictionary
select option type-group: zshan create
short text: my type-pools
save as local object

types: 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 editor
go to se38: abap editor
program: zshancalltyp create
title: calling program for type-pools
type: executable program save as local object
REPORT ZSHANCALLTYP.
type-pools: zshan.
data: emp type zshan_str1.
data: cust type zshan_cust.
data: vend type zshan_vend.
emp-no =
emp-name
emp-city
write:/5
uline.

'1000'.
= 'raj'.
= 'hyd'.
emp-no, 10 emp-name, 20 emp-city.

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 LIS

T 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 KEYWORD
TYPES: 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 TYPES
TYPES: 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.
===================================================

You might also like