internal tables

47
 INTERNAL TABLES INTERNAL T A BLES BY BY B.SANKAR KUMARAN ,B.E,M.B.A B.SANKAR KUMARAN ,B.E,M.B.A

Upload: akkiramreddy

Post on 13-Jan-2016

7 views

Category:

Documents


0 download

DESCRIPTION

internal tables

TRANSCRIPT

7/18/2019 Internal Tables

http://slidepdf.com/reader/full/internal-tables-5695e7a745319 1/47

INTERNAL TABLESINTERNAL TABLESBYBY

B.SANKAR KUMARAN ,B.E,M.B.AB.SANKAR KUMARAN ,B.E,M.B.A

7/18/2019 Internal Tables

http://slidepdf.com/reader/full/internal-tables-5695e7a745319 2/47

Internal tablesInternal tables

Internal tables provide a means of tain! data from aInternal tables provide a means of tain! data from afi"ed str#$t#re and storin! it in %orin! memor& in ABA'.fi"ed str#$t#re and storin! it in %orin! memor& in ABA'.T(e data is stored line b& line in memor&, and ea$( lineT(e data is stored line b& line in memor&, and ea$( line(as t(e same str#$t#re. In ABA', internal tables f#lfill t(e(as t(e same str#$t#re. In ABA', internal tables f#lfill t(e

f#n$tion of arra&s. Sin$e t(e& are d&nami$ data ob)e$ts,f#n$tion of arra&s. Sin$e t(e& are d&nami$ data ob)e$ts,t(e& save t(e pro!rammer t(e tas of d&nami$ memor&t(e& save t(e pro!rammer t(e tas of d&nami$ memor&mana!ement in (is or (er pro!rams. Yo# s(o#ld #semana!ement in (is or (er pro!rams. Yo# s(o#ld #seinternal tables %(enever &o# %ant to pro$ess a datasetinternal tables %(enever &o# %ant to pro$ess a dataset%it( a fi"ed str#$t#re %it(in a pro!ram. A parti$#larl&%it( a fi"ed str#$t#re %it(in a pro!ram. A parti$#larl&

important #se for internal tables is for storin! andimportant #se for internal tables is for storin! andformattin! data from a database table %it(in a pro!ram.formattin! data from a database table %it(in a pro!ram.T(e& are also a !ood %a& of in$l#din! ver& $ompli$atedT(e& are also a !ood %a& of in$l#din! ver& $ompli$ateddata str#$t#res in an ABA' pro!ram.data str#$t#res in an ABA' pro!ram.

7/18/2019 Internal Tables

http://slidepdf.com/reader/full/internal-tables-5695e7a745319 3/47

Line typeLine type

The line type of an internal table can beThe line type of an internal table can be

any data type. The data type of anany data type. The data type of aninternal table is normally a structure.internal table is normally a structure.

Each component of the structure is aEach component of the structure is a

column in the internal table. However,column in the internal table. However,

the line type may also be elementary orthe line type may also be elementary or

another internal table.another internal table. 

7/18/2019 Internal Tables

http://slidepdf.com/reader/full/internal-tables-5695e7a745319 4/47

KeyKey The key identifies table rows. There are two kinds of key for internalThe key identifies table rows. There are two kinds of key for internal

tables - the standard key and a user-defined key. You can specifytables - the standard key and a user-defined key. You can specifywhether the key should be !"#E or !$!-!"#E. "nternal tableswhether the key should be !"#E or !$!-!"#E. "nternal tableswith a uni%ue key cannot contain duplicate entries. The uni%uenesswith a uni%ue key cannot contain duplicate entries. The uni%uenessdepends on the table access method.depends on the table access method.

"f a table has a structured line type, its default key consists of all of its"f a table has a structured line type, its default key consists of all of itsnon-numerical columns that are not references or themselves internalnon-numerical columns that are not references or themselves internaltables. "f a table has an elementary line type, the default key is thetables. "f a table has an elementary line type, the default key is theentire line. The default key of an internal table whose line type is anentire line. The default key of an internal table whose line type is aninternal table, the default key is empty.internal table, the default key is empty.

The user-defined key can contain any columns of the internal tableThe user-defined key can contain any columns of the internal tablethat are not references or themselves internal tables. "nternal tablesthat are not references or themselves internal tables. "nternal tables

with a user-defined key are called key tables. &hen you define the key,with a user-defined key are called key tables. &hen you define the key,the se%uence of the key fields is si'nificant. You should rememberthe se%uence of the key fields is si'nificant. You should rememberthis, for e(ample, if you intend to sort the table accordin' to the key.this, for e(ample, if you intend to sort the table accordin' to the key.

7/18/2019 Internal Tables

http://slidepdf.com/reader/full/internal-tables-5695e7a745319 5/47

)**E++ $E)**E++ $E 

