Skip to content

Commit dcadbaf

Browse files
authored
Merge branch 'master' into master
2 parents 9c6b2f1 + de456b5 commit dcadbaf

File tree

8,355 files changed

+48035
-89594
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

8,355 files changed

+48035
-89594
lines changed

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,7 @@ Thumbs.db
4545

4646
# validation files #
4747
######################
48-
rules.vr
48+
# VSCode specific files
49+
*.vr
50+
*.code-workspace
51+

.reuse/dep5

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
2+
Upstream-Name: Tutorials
3+
Upstream-Contact: Joshua Margo ([email protected])
4+
Source: https://github.com/sap-tutorials/Tutorials
5+
6+
Files: *
7+
Copyright: 2022 SAP SE or an SAP affiliate company and https://github.com/sap-tutorials/Tutorials contributors
8+
License: CC-BY-4.0

LICENSE.txt

Lines changed: 395 additions & 233 deletions
Large diffs are not rendered by default.

LICENSES/CC-BY-4.0.txt

Lines changed: 156 additions & 0 deletions
Large diffs are not rendered by default.

MaddiesTutorials.code-workspace

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"folders": [
3+
{
4+
"path": "."
5+
},
6+
{
7+
"path": "../Tutorials-Contribution"
8+
}
9+
],
10+
"settings": {
11+
"githubPullRequests.ignoredPullRequestBranches": [
12+
"master"
13+
]
14+
}
15+
}

