-------------------- -------------------- -------------------- -------

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
*&---------------------------------------------------------------------*
*& Report ZBC400_04_ITAB_LOOP
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT zbc400_04_itab_loop.
TABLES zcolor.
DATA: lt_color TYPE z_tzcolor,
ls_color LIKE LINE OF lt_color,
lv_str(80) TYPE c.
SELECT * FROM zcolor INTO TABLE lt_color WHERE colorname = 'RED' OR colorname = 'GREEN' OR colorname = 'BLUE'.
LOOP AT lt_color INTO ls_color.
IF ls_color-colorname = 'RED'.
"If string is too long then clear it.
IF strlen( ls_color-note ) > 70.
ls_color-note = ''.
ENDIF.
CONCATENATE ls_color-note 'x' INTO ls_color-note.
"Read red record counter
ls_color-counter = ls_color-counter + 1.
"Modify internal table
MODIFY lt_color FROM ls_color.
ENDIF.
ENDLOOP.
"Modify table in DB
MODIFY zcolor FROM TABLE lt_color.
"Read and display data from DB table
SELECT * FROM zcolor INTO TABLE lt_color.
SORT lt_color BY colorname.
LOOP AT lt_color INTO ls_color.
WRITE: / ls_color-id, ls_color-colorname,ls_color-counter , ls_color-note.
ENDLOOP.
ULINE.
*DATA lv_lastindex TYPE i.
*lv_lastindex = ls_color-id.
*ls_color-id = lv_lastindex + 1.
*ls_color-colorcode = 'dc143c'.
*ls_color-colorname = 'малиновый'.
*INSERT ls_color INTO TABLE lt_color.
*MODIFY zcolor FROM TABLE lt_color.