Hi ABAPers
I am learning ABAP programming. I am having some doubts in some programs which are there in the book TEACH YOURSELF ABAP/4 in 21 Days.
I hope you will clear all my doubts
1) when I execute this program it is giving me error message and I am unable to resolve the error in it.
I dont remember the error message but it is something related to data conversion.
Listing 9.5 Variables Filled with Characters Other than Blanks or Zeros Using the WITH Addition of the CLEAR Statement
1 report ztx0905.
2 tables ztxlfa1.
3 data: f1(2) type c value 'AB',
4 f2(2) type c,
5 f3 type i value 12345,
6 begin of s1,
7 f1(3) type c value 'XYZ',
8 f2 type i value 123456,
9 end of s1.
10 write: / 'f1=''' no-gap, f1 no-gap, '''',
11 / 'f2=''' no-gap, f2 no-gap, '''',
12 / 'f3=''' no-gap, f3 no-gap, '''',
13 / 's1-f1=''' no-gap, s1-f1 no-gap, '''',
14 / 's1-f2=''' no-gap, s1-f2 no-gap, '''',
15 / 'ztxlfa1-lifnr=''' no-gap, ztxlfa1-lifnr no-gap, '''',
16 / 'ztxlfa1-land1=''' no-gap, ztxlfa1-land1 no-gap, '''',
17 /.
18 clear: f1 with 'X',
19 f2 with f1,
20 f3 with 3,
21 s1 with 'X',
22 ztxlfa1 with 0.
23 write: / 'f1=''' no-gap, f1 no-gap, '''',
24 / 'f2=''' no-gap, f2 no-gap, '''',
25 / 'f3=''' no-gap, f3 no-gap, '''',
26 / 's1-f1=''' no-gap, s1-f1 no-gap, '''',
27 / 's1-f2=''' no-gap, s1-f2 no-gap, '''',
28 / 'ztxlfa1-lifnr=''' no-gap, ztxlfa1-lifnr no-gap, '''',
29 / 'ztxlfa1-land1=''' no-gap, ztxlfa1-land1 no-gap, ''''.
according the book the output should be
The code in Listing 9.5 produces this output:
f1='AB'
f2=' '
f3=' 12,345 '
s1-f1='XYZ'
s1-f2=' 123,456 '
ztxlfa1-lifnr=' '
ztxlfa1-land1=' '
f1='XX'
f2='XX'
f3='50,529,027 '
s1-f1='XXX'
s1-f2='1482184792 '
ztxlfa1-lifnr='##########'
ztxlfa1-land1='###'
can you please explain me this program.
2) This program is giving me the following error message at line 7.
ALPHA AND IT-F1 ARE TYPE- INCOMPATIBLE.
The program is as follows.
Listing 12.9 Deleting Rows from an Internal Table Can also be Done Using the delete Statement
1 report ztx1209.
2 data: begin of it occurs 12,
3 f1,
4 end of it,
5 alpha(12) value 'ABCDEFGHIJKL'.
6
7 do 12 times varying it-f1 from alpha0 next alpha1.
8 append it.
9 enddo.
10
11 loop at it.
12 write: / sy-tabix, it-f1.
13 endloop.
14
15 delete it index 5.
16 skip.
17 loop at it.
18 write: / sy-tabix, it-f1.
19 endloop.
20
21 delete it from 6 to 8.
22 skip.
23 loop at it.
24 write: / sy-tabix, it-f1.
25 endloop.
26
27 delete it where f1 between 'B' and 'D'.
28 skip.
29 loop at it.
30 write: / sy-tabix, it-f1.
31 endloop.
32
33 loop at it where f1 between 'E' and 'J'.
34 delete it.
35 endloop.
36
37 skip.
38 loop at it.
39 write: / sy-tabix, it-f1.
40 endloop.
41
42 read table it with key f1 = 'K' binary search.
43 write: /, / 'sy-subrc=', sy-subrc, 'sy-tabix=', sy-tabix, / ''.
44 if sy-subrc = 0.
45 delete it index sy-tabix.
46 endif.
47
48 skip.
49 loop at it.
50 write: / sy-tabix, it-f1.
51 endloop.
52
53 free it.
And the out put according to the book is as follows
The code in Listing 12.9 produces this output:
1 A
2 B
3 C
4 D
5 E
6 F
7 G
8 H
9 I
10 J
11 K
12 L
1 A
2 B
3 C
4 D
5 F
6 G
7 H
8 I
9 J
10 K
11 L
1 A
2 B
3 C
4 D
5 F
6 J
7 K
8 L
1 A
2 F
3 J
4 K
5 L
1 A
2 K
3 L
sy-subrc= 0 sy-tabix= 2
1 A
2 L
How to rectify the error in this program.
3) In this program I want to ask is there any way that I can be able to see the write statement output which is there in the initialization event block. If yes then how .
(Note I dont want to remove the paramter (selection screen) statement.)
Listing 18.13 Explain the Sequence of Events That Occurs in this Program
report ztx1813 no standard page heading.
ztx1813 data: flag,
ctr type i.
parameters p1.
initialization.
flag = 'I'.
write: / 'in Initialization'.
start-of-selection.
flag = 'S'.
write: / 'in Start-Of-Selection',
/ 'p1 =', p1.
top-of-page.
add 1 to ctr.
write: / 'Top of page, flag =', flag, 'ctr =', ctr.
uline.
4) can anybody please mail me some exercise program queries ( right from the basic to complex one) on this mail id maqsood.sap@gmail.com or else u can give me the url of the website which contains such program.
EARGERLY WAITING FOR UR REPLIES
Regards,
maqsood