README.MD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
[![Circle CI](https://circleci.com/gh/SAPDocuments/Tutorials.svg?style=svg)](https://circleci.com/gh/SAPDocuments/Tutorials)
22
[![devDependency Status](https://david-dm.org/SAPDocuments/Tutorials/dev-status.svg)](https://david-dm.org/SAPDocuments/Tutorials?type=dev)
3+
[![REUSE status](https://api.reuse.software/badge/github.com/sap-tutorials/Tutorials)](https://api.reuse.software/info/github.com/sap-tutorials/Tutorials)
34

45
# Tutorials for https://developers.sap.com
56
Welcome to the Markdown tutorial catalog for tutorials you can find on the [SAP developer pages](https://developers.sap.com) here: <https://developers.sap.com/tutorial-navigator.html>.

lpentitlement.png

101 KB
Loading

tutorials/abap-connectivity-daemon-mqtt-bridge/abap-connectivity-daemon-mqtt-bridge.md

Lines changed: 28 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,34 @@
11
---
2-
title: Forward MQTT and AMC Messages Using an ABAP Daemon
3-
description: Forward MQTT and AMC Messages using an ABAP Daemon.
2+
parser: v2
43
auto_validation: true
54
primary_tag: topic>abap-development
65
tags: [ tutorial>intermediate, topic>abap-development ]
76
---
87

9-
### Prerequisites
8+
# Forward MQTT and AMC Messages Using an ABAP Daemon
9+
<!-- description --> Forward MQTT and AMC Messages using an ABAP Daemon.
10+
11+
## Prerequisites
1012
- The ABAP MQTT Client is available on **ABAP Platform 1809** and above.
1113
- You need to use **ABAP Development Tools**.
1214

13-
## Details
14-
### You will learn
15+
16+
## You will learn
1517
- How to use ABAP Messaging Channels (AMC)
1618
- How to combine MQTT, AMC and ABAP Daemons
1719

1820

1921

20-
### Time to Complete
22+
## Time to Complete
2123
**25 Min**.
2224

2325
---
2426

27+
## Intro
2528
In this tutorial, you will create an ABAP Daemon that should act as a bi-directional protocol converter between MQTT and AMC. The daemon should receive MQTT messages, convert them to PCP messages, and forward them via an ABAP Messaging Channel (AMC) to other applications. Forwarding also works in the reverse direction.
2629

27-
[ACCORDION-BEGIN [Step 1: ](Create an ABAP Daemon class)]
30+
### Create an ABAP Daemon class
31+
2832
Create a new ABAP class **`ZCL_TUTORIAL_MQTT_DAEMON`** extending the base class `CL_ABAP_DAEMON_EXT_BASE`.
2933

3034
As you can see, there is an error in line 1 since the necessary abstract methods have not been implemented yet. Click on the light bulb next to the line number and select **Add 9 unimplemented methods** to resolve this:
@@ -39,10 +43,9 @@ DATA: mv_subscription_topic TYPE string,
3943
```
4044
You will need them later.
4145

42-
[DONE]
43-
[ACCORDION-END]
4446

45-
[ACCORDION-BEGIN [Step 2: ](Create an ABAP Messaging Channel)]
47+
### Create an ABAP Messaging Channel
48+
4649
Create a new ABAP Messaging Channel (AMC). To do so, click on **File** > **New** > **Other...** or press **`Ctrl+N`**.
4750

4851
In the popup window, select **ABAP** > **Connectivity** > **ABAP Messaging Channel Application** or simply search for it.
@@ -65,9 +68,8 @@ Specify further details regarding the channel. Select **`Client`** as the *Activ
6568

6669
Finally, **activate your AMC Application** by pressing **`Ctrl+F3`**.
6770

68-
[DONE]
69-
[ACCORDION-END]
70-
[ACCORDION-BEGIN [Step 3: ](Implement ABAP Daemon events)]
71+
### Implement ABAP Daemon events
72+
7173

7274
>The implementation of the events `ON_ACCEPT`, `ON_START` and `ON_STOP` is based on the tutorial [**Create a Simple ABAP Daemon**](abap-connectivity-daemon-simple). If you need further information regarding these events, check out the tutorial or take a look at the [official documentation](https://help.sap.com/viewer/753088fc00704d0a80e7fbd6803c8adb/1709.001/en-US/311af9b769d84fffa7b7384bae27109c.html).
7375
@@ -150,10 +152,9 @@ METHOD if_abap_daemon_extension~on_stop.
150152
ENDMETHOD.
151153
```
152154

153-
[DONE]
154-
[ACCORDION-END]
155155

156-
[ACCORDION-BEGIN [Step 4: ](Implement static methods)]
156+
### Implement static methods
157+
157158
In this step, you will create two static methods `START` and `STOP`. They are used to instantiate and terminate your ABAP Daemon and will be called by another ABAP Program.
158159

159160
At first, define the methods by inserting the following code into the `PUBLIC SECTION` in the class definition of your ABAP Daemon class:
@@ -215,9 +216,8 @@ METHOD stop.
215216
ENDMETHOD.
216217
```
217218

218-
[DONE]
219-
[ACCORDION-END]
220-
[ACCORDION-BEGIN [Step 5: ](Handle incoming MQTT messages)]
219+
### Handle incoming MQTT messages
220+
221221

222222
Your ABAP Daemon will process each incoming MQTT message by simply forwarding it to the ABAP Messaging Channel.
223223

@@ -254,9 +254,8 @@ METHOD if_mqtt_event_handler~on_message.
254254
ENDMETHOD.
255255
```
256256

257-
[DONE]
258-
[ACCORDION-END]
259-
[ACCORDION-BEGIN [Step 6: ](Handle AMC messages)]
257+
### Handle AMC messages
258+
260259
As your ABAP Daemon shall also receive AMC messages, you will need to add another interface to your class definition:
261260
```ABAP
262261
INTERFACES if_amc_message_receiver_pcp.
@@ -284,10 +283,9 @@ METHOD if_amc_message_receiver_pcp~receive.
284283
ENDMETHOD.
285284
```
286285

287-
[DONE]
288-
[ACCORDION-END]
289286

290-
[ACCORDION-BEGIN [Step 7: ](Run the ABAP Daemon)]
287+
### Run the ABAP Daemon
288+
291289
**Activate your ABAP Daemon class by pressing `Ctrl+F3`.**
292290

293291
To run the ABAP Daemon, create a new ABAP Program **`Z_TUTORIAL_MQTT_DAEMON_START`** that contains the following line:
@@ -300,10 +298,9 @@ zcl_tutorial_mqtt_daemon=>start( iv_daemon_name = 'mqtt_daemon' iv_subscription_
300298

301299
> Your daemon should now be running in the background. You can check this in the transaction `SMDAEMON`.
302300
303-
[DONE]
304-
[ACCORDION-END]
305301

306-
[ACCORDION-BEGIN [Step 8: ](Prepare interaction with the ABAP Daemon)]
302+
### Prepare interaction with the ABAP Daemon
303+
307304
In this step, you will create two programs to test the functionality of your ABAP Daemon.
308305

309306
Create an ABAP Program **`Z_TUTORIAL_MQTT_DAEMON_SEND`**, which should send a message to the ABAP Messaging Channel to trigger the forwarding mechanism from AMC to MQTT. Copy the implementation below into this new program:
@@ -384,10 +381,9 @@ As these two programs will need to access your ABAP Messaging Channel, make sure
384381

385382
![Add authorized programs to the ABAP Messaging Channel](add-authorized-programs.png)
386383

387-
[DONE]
388-
[ACCORDION-END]
389384

390-
[ACCORDION-BEGIN [Step 9: ](Interact with the ABAP Daemon)]
385+
### Interact with the ABAP Daemon
386+
391387

392388
Use the [HiveMQ Websocket Client](http://www.hivemq.com/demos/websocket-client/) to subscribe to the MQTT topic `abaptopic/tutorial/publish` as you can see in the image below:
393389

@@ -413,5 +409,4 @@ This triggers the forwarding process and your ABAP class will output the receive
413409

414410
![The forwarded MQTT message was received via the AMC](console-received-message.png)
415411

416-
[VALIDATE_1]
417-
[ACCORDION-END]
412+

tutorials/abap-connectivity-daemon-simple/abap-connectivity-daemon-simple.md

Lines changed: 31 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,33 @@
11
---
2-
title: Create a Simple ABAP Daemon
3-
description: Learn how to create ABAP Daemons and interact with them using PCP messages.
2+
parser: v2
43
auto_validation: true
54
primary_tag: topic>abap-development
65
tags: [ tutorial>intermediate, topic>abap-development ]
76
---
87

8+
# Create a Simple ABAP Daemon
9+
<!-- description --> Learn how to create ABAP Daemons and interact with them using PCP messages.
10+
911
## Prerequisites
1012
- Your system needs to be based on **SAP NetWeaver 7.52** or higher.
1113
- You need to use **ABAP Development Tools**.
1214

13-
## Details
14-
### You will learn
15+
## You will learn
1516
- How to create and run an ABAP Daemon
1617
- How to send PCP messages to an ABAP Daemon
1718

18-
19-
### Introduction to ABAP Daemons
19+
## Introduction to ABAP Daemons
2020
ABAP Daemons are provided by the ABAP Daemon Framework (ADF). They are used to handle events in a reliable way by running in sessions with unlimited lifetime. ABAP programs can communicate with the daemons by sending messages to them using ABAP Messaging Channels and message type Push Channel Protocol.
2121

22+
## Intro
2223
You can make yourself more familiar with the ABAP Daemon Framework by reading the [official documentation](https://help.sap.com/viewer/753088fc00704d0a80e7fbd6803c8adb/1709.001/en-US/311af9b769d84fffa7b7384bae27109c.html).
2324

2425
> **Push Channel Protocol (PCP)** is a communications format similar to a simple HTTP message. It consists of header fields (name-value pairs) for metadata and a message body. For further information, have a look at the [Specification of the Push Channel Protocol](https://blogs.sap.com/2015/07/27/specification-of-the-push-channel-protocol-pcp/).
25-
26-
### Time to Complete
26+
## Time to Complete
2727
**20 Min**.
2828

29-
[ACCORDION-BEGIN [Step 1: ](Create a new ABAP Daemon class)]
29+
### Create a new ABAP Daemon class
30+
3031
ABAP Daemons are instances of an ABAP Daemon class that extend the base class `CL_ABAP_DAEMON_EXT_BASE`.
3132

3233
First, create a new ABAP class `ZCL_TUTORIAL_SIMPLE_DAEMON` and set `CL_ABAP_DAEMON_EXT_BASE` as its superclass.
@@ -35,10 +36,9 @@ As you can see there is an error in line 1 since the necessary abstract methods
3536

3637
![Add unimplemented methods in ABAP Development Tools](add-unimplemented-methods.png)
3738

38-
[DONE]
39-
[ACCORDION-END]
4039

41-
[ACCORDION-BEGIN [Step 2: ](Implement ON_ACCEPT method)]
40+
### Implement ON_ACCEPT method
41+
4242
Before a new instance of the ABAP Daemon class can be created, its `ON_ACCEPT` method is called to determine if the daemon should start.
4343

4444
Replace your `ON_ACCEPT` method with the following code. It accepts all start requests from your own class and rejects all requests from any other program. This is achieved by checking the calling program that initiated the start.
@@ -61,11 +61,10 @@ METHOD if_abap_daemon_extension~on_accept.
6161
ENDMETHOD.
6262
```
6363

64-
[DONE]
65-
[ACCORDION-END]
6664

6765

68-
[ACCORDION-BEGIN [Step 3: ](Implement ON_START method)]
66+
### Implement ON_START method
67+
6968
To start the ABAP Daemon, the `ON_START` method is executed.
7069

7170
You can include a PCP message containing arbitrary startup parameters which can be accessed in the `ON_START` method.
@@ -97,10 +96,9 @@ ENDMETHOD.
9796
```
9897
> **CAUTION!** Please add your own exception handling for productive applications as this has not been included in this simple tutorial.
9998
100-
[DONE]
101-
[ACCORDION-END]
10299

103-
[ACCORDION-BEGIN [Step 4: ](Implement ON_TIMEOUT method)]
100+
### Implement ON_TIMEOUT method
101+
104102
While your ABAP Daemon is running in the background, the `ON_TIMEOUT` method will be triggered when the timeout elapses. Therefore, you need to implement a handler interface. Add this code to the `PUBLIC SECTION` of your class:
105103
```ABAP
106104
INTERFACES if_abap_timer_handler.
@@ -131,10 +129,9 @@ METHOD if_abap_timer_handler~on_timeout.
131129
ENDMETHOD.
132130
```
133131

134-
[DONE]
135-
[ACCORDION-END]
136132

137-
[ACCORDION-BEGIN [Step 5: ](Implement ON_MESSAGE method)]
133+
### Implement ON_MESSAGE method
134+
138135
You can also send PCP messages to your daemon while it is continuously running in the background. The `ON_MESSAGE` method will be called every time the daemon receives a PCP message.
139136

140137
In this tutorial, you will send a plain text to the daemon, which then will be shown in a popup message. As a real life example, you could imagine the ABAP Daemon receiving live data from a sensor and sending a notification under certain conditions.
@@ -158,10 +155,9 @@ METHOD if_abap_daemon_extension~on_message.
158155
ENDMETHOD.
159156
```
160157

161-
[DONE]
162-
[ACCORDION-END]
163158

164-
[ACCORDION-BEGIN [Step 6: ](Implement the static method START)]
159+
### Implement the static method START
160+
165161
> Since the security concept of ABAP Daemons is based on "source code authorization" (see documentation), i.e. only the program (e.g. a class) which starts the daemon has the right to send messages to the daemon or to stop it. For simplicity reasons we use the daemon class to implement the start, stop and send functionalities for the daemon to access them from different programs.
166162
167163
This simple ABAP Daemon will be started by a static method. Thus, you need to create a new method `START` in your daemon class with two import parameters:
@@ -198,10 +194,9 @@ METHOD start.
198194
ENDMETHOD.
199195
```
200196

201-
[DONE]
202-
[ACCORDION-END]
203197

204-
[ACCORDION-BEGIN [Step 7: ](Implement the static method SEND)]
198+
### Implement the static method SEND
199+
205200
Implement a static method `SEND` which will be used to send text to the daemon and therefore trigger its `ON_MESSAGE` method. The method will need the following importing parameters:
206201

207202
- `IV_DAEMON_NAME`: The name of the daemon that will receive the message.
@@ -244,10 +239,9 @@ METHOD send.
244239
ENDMETHOD.
245240
```
246241

247-
[DONE]
248-
[ACCORDION-END]
249242

250-
[ACCORDION-BEGIN [Step 8: ](Run the ABAP Daemon)]
243+
### Run the ABAP Daemon
244+
251245
**Congratulations, you have now created your first ABAP Daemon class!
252246
Activate it by pressing `Ctrl+F3`.**
253247

@@ -265,10 +259,9 @@ You should see a popup notification every 10 seconds:
265259

266260
![Popup message from an ABAP Daemon](popup-timeout.png)
267261

268-
[DONE]
269-
[ACCORDION-END]
270262

271-
[ACCORDION-BEGIN [Step 9: ](Send messages to the ABAP Daemon)]
263+
### Send messages to the ABAP Daemon
264+
272265
In addition to the timeout, you can trigger a popup message manually by calling the static `SEND` method. Create another ABAP Program `Z_TUTORIAL_SIMPLE_DAEMON_SEND` with the following content:
273266

274267
```abap
@@ -282,10 +275,9 @@ Feel free to change the message text in line 1. After activating and executing t
282275

283276
> **If you do not receive any message:** Make sure your daemon has been started previously in step 8. The daemon will keep running even after the popup messages stop.
284277
285-
[DONE]
286-
[ACCORDION-END]
287278

288-
[ACCORDION-BEGIN [Step 10: ](Stop the ABAP Daemon)]
279+
### Stop the ABAP Daemon
280+
289281
You can monitor all running ABAP Daemons using transaction `SMDAEMON` in SAPGUI. There you can see their state, check for errors, and also restart and terminate them.
290282

291283
To stop your daemon, select it from the list and go to **ABAP Daemon** > **Terminate Daemon**.
@@ -328,16 +320,14 @@ from any ABAP Program.
328320

329321
> For further information on ABAP Daemons, see the [ABAP Daemons documentation](https://help.sap.com/viewer/753088fc00704d0a80e7fbd6803c8adb/1709.001/en-US/311af9b769d84fffa7b7384bae27109c.html).
330322
331-
[DONE]
332-
[ACCORDION-END]
333323

334-
[ACCORDION-BEGIN [Step 11: ](Test your application)]
324+
### Test your application
325+
335326

336327
Start your daemon using the following line of code. Note that the daemon name is now significantly longer and the timeout is negative.
337328

338329
```ABAP
339330
zcl_tutorial_simple_daemon=>start( iv_daemon_name = 'does_the_daemon_start_up_if_you_use_this_as_your_daemon_name' iv_timeout = -10000 ).
340331
```
341332

342-
[VALIDATE_1]
343-
[ACCORDION-END]
333+

0 commit comments

Comments
 (0)