Jerry has written this tool for support colleague in Zeiss to enable them to conveniently check a given OData Model cache status at any time.
How to use
執行report,輸入OData model name和metadata 實作class name:
執行report,可在debuger裡檢視該model的所有cache資料(如果cache确實存在):
并列印model class 最後修改的時間戳:
源代碼分享給大家:
REPORT tool_gateway_model_cache_view.
PARAMETERS: cls TYPE seoclsname OBLIGATORY DEFAULT 'CL_CRM_OPPORTUNITY_MPC_EXT',
name TYPE /iwbep/med_mdl_technical_name OBLIGATORY DEFAULT 'CRM_OPPORTUNITY'.
DATA: ls_data TYPE /iwbep/if_mgw_med_odata_types=>ty_s_med_model,
lv_found TYPE abap_bool,
lv_lastchange TYPE timestamp,
lv_timezone TYPE tzonref-tzone,
lv_include_name TYPE program,
lv_sdate TYPE rdir_sdate, " Standard selection screen generation: Date
lv_stime TYPE rdir_stime.
CALL FUNCTION 'GET_SYSTEM_TIMEZONE'
IMPORTING
timezone = lv_timezone
EXCEPTIONS
OTHERS = 0. " initial lv_timezone means UTC in CONVERT ...
lv_include_name = cl_oo_classname_service=>get_classpool_name( clsname = cls ). "Is enough for last_modified
SELECT SINGLE sdate stime
FROM reposrc
INTO (lv_sdate, lv_stime)
WHERE progname = lv_include_name
AND r3state = 'A'.
* Create timestamp
CONVERT DATE lv_sdate TIME lv_stime INTO TIME STAMP lv_lastchange TIME ZONE lv_timezone.
CALL METHOD /iwbep/cl_mgw_med_utils=>get_cached_model
EXPORTING
iv_last_modified = lv_lastchange
iv_version = '0001'
iv_technical_name = name
es_model_data = ls_data
ev_found = lv_found.
WRITE: / 'Cache found? : ' , lv_found COLOR COL_NEGATIVE, ' name: ' , ls_data-header-ext_model_tname COLOR COL_GROUP,
' last changed' , ls_data-header-changed_timestmp COLOR COL_POSITIVE.