FUNCTION zemc_cagent_getlist_r

 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
FUNCTION zemc_cagent_getlist_r.
*"----------------------------------------------------------------------
*"*"Локальный интерфейс:
*" IMPORTING
*" VALUE(SUBSTRING) TYPE STRING OPTIONAL
*" TABLES
*" CAGENTS STRUCTURE ZEMC_CAGENT_INFO
*"----------------------------------------------------------------------
DATA: substring_clause TYPE string.
* IF substring <> '' AND substring <> ' '.
CONCATENATE '*' substring '*' INTO substring_clause.
* ENDIF.
DATA: code LIKE zemc_cagent_info-code,
name1 LIKE kna1-name1,
name2 LIKE kna1-name2,
name3 LIKE lfa1-name3,
name4 LIKE lfa1-name4.
DATA: changedate_clause TYPE string.
DATA lt_all_cagents TYPE STANDARD TABLE OF zemc_cagent_info.
DATA ls_cagent TYPE zemc_cagent_info.
SELECT kunnr name1 name2
INTO (code, name1, name2)
FROM kna1
WHERE name1 <> '' AND (substring_clause) ORDER BY name1.
ls_cagent-code = code.
CONCATENATE name1 name2 INTO ls_cagent-name.
ls_cagent-name_u = ls_cagent-name.
TRANSLATE ls_cagent-name_u TO UPPER CASE.
ls_cagent-kind = 'Д'.
APPEND ls_cagent TO lt_all_cagents.
ENDSELECT.
clear ls_cagent.
SELECT lifnr name1 name2 name3 name4
INTO (code, name1, name2, name3, name4)
FROM lfa1
WHERE name1 <> '' AND (substring_clause) ORDER BY name1.
ls_cagent-code = code.
CONCATENATE name1 name2 name3 name4 INTO ls_cagent-name.
ls_cagent-name_u = ls_cagent-name.
TRANSLATE ls_cagent-name_u TO UPPER CASE.
ls_cagent-kind = 'К'.
APPEND ls_cagent TO lt_all_cagents.
ENDSELECT.
LOOP AT lt_all_cagents INTO ls_cagent WHERE name_u CP substring_clause.
APPEND ls_cagent TO cagents.
ENDLOOP.
ENDFUNCTION.