-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathalv_simplificado.abap
232 lines (164 loc) · 5.25 KB
/
alv_simplificado.abap
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
report alv_simplificado.
class class_report definition .
public section .
types:
begin of ty_out,
bp_id type snwd_bpa-bp_id,
company_name type snwd_bpa-company_name,
currency_code type snwd_bpa-currency_code,
web_address type snwd_bpa-web_address,
email_address type snwd_bpa-email_address,
country type snwd_ad-country,
city type snwd_ad-city,
postal_code type snwd_ad-postal_code,
street type snwd_ad-street,
end of ty_out,
tab_out type table of ty_out,
range_bp_id type range of snwd_bpa-bp_id,
tab_bpa type table of snwd_bpa, " Address Table
tab_ad type table of snwd_ad . " Business Partners
methods buscar_dados
importing
!bp_id type class_report=>range_bp_id
changing
!bpa_tab type class_report=>tab_bpa
!ad_tab type class_report=>tab_ad .
methods processar_dados
importing
!bpa_tab type class_report=>tab_bpa
!ad_tab type class_report=>tab_ad
changing
!out_tab type class_report=>tab_out .
methods exibir_informacoes
changing
!out_tab type class_report=>tab_out .
protected section .
private section .
endclass .
class class_report implementation .
method buscar_dados .
refresh:
bpa_tab, ad_tab .
if ( lines( bp_id ) eq 0 ) .
else .
select *
into table bpa_tab
from snwd_bpa
where bp_id in bp_id .
if ( sy-subrc eq 0 ) .
select *
into table ad_tab
from snwd_ad
for all entries in bpa_tab
where node_key eq bpa_tab-address_guid .
if ( sy-subrc eq 0 ) .
endif .
endif .
endif .
endmethod .
method processar_dados .
data:
out_line type class_report=>ty_out .
refresh out_tab .
if ( lines( bpa_tab ) gt 0 ) and
( lines( ad_tab ) gt 0 ) .
loop at bpa_tab into data(bpa_line) .
out_line-bp_id = bpa_line-bp_id .
out_line-company_name = bpa_line-company_name .
out_line-currency_code = bpa_line-currency_code .
out_line-web_address = bpa_line-web_address .
out_line-email_address = bpa_line-email_address .
read table ad_tab into data(ad_line)
with key node_key = bpa_line-address_guid .
if ( sy-subrc eq 0 ) .
out_line-country = ad_line-country .
out_line-city = ad_line-city .
out_line-postal_code = ad_line-postal_code .
out_line-street = ad_line-street .
append out_line to out_tab .
clear out_line .
endif .
endloop .
endif .
endmethod .
method exibir_informacoes .
data:
salv_table type ref to cl_salv_table,
columns type ref to cl_salv_columns_table,
display type ref to cl_salv_display_settings.
if ( lines( out_tab ) eq 0 ) .
else .
try .
cl_salv_table=>factory(
* exporting
* list_display = if_salv_c_bool_sap=>true
importing
r_salv_table = salv_table
changing
t_table = out_tab
) .
* Otimizar largura da columa
columns = salv_table->get_columns( ) .
if ( columns is bound ) .
columns->set_optimize( cl_salv_display_settings=>true ).
endif .
* Usando Status
salv_table->set_screen_status(
pfstatus = 'STANDARD_FULLSCREEN'
report = 'SAPLKKBL'
set_functions = salv_table->c_functions_all
).
* Layout de Zebra
display = salv_table->get_display_settings( ) .
if ( display is bound ) .
display->set_striped_pattern( cl_salv_display_settings=>true ) .
endif .
salv_table->display( ).
catch cx_salv_msg .
catch cx_salv_not_found .
catch cx_salv_existing .
catch cx_salv_data_error .
catch cx_salv_object_not_found .
endtry.
endif .
endmethod .
endclass .
* Evento para chamada dos metodos
initialization .
data:
filtro type class_report=>range_bp_id,
alv_report type ref to class_report,
bpa_table type class_report=>tab_bpa,
ad_table type class_report=>tab_ad,
out_table type class_report=>tab_out.
* Essa opcao pode/deve ser substituida por um parametro de selecao
filtro =
value #(
( sign = 'I' option = 'EQ' low = '0100000000' )
( sign = 'I' option = 'EQ' low = '0100000001' )
( sign = 'I' option = 'EQ' low = '0100000002' )
( sign = 'I' option = 'EQ' low = '0100000003' )
( sign = 'I' option = 'EQ' low = '0100000004' )
( sign = 'I' option = 'EQ' low = '0100000005' )
) .
alv_report = new class_report( ) .
if ( alv_report is bound ) .
alv_report->buscar_dados(
exporting
bp_id = filtro
changing
bpa_tab = bpa_table
ad_tab = ad_table
).
alv_report->processar_dados(
exporting
bpa_tab = bpa_table
ad_tab = ad_table
changing
out_tab = out_table
).
alv_report->exibir_informacoes(
changing
out_tab = out_table
).
endif .