Skip to content
This repository has been archived by the owner on Dec 17, 2023. It is now read-only.

Refactor time date passing #49

Merged
merged 1 commit into from
Jan 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions src/amp_collector/zcl_amp_c_workloads.clas.abap
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ CLASS zcl_amp_c_workloads IMPLEMENTATION.
IMPORTING
timezone = tz.

CONVERT TIME STAMP last_run TIME ZONE tz
INTO DATE DATA(date_last_run) TIME DATA(time_last_run).

GET TIME STAMP FIELD DATA(timestamp_current).

CONVERT TIME STAMP timestamp_current TIME ZONE tz
Expand Down
8 changes: 5 additions & 3 deletions src/amp_collector/zif_amp_collector.intf.abap
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@ INTERFACE zif_amp_collector
PUBLIC .

TYPES: BEGIN OF metric,
metric_key TYPE zamp_store-metric_key,
metric_value TYPE zamp_store-metric_value,
metric_key TYPE zamp_store-metric_key,
metric_value TYPE zamp_store-metric_value,
END OF metric.

TYPES metrics TYPE STANDARD TABLE OF metric WITH KEY metric_key.

METHODS get_metrics
IMPORTING
last_run type zamp_store-metric_last_run
last_run TYPE zamp_store-metric_last_run
date_last_run TYPE d
time_last_run TYPE t
RETURNING VALUE(metrics) TYPE metrics.

ENDINTERFACE.
8 changes: 8 additions & 0 deletions src/zamp_clear_zamp_store.prog.abap
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
*&---------------------------------------------------------------------*
*& Report zamp_clear_zamp_store
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT zamp_clear_zamp_store.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can extend that in the future to a admin report e.g. delete for specific scenarios.
We should also think about what can be the dangers to run such a program in production :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We may also remove it later when the zamp_store is in a solid state.
I created an issue for that topic (https://github.com/Goala/abap-metrics-provider/issues/51)


DELETE FROM zamp_store.
22 changes: 22 additions & 0 deletions src/zamp_clear_zamp_store.prog.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<abapGit version="v1.0.0" serializer="LCL_OBJECT_PROG" serializer_version="v1.0.0">
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
<asx:values>
<PROGDIR>
<NAME>ZAMP_CLEAR_ZAMP_STORE</NAME>
<DBAPL>S</DBAPL>
<SUBC>1</SUBC>
<FIXPT>X</FIXPT>
<LDBNAME>D$S</LDBNAME>
<UCCHECK>X</UCCHECK>
</PROGDIR>
<TPOOL>
<item>
<ID>R</ID>
<ENTRY>Clear ZAMP_STORE</ENTRY>
<LENGTH>16</LENGTH>
</item>
</TPOOL>
</asx:values>
</asx:abap>
</abapGit>
59 changes: 52 additions & 7 deletions src/zcl_amp_strategist.clas.abap
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,19 @@ CLASS zcl_amp_strategist DEFINITION
PROTECTED SECTION.
PRIVATE SECTION.

METHODS get_last_run
IMPORTING
scenario TYPE zamp_scenario
metric_group_name TYPE zamp_store-metric_group
RETURNING VALUE(last_run) TYPE zamp_store-metric_last_run.

METHODS extract_date_time
IMPORTING
timestamp TYPE zamp_store-metric_last_run
EXPORTING
date TYPE d
time TYPE t.

ENDCLASS.


Expand All @@ -29,14 +42,21 @@ CLASS zcl_amp_strategist IMPLEMENTATION.

CREATE OBJECT metric_collector TYPE (<metric_collector>-metric_class).

SELECT metric_last_run
FROM zamp_store
WHERE zamp_store~metric_scenario = @scenario
AND zamp_store~metric_group = @<metric_collector>-metric_group_name
INTO @DATA(last_run) UP TO 1 ROWS.
ENDSELECT.
DATA(last_run) = me->get_last_run( scenario = scenario
metric_group_name = <metric_collector>-metric_group_name ).

me->extract_date_time(
EXPORTING
timestamp = last_run
IMPORTING
date = DATA(date)
time = DATA(time)
).

collector_metrics = metric_collector->get_metrics( last_run = last_run
date_last_run = date
time_last_run = time ).

collector_metrics = metric_collector->get_metrics( last_run ).

GET TIME STAMP FIELD DATA(ts).

Expand All @@ -53,6 +73,31 @@ CLASS zcl_amp_strategist IMPLEMENTATION.
ENDLOOP.

MODIFY zamp_store FROM TABLE metrics_total.

ENDMETHOD.

METHOD get_last_run.

SELECT metric_last_run
FROM zamp_store
WHERE zamp_store~metric_scenario = @scenario
AND zamp_store~metric_group = @metric_group_name
INTO @last_run UP TO 1 ROWS.
ENDSELECT.

ENDMETHOD.

METHOD extract_date_time.

DATA tz TYPE timezone.

CALL FUNCTION 'GET_SYSTEM_TIMEZONE'
IMPORTING
timezone = tz.

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

ENDMETHOD.

ENDCLASS.