+tandard tables have an internal linear inde(. rom a particular si/e upwards,+tandard tables have an internal linear inde(. rom a particular si/e upwards,the inde(es of internal tables are administered as trees. "n this case, the inde(the inde(es of internal tables are administered as trees. "n this case, the inde(administration overhead increases in lo'arithmic and not linear relation to theadministration overhead increases in lo'arithmic and not linear relation to thenumber of lines. The system can access records either by usin' the table inde(number of lines. The system can access records either by usin' the table inde(or the key. The response time for key access is proportional to the number ofor the key. The response time for key access is proportional to the number ofentries in the table. The key of a standard table is always non-uni%ue. Youentries in the table. The key of a standard table is always non-uni%ue. Youcannot specify a uni%ue key. This means that standard tables can always becannot specify a uni%ue key. This means that standard tables can always be

filled very %uickly, since the system does not have to check whether there arefilled very %uickly, since the system does not have to check whether there arealready e(istin' entries.already e(istin' entries. +orted tables are always saved sorted by the key. They also have an internal+orted tables are always saved sorted by the key. They also have an internal

inde(. The system can access records either by usin' the table inde( or theinde(. The system can access records either by usin' the table inde( or thekey. The response time for key access is lo'arithmically proportional to thekey. The response time for key access is lo'arithmically proportional to thenumber of table entries, since the system uses a binary search. The key of anumber of table entries, since the system uses a binary search. The key of asorted table can be either uni%ue or non-uni%ue. &hen you define the table, yousorted table can be either uni%ue or non-uni%ue. &hen you define the table, youmust specify whether the key is to be uni%ue or not. +tandard tables and sortedmust specify whether the key is to be uni%ue or not. +tandard tables and sorted

tables are known 'enerically as inde( tables.tables are known 'enerically as inde( tables. Hashed tables have no linear inde(. You can only access a hashed table usin'Hashed tables have no linear inde(. You can only access a hashed table usin'

its key. The response time is independent of the number of table entries, and isits key. The response time is independent of the number of table entries, and isconstant, since the system access the table entries usin' a hash al'orithm. Theconstant, since the system access the table entries usin' a hash al'orithm. Thekey of a hashed table must be uni%ue. &hen you define the table, you mustkey of a hashed table must be uni%ue. &hen you define the table, you mustspecify the key as !"#E.specify the key as !"#E.

7/18/2019 Internal Tables

http://slidepdf.com/reader/full/internal-tables-5695e7a745319 6/47

Internal Tables as *&nami$ *ataInternal Tables as *&nami$ *ata

+b)e$ts+b)e$ts *ata ob)e$ts t(at are defined eit(er %it( t(e data t&pe of an internal*ata ob)e$ts t(at are defined eit(er %it( t(e data t&pe of an internal

table, or dire$tl& as an internal table, are al%a&s f#ll& defined intable, or dire$tl& as an internal table, are al%a&s f#ll& defined inrespe$t of t(eir line t&pe, e& and a$$ess met(od. o%ever, t(erespe$t of t(eir line t&pe, e& and a$$ess met(od. o%ever, t(en#mber of lines is not fi"ed. T(#s internal tables are d&nami$ datan#mber of lines is not fi"ed. T(#s internal tables are d&nami$ dataob)e$ts, sin$e t(e& $an $ontain an& n#mber of lines of a parti$#larob)e$ts, sin$e t(e& $an $ontain an& n#mber of lines of a parti$#lart&pe. T(e onl& restri$tion on t(e n#mber of lines an internal tablet&pe. T(e onl& restri$tion on t(e n#mber of lines an internal tablema& $ontain are t(e limits of &o#r s&stem installation. T(e ma"im#mma& $ontain are t(e limits of &o#r s&stem installation. T(e ma"im#mmemor& t(at $an be o$$#pied b& an internal table -in$l#din! itsmemor& t(at $an be o$$#pied b& an internal table -in$l#din! itsinternal administration is / !i!ab&tes. A more realisti$ fi!#re is #p tointernal administration is / !i!ab&tes. A more realisti$ fi!#re is #p to011 me!ab&tes. An additional restri$tion for (as(ed tables is t(at011 me!ab&tes. An additional restri$tion for (as(ed tables is t(att(e& ma& not $ontain more t(an / million entries. T(e line t&pes oft(e& ma& not $ontain more t(an / million entries. T(e line t&pes ofinternal tables $an be an& ABA' data t&pes 2 elementar&, str#$t#red,internal tables $an be an& ABA' data t&pes 2 elementar&, str#$t#red,

or internal tables. T(e individ#al lines of an internal table are $alledor internal tables. T(e individ#al lines of an internal table are $alledtable lines or table entries. Ea$( $omponent of a str#$t#red line istable lines or table entries. Ea$( $omponent of a str#$t#red line is$alled a $ol#mn in t(e internal table.$alled a $ol#mn in t(e internal table.

7/18/2019 Internal Tables

http://slidepdf.com/reader/full/internal-tables-5695e7a745319 7/47

INTERNAL TABLE TY'ESINTERNAL TABLE TY'ES

STAN*AR* TABLESTAN*AR* TABLE

S+RTE* TABLES+RTE* TABLE

ASE* TABLEASE* TABLE

7/18/2019 Internal Tables

http://slidepdf.com/reader/full/internal-tables-5695e7a745319 8/47

STAN*AR* TABLESTAN*AR* TABLE

T(is is t(e most appropriate t&pe if &o# are !oin! toT(is is t(e most appropriate t&pe if &o# are !oin! toaddress t(e individ#al table entries #sin! t(e inde". Inde"address t(e individ#al table entries #sin! t(e inde". Inde"a$$ess is t(e 3#i$est possible a$$ess. Yo# s(o#ld fill aa$$ess is t(e 3#i$est possible a$$ess. Yo# s(o#ld fill astandard table b& appendin! lines -ABA' A''EN*standard table b& appendin! lines -ABA' A''EN*statement, and read, modif& and delete entries b&statement, and read, modif& and delete entries b&spe$if&in! t(e inde" -IN*E4 option %it( t(e relevantspe$if&in! t(e inde" -IN*E4 option %it( t(e relevant

 ABA' $ommand. T(e a$$ess time for a standard table ABA' $ommand. T(e a$$ess time for a standard tablein$reases in a linear relations(ip %it( t(e n#mber of tablein$reases in a linear relations(ip %it( t(e n#mber of tableentries. If &o# need e& a$$ess, standard tables areentries. If &o# need e& a$$ess, standard tables areparti$#larl& #sef#l if &o# $an fill and pro$ess t(e table inparti$#larl& #sef#l if &o# $an fill and pro$ess t(e table in

separate steps. 5or e"ample, &o# $o#ld fill t(e table b&separate steps. 5or e"ample, &o# $o#ld fill t(e table b&appendin! entries, and t(en sort it. If &o# #se t(e binar&appendin! entries, and t(en sort it. If &o# #se t(e binar&sear$( option %it( e& a$$ess, t(e response time issear$( option %it( e& a$$ess, t(e response time islo!arit(mi$all& proportional to t(e n#mber of table entries.lo!arit(mi$all& proportional to t(e n#mber of table entries.

7/18/2019 Internal Tables

http://slidepdf.com/reader/full/internal-tables-5695e7a745319 9/47

S+RTE* TABLES+RTE* TABLE

T(is is t(e most appropriate t&pe if &o# need a tableT(is is t(e most appropriate t&pe if &o# need a table%(i$( is sorted as &o# fill it. Yo# fill sorted tables #sin!%(i$( is sorted as &o# fill it. Yo# fill sorted tables #sin!t(e INSERT statement. Entries are inserted a$$ordin! tot(e INSERT statement. Entries are inserted a$$ordin! tot(e sort se3#en$e defined t(ro#!( t(e table e&. An&t(e sort se3#en$e defined t(ro#!( t(e table e&. An&

ille!al entries are re$o!ni6ed as soon as &o# tr& to addille!al entries are re$o!ni6ed as soon as &o# tr& to addt(em to t(e table. T(e response time for e& a$$ess ist(em to t(e table. T(e response time for e& a$$ess islo!arit(mi$all& proportional to t(e n#mber of tablelo!arit(mi$all& proportional to t(e n#mber of tableentries, sin$e t(e s&stem al%a&s #ses a binar& sear$(.entries, sin$e t(e s&stem al%a&s #ses a binar& sear$(.Sorted tables are parti$#larl& #sef#l for partiall&Sorted tables are parti$#larl& #sef#l for partiall&

se3#ential pro$essin! in a L++' if &o# spe$if& t(ese3#ential pro$essin! in a L++' if &o# spe$if& t(ebe!innin! of t(e table e& in t(e 7ERE $ondition.be!innin! of t(e table e& in t(e 7ERE $ondition.

7/18/2019 Internal Tables

http://slidepdf.com/reader/full/internal-tables-5695e7a745319 10/47

ASE* TABLEASE* TABLE

T(is is t(e most appropriate t&pe for an& tableT(is is t(e most appropriate t&pe for an& table

%(ere t(e main operation is e& a$$ess. Yo#%(ere t(e main operation is e& a$$ess. Yo#

$annot a$$ess a (as(ed table #sin! its inde".$annot a$$ess a (as(ed table #sin! its inde".

T(e response time for e& a$$ess remainsT(e response time for e& a$$ess remains$onstant, re!ardless of t(e n#mber of table$onstant, re!ardless of t(e n#mber of table

entries. Lie database tables, (as(ed tablesentries. Lie database tables, (as(ed tables

al%a&s (ave a #ni3#e e&. as(ed tables areal%a&s (ave a #ni3#e e&. as(ed tables are

#sef#l if &o# %ant to $onstr#$t and #se an#sef#l if &o# %ant to $onstr#$t and #se aninternal table %(i$( resembles a database tableinternal table %(i$( resembles a database table

or for pro$essin! lar!e amo#nts of data.or for pro$essin! lar!e amo#nts of data.

7/18/2019 Internal Tables

http://slidepdf.com/reader/full/internal-tables-5695e7a745319 11/47

Internal table t&pesInternal table t&pes

to define internal tables lo$all& in a pro!ram. Yo# $an also defineto define internal tables lo$all& in a pro!ram. Yo# $an also defineinternal tables !loball& as data t&pes in t(e ABA' *i$tionar&.internal tables !loball& as data t&pes in t(e ABA' *i$tionar&.

Lie all lo$al data t&pes in pro!rams , &o# define internal tablesLie all lo$al data t&pes in pro!rams , &o# define internal tables#sin! t(e TY'ES statement. If &o# do not refer to an e"istin! table#sin! t(e TY'ES statement. If &o# do not refer to an e"istin! tablet&pe #sin! t(e TY'E or LIKE addition, &o# $an #se t(e TY'ESt&pe #sin! t(e TY'E or LIKE addition, &o# $an #se t(e TY'ES

statement to $onstr#$t a ne% lo$al internal table in &o#r pro!ram.statement to $onstr#$t a ne% lo$al internal table in &o#r pro!ram.

TY0E+ 1t2 TY0E3L"KE 1tabkind2 $ 1linetype2 4&"TH 1key25TY0E+ 1t2 TY0E3L"KE 1tabkind2 $ 1linetype2 4&"TH 1key25  4"!"T")L +"6E 1n25.  4"!"T")L +"6E 1n25.

)fter TY0E or L"KE, there is no reference to an e(istin' data)fter TY0E or L"KE, there is no reference to an e(istin' data

type. "nstead, the type constructor occurs7type. "nstead, the type constructor occurs7 1tabkind2 $ 1linetype2 4&"TH 1key251tabkind2 $ 1linetype2 4&"TH 1key25

7/18/2019 Internal Tables

http://slidepdf.com/reader/full/internal-tables-5695e7a745319 12/47

7/18/2019 Internal Tables

http://slidepdf.com/reader/full/internal-tables-5695e7a745319 13/47

E4AM'LEE4AM'LE

TY0E+7 8E9"! $ L"!E,TY0E+7 8E9"! $ L"!E,

*$L!: TY0E ",*$L!: TY0E ",

*$L!; TY0E ",*$L!; TY0E ",

*$L!< TY0E ",*$L!< TY0E ",

E! $ L"!E.E! $ L"!E.

TY0E+ "T)8 TY0E +$=TE T)8LE $ L"!E &"TH !"#E KEYTY0E+ "T)8 TY0E +$=TE T)8LE $ L"!E &"TH !"#E KEY*$L!:.*$L!:.

7/18/2019 Internal Tables

http://slidepdf.com/reader/full/internal-tables-5695e7a745319 14/47

E4AM'LEE4AM'LE

TY0E+ >E*T$= TY0E H)+HE T)8LE $ " &"TH !"#E KEYTY0E+ >E*T$= TY0E H)+HE T)8LE $ " &"TH !"#E KEYT)8LE L"!E.T)8LE L"!E.

TY0E+7 8E9"! $ L"!E,TY0E+7 8E9"! $ L"!E,*$L!: TY0E ",*$L!: TY0E ",*$L!; TY0E ",*$L!; TY0E ",

*$L!< TY0E ",*$L!< TY0E ",E! $ L"!E.E! $ L"!E. TY0E+ "T)8 TY0E +$=TE T)8LE $ L"!E &"TH !"#E KEYTY0E+ "T)8 TY0E +$=TE T)8LE $ L"!E &"TH !"#E KEY

*$L!:.*$L!:. TY0E+7 8E9"! $ EE0L"!E,TY0E+7 8E9"! $ EE0L"!E,

"EL TY0E *,"EL TY0E *,

T)8LE: TY0E >E*T$=,T)8LE: TY0E >E*T$=,T)8LE; TY0E "T)8,T)8LE; TY0E "T)8,E! $ EE0L"!E.E! $ EE0L"!E.

TY0E+ EE0T)8LE TY0E +T)!)= T)8LE $ EE0L"!ETY0E+ EE0T)8LE TY0E +T)!)= T)8LE $ EE0L"!E&"TH E)LT KEY.&"TH E)LT KEY.

7/18/2019 Internal Tables

http://slidepdf.com/reader/full/internal-tables-5695e7a745319 15/47

*ATA +B8E9T : INTERNAL*ATA +B8E9T : INTERNAL

TABLETABLE Lie all ot(er data ob)e$ts, &o# $an de$lare internal table ob)e$tsLie all ot(er data ob)e$ts, &o# $an de$lare internal table ob)e$ts

#sin! t(e LIKE or TY'E addition of t(e *ATA statement.#sin! t(e LIKE or TY'E addition of t(e *ATA statement.

*ATA ;itab< TY'E ;t&pe<=LIKE ;ob)< >7IT EA*ER LINE?.*ATA ;itab< TY'E ;t&pe<=LIKE ;ob)< >7IT EA*ER LINE?.

ere, t(e LIKE addition refers to an e"istin! table ob)e$t in t(e sameere, t(e LIKE addition refers to an e"istin! table ob)e$t in t(e samepro!ram. T(e TY'E addition $an refer to an internal t&pe in t(epro!ram. T(e TY'E addition $an refer to an internal t&pe in t(epro!ram de$lared #sin! t(e TY'ES statement, or a table t&pe in t(epro!ram de$lared #sin! t(e TY'ES statement, or a table t&pe in t(e

 ABA' *i$tionar&. ABA' *i$tionar&. Yo# m#st ens#re t(at &o# onl& refer to tables t(at are f#ll& t&ped.Yo# m#st ens#re t(at &o# onl& refer to tables t(at are f#ll& t&ped.

Referrin! to !eneri$ table t&pes -ANY TABLE, IN*E4 TABLE or notReferrin! to !eneri$ table t&pes -ANY TABLE, IN*E4 TABLE or not

spe$if&in! t(e e& f#ll& is not allo%ed.spe$if&in! t(e e& f#ll& is not allo%ed.

7/18/2019 Internal Tables

http://slidepdf.com/reader/full/internal-tables-5695e7a745319 16/47

7IT 7+RK AREA +R EA*ER7IT 7+RK AREA +R EA*ER

LINELINE T(e optional addition 7IT EA*ER line de$lares anT(e optional addition 7IT EA*ER line de$lares an e(tra datae(tra data

ob?ectob?ect %it( t(e%it( t(e same namesame name andand line typeline type as t(e internal table. T(isas t(e internal table. T(isdata ob)e$t is no%n as t(e (eader line of t(e internal table. Yo# #sedata ob)e$t is no%n as t(e (eader line of t(e internal table. Yo# #seit as a %or area %(en %orin! %it( t(e internal table -seeit as a %or area %(en %orin! %it( t(e internal table -seeUsin! t(e eader Line as a 7or AreaUsin! t(e eader Line as a 7or Area. 7(en &o# #se internal. 7(en &o# #se internaltables %it( (eader lines, &o# m#st remember t(at t(e (eader linetables %it( (eader lines, &o# m#st remember t(at t(e (eader lineand t(e bod& of t(e table (ave t(e same name. If &o# (ave anand t(e bod& of t(e table (ave t(e same name. If &o# (ave aninternal table %it( (eader line and &o# %ant to address t(e bod& ofinternal table %it( (eader line and &o# %ant to address t(e bod& oft(e table, &o# m#st indi$ate t(is b& pla$in! bra$ets after t(e tablet(e table, &o# m#st indi$ate t(is b& pla$in! bra$ets after t(e tablename -;itab<>?. +t(er%ise, ABA' interprets t(e name as t(e namename -;itab<>?. +t(er%ise, ABA' interprets t(e name as t(e nameof t(e (eader line and not of t(e bod& of t(e table. Yo# $an avoidof t(e (eader line and not of t(e bod& of t(e table. Yo# $an avoidt(is potential $onf#sion b& #sin! internal tables %it(o#t (eader lines.t(is potential $onf#sion b& #sin! internal tables %it(o#t (eader lines.

In parti$#lar, internal tables nested in str#$t#res or ot(er internalIn parti$#lar, internal tables nested in str#$t#res or ot(er internaltablestables must notmust not (ave a (eader line, sin$e t(is $an lead to(ave a (eader line, sin$e t(is $an lead toambi!#o#s e"pressions.ambi!#o#s e"pressions.

 

7/18/2019 Internal Tables

http://slidepdf.com/reader/full/internal-tables-5695e7a745319 17/47

E4AM'LEE4AM'LE

TY'ES @E9T+R TY'E S+RTE* TABLE +5 I 7IT UNIUE KEY TABLETY'ES @E9T+R TY'E S+RTE* TABLE +5 I 7IT UNIUE KEY TABLE

LINE.LINE.

*ATA ITAB TY'E @E9T+R,*ATA ITAB TY'E @E9T+R,

  8TAB LIKE ITAB 7IT EA*ER LINE.  8TAB LIKE ITAB 7IT EA*ER LINE.

M+@E ITAB T+ 8TAB> ?.M+@E ITAB T+ 8TAB> ?.

7/18/2019 Internal Tables

http://slidepdf.com/reader/full/internal-tables-5695e7a745319 18/47

*e$larin! Ne% Internal Tables*e$larin! Ne% Internal Tables

Yo# $an #se t(e *ATA statement to $onstr#$t ne% internal tables asYo# $an #se t(e *ATA statement to $onstr#$t ne% internal tables as%ell as #sin! t(e LIKE or TY'E addition to refer to e"istin! t&pes or%ell as #sin! t(e LIKE or TY'E addition to refer to e"istin! t&pes orob)e$ts. T(e table t&pe t(at &o# $onstr#$t does not e"ist in its o%nob)e$ts. T(e table t&pe t(at &o# $onstr#$t does not e"ist in its o%nri!(tC instead, it is onl& an attrib#te of t(e table ob)e$t. Yo# $an referri!(tC instead, it is onl& an attrib#te of t(e table ob)e$t. Yo# $an referto it #sin! t(e LIKE addition, b#t not #sin! TY'E. T(e s&nta" forto it #sin! t(e LIKE addition, b#t not #sin! TY'E. T(e s&nta" for$onstr#$tin! a table ob)e$t in t(e *ATA statement is similar to t(at$onstr#$tin! a table ob)e$t in t(e *ATA statement is similar to t(atfor definin! a table t&pe in t(e TY'ES statement.for definin! a table t&pe in t(e TY'ES statement.

)T) 1itab2 TY0E3L"KE 1tabkind2 $ 1linetype2 &"TH 1key2)T) 1itab2 TY0E3L"KE 1tabkind2 $ 1linetype2 &"TH 1key2  4"!"T")L +"6E 1n25  4"!"T")L +"6E 1n25  4&"TH HE)E= L"!E5.  4&"TH HE)E= L"!E5.

E@)0LEE@)0LE

)T) "T)8 TY0E H)+HE T)8LE $ +0L")T) "T)8 TY0E H)+HE T)8LE $ +0L"&"TH !"#E KEY *)==" *$!!".&"TH !"#E KEY *)==" *$!!".

7/18/2019 Internal Tables

http://slidepdf.com/reader/full/internal-tables-5695e7a745319 19/47

 Assi!nin! Internal Tables Assi!nin! Internal Tables

Lie ot(er data ob)e$ts, &o# $an mae internal tables operands in t(e M+@ELie ot(er data ob)e$ts, &o# $an mae internal tables operands in t(e M+@Estatementstatement

M+@E ;itabD< T+ ;itab/<.M+@E ;itabD< T+ ;itab/<.

or t(e e3#ivalent statementor t(e e3#ivalent statement

;itab/< ;itabD<.;itab/< ;itabD<.

E@)0LEE@)0LE*ATA BEFIN +5 LINE,*ATA BEFIN +5 LINE,  9+LD,  9+LD,  9+L/,  9+L/,  EN* +5 LINE.  EN* +5 LINE.

*ATA ETAB LIKE TABLE +5 LINE 7IT EA*ER LINE,*ATA ETAB LIKE TABLE +5 LINE 7IT EA*ER LINE,  5TAB LIKE TABLE +5 LINE.  5TAB LIKE TABLE +5 LINE.

LINE29+LD GAG. LINE29+L/ GBG.LINE29+LD GAG. LINE29+L/ GBG. A''EN* LINE T+ ETAB. A''EN* LINE T+ ETAB.

M+@E ETAB>? T+ 5TAB.M+@E ETAB>? T+ 5TAB.

L++' AT 5TAB INT+ LINE.L++' AT 5TAB INT+ LINE.  7RITE H LINE29+LD, LINE29+L/. 7RITE H LINE29+LD, LINE29+L/.EN*L++'.EN*L++'.

T(e o#tp#t isT(e o#tp#t is A B A B

7/18/2019 Internal Tables

http://slidepdf.com/reader/full/internal-tables-5695e7a745319 20/47

Initiali6in! Internal TablesInitiali6in! Internal Tables

Lie all data ob)e$ts, &o# $an initiali6e internal tables %it( t(eLie all data ob)e$ts, &o# $an initiali6e internal tables %it( t(e 9LEAR ;itab<.9LEAR ;itab<. statement. T(is statement restores an internal table to t(e state it %as instatement. T(is statement restores an internal table to t(e state it %as in

immediatel& after &o# de$lared it. T(is means t(at t(e table $ontains noimmediatel& after &o# de$lared it. T(is means t(at t(e table $ontains nolines. o%ever, t(e memor& alread& o$$#pied b& t(e memor& #p #ntil &o#lines. o%ever, t(e memor& alread& o$$#pied b& t(e memor& #p #ntil &o#$leared it remains allo$ated to t(e table.$leared it remains allo$ated to t(e table.

If &o# are #sin! internal tables %it( (eader lines, remember t(at t(e (eaderIf &o# are #sin! internal tables %it( (eader lines, remember t(at t(e (eaderline and t(e bod& of t(e table (ave t(e same name. If &o# %ant to addressline and t(e bod& of t(e table (ave t(e same name. If &o# %ant to addresst(e bod& of t(e table in a $omparison, &o# m#st pla$e t%o bra$ets -> ? aftert(e bod& of t(e table in a $omparison, &o# m#st pla$e t%o bra$ets -> ? aftert(e table name.t(e table name.

9LEAR ;itab<>?.9LEAR ;itab<>?. To ens#re t(at t(e table itself (as been initiali6ed, &o# $an #se t(eTo ens#re t(at t(e table itself (as been initiali6ed, &o# $an #se t(e

RE5RES ;itab<.RE5RES ;itab<. statement. T(is al%a&s applies to t(e bod& of t(e table. As %it( t(e 9LEARstatement. T(is al%a&s applies to t(e bod& of t(e table. As %it( t(e 9LEAR

statement, t(e memor& #sed b& t(e table before &o# initiali6ed it remainsstatement, t(e memor& #sed b& t(e table before &o# initiali6ed it remainsallo$ated. To release t(e memor& spa$e, #se t(e statementallo$ated. To release t(e memor& spa$e, #se t(e statement

5REE ;itab<.5REE ;itab<. Yo# $an #se 5REE to initiali6e an internal table and release its memor&Yo# $an #se 5REE to initiali6e an internal table and release its memor&

spa$e %it(o#t first #sin! t(e RE5RES or 9LEAR statement.spa$e %it(o#t first #sin! t(e RE5RES or 9LEAR statement.

7/18/2019 Internal Tables

http://slidepdf.com/reader/full/internal-tables-5695e7a745319 21/47

E4AM'LEE4AM'LE

)T)7 8E9"! $ L"!E,)T)7 8E9"! $ L"!E,*$L:,*$L:,*$L;,*$L;,E! $ L"!E.E! $ L"!E.

)T) "T)8 L"KE T)8LE $ L"!E.)T) "T)8 L"KE T)8LE $ L"!E.

L"!E-*$L: A B)B. L"!E-*$L; A B8B.L"!E-*$L: A B)B. L"!E-*$L; A B8B. )00E! L"!E T$ "T)8.)00E! L"!E T$ "T)8. =E=E+H "T)8.=E=E+H "T)8. " "T)8 "+ "!"T")L." "T)8 "+ "!"T")L.

&="TE B"T)8 is emptyB.&="TE B"T)8 is emptyB.=EE "T)8.=EE "T)8.

E!".E!". The output is7The output is7 "T)8 is empty."T)8 is empty.

7/18/2019 Internal Tables

http://slidepdf.com/reader/full/internal-tables-5695e7a745319 22/47

Sortin! Internal TablesSortin! Internal Tables

Yo# $an sort a standard or (as(ed table in a pro!ram. To sort a table b& itsYo# $an sort a standard or (as(ed table in a pro!ram. To sort a table b& itse&, #se t(e statemente&, #se t(e statement

S+RT ;itab< >AS9EN*INF=*ES9EN*INF? >AS TE4T? >STABLE?.S+RT ;itab< >AS9EN*INF=*ES9EN*INF? >AS TE4T? >STABLE?.

T(e statement sorts t(e internal table ;itab< in as$endin! order b& its e&.T(e statement sorts t(e internal table ;itab< in as$endin! order b& its e&.T(e statement al%a&s applies to t(e table itself, not to t(e (eader line. T(eT(e statement al%a&s applies to t(e table itself, not to t(e (eader line. T(esort order depends on t(e se3#en$e of t(e standard e& fields in t(e internalsort order depends on t(e se3#en$e of t(e standard e& fields in t(e internaltable. T(e defa#lt e& is made #p of t(e non2n#meri$ fields of t(e table linetable. T(e defa#lt e& is made #p of t(e non2n#meri$ fields of t(e table linein t(e order in %(i$( t(e& o$$#r.in t(e order in %(i$( t(e& o$$#r.

Yo# $an spe$if& t(e dire$tion of t(e sort #sin! t(e additions AS9EN*INFYo# $an spe$if& t(e dire$tion of t(e sort #sin! t(e additions AS9EN*INFand *ES9EN*INF. T(e defa#lt is as$endin!.and *ES9EN*INF. T(e defa#lt is as$endin!.

7/18/2019 Internal Tables

http://slidepdf.com/reader/full/internal-tables-5695e7a745319 23/47

*eterminin! t(e Attrib#tes of*eterminin! t(e Attrib#tes of

Internal TablesInternal Tables To find o#t t(e attrib#tes of an internal table at r#ntimeTo find o#t t(e attrib#tes of an internal table at r#ntime

t(at %ere not available stati$all&, #se t(e statementt(at %ere not available stati$all&, #se t(e statement E+*="8E T)8LE 1itab2 4L"!E+ 1l25 4$**=+ 1n25E+*="8E T)8LE 1itab2 4L"!E+ 1l25 4$**=+ 1n25

4K"! 1k25.4K"! 1k25.

"f you use the L"!E+ parameter, the number of filled"f you use the L"!E+ parameter, the number of filledlines is written to the variable 1lin2. "f you use thelines is written to the variable 1lin2. "f you use the$**=+ parameter, the value of the "!"T")L +"6E of$**=+ parameter, the value of the "!"T")L +"6E ofthe table is returned to the variable 1n2. "f you usethe table is returned to the variable 1n2. "f you usethe K"! parameter, the table type is returned to thethe K"! parameter, the table type is returned to thevariable 1k27 CTD for standard table, C+D for sortedvariable 1k27 CTD for standard table, C+D for sortedtable, and CHD for hashed table.table, and CHD for hashed table.  

7/18/2019 Internal Tables

http://slidepdf.com/reader/full/internal-tables-5695e7a745319 24/47

E4AM'LEE4AM'LE

)T)7 8E9"! $ L"!E,)T)7 8E9"! $ L"!E,  *$L: TY0E ",  *$L: TY0E ",  *$L; TY0E ",  *$L; TY0E ",  E! $ L"!E.  E! $ L"!E.

)T) "T)8 L"KE H)+HE T)8LE $ L"!E &"TH !"#E KEY *$L:)T) "T)8 L"KE H)+HE T)8LE $ L"!E &"TH !"#E KEY *$L:  "!"T")L +"6E :.  "!"T")L +"6E :.

)T)7 L"! TY0E ",)T)7 L"! TY0E ",  "!" TY0E ",  "!" TY0E ",  K! TY0E *.  K! TY0E *.

E+*="8E T)8LE "T)8 L"!E+ L"! $**=+ "!" K"! K!.E+*="8E T)8LE "T)8 L"!E+ L"! $**=+ "!" K"! K!.&="TE7 F L"!, "!", K!.&="TE7 F L"!, "!", K!.

$ : T"E+.$ : T"E+.  L"!E-*$L: A +Y-"!E@. L"!E-*$L: A +Y-"!E@.

  L"!E-*$L; A +Y-"!E@ GG ;. L"!E-*$L; A +Y-"!E@ GG ;."!+E=T L"!E "!T$ T)8LE "T)8."!+E=T L"!E "!T$ T)8LE "T)8.E!$.E!$.

E+*="8E T)8LE "T)8 L"!E+ L"! $**=+ "!" K"! K!.E+*="8E T)8LE "T)8 L"!E+ L"! $**=+ "!" K"! K!.&="TE7 F L"!, "!", K!.&="TE7 F L"!, "!", K!.

The output is7The output is7

: H : H  :, : H:, : H

7/18/2019 Internal Tables

http://slidepdf.com/reader/full/internal-tables-5695e7a745319 25/47

+perations on Individ#al Lines+perations on Individ#al Lines

T(e follo%in! are t&pi$al operationsT(e follo%in! are t&pi$al operations

involvin! sin!le lines of a tableinvolvin! sin!le lines of a table

5illin! a table line b& line5illin! a table line b& line

Readin! a table line b& lineReadin! a table line b& line

Modif&in! individ#al linesModif&in! individ#al lines

*eletin! individ#al lines*eletin! individ#al lines

7/18/2019 Internal Tables

http://slidepdf.com/reader/full/internal-tables-5695e7a745319 26/47

)ccess sin' a &ork )rea)ccess sin' a &ork )rea

7(en &o# a$$ess individ#al table entries #sin! a %or area, &o# are not7(en &o# a$$ess individ#al table entries #sin! a %or area, &o# are not%orin! dire$tl& %it( t(e data in t(e table. Instead, &o# %or %it( anot(er%orin! dire$tl& %it( t(e data in t(e table. Instead, &o# %or %it( anot(erdata ob)e$t as a %or area. T(e %or area is an interfa$e to t(e entries indata ob)e$t as a %or area. T(e %or area is an interfa$e to t(e entries int(e internal table, and m#st be $onvertible into t(e line t&pe of t(e internalt(e internal table, and m#st be $onvertible into t(e line t&pe of t(e internaltable. T(e most effi$ient %orin! met(od is to #se a %or area $ompatibletable. T(e most effi$ient %orin! met(od is to #se a %or area $ompatible%it( t(e line t&pe of t(e internal table. 7(en &o# read data from a table%it( t(e line t&pe of t(e internal table. 7(en &o# read data from a tablere$ord, t(e data &o# are readin! over%rites t(e $#rrent $ontents of t(e %orre$ord, t(e data &o# are readin! over%rites t(e $#rrent $ontents of t(e %orarea. Yo# $an t(en #se t(is data in t(e pro!ram. 7(en &o# %rite data to t(earea. Yo# $an t(en #se t(is data in t(e pro!ram. 7(en &o# %rite data to t(einternal table, t(is m#st first be pla$ed in t(e %or area. T(e s&stem t(eninternal table, t(is m#st first be pla$ed in t(e %or area. T(e s&stem t(entransfers it from t(e %or area to t(e appropriate table entr&. *ata transfertransfers it from t(e %or area to t(e appropriate table entr&. *ata transferfollo%s t(e r#les of assi!nin! data #sin! [email protected]%s t(e r#les of assi!nin! data #sin! M+@E.

7/18/2019 Internal Tables

http://slidepdf.com/reader/full/internal-tables-5695e7a745319 27/47

7/18/2019 Internal Tables

http://slidepdf.com/reader/full/internal-tables-5695e7a745319 28/47

7/18/2019 Internal Tables

http://slidepdf.com/reader/full/internal-tables-5695e7a745319 29/47

+'ERATI+NS +N INTERNAL+'ERATI+NS +N INTERNAL

TABLESTABLES 7(en &o# $reate an internal table ob)e$t &o# $an also7(en &o# $reate an internal table ob)e$t &o# $an also

de$lare a (eader line %it( t(e same name. Yo# $an #sede$lare a (eader line %it( t(e same name. Yo# $an #set(e (eader line as a %or area %(en &o# pro$ess t(et(e (eader line as a %or area %(en &o# pro$ess t(einternal table. T(e ABA' statements t(at &o# #se %it(internal table. T(e ABA' statements t(at &o# #se %it(

internal tables (ave s(ort forms t(at &o# $an #se if &o#rinternal tables (ave s(ort forms t(at &o# $an #se if &o#rinternal table (as a (eader line. T(ese statementsinternal table (as a (eader line. T(ese statementsa#tomati$all& ass#me t(e (eader line as an impli$it %ora#tomati$all& ass#me t(e (eader line as an impli$it %orarea. T(e follo%in! table s(o%s t(e statements t(at &o#area. T(e follo%in! table s(o%s t(e statements t(at &o#m#st #se for internal tables %it(o#t a (eader line, andm#st #se for internal tables %it(o#t a (eader line, and

t(e e3#ivalent statements t(at &o# $an #se for internalt(e e3#ivalent statements t(at &o# $an #se for internaltables %it( a (eader linetables %it( a (eader line

7/18/2019 Internal Tables

http://slidepdf.com/reader/full/internal-tables-5695e7a745319 30/47

E4AM'LE 7IT EA*ER LINEE4AM'LE 7IT EA*ER LINE

TY0E+7 8E9"! $ L"!E,TY0E+7 8E9"! $ L"!E,  *$L: TY0E ",  *$L: TY0E ",  *$L; TY0E ",  *$L; TY0E ",  E! $ L"!E.  E! $ L"!E.

)T) "T)8 TY0E H)+HE T)8LE $ L"!E &"TH !"#E KEY *$L:)T) "T)8 TY0E H)+HE T)8LE $ L"!E &"TH !"#E KEY *$L:  &"TH HE)E= L"!E.  &"TH HE)E= L"!E.

$ T"E+.$ T"E+.

  "T)8-*$L: A +Y-"!E@. "T)8-*$L: A +Y-"!E@.  "T)8-*$L; A +Y-"!E@ GG ;. "T)8-*$L; A +Y-"!E@ GG ;.  "!+E=T T)8LE "T)8. "!+E=T T)8LE "T)8.E!$.E!$.

"T)8-*$L: A ;."T)8-*$L: A ;.=E) T)8LE "T)8 =$ "T)8.=E) T)8LE "T)8 =$ "T)8.

"T)8-*$L; A :."T)8-*$L; A :.$"Y T)8LE "T)8.$"Y T)8LE "T)8.

"T)8-*$L: A ."T)8-*$L: A .ELETE T)8LE "T)8.ELETE T)8LE "T)8.

L$$0 )T "T)8.L$$0 )T "T)8.  &="TE7 F "T)8-*$L:, "T)8-*$L;. &="TE7 F "T)8-*$L:, "T)8-*$L;.E!L$$0.E!L$$0.

7/18/2019 Internal Tables

http://slidepdf.com/reader/full/internal-tables-5695e7a745319 31/47

E4AM'LE 7IT 7+RK AREAE4AM'LE 7IT 7+RK AREA

TY0E+7 8E9"! $ L"!E,TY0E+7 8E9"! $ L"!E,  *$L: TY0E ",  *$L: TY0E ",  *$L; TY0E ",  *$L; TY0E ",  E! $ L"!E.  E! $ L"!E.

)T)7 "T)8 TY0E H)+HE T)8LE $)T)7 "T)8 TY0E H)+HE T)8LE $L"!E &"TH !"#E KEY *$L:,L"!E &"TH !"#E KEY *$L:,  &) L"KE L"!E $ "T)8.  &) L"KE L"!E $ "T)8.

$ T"E+.$ T"E+.

  &)-*$L: A +Y-"!E@. &)-*$L: A +Y-"!E@.  &)-*$L; A +Y-"!E@ GG ;. &)-*$L; A +Y-"!E@ GG ;.  "!+E=T &) "!T$ T)8LE "T)8. "!+E=T &) "!T$ T)8LE "T)8.E!$.E!$.

&)-*$L: A ;.&)-*$L: A ;.=E) T)8LE "T)8 =$ &) "!T$ &).=E) T)8LE "T)8 =$ &) "!T$ &).

