Application Development Blog Posts
Learn and share on deeper, cross technology development topics such as integration and connectivity, automation, cloud extensibility, developing at scale, and security.
cancel
Showing results for 
Search instead for 
Did you mean: 
JK
Contributor

Scenario: Your Boss says you are getting your HANA Server as a christmas present, under the condition you provide a real-time cockpit for some KPIs from your production ERP by tonight.

Mission Impossible?

i guess you don't have a preinstalled HANA-Live with the KPI Framework(and also no Hana yet), Fiori, UI5 Framework, ADT on Eclipse or Hana Studio and maybe your javascript skills are not yet up to date

but you still can trust on good old ABAP (Screens)

you only use Old-Fashioned SE80 and after a few clicks, you (auto-refreshing) Dasboard looks like a fiori launchpad with 'smart' tiles, where the numbers in the box represent the actual kpi, the screen is auto-refreshed and also works with webgui. a double click on the kpi is calling the transaction with the details

(as i use SAPGUI 7.40 with BlueCrystal Design, you have the fiori-style icons)

so what's the task?

create a report with a screen:

REPORT Z_MY_DASHBOARD.
DATA : ob_timer  TYPE REF TO cl_gui_timer .

data: lv_error_01 type i, lv_warning_01 type i.
data: lv_error_02 type i, lv_warning_02 type i.
data: frame01(30).
data: frame02(30).
data: number01 type i.
data: number02 type i.
data: icon01(50).
data: icon02(50).
data: it_session_list type  SSI_SESSION_LIST.
data: it_worker_list type SSI_WORKER_LIST.
data: lo_server_info type ref to cl_server_info.
create object lo_server_info.


class lcl_event_handler definition.

public section.

class-methods: on_finished for event finished of cl_gui_timer.

endclass.                    "lcl_event_handler DEFINITION

class lcl_event_handler implementation.

method on_finished.

perform get_data.
ob_timer
->run( ) .
*cause PAI
call method cl_gui_cfw=>set_new_ok_code
EXPORTING
new_code
= 'REFRESH'.

endmethod.                    "on_finished

endclass.                    "lcl_event_handler IMPLEMENTATION


start-of-selection.
*   Initialise object CL_GUI_TIMER.
data: event_handler type ref to lcl_event_handler.
CREATE OBJECT ob_timer .
create object event_handler .
*   Bind event handling method to object of CL_GUI_TIMER
*    SET HANDLER timer_event FOR ob_timer .
set handler  event_handler->on_finished for ob_timer.

*   Set interval for timer
ob_timer
->interval = 10.

*   Call method RUN of CL_GUI_TIMER.
ob_timer
->run( ) .


perform get_data.

call screen 0100.

*----------------------------------------------------------------------*
***INCLUDE Z_MY_DASHBOARD_STATUS_0100O01.
*----------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*&      Module  STATUS_0100  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE STATUS_0100 OUTPUT.
SET PF-STATUS 'MAIN'.
*  SET TITLEBAR 'xxx'.
ENDMODULE.                 " STATUS_0100  OUTPUT


MODULE USER_COMMAND_0100 INPUT.

data: lv_field(50).

case sy-ucomm.
when 'EXIT' or 'CANC' or 'BACK'.
leave program.
when 'SELE'.
* Double Click for Navigation/Drill Down

GET CURSOR FIELD lv_field.
if lv_field cp '*01'.
call transaction 'VF04'.
elseif lv_field cp '*02'.
call transaction 'SM04'.
endif.

endcase.
ENDMODULE.                 " USER_COMMAND_0100  INPUT

form get_data.


FRAME01 = 'Amount Billing Due List'.
FRAME02
= 'Logged in Sessions'.

* KPI 1:
select sum( netwr ) from vkdfs
*    connection dbco-con_name "for sidecar/hana live
into number01. "where fkdat le sy-datum.


* KPI 2:

CALL METHOD lo_SERVER_INFO->GET_SESSION_LIST
*  EXPORTING
*    WITH_APPLICATION_INFO = 1
*    TENANT                = ''
RECEIVING
SESSION_LIST         
= it_session_list
.
describe table it_session_list lines number02.

* For SM50/Processes:

*CALL METHOD lo_SERVER_INFO->GET_WORKER_LIST


perform get_icon using number01 lv_warning_01 lv_error_01 icon01.
perform get_icon using number02 lv_warning_02 lv_error_02 icon02.
endform.
 
form get_icon using number warning error icon.

if number > error.
data: lv_icon(50).
CALL FUNCTION 'ICON_CREATE'
EXPORTING
name  
= 'ICON_RED_LIGHT'
*      text   = 'Refresh'
*      info   = 'Refresh Monitor Status'
IMPORTING
RESULT
= lv_icon
EXCEPTIONS
OTHERS = 0.
else.
if number > warning.
CALL FUNCTION 'ICON_CREATE'
EXPORTING
name  
= 'ICON_YELLOW_LIGHT'
*      text   = 'Refresh'
*      info   = 'Refresh Monitor Status'
IMPORTING
RESULT
= lv_icon
EXCEPTIONS
OTHERS = 0.
else.

CALL FUNCTION 'ICON_CREATE'
EXPORTING
name  
= 'ICON_GREEN_LIGHT'
*      text   = 'Refresh'
*      info   = 'Refresh Monitor Status'
IMPORTING
RESULT
= lv_icon
EXCEPTIONS
OTHERS = 0.
endif.
endif.
ICON = lv_icon.

endform.

Screen:

PROCESS BEFORE OUTPUT.
MODULE STATUS_0100.

PROCESS AFTER
INPUT.
MODULE USER_COMMAND_0100.



thats it -> welcome to simple smart business



of course its all hardcoded, but maybe your boss gives you some time till tomorrow to add a control table (/NSE11)

similar to

framenr
, "Frame Number 01, 02 etc
text type text50, "Frame Description
db_con
type dbcon-con_name, "Database connection for Hana Live/Sidecar
sql_statement
type string, "SQL Statement with Placeholders
class type char50, "or Name of an ABAP Class that retrieves the KPI as a Returning Parameter called RESULT
warning
type int4, "show Yellow Icon if value higher 
error
type int4,   "show red light if value higher
symbol type char50,"ICON Name

last_value type char 50, "(if youre not having hana you can use a periodic job to update kpi here)

christmas wish list: which kpis your boss likes to have?


-> definitely look at the new OPEN SQL Syntax for realtime-database-calculations on the fly (also for Non-Hana DB):  http://help.sap.com/abapdocu_740/en/index.htm?file=ABENNEWS-740_SP05-OPEN_SQL.htm



after that you should get your christmas hana present and start doing the real thing!



3 Comments