Sei sulla pagina 1di 4

1. Declare the structure of Internal Table i.e.

A User Defined Data type with the required


fields, According tp the fileds required from the Corresponding database tabless!.
T"#$% & '$(I) *+ ,T"-
+1 T"#$ ,.ef. Datatype- ,
+/ T"#$ ,.ef. Datatype- ,
+0 T"#$ ,.ef. Datatype- ,
1
$)D *+ ,T"-.
)*T$& T"#$% is to define user defined Datatype.
1. Declare Internal Table i.e. Array of abo2e structure.DATA ,ITA'- T"#$ TA'3$
*+ ,T"-.
EXAMPLE: Declare an ITA' to maintain data from table T441 Company Code Data!
)*T$& 5hile Declaring ,ITA'-, refer the corresponding database table i.e. T441 here.
1
/
0
6
7
8
9
:
;
1
4
1
1
1
/
1
0
1
6
1
7
1
8
1
9
*Declare the required datatypes

TYPES : BEGIN OF TY_T00!

B"#$S TYPE B"#$S! %&'(pa)y &'de

B"T*T TYPE B"T*T! %&'(ap)y Na(e

O$T0 TYPE O$T0! %&ity

+,ND TYPE +,ND! %&'u)try #ey

END OF TY_T00-

*Declare I)ter)al Ta.le /r'( a.'0e structure

D,T, IT_T00 TYPE T,B+E OF TY_T00-
%ynta< to select the Data from Database table into Internal table&
%$3$CT ,+1-,
,+/-,
,+0-,
11..
I)T* TA'3$ ,ITA'-
+.*= ,D'T-
5>$.$ ,Condition if Any-.
)*T$& =a?e sure that the structure order! of the fields in the %$3$CT and Internal table
should be same, because the content if 1
st
filed in %$3$CT is transferred to the 1
st
filed of
,ITA'- and similarly /
nd
, 0
rd
etc.
EXAMPLE: Display the 3ist of (erman Companies@s Details
Company Code, name, city, Country! from T441.
1
/
0
6
7
8
9
:
;
1
4
1
1
1
/
1
0
1
6
1
7
1
8
1
9
1
*Declare the $equired Datatype

TYPES : BEGIN OF TY_T00!

B"#$S TYPE B"#$S! %&'(pa)y &'de

B"T*T TYPE B"T*T! %&'(pa)y Na(e

O$T0 TYPE O$T0! &ity

+,ND TYPE +,ND! %&'u)try #ey

END OF TY_T00-

*Declare I)ter)al ta.le /r'( the a.'0e structure

D,T, IT_T00 TYPE T,BE+ OF TY_T00-

*Fetch data /r'( T00 i)t' IT_T00

SE+E&T B"#$S!

B"T*T!

O$T0!

+,ND

INTO T,B+E IT_T00
:
1
;
/
4
/
1
/
/
/
0
/
6
/
7
/
8
/
9
/
:
/
;
0
4
0
1
0
/
0
0

F$O1 T00

23E$E +,ND 4 5DE5- %Ger(a)y &'de
)*T$& After the %$3$CT data from database table is transferred to Internal table.
ADisplay data in Internal Table
A%ince data in Internal table is %orted record by record, AccessingBDisplaying Data from
Internal table is also record by recoord. %o that there is a special loop which starts with the 1
st

record and ends with the second record of ,ITA'- by default..
ACeep the Internal table in a 3**#, 3**# points to the first record by default and collect it
into ,5A- and process #rint! the data from ,5A-.
$a<mple using D'AC table.
1
/
0
6
7
$EPO$T 67,1P$OG$,189-

ta.les 0.a:-
select;'pti')s : s'_0.el) /'r 0.a:;0.el)-

types : .e<i) '/ ty_0.a:!
8
9
:
;
1
4
1
1
1
/
1
0
1
6
1
7
1
8
1
9
1
:
1
;
/
4
/
1
/
/
/
0
/
6
/
7
/
8
/
9
/
:
erdat type 0.a:;erdat!
er=et type 0.a:;er=et!
er)a( type 0.a:;er)a(!
e)d '/ ty_0.a:-

data : lt_0.a: type sta)dard ta.le '/ ty_0.a:!
ls_0.a: type ty_0.a:-

select erdat er=et er)a(
/r'( 0.a:
i)t' ta.le lt_0.a:
>here 0.el) i) s'_0.el)-
i/ sy;su.rc eq 0-
>rite :? 5N' '/ rec'rds :5!sy;d.c)t-
l''p at lt_0.a: i)t' ls_0.a:-
>rite :? ls_0.a:;erdat!
ls_0.a:;er=et!
ls_0.a:;er)a(-
e)dl''p-
else-
>rite :? 5N' data5-
e)di/-

Potrebbero piacerti anche