♦ Types Kullanımı:
•Veri tipinin kullanıcı tarafından belirlenmesi
1 report ztx0811. 2 types char2(2) type c. 3 data: v1 type char2 value 'AB', 4 v2 type char2 value 'CD'. 5 6 write: v1, v2.
Programın çıktısı:
AB CD
•’Types’ kullanmak, kodunuzu daha açık ve daha anlaşılır yapacaktır.
1 report ztx0812. 2 types: dollars(16) type p decimals 2, 3 lira(16) type p decimals 0. "italian lira have no decimals 4 5 data: begin of american_sums, 6 petty_cash type dollars, 7 pay_outs type dollars, 8 lump_sums type dollars, 9 end of american_sums, 10 begin of italian_sums, 11 petty_cash type lira, 12 pay_outs type lira, 13 lump_sums type lira, 14 end of italian_sums. 15 16 american_sums-pay_outs = '9500.03'. "need quotes when literal contains a decimal 17 italian_sums-lump_sums = 5141. 18 19 write: / american_sums-pay_outs, 20 / italian_sums-lump_sums.
Programın çıktısı:
9,500.00
5,141
•Structured Types kullanma, artıklığı azaltır ve bakımı daha kolay yapılır.
1 report ztx0813. 2 types: begin of address, 3 street(25), 4 city(20), 5 region(7), 6 country(15), 7 postal_code(9), 8 end of address. 9 10 data: customer_addr type address, 11 vendor_addr type address, 12 employee_addr type address, 13 shipto_addr type address. 14 15 customer_addr-street = '101 Memory Lane'. 16 employee_addr-country = 'Transylvania'. 17 18 write: / customer_addr-street, 19 employee_addr-country.
kaynak: Sams Teach Yourself ABAP/4 in 21 Days