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 | FORM get_src_compressed |
33 | USING |
34 | it_src TYPE table |
35 | value(i_compress_better) TYPE flag |
36 | CHANGING |
37 | ct_compressed TYPE table. |
38 | |
39 | DATA: |
40 | ls_src TYPE string, |
41 | l_is_header TYPE flag VALUE abap_true, |
42 | l_length TYPE i, |
43 | l_pos TYPE i, |
44 | l_is_string TYPE flag, |
45 | l_chars(72) TYPE c, |
46 | l_str TYPE string, |
47 | l_str2 TYPE string, |
48 | l_srclen TYPE i, |
49 | l_strlen TYPE i, |
50 | l_line TYPE string, |
51 | l_linelen TYPE i. |
52 | |
53 | REFRESH ct_compressed. |
54 | |
55 |
56 | IF i_compress_better = abap_true. |
57 | l_is_header = abap_false. |
58 | ENDIF. |
59 | |
60 | LOOP AT it_src INTO ls_src. |
61 |
62 | IF ls_src IS INITIAL. |
63 | l_is_header = abap_false. |
64 | CONTINUE. |
65 | ENDIF. |
66 |
67 | IF ls_src+0(1) = '*'. |
68 | IF l_is_header = abap_true. |
69 | APPEND ls_src TO ct_compressed. |
70 | ENDIF. |
71 | CONTINUE. |
72 | ENDIF. |
73 |
74 | IF ls_src CA '"'. |
75 | PERFORM split_src_string |
76 | USING |
77 | ls_src |
78 | '"' |
79 | CHANGING |
80 | l_str |
81 | l_str2. |
82 | ls_src = l_str. |
83 | ENDIF. |
84 |
85 | PERFORM get_src_line_compressed |
86 | CHANGING ls_src. |
87 |
88 | IF NOT l_line IS INITIAL. |
89 | l_srclen = strlen( ls_src ). |
90 | l_linelen = strlen( l_line ). |
91 | l_length = l_srclen + l_linelen. |
92 | IF l_length < 71. |
93 | CONCATENATE l_line ls_src INTO l_line SEPARATED BY space. |
94 | CONTINUE. |
95 | ELSE. |
96 | DO. |
97 | PERFORM split_src_string |
98 | USING |
99 | ls_src |
100 | space |
101 | CHANGING |
102 | l_str |
103 | l_str2. |
104 | l_strlen = strlen( l_str ). |
105 | l_linelen = strlen( l_line ). |
106 | l_length = l_strlen + l_linelen. |
107 | IF l_length < 71. |
108 | CONCATENATE l_line l_str INTO l_line |
109 | SEPARATED BY space. |
110 | IF NOT l_str2 IS INITIAL AND l_str2+0(1) = '*'. |
111 | CLEAR l_chars. |
112 | CLEAR ls_src. |
113 | l_chars+1 = l_str2. |
114 | ls_src = l_chars. |
115 | ELSE. |
116 | ls_src = l_str2. |
117 | ENDIF. |
118 | ELSE. |
119 | EXIT. |
120 | ENDIF. |
121 | IF ls_src IS INITIAL. |
122 | EXIT. |
123 | ENDIF. |
124 | ENDDO. |
125 | ENDIF. |
126 | ENDIF. |
127 | IF NOT l_line IS INITIAL. |
128 | APPEND l_line TO ct_compressed. |
129 | ENDIF. |
130 | l_line = ls_src. |
131 | l_is_header = abap_false. |
132 | ENDLOOP. |
133 | IF NOT l_line IS INITIAL. |
134 | APPEND l_line TO ct_compressed. |
135 | ENDIF. |
136 | |
137 | ENDFORM. "get_src_compressed |
138 | |
139 | |
140 |
141 |
142 |
143 | FORM get_src_line_compressed |
144 | CHANGING |
145 | c_line TYPE string. |
146 | |
147 | DATA: |
148 | l_str TYPE string, |
149 | l_str1 TYPE string, |
150 | l_str2 TYPE string, |
151 | l_line_new TYPE string. |
152 | |
153 | l_str = c_line. |
154 | |
155 | DO. |
156 | PERFORM split_src_string |
157 | USING |
158 | l_str |
159 | space |
160 | CHANGING |
161 | l_str1 |
162 | l_str2. |
163 | |
164 | IF l_line_new IS INITIAL. |
165 | l_line_new = l_str1. |
166 | ELSE. |
167 | CONCATENATE l_line_new l_str1 INTO l_line_new SEPARATED BY space. |
168 | ENDIF. |
169 | |
170 | IF l_str2 IS INITIAL. |
171 | EXIT. |
172 | ENDIF. |
173 | l_str = l_str2. |
174 | ENDDO. |
175 | |
176 | c_line = l_line_new. |
177 | |
178 | ENDFORM. "get_src_line_compressed |
179 | |
180 | |
181 |
182 |
183 |
184 | FORM split_src_string |
185 | USING |
186 | value(i_src) TYPE string |
187 | value(i_sep) TYPE char1 |
188 | CHANGING |
189 | c_str1 TYPE string |
190 | c_str2 TYPE string. |
191 | |
192 | DATA: |
193 | l_src TYPE string, |
194 | l_is_string TYPE flag VALUE abap_false, |
195 | l_pos TYPE i VALUE 0, |
196 | l_char TYPE char1, |
197 | l_srclen TYPE i. |
198 | |
199 | |
200 | CLEAR: |
201 | c_str1, |
202 | c_str2. |
203 | |
204 | l_src = i_src. |
205 | |
206 | SHIFT l_src LEFT DELETING LEADING space. |
207 | |
208 | SPLIT l_src AT i_sep INTO c_str1 c_str2. |
209 | |
210 | IF c_str1 CA '''' AND c_str2 CA ''''. |
211 | CLEAR: c_str1, c_str2. |
212 | l_srclen = strlen( l_src ). |
213 | DO. |
214 | l_char = l_src+l_pos(1). |
215 | CONDENSE l_char. |
216 | CASE l_char. |
217 | WHEN ''''. |
218 | IF l_is_string = abap_true. |
219 | l_is_string = abap_false. |
220 | ELSE. |
221 | l_is_string = abap_true. |
222 | ENDIF. |
223 | WHEN i_sep. |
224 | IF l_is_string = abap_false. |
225 | c_str1 = l_src+0(l_pos). |
226 | ADD 1 TO l_pos. |
227 | c_str2 = l_src+l_pos. |
228 | EXIT. |
229 | ENDIF. |
230 | ENDCASE. |
231 | ADD 1 TO l_pos. |
232 | IF l_pos = l_srclen. |
233 | c_str1 = l_src. |
234 | EXIT. |
235 | ENDIF. |
236 | ENDDO. |
237 | ENDIF. |
238 | |
239 | SHIFT c_str2 LEFT DELETING LEADING space. |
240 | IF c_str1 NA ''''. |
241 | CONDENSE c_str1. |
242 | ENDIF. |
243 | IF c_str2 NA ''''. |
244 | CONDENSE c_str2. |
245 | ENDIF. |
246 | |
247 | ENDFORM. "split_src_string |