&)-*$L; A :.&)-*$L; A :.$"Y T)8LE "T)8 =$ &).$"Y T)8LE "T)8 =$ &).

&)-*$L: A .&)-*$L: A .ELETE T)8LE "T)8 =$ &).ELETE T)8LE "T)8 =$ &).

L$$0 )T "T)8 "!T$ &).L$$0 )T "T)8 "!T$ &).  &="TE7 F &)-*$L:, &)-*$L;. &="TE7 F &)-*$L:, &)-*$L;.E!L$$0.E!L$$0.

The list, in bothThe list, in both

cases, appears ascases, appears as

follows7follows7

  : :: :   ; :; :

  < I< I

7/18/2019 Internal Tables

http://slidepdf.com/reader/full/internal-tables-5695e7a745319 32/47

"nsertin' +everal Lines"nsertin' +everal Lines

To add several lines to an internal table, #se t(e statementTo add several lines to an internal table, #se t(e statement

INSERT LINES +5 ;itabD< >5R+M ;nD<? >T+ ;n /<? INT+ TABLE ;itab/<.INSERT LINES +5 ;itabD< >5R+M ;nD<? >T+ ;n /<? INT+ TABLE ;itab/<.

;itabD< and ;itab/< are tables %it( a $ompatible line t&pe. T(e s&stem inserts;itabD< and ;itab/< are tables %it( a $ompatible line t&pe. T(e s&stem inserts

t(e lines of table ;itabD< one b& one into ;itab/< #sin! t(e same r#les ast(e lines of table ;itabD< one b& one into ;itab/< #sin! t(e same r#les asfor sin!le lines.for sin!le lines.

7/18/2019 Internal Tables

http://slidepdf.com/reader/full/internal-tables-5695e7a745319 33/47

9+LLE9T9+LLE9T

T(e follo%in! statement allo%s &o# to s#mmate entries in anT(e follo%in! statement allo%s &o# to s#mmate entries in aninternal tableinternal table

*$LLE*T 1wa2 "!T$ 1itab2.*$LLE*T 1wa2 "!T$ 1itab2. 1itab2 must have a flat line type, and all of the fields that are1itab2 must have a flat line type, and all of the fields that are

not part of the table key must have a numeric type J, ", or 0.not part of the table key must have a numeric type J, ", or 0.

 You specify the line that you want to add in a work area that is You specify the line that you want to add in a work area that iscompatible with the line type.compatible with the line type. &hen the line is inserted, the system checks whether there is&hen the line is inserted, the system checks whether there is

already a table entry that matches the key. "f there is noalready a table entry that matches the key. "f there is nocorrespondin' entry already in the table, the *$LLE*Tcorrespondin' entry already in the table, the *$LLE*Tstatement has the same effect asstatement has the same effect as insertin' the new lineinsertin' the new line. "f an. "f anentry with the same key already e(ists, the *$LLE*T statemententry with the same key already e(ists, the *$LLE*T statementdoes not append a new line, but adds the contents of thedoes not append a new line, but adds the contents of thenumeric fields in the work area to the contents of the numericnumeric fields in the work area to the contents of the numericfields in the e(istin' entry.fields in the e(istin' entry.

7/18/2019 Internal Tables

http://slidepdf.com/reader/full/internal-tables-5695e7a745319 34/47

REA* INTERNAL TABLEREA* INTERNAL TABLE

To read a sin!le line of an& table, #se t(e statementTo read a sin!le line of an& table, #se t(e statement =E) T)8LE 1itab2 1key2 1result2.=E) T)8LE 1itab2 1key2 1result2. or the statement to be valid for any kind of table,or the statement to be valid for any kind of table,

you must specify the entry usin' the key and not theyou must specify the entry usin' the key and not the

inde(. You specify the key in the 1key2 part of theinde(. You specify the key in the 1key2 part of thestatement. The 1result2 part can specify a furtherstatement. The 1result2 part can specify a furtherprocessin' option for the line that is retrieved.processin' option for the line that is retrieved. 

If t(e s&stem finds an entr&, it sets SY2SUBR9 to 6ero, ifIf t(e s&stem finds an entr&, it sets SY2SUBR9 to 6ero, ifnot, it taes t(e val#e , as lon! as it is not infl#en$ed b&not, it taes t(e val#e , as lon! as it is not infl#en$ed b&

one of t(e possible additions. If t(e internal table is anone of t(e possible additions. If t(e internal table is aninde" table, SY2TABI4 is set to t(e inde" of t(e lineinde" table, SY2TABI4 is set to t(e inde" of t(e lineretrieved. If t(e table (as a non2#ni3#e e& and t(ere areretrieved. If t(e table (as a non2#ni3#e e& and t(ere ared#pli$ate entries, t(e first entr& is read.d#pli$ate entries, t(e first entr& is read.

7/18/2019 Internal Tables

http://slidepdf.com/reader/full/internal-tables-5695e7a745319 35/47

To #se t(e table e& of ;itab< as a sear$( e&, enter ;e&< as follo%sTo #se t(e table e& of ;itab< as a sear$( e&, enter ;e&< as follo%s =E) T)8LE 1itab2 =$ 1wa2 1result2.=E) T)8LE 1itab2 =$ 1wa2 1result2. or as followsor as follows =E) T)8LE 1itab2 &"TH T)8LE KEY 1k:2 A 1f :2 ... 1k n2 A 1f n2=E) T)8LE 1itab2 &"TH T)8LE KEY 1k:2 A 1f :2 ... 1k n2 A 1f n2

1result2.1result2. sin' a &ork )reasin' a &ork )rea  You can write the table entry read from the table into a work area by You can write the table entry read from the table into a work area by

specifyin' 1result2 as follows7specifyin' 1result2 as follows7 =E) T)8LE 1itab2 1key2 "!T$ 1wa2 4*$0)="!9 1f:2 1f ;2 ...=E) T)8LE 1itab2 1key2 "!T$ 1wa2 4*$0)="!9 1f:2 1f ;2 ...

3)LL "EL+53)LL "EL+54T=)!+0$=T"!9 1f:2 1f ;2 ...4T=)!+0$=T"!9 1f:2 1f ;2 ...

3)LL "EL+3)LL "EL+

3!$ "EL+5.  3!$ "EL+5. "f you do not use the additions *$0)="!9 or T=)!+0$=T"!9, the"f you do not use the additions *$0)="!9 or T=)!+0$=T"!9, thecontents of the table line must be convertible into the data type of thecontents of the table line must be convertible into the data type of thework area 1wa2. "f you specify *$0)="!9 or T=)!+0$=T"!9, thework area 1wa2. "f you specify *$0)="!9 or T=)!+0$=T"!9, theline type and work area must be compatible. You should always use aline type and work area must be compatible. You should always use awork area that is compatible with the line type of the relevant internalwork area that is compatible with the line type of the relevant internaltable.table.

7/18/2019 Internal Tables

http://slidepdf.com/reader/full/internal-tables-5695e7a745319 36/47

"f you use the *$0)="!9 addition, the specified table fields 1f i 2 of"f you use the *$0)="!9 addition, the specified table fields 1f i 2 ofthe structured line type are compared with the correspondin' fields ofthe structured line type are compared with the correspondin' fields ofthe work area before bein' transported. "f you use the )LL "EL+the work area before bein' transported. "f you use the )LL "EL+option, the system compares all components. "f the system finds anoption, the system compares all components. "f the system finds anentry with the specified key 1key2 and if the contents of the comparedentry with the specified key 1key2 and if the contents of the comparedfields are the same, +Y-+8=* is set to . "f the contents of thefields are the same, +Y-+8=* is set to . "f the contents of thecompared fields are not the same, it returns the value ;. "f the systemcompared fields are not the same, it returns the value ;. "f the systemcannot find an entry, +Y-+8=* is set to . "f the system finds ancannot find an entry, +Y-+8=* is set to . "f the system finds anentry, it copies it into the tar'et work area re'ardless of the result ofentry, it copies it into the tar'et work area re'ardless of the result ofthe comparison.the comparison.

"f you use the T=)!+0$=T"!9 addition, you can specify the table"f you use the T=)!+0$=T"!9 addition, you can specify the tablefields of the structured line type that you want to transport into thefields of the structured line type that you want to transport into thework area. "f you specify )LL "EL+ without T=)!+0$=T"!9, thework area. "f you specify )LL "EL+ without T=)!+0$=T"!9, thecontents of all of the fields are transported. "f you specify !$ "EL+,contents of all of the fields are transported. "f you specify !$ "EL+,no fields are transported. "n the latter case, the =E) statement onlyno fields are transported. "n the latter case, the =E) statement onlyfills the system fields +Y-+8=* and +Y-T)8"@. +pecifyin' the workfills the system fields +Y-+8=* and +Y-T)8"@. +pecifyin' the workarea 1wa2 with T=)!+0$=T"!9 !$ "EL+ is unnecessary, andarea 1wa2 with T=)!+0$=T"!9 !$ "EL+ is unnecessary, andshould be omitted.should be omitted.

"n both additions, you can specify a field 1f i 2 dynamically as the"n both additions, you can specify a field 1f i 2 dynamically as thecontents of a field 1n i 2 in the form J1n i 2. "f 1n i 2 is empty when thecontents of a field 1n i 2 in the form J1n i 2. "f 1n i 2 is empty when thestatement is e(ecuted, it is i'nored. You can restrict the search tostatement is e(ecuted, it is i'nored. You can restrict the search topartial fields by specifyin' offset and len'th.partial fields by specifyin' offset and len'th.

7/18/2019 Internal Tables

http://slidepdf.com/reader/full/internal-tables-5695e7a745319 37/47

REA* E4AM'LEREA* E4AM'LE

)T)7 8E9"! $ L"!E,)T)7 8E9"! $ L"!E,  *$L: TY0E ",  *$L: TY0E ",  *$L; TY0E ",  *$L; TY0E ",  E! $ L"!E.  E! $ L"!E.

)T) "T)8 L"KE +$=TE T)8LE $ L"!E &"TH !"#E KEY *$L:.)T) "T)8 L"KE +$=TE T)8LE $ L"!E &"TH !"#E KEY *$L:. $ T"E+.$ T"E+.

  L"!E-*$L: A +Y-"!E@. L"!E-*$L: A +Y-"!E@.  L"!E-*$L; A +Y-"!E@ GG ;. L"!E-*$L; A +Y-"!E@ GG ;.  "!+E=T L"!E "!T$ T)8LE "T)8. "!+E=T L"!E "!T$ T)8LE "T)8.E!$.E!$.

