SAP BTE Agorum DMS Listing

Hier das Listing zum Beitrag (Link). Der Funktionsbaustein SAMPLE_INTERFACE_00001030 wurde in den Kundennamensraum kopiert und wie folgt programmiert.

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
FUNCTION z_bte_00001030.
*"------------------------------------------------------------------
*"*"Lokale Schnittstelle:
*" IMPORTING
*" VALUE(I_BKDF) LIKE BKDF STRUCTURE BKDF
*" VALUE(I_UF05A) LIKE UF05A STRUCTURE UF05A
*" VALUE(I_XVBUP) LIKE OFIWA-XVBUP DEFAULT 'X'
*" TABLES
*" T_AUSZ1 STRUCTURE AUSZ1 OPTIONAL
*" T_AUSZ2 STRUCTURE AUSZ2 OPTIONAL
*" T_AUSZ3 STRUCTURE AUSZ_CLR OPTIONAL
*" T_BKP1 STRUCTURE BKP1
*" T_BKPF STRUCTURE BKPF
*" T_BSEC STRUCTURE BSEC
*" T_BSED STRUCTURE BSED
*" T_BSEG STRUCTURE BSEG
*" T_BSET STRUCTURE BSET
*" T_BSEU STRUCTURE BSEU
*"------------------------------------------------------------------
 
CHECK t_bkpf-blart = 'AG'.
 
TYPES: BEGIN OF agorum,
id TYPE c LENGTH 10,
name TYPE c LENGTH 100,
END OF agorum.
 
DATA: lo_client TYPE REF TO if_http_client,
lv_result_url TYPE string,
jdata TYPE string,
e_jdata TYPE string,
lv_bin TYPE xstring,
lo_conv TYPE REF TO cl_abap_conv_in_ce,
lv_response TYPE string,
lv_conf TYPE string,
itab TYPE TABLE OF smum_xmltb,
wa LIKE LINE OF itab,
gt_return TYPE TABLE OF bapiret2,
session(30) TYPE c.
 
DATA: itabres TYPE TABLE OF agorum,
wares LIKE LINE OF itabres,
zaehler TYPE i.
 
cl_http_client=>create(
EXPORTING
host = 'roihost'
service = '81'
scheme = 1
IMPORTING
client = lo_client ).
 
lo_client->request->set_method( if_http_request=>co_request_method_post ).
 
CONCATENATE '/api/rest/session?'
'username=Demo&password=Gast'
INTO
lv_result_url.
 
cl_http_utility=>set_request_uri( request = lo_client->request uri = lv_result_url ).
 
lo_client->send( ).
lo_client->receive( ).
 
lv_bin = lo_client->response->get_data( ).
 
CALL FUNCTION 'SMUM_XML_PARSE'
EXPORTING
xml_input = lv_bin
TABLES
xml_table = itab
return = gt_return.
 
LOOP AT itab INTO wa.
IF wa-cname = 'sessionId'.
session = wa-cvalue.
ENDIF.
ENDLOOP.
 
CONCATENATE '/api/rest/object?provider=search&'
'query=' t_bkpf-bktxt '&properties=name&sessionId='
session
INTO
lv_result_url.
 
lo_client->request->set_method( if_http_request=>co_request_method_get ).
 
cl_http_utility=>set_request_uri( request = lo_client->request uri = lv_result_url ).
 
lo_client->send( ).
lo_client->receive( ).
 
lv_bin = lo_client->response->get_data( ).
 
CALL FUNCTION 'SMUM_XML_PARSE'
EXPORTING
xml_input = lv_bin
TABLES
xml_table = itab
return = gt_return.
 
LOOP AT itab INTO wa.
IF wa-cname = 'value'.
wares-name = wa-cvalue.
MOVE t_bkpf-xblnr TO wares-id.
APPEND wares TO itabres.
ENDIF.
ENDLOOP.
 
* Notiz schreiben und senden
 
CONCATENATE '{ "target":"'
t_bkpf-bktxt
'","sessionid":"'
session
'","content":"SAP Buchung von \n '
sy-uname '- ' sy-datum ' \n '
'Belegnummer \n ' t_bkpf-belnr ' \n '
'Buchungskreis \n ' t_bkpf-bukrs ' \n '
'Geschaeftsjahr \n ' t_bkpf-gjahr ' \n '
'Buchungsdatum \n ' t_bkpf-budat '"'
',"recipients":["user:Demo"] }'
INTO
jdata .
 
CALL METHOD cl_http_utility=>escape_url
EXPORTING
unescaped = jdata
RECEIVING
escaped = e_jdata.
 
CONCATENATE '/api/rest/object?handler=note&data='
e_jdata
INTO
lv_result_url.
 
lo_client->request->set_method( if_http_request=>co_request_method_post ).
 
cl_http_utility=>set_request_uri( request = lo_client->request uri = lv_result_url ).
 
lo_client->send( ).
lo_client->receive( ).
* ****************************************************************
lo_client->close( ).
* MESSAGE s000(zago) WITH wares-name.
CLEAR itab.
CLEAR itabres.
CLEAR gt_return.
 
ENDFUNCTION.