Skip to content

Commit

Permalink
metrics delete prog depending on timestamp added (abap-observability-…
Browse files Browse the repository at this point in the history
…tools#155)

* metrics delete prog depending on timestamp added

* store del prog: exlipzit timestamp declaration
  • Loading branch information
JohannesKonings authored Feb 13, 2021
1 parent 2c5250d commit 1c7727c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/zamp_store/zamp_clear_zamp_store.prog.abap
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,28 @@ TABLES zamp_store.
SELECT-OPTIONS scenario FOR zamp_store-metric_scenario.
SELECT-OPTIONS group FOR zamp_store-metric_group.
SELECT-OPTIONS key FOR zamp_store-metric_key.
PARAMETERS date TYPE dats OBLIGATORY DEFAULT sy-datum.
PARAMETERS time TYPE tims OBLIGATORY DEFAULT sy-uzeit.

DATA metric_last_run TYPE zamp_store-metric_last_run.

START-OF-SELECTION.

IF NEW zcl_amp_auth_checker( )->is_deleting_allowed( ) = abap_true.

DATA tz TYPE timezone.

CALL FUNCTION 'GET_SYSTEM_TIMEZONE'
IMPORTING
timezone = tz.

CONVERT DATE date TIME time INTO TIME STAMP metric_last_run TIME ZONE tz.

DELETE FROM zamp_store
WHERE metric_scenario IN @scenario
AND metric_group IN @group
AND metric_key IN @key.
AND metric_key IN @key
AND metric_last_run < @metric_last_run.
IF sy-subrc = 0.
WRITE |{ sy-dbcnt } entries deleted|.
ELSE.
Expand Down
12 changes: 12 additions & 0 deletions src/zamp_store/zamp_clear_zamp_store.prog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@
<ENTRY>Clear ZAMP_STORE</ENTRY>
<LENGTH>16</LENGTH>
</item>
<item>
<ID>S</ID>
<KEY>DATE</KEY>
<ENTRY>delete before date</ENTRY>
<LENGTH>26</LENGTH>
</item>
<item>
<ID>S</ID>
<KEY>GROUP</KEY>
Expand All @@ -37,6 +43,12 @@
<LENGTH>9</LENGTH>
<SPLIT>D</SPLIT>
</item>
<item>
<ID>S</ID>
<KEY>TIME</KEY>
<ENTRY>delete before time</ENTRY>
<LENGTH>26</LENGTH>
</item>
</TPOOL>
</asx:values>
</asx:abap>
Expand Down

0 comments on commit 1c7727c

Please sign in to comment.