=E) T)8LE "T)8 &"TH KEY *$L; A : T=)!+0$=T"!9 !$=E) T)8LE "T)8 &"TH KEY *$L; A : T=)!+0$=T"!9 !$"EL+."EL+.

&="TE7 B+Y-+8=* AB, +Y-+8=*,&="TE7 B+Y-+8=* AB, +Y-+8=*,

  F B+Y-T)8"@ AB, +Y-T)8"@.  F B+Y-T)8"@ AB, +Y-T)8"@. The output is7The output is7 +Y-+8=* A +Y-+8=* A

+Y-T)8"@ A +Y-T)8"@ A

7/18/2019 Internal Tables

http://slidepdf.com/reader/full/internal-tables-5695e7a745319 38/47

M+*I5Y ITABM+*I5Y ITAB

To $(an!e a sin!le line of an& internal table, #se t(e M+*I5Y statement. Yo#To $(an!e a sin!le line of an& internal table, #se t(e M+*I5Y statement. Yo#$an eit(er #se t(e table e& to find and $(an!e a sin!le line #sin! its e&, or$an eit(er #se t(e table e& to find and $(an!e a sin!le line #sin! its e&, orfind and $(an!e a set of lines t(at meet a $ertain $ondition. If t(e table (asfind and $(an!e a set of lines t(at meet a $ertain $ondition. If t(e table (asa non2#ni3#e e& and t(ere are d#pli$ate entries, t(e first entr& is $(an!ed.a non2#ni3#e e& and t(ere are d#pli$ate entries, t(e first entr& is $(an!ed.

M+*I5Y TABLE ;itab< 5R+M ;%a< >TRANS'+RTINF ;fD< ;f /< ...?.M+*I5Y TABLE ;itab< 5R+M ;%a< >TRANS'+RTINF ;fD< ;f /< ...?.

T(e %or area ;%a<, %(i$( m#st be $ompatible %it( t(e line t&pe of t(e internalT(e %or area ;%a<, %(i$( m#st be $ompatible %it( t(e line t&pe of t(e internaltable, pla&s a do#ble role in t(is statement. Not onl& it is #sed to find t(e linetable, pla&s a do#ble role in t(is statement. Not onl& it is #sed to find t(e linet(at &o# %ant to $(an!e, b#t it also $ontains t(e ne% $ontents. T(e s&stemt(at &o# %ant to $(an!e, b#t it also $ontains t(e ne% $ontents. T(e s&stemsear$(es t(e internal table for t(e line %(ose table e& $orresponds to t(esear$(es t(e internal table for t(e line %(ose table e& $orresponds to t(ee& fields in ;%a<.e& fields in ;%a<.

7/18/2019 Internal Tables

http://slidepdf.com/reader/full/internal-tables-5695e7a745319 39/47

E4AM'LE +5 M+*I5YE4AM'LE +5 M+*I5Y

data7 be'in of line,data7 be'in of line,col: type i,col: type i,col; type i,col; type i,end of line.end of line.

data itab like hashed table of line with uni%ue key col:.data itab like hashed table of line with uni%ue key col:.

do times.do times.line-col: A sy-inde(.line-col: A sy-inde(.line-col; A sy-inde( GG ;.line-col; A sy-inde( GG ;.insert line into table itab.insert line into table itab.

enddo.enddo.

  line-col; A :.line-col; A :.

modify itab from line transportin' col;modify itab from line transportin' col;where J col; 2 : and J col: 1 .where J col; 2 : and J col: 1 .

loop at itab into line.loop at itab into line.write7 F line-col:, line-col;.write7 F line-col:, line-col;.

endloop.endloop.

the output is7the output is7

: :: :  ; :  ; :  < :  < :

  :  :

7/18/2019 Internal Tables

http://slidepdf.com/reader/full/internal-tables-5695e7a745319 40/47

eletin' a Lineeletin' a Line

To use the table key of table 1itab2 as a search key, use one of theTo use the table key of table 1itab2 as a search key, use one of thefollowin' statements7followin' statements7

ELETE T)8LE 1itab2 =$ 1wa2.ELETE T)8LE 1itab2 =$ 1wa2.

or or 

ELETE T)8LE 1itab2 &"TH T)8LE KEY 1k:2 A 1f :2 ... 1k n2 A 1f n2.ELETE T)8LE 1itab2 &"TH T)8LE KEY 1k:2 A 1f :2 ... 1k n2 A 1f n2.

  "n the first case, 1wa2 must be a work area compatible with the line"n the first case, 1wa2 must be a work area compatible with the linetype of 1itab2. The values of the key fields are taken from thetype of 1itab2. The values of the key fields are taken from thecorrespondin' components of the work area.correspondin' components of the work area.

"n the second case, you have to supply the values of each key field"n the second case, you have to supply the values of each key field

e(plicitly. "f you do not know the name of one of the key fields untile(plicitly. "f you do not know the name of one of the key fields untilruntime, you can specify it as the content of a field 1n i 2 usin' theruntime, you can specify it as the content of a field 1n i 2 usin' theform J1n i 2 A 1f i 2. "f the data types of 1f i 2 are not compatible withform J1n i 2 A 1f i 2. "f the data types of 1f i 2 are not compatible withthe key fields, the system converts them.the key fields, the system converts them.

7/18/2019 Internal Tables

http://slidepdf.com/reader/full/internal-tables-5695e7a745319 41/47

E4AM'LE *ELETE ITABE4AM'LE *ELETE ITAB

data be!in of line,data be!in of line,$olD t&pe i,$olD t&pe i,$ol/ t&pe i,$ol/ t&pe i,end of line.end of line.

data itab lie (as(ed table of line %it( #ni3#e e& $olD.data itab lie (as(ed table of line %it( #ni3#e e& $olD. do times.do times.

line2$olD s&2inde".line2$olD s&2inde".line2$ol/ s&2inde" JJ /.line2$ol/ s&2inde" JJ /.insert line into table itab.insert line into table itab.enddo.enddo.

line2$olD D.line2$olD D. delete table itab from line,delete table itab from line,

%it( table e& $olD .%it( table e& $olD .

loop at itab into line.loop at itab into line.%rite H line2$olD, line2$ol/.%rite H line2$olD, line2$ol/.endloop.endloop.

t(e o#tp#t ist(e o#tp#t is   / /

  D  D

7/18/2019 Internal Tables

http://slidepdf.com/reader/full/internal-tables-5695e7a745319 42/47

'ro$essin! Table Entries in Loops'ro$essin! Table Entries in Loops

Yo# $an #se t(e L++' statement to pro$ess spe$ial loops for an& internalYo# $an #se t(e L++' statement to pro$ess spe$ial loops for an& internaltable.table.

  L++' AT ;itab< ;res#lt< ;$ondition<.L++' AT ;itab< ;res#lt< ;$ondition<.  ;statement blo$< ;statement blo$<EN*L++'.EN*L++'.

  T(is reads t(e lines of t(e table one b& one as spe$ified in t(e ;res#lt< partT(is reads t(e lines of t(e table one b& one as spe$ified in t(e ;res#lt< partof t(e L++' statement. Yo# $an t(en pro$ess t(em in t(e statements %it(inof t(e L++' statement. Yo# $an t(en pro$ess t(em in t(e statements %it(in

t(e L++'... EN*L++' $ontrol str#$t#re. Yo# $an eit(er r#n t(e loop for allt(e L++'... EN*L++' $ontrol str#$t#re. Yo# $an eit(er r#n t(e loop for allentries in t(e internal table, or restri$t t(e n#mber of lines read b& spe$if&in!entries in t(e internal table, or restri$t t(e n#mber of lines read b& spe$if&in!a ;$ondition<. 9ontrol level pro$essin! is allo%ed %it(in t(e loop.a ;$ondition<. 9ontrol level pro$essin! is allo%ed %it(in t(e loop.

sin' a &ork )reasin' a &ork )rea

  To pla$e t(e $#rrent loop line into a %or area, spe$if& ;res#lt< asTo pla$e t(e $#rrent loop line into a %or area, spe$if& ;res#lt< asfollo%sfollo%s

L++' AT ;itab< INT+ ;%a< ;$ondition<.L++' AT ;itab< INT+ ;%a< ;$ondition<.  T(e $ontents of t(e table lines m#st be $onvertible into t(e data t&peT(e $ontents of t(e table lines m#st be $onvertible into t(e data t&peof t(e %or area ;%a<. In ea$( loop pass, one line of t(e table isof t(e %or area ;%a<. In ea$( loop pass, one line of t(e table is$opied into t(e %or area. T(e end of t(e loop does not affe$t t(e$opied into t(e %or area. T(e end of t(e loop does not affe$t t(e%or area, t(at is, t(e $ontents of ;%a< are t(e same after t(e%or area, t(at is, t(e $ontents of ;%a< are t(e same after t(eEN*L++' statement as t(e& %ere in t(e final loop pass. If no tableEN*L++' statement as t(e& %ere in t(e final loop pass. If no tableentries are pro$essed in t(e loop, be$a#se t(e table is entr&, or noentries are pro$essed in t(e loop, be$a#se t(e table is entr&, or noline meets t(e $ondition ;$ondition<, t(e %or area is not $(an!ed.line meets t(e $ondition ;$ondition<, t(e %or area is not $(an!ed.

7/18/2019 Internal Tables

http://slidepdf.com/reader/full/internal-tables-5695e7a745319 43/47

9+NTR+L LE@EL 'R+9ESSINF9+NTR+L LE@EL 'R+9ESSINF

9ontrol level pro$essin! is allo%ed %it(in a L++' over9ontrol level pro$essin! is allo%ed %it(in a L++' overan internal table. T(is means t(at &o# $an dividean internal table. T(is means t(at &o# $an dividese3#en$es of entries into !ro#ps based on t(e $ontentsse3#en$es of entries into !ro#ps based on t(e $ontentsof $ertain fields.of $ertain fields.

Internal tables are divided into !ro#ps a$$ordin! to t(eInternal tables are divided into !ro#ps a$$ordin! to t(ese3#en$e of t(e fields in t(e line str#$t#re. T(e firstse3#en$e of t(e fields in t(e line str#$t#re. T(e first$ol#mn defines t(e (i!(est $ontrol level and so on. T(e$ol#mn defines t(e (i!(est $ontrol level and so on. T(e$ontrol level (ierar$(& m#st be no%n %(en &o# $reate$ontrol level (ierar$(& m#st be no%n %(en &o# $reatet(e internal table.t(e internal table.

T(e $ontrol levels are formed b& sortin! t(e internal tableT(e $ontrol levels are formed b& sortin! t(e internal table

in t(e se3#en$e of its str#$t#re, t(at is, b& t(e first fieldin t(e se3#en$e of its str#$t#re, t(at is, b& t(e first fieldfirst, t(en b& t(e se$ond field, and so on. Tables in %(i$(first, t(en b& t(e se$ond field, and so on. Tables in %(i$(t(e table e& o$$#rs at t(e start of t(e table aret(e table e& o$$#rs at t(e start of t(e table areparti$#larl& s#itable for $ontrol level pro$essin!.parti$#larl& s#itable for $ontrol level pro$essin!.

7/18/2019 Internal Tables

http://slidepdf.com/reader/full/internal-tables-5695e7a745319 44/47

t(e at statement introd#$es a statement blo$ t(at &o# end %it( t(et(e at statement introd#$es a statement blo$ t(at &o# end %it( t(e

endat statement.endat statement.

at 1level2.at 1level2.

  1statement block2 1statement block2

endat.endat.

you can react to the followin' control level chan'es7you can react to the followin' control level chan'es7

7/18/2019 Internal Tables

http://slidepdf.com/reader/full/internal-tables-5695e7a745319 45/47

Yo# $an #se $ontrol level statements to rea$t to $ontrol breas inYo# $an #se $ontrol level statements to rea$t to $ontrol breas ininternal tables instead of pro!rammin! t(em &o#rself %it( lo!i$alinternal tables instead of pro!rammin! t(em &o#rself %it( lo!i$ale"pressions. 7it(in t(e loop, &o# m#st order t(e AT2EN*ATe"pressions. 7it(in t(e loop, &o# m#st order t(e AT2EN*ATstatement blo$s a$$ordin! to t(e (ierar$(& of t(e $ontrol levels. Ifstatement blo$s a$$ordin! to t(e (ierar$(& of t(e $ontrol levels. Ift(e internal table (as t(e $ol#mns ;fD<, ;f /<, ...., and if it is sortedt(e internal table (as t(e $ol#mns ;fD<, ;f /<, ...., and if it is sortedb& t(ese $ol#mns, &o# m#st pro!ram t(e loop as follo%sb& t(ese $ol#mns, &o# m#st pro!ram t(e loop as follo%s

L$$0 )T 1itab2.L$$0 )T 1itab2.  )T "=+T. ... E!)T. )T "=+T. ... E!)T.  )T !E& 1f:2. ...... E!)T.  )T !E& 1f:2. ...... E!)T.  )T !E& 1f; 2. ...... E!)T.  )T !E& 1f; 2. ...... E!)T.  ..............

1sin'le line processin'2  1sin'le line processin'2

..............)T E! $ 1f;2. ... E!)T.  )T E! $ 1f;2. ... E!)T.  )T E! $ 1f:2. ... E!)T.  )T E! $ 1f:2. ... E!)T.  )T L)+T. .... E!)T. )T L)+T. .... E!)T.E!L$$0.E!L$$0.

7/18/2019 Internal Tables

http://slidepdf.com/reader/full/internal-tables-5695e7a745319 46/47

SUMSUM

7it(in an AT...EN*AT blo$, &o# $an $al$#late t(e $ontents of t(e7it(in an AT...EN*AT blo$, &o# $an $al$#late t(e $ontents of t(en#meri$ fields of t(e $orrespondin! $ontrol level #sin! t(e SUMn#meri$ fields of t(e $orrespondin! $ontrol level #sin! t(e SUMstatement.statement.

SUM.SUM. Yo# $an onl& #se t(is statement %it(in a L++'. If &o# #se SUM inYo# $an onl& #se t(is statement %it(in a L++'. If &o# #se SUM in

an AT 2 EN*AT blo$, t(e s&stem $al$#lates totals for t(e n#meri$an AT 2 EN*AT blo$, t(e s&stem $al$#lates totals for t(e n#meri$fields of all lines in t(e $#rrent line !ro#p and %rites t(em to t(efields of all lines in t(e $#rrent line !ro#p and %rites t(em to t(e$orrespondin! fields in t(e %or area -see e"ample in . If &o# #se$orrespondin! fields in t(e %or area -see e"ample in . If &o# #set(e SUM statement o#tside an AT 2 EN*AT blo$ -sin!le entr&t(e SUM statement o#tside an AT 2 EN*AT blo$ -sin!le entr&pro$essin!, t(e s&stem $al$#lates totals for t(e n#meri$ fields of allpro$essin!, t(e s&stem $al$#lates totals for t(e n#meri$ fields of alllines of t(e internal table in ea$( loop pass and %rites t(em to t(elines of t(e internal table in ea$( loop pass and %rites t(em to t(e$orrespondin! fields of t(e %or area. It t(erefore onl& maes sense$orrespondin! fields of t(e %or area. It t(erefore onl& maes sense

to #se t(e SUM statement in AT...EN*AT blo$s.to #se t(e SUM statement in AT...EN*AT blo$s.

7/18/2019 Internal Tables

http://slidepdf.com/reader/full/internal-tables-5695e7a745319 47/47

E4AM'LE 5+R 9+NTR+L LE@ELE4AM'LE 5+R 9+NTR+L LE@EL

)T)7 8E9"! $ L"!E,)T)7 8E9"! $ L"!E,  *$L: TY0E *,  *$L: TY0E *,  *$L; TY0E ",  *$L; TY0E ",  *$L< TY0E ",  *$L< TY0E ",  E! $ L"!E.  E! $ L"!E.

)T) "T)8 L"KE H)+HE T)8LE $)T) "T)8 L"KE H)+HE T)8LE $L"!EL"!E

  &"TH !"#E KEY *$L:&"TH !"#E KEY *$L:*$L;.*$L;. L"!E-*$L: A B)B.L"!E-*$L: A B)B.

$ < T"E+.$ < T"E+.  L"!E-*$L; A +Y-"!E@. L"!E-*$L; A +Y-"!E@.  L"!E-*$L< A +Y-"!E@ GG ;. L"!E-*$L< A +Y-"!E@ GG ;.  "!+E=T L"!E "!T$ T)8LE "T)8. "!+E=T L"!E "!T$ T)8LE "T)8.E!$.E!$.

L"!E-*$L: A B8B.L"!E-*$L: A B8B.$ < T"E+.$ < T"E+.  L"!E-*$L; A ; G +Y-"!E@. L"!E-*$L; A ; G +Y-"!E@.  L"!E-*$L< A J ; G +Y-"!E@ GG ;. L"!E-*$L< A J ; G +Y-"!E@ GG ;.  "!+E=T L"!E "!T$ T)8LE "T)8. "!+E=T L"!E "!T$ T)8LE "T)8.E!$.E!$.

+$=T "T)8.+$=T "T)8. L$$0 )T "T)8 "!T$ L"!E.L$$0 )T "T)8 "!T$ L"!E.

  &="TE7 F L"!E-*$L:, L"!E-*$L;,&="TE7 F L"!E-*$L:, L"!E-*$L;,L"!E-*$L<.L"!E-*$L<.  )T E! $ *$L:. )T E! $ *$L:.  +.  +.  L"!E.  L"!E.

  &="TE7 F L"!E-*$L:, L"!E-*$L;,&="TE7 F L"!E-*$L:, L"!E-*$L;,L"!E-*$L<.L"!E-*$L<.  +K"0.  +K"0.  E!)T. E!)T.  )T L)+T. )T L)+T.  +.  +.  L"!E.  L"!E.  &="TE7 F L"!E-*$L:, L"!E-*$L;,&="TE7 F L"!E-*$L:, L"!E-*$L;,L"!E-*$L<.L"!E-*$L<.  E!)T. E!)T.E!L$$0.E!L$$0.