for a small sidecar Scenario i replicated some abap tables into hana
as i did not want to install the DMIS Addon on the source System, i decided to use the (Non-SAP) DB Replication Mode as Source and Hana DB Connection as target
so i have a separate SLT Server, but no Installation on the source system
i think there are more features using DMIS Addon (like Mapping etc) but for what i needed this works fine.
then i created a db Connection in DBCO from SOURCE ABAP System to the Hana Database, giving me the Option of
using SELECT CONNECTION Statement in ABAP in order to read the Hana Tables.
now i can just use the existing select Statements in my abap Report and add the Connection parameter
i did a customizing table with the Name of the database Connection and a flag wether hana should be used or not
what i now wanted to do is:
if hana sidecar is available and latency is fine, use hana tables, if for whatever reason hana is not available, use legacy relational database
so i can use a non-productive hana as a sidecar because it is not a spof for my process
first i am checking if the db Connection is ok
TRY.
*...open a remote connection, if not local system
rem_con_ref = cl_sql_connection=>get_connection( con_abap ).
rem_con_ref->close( ).
select single msgguid from sxmspmast into wf_msgguid
connection (con_abap).
CATCH cx_sql_exception. " INTO l_sqlerr_ref.
catch cx_root.
CALL METHOD set_hana_off.
CALL METHOD set_hana_error.
hana_error_message = 'Hana deaktiviert (Fehler DB Verbindung)'.
endtry.
Now i do an RFC Call to the SLT Server to get the Latency Values
data: wa_data like line of data.
data: wf_len type i.
data: wf_guid(22).
data: wa_fields like line of fields.
data: wa_options like line of options.
data: wf_datum like sy-datum.
data: wf_uzeit like sy-uzeit.
data: wf_timestamp TYPE timestampl.
data: wf_char50(50).
data: wf_tzone type timezone value 'CET'.
CALL FUNCTION 'RFC_READ_TABLE'
destination p_rfc
EXPORTING
QUERY_TABLE = 'IUUC_TABLES' "_CONPAR, _MAP, IUUC_RS_STATUS, IUUC_REPL_STAT, IUUC_REPL_LTNCY IUUC_REPL_HDR
* DELIMITER = ' '
* NO_DATA = ' '
* ROWSKIPS = 0
* ROWCOUNT = 0
TABLES
OPTIONS = options[]
FIELDS = fields[]
DATA = data[]
EXCEPTIONS
TABLE_NOT_AVAILABLE = 1
TABLE_WITHOUT_DATA = 2
OPTION_NOT_VALID = 3
FIELD_NOT_VALID = 4
NOT_AUTHORIZED = 5
DATA_BUFFER_EXCEEDED = 6
OTHERS = 7
.
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.
loop at data into wa_data.
write: / wa_data-wa+3(30).
clear wf_len.
loop at fields into wa_fields.
if wa_fields-fieldname <> 'COBJ_GUID'.
add wa_fields-length to wf_len.
else.
exit.
endif.
endloop.
wf_guid = wa_data-wa+wf_len.
refresh: options, fields2, data2.
wa_options-text = 'COBJ_GUID = '.
concatenate wa_options-text '''' into wa_options-text separated by space.
concatenate wa_options-text wf_guid '''' into wa_options-text.
append wa_options to options.
clear wa_options.
concatenate wa_options-text 'AND END_TIME >=' '''' into wa_options-text separated by space.
get time field wf_uzeit.
wf_uzeit = wf_uzeit - p_value.
wf_datum = sy-datum.
*
*
CONVERT DATE wf_datum time wf_uzeit "[TIME tim [DAYLIGHT SAVING TIME dst]]
INTO TIME STAMP wf_timestamp TIME ZONE wf_tzone.
* YYYYMMDDhhmmss
*get time stamp field wf_timestamp.
"?UTC/CET etc
* YYYYMMDDHH24MISS
* YYYYMMDDhhmmss
* time zone wf_tzone.
write: wf_timestamp to wf_char50.condense wf_char50.
replace all OCCURRENCES OF ',' in wf_char50 with ''.
replace all OCCURRENCES OF '.' in wf_char50 with ''.
replace all OCCURRENCES OF ';' in wf_char50 with ''.
*format CL_ABAP_FORMAT=>TS_RAW.
concatenate wa_options-text wf_char50(14) '''' into wa_options-text.
append wa_options to options.
* data : d like sy-datum. ... CONVERT TIME STAMP tstamp TIME ZONE 'UTC' INTO DATE d TIME t.
*Check also fm : 'CIF_GEN3_CONVERT_TIMESTAMP'
CALL FUNCTION 'RFC_READ_TABLE'
destination p_rfc
EXPORTING
QUERY_TABLE = 'IUUC_REPL_LTNCY' "_CONPAR, _MAP, IUUC_RS_STATUS, IUUC_REPL_STAT, IUUC_REPL_LTNCY IUUC_REPL_HDR
* DELIMITER = ' '
* NO_DATA = ' '
* ROWSKIPS = 0
* ROWCOUNT = 0
TABLES
OPTIONS = options[]
FIELDS = fields2[]
DATA = data2[]
EXCEPTIONS
TABLE_NOT_AVAILABLE = 1
TABLE_WITHOUT_DATA = 2
OPTION_NOT_VALID = 3
FIELD_NOT_VALID = 4
NOT_AUTHORIZED = 5
DATA_BUFFER_EXCEEDED = 6
OTHERS = 7
.
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.
data: begin of wa_rec,
guid(22),
Portion(10),
start_time(21),
end_time(21),
min_latency(21),
max_latency(21),
end of wa_rec.
data: wf_max_latency type p decimals 2, wf_min_latency type p decimals 2.
loop at data2 into wa_rec.
wf_timestamp = wa_rec-max_latency .
* write: / 'Latenz:', wa_rec-start_time, wa_rec-end_time, wa_rec-min_latency , wa_rec-max_latency .
if wa_rec-max_latency > wf_max_latency. wf_max_latency = wa_rec-max_latency. endif.
if wa_rec-min_latency > wf_min_latency. wf_min_latency = wa_rec-min_latency. endif.
endloop.
endloop.
if wf_min_latency = 0 and wf_max_latency = 0.
quality = 'VERY_BAD'.
endif.
if wf_max_latency > p_max_latency.
quality = 'POOR'.
endif.