Professional Documents
Culture Documents
Applies to:
SAP BW 3.5. For more information, visit the Business Intelligence homepage.
Summary
This document guides the user to generate an ABAP report on the status of Daily Transaction Data Loads in BW Server, to minimize the time and effort it takes to check several periodic loads in Production server. Author: Mythili Kommu
Author Bio
Mythili Kommu is a NetWeaver 2004s (BI 7) Certified consultant working with Intelligroup Asia Pvt. Ltd, Hyderabad. Has very good working knowledge in ABAP, Worked with SAP modules which include FI-CO, HR, ECC, SEM, APO and EP Application support. She has completed her Masters in Computer Applications (M.C.A) from Osmania University.
Table of Contents
Introduction .........................................................................................................................................................3 Business Scenario ..........................................................................................................................................3
Key Point......................................................................................................................................................................3
Introduction
The purpose of developing this ABAP program Z_DAILY_LOAD_STATUS_REPORT in BW server is to generate daily transaction data load status where there are number of periodic deltas and full loads to check, mainly in the Production server. Business Scenario In typical scenarios/cases when the loads are triggered in the nights or early hours of the day so that the business is not affected; this report minimizes the time and effort it takes to verify and validate the daily/weekly data loads, and all the data/reports are readily available for decision making at start of the business day. This was the case in one of the support projects that I was involved in, where there were several periodic loads triggered every night and in the early hours of the day. Once all the loads were through successfully I had to check the status, fix the errors and record the status of all the Infoproviders to an excel sheet and update it to the client. To overcome this tedious & manual job of documenting, I thought it prudent to automate the process using ABAP; and hence I developed this program which helped me a great deal in cutting down the time & efforts to capture the status of the data loads so that the client is informed before start of the business day. Key Point One distinct advantage of this report is to view the status report of transaction data loads in required time zone This report converts UTC timestamp in the tables (typically in SAP all timestamps are in UTC format) to server time, provided the time zone is specified in the program, and also identify requests with Zero updated records.
Tables Used
Note: Infoproviders, default dates and path (physical and logical) can be modified based on the requirement. Populate field tz with required Server time zone from ttzz table. Example: - tz = 'MSTNO' display timestamp in Mountain Standard Time.
RSICCONT - Monitor: Saving of the updated IC and ODS per request RSSELDONE - Monitor: Selections for executed request RSREQDONE - Monitor: Saving of the QM entries RSMONICTAB - Monitor IC table RSDCUBET - Texts for the InfoCubes RSDODSOT - Texts of ODS objects TADIR - Directory of Repository Objects TTZZ - Time zones
Step-by-Step Procedure for Implementing the Program This program is created in BW server. Text elements and Selection Texts are included in the implementation. STEP 1: Creation of Program Go to TCODE: SE38 Create an executable program Z_DAILY_LOAD_STATUS_REPORT Copy the below code in the Editor and save.
* Frame1 for selection screen SELECTION-SCREEN BEGIN OF BLOCK bl1 WITH FRAME TITLE text-bl1. SELECT-OPTIONS:sel_cube FOR i_prov, date FOR sy-datum. SELECTION-SCREEN END OF BLOCK bl1.
*Frame2 for selection Screen SELECTION-SCREEN BEGIN OF BLOCK bl2 WITH FRAME TITLE text-bl2. *Output to Presentation Server PARAMETERS: p_phys RADIOBUTTON GROUP rad1 DEFAULT 'X', path(128) TYPE c DEFAULT '\\ C:\Daily Loads\Daily Load Status'." Physical path sample *Output to Application server PARAMETERS: p_log RADIOBUTTON GROUP rad1, path1 TYPE filename-fileextern DEFAULT 'Z_DAILY_LOAD_STATUS1'. "Logical file name sample *Physical path assigned to logical file 'Z_DAILY_LOAD_STATUS' * '/SAP/erp/dataload/'.
SELECTION-SCREEN END OF BLOCK bl2. *Default yesterday and current dates as From and To dates as selections INITIALIZATION. date-low = sy-datum - 1. date-high = sy-datum. date-option = 'BT'. date-sign = 'I'. APPEND date.
*********************************************************************** * Enable F4 functionality to identify the Presentation server path * *********************************************************************** AT SELECTION-SCREEN ON VALUE-REQUEST FOR path. DATA: l_dir TYPE string.
* Browse the Directories CALL METHOD cl_gui_frontend_services=>directory_browse * EXPORTING * WINDOW_TITLE = * INITIAL_FOLDER = CHANGING
selected_folder = l_dir
EXCEPTIONS
cntl_error = 1 error_no_gui = 2 not_supported_by_gui = 3 OTHERS = 4 . IF sy-subrc NE 0.
* *
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. ELSE.
path = l_dir.
ENDIF.
END OF work.
TYPES:BEGIN OF it_source1,
rnr TYPE rsiccont-rnr, icube TYPE rsiccont-icube, timestamp TYPE rsiccont-timestamp, source TYPE rsseldone-source, logdpid TYPE rsseldone-logdpid,
END OF it_reqdone3.
TYPES:BEGIN OF it_sreq1,
icube TYPE rsiccont-icube, source TYPE rsseldone-source, object TYPE tadir-object, txtlg TYPE rsdcubet-txtlg, logdpid TYPE rsseldone-logdpid, rnr TYPE rsiccont-rnr, tstatus TYPE rsreqdone-tstatus, datum TYPE rsreqdone-datum, uzeit TYPE rsreqdone-uzeit, tuzeit TYPE rsreqdone-tuzeit, timestampbegin TYPE rsreqdone-timestampbegin, timestamp TYPE rsiccont-timestamp, records TYPE rsreqdone-records, req_insert TYPE rsmonictab-req_insert,
END OF it_sreq1.
TYPES:BEGIN OF it_stat,
object TYPE tadir-object, icube TYPE rsiccont-icube, txtlg TYPE rsdcubet-txtlg, source TYPE rsseldone-source, logdpid TYPE rsseldone-logdpid, rnr TYPE rsiccont-rnr, tstatus TYPE rsreqdone-tstatus, datum TYPE sy-datum, "rsreqdone-datum, uzeit TYPE sy-uzeit, "rsreqdone-uzeit,
tuzeit TYPE sy-uzeit,"rsreqdone-tuzeit, records TYPE rsreqdone-records, req_insert TYPE rsmonictab-req_insert, timestampbegin TYPE rsreqdone-timestampbegin, timestamp TYPE rsiccont-timestamp,
END OF it_stat.
TYPES:BEGIN OF it_mon,
object TYPE tadir-object, icube TYPE rsiccont-icube, txtlg TYPE rsdcubet-txtlg, source TYPE rsseldone-source, logdpid TYPE rsseldone-logdpid, rnr TYPE rsiccont-rnr, tstatus TYPE rsreqdone-tstatus, datum TYPE sy-datum, "rsreqdone-datum, uzeit TYPE sy-uzeit, "rsreqdone-uzeit, tuzeit TYPE sy-uzeit,"rsreqdone-tuzeit, records TYPE rsreqdone-records, req_insert TYPE rsmonictab-req_insert,
END OF it_mon.
TYPES:BEGIN OF it_object1,
object TYPE tadir-object, obj_name TYPE tadir-obj_name,
END OF it_object1.
TYPES:BEGIN OF it_cubet1,
infocube TYPE rsdcubet-infocube, txtlg TYPE rsdcubet-txtlg,
END OF it_cubet1.
TYPES:BEGIN OF it_odsot1,
odsobject TYPE rsdodsot-odsobject, txtlg TYPE rsdodsot-txtlg,
END OF it_odsot1.
TYPES:BEGIN OF it_urec1,
rnr TYPE rsmonictab-rnr, infocube TYPE rsmonictab-infocube, req_insert TYPE rsmonictab-req_insert,
END OF it_urec1.
END OF it_file1.
it_tstat TYPE STANDARD TABLE OF it_stat, wa_tstat TYPE it_stat, it_time TYPE STANDARD TABLE OF it_mon, wa_time TYPE it_mon, it_file TYPE STANDARD TABLE OF it_file1, wa_file TYPE it_file1.
*********************************************************************** * Subroutines * *********************************************************************** PERFORM PERFORM PERFORM PERFORM PERFORM PERFORM PERFORM PERFORM PERFORM
it_source. it_reqdone. it_sreq. it_urec. it_obj_txt. it_final. it_tstat. it_time. get_physical_filename
USING
path1
*&-------------------------------------------------------------------* *& Form it_source *&--------------------------------------------------------------------* * Get Infosource and timestampend *---------------------------------------------------------------------* FORM it_source . SELECT a~rnr
a~icube a~timestamp b~source b~logdpid
INTO TABLE it_source FROM rsiccont AS a INNER JOIN rsseldone AS b ON a~rnr = b~rnr WHERE a~icube IN sel_cube.
ENDFORM.
" it_source
*&--------------------------------------------------------------------* *& Form it_reqdone *&--------------------------------------------------------------------* * Get details of request including timestampbegin, transfered
WHERE
rnr = it_source-rnr
AND
datum IN date.
ENDFORM.
" it_reqdone
*&--------------------------------------------------------------------* *& Form it_sreq *&--------------------------------------------------------------------* * Combine infosource and request detials *---------------------------------------------------------------------* FORM it_sreq . LOOP AT it_source INTO wa_source. READ TABLE it_reqdone1 INTO wa_reqdone1 WITH KEY rnr = wa_source-rnr.
IF sy-subrc = 0. MOVE:wa_source-icube TO wa_sreq-icube, wa_source-source TO wa_sreq-source, wa_source-logdpid TO wa_sreq-logdpid, wa_source-timestamp TO wa_sreq-timestamp, wa_reqdone1-tstatus TO wa_sreq-tstatus, wa_reqdone1-datum TO wa_sreq-datum, wa_reqdone1-uzeit TO wa_sreq-uzeit , wa_reqdone1-tuzeit TO wa_sreq-tuzeit, wa_reqdone1-records TO wa_sreq-records, wa_reqdone1-timestampbegin TO wa_sreq-timestampbegin, wa_reqdone1-rnr TO wa_sreq-rnr.
ENDFORM.
" it_sreq
*&---------------------------------------------------------------------* *& Form it_urec *&---------------------------------------------------------------------* * Get Updated Records for Requests *----------------------------------------------------------------------*
LOOP AT it_sreq INTO wa_sreq. MOVE:wa_sreq-icube TO wa_req-icube, wa_sreq-source TO wa_req-source, wa_sreq-rnr TO wa_req-rnr, wa_sreq-logdpid TO wa_req-logdpid, wa_sreq-tstatus TO wa_req-tstatus, wa_sreq-datum TO wa_req-datum, wa_sreq-uzeit TO wa_req-uzeit , wa_sreq-tuzeit TO wa_req-tuzeit, wa_sreq-records TO wa_req-records, wa_sreq-timestampbegin TO wa_req-timestampbegin, wa_sreq-timestamp TO wa_req-timestamp. READ TABLE it_urec INTO wa_urec WITH KEY rnr = wa_sreq-rnr. IF sy-subrc = 0. MOVE:wa_urec-req_insert TO wa_req-req_insert. ELSE.
wa_req-req_insert = 0.
ENDFORM.
" it_urec
*&---------------------------------------------------------------------* *& Form it_obj_txt *&---------------------------------------------------------------------* * Get object types and texts for Infoproviders *----------------------------------------------------------------------* FORM it_obj_txt .
SELECT object
obj_name FROM tadir
SELECT infocube
txtlg
FROM rsdcubet INTO TABLE it_cubet WHERE infocube IN sel_cube AND langu = 'EN' AND objvers = 'A'.
SELECT odsobject
txtlg
FROM rsdodsot INTO TABLE it_odsot WHERE odsobject IN sel_cube AND langu = 'EN' AND objvers = 'A'.
MOVE:wa_req-icube TO wa_obj_txt-icube, wa_req-source TO wa_obj_txt-source, wa_req-logdpid TO wa_obj_txt-logdpid, wa_req-rnr TO wa_obj_txt-rnr, wa_req-tstatus TO wa_obj_txt-tstatus, wa_req-datum TO wa_obj_txt-datum, wa_req-uzeit TO wa_obj_txt-uzeit , wa_req-tuzeit TO wa_obj_txt-tuzeit,
READ TABLE it_object INTO wa_object WITH KEY obj_name = wa_req-icube. IF sy-subrc = 0. MOVE: wa_object-object TO wa_obj_txt-object. ENDIF.
READ TABLE it_cubet INTO wa_cubet WITH KEY infocube = wa_req-icube. IF sy-subrc = 0. MOVE:wa_cubet-txtlg TO wa_obj_txt-txtlg. ELSE. READ TABLE it_odsot INTO wa_odsot WITH KEY odsobject = wa_req-icube. IF sy-subrc = 0. MOVE:wa_odsot-txtlg TO wa_obj_txt-txtlg. ENDIF. ENDIF. APPEND wa_obj_txt TO it_obj_txt. CLEAR wa_obj_txt. ENDLOOP.
ENDFORM.
" it_obj_txt
*&---------------------------------------------------------------------* *& Form it_final *&---------------------------------------------------------------------* * Get current request for each Infosource in Infoprovider *----------------------------------------------------------------------* FORM it_final . SORT it_obj_txt BY icube source timestampbegin DESCENDING timestampbegin
.
count = sy-tabix. AT NEW source. READ TABLE it_obj_txt INTO wa_final INDEX count. IF sy-subrc = 0. APPEND wa_final TO it_final. ENDIF. ENDAT. ENDLOOP. SORT it_final BY object DESCENDING. ENDFORM. " it_final
*&---------------------------------------------------------------------* *& Form it_tstat *&---------------------------------------------------------------------* * Get texts for Request status *----------------------------------------------------------------------*
FORM it_tstat . DATA: green(10) TYPE c VALUE 'C', yellow(10) TYPE c VALUE 'P', red(10) TYPE c VALUE 'F'. "Completed "Processing "Failed
LOOP AT it_final INTO wa_final. MOVE:wa_final-object TO wa_tstat-object, wa_final-icube TO wa_tstat-icube, wa_final-txtlg TO wa_tstat-txtlg, wa_final-source TO wa_tstat-source, wa_final-logdpid TO wa_tstat-logdpid, wa_final-rnr TO wa_tstat-rnr, wa_final-tstatus TO wa_tstat-tstatus, wa_final-datum TO wa_tstat-datum, wa_final-uzeit TO wa_tstat-uzeit, wa_final-tuzeit TO wa_tstat-tuzeit, wa_final-records TO wa_tstat-records, wa_final-req_insert TO wa_tstat-req_insert, wa_final-timestampbegin TO wa_tstat-timestampbegin, wa_final-timestamp TO wa_tstat-timestamp.
IF wa_finaltstatus = '@08@'. "Technical value for a Successful request MOVE green TO wa_tstat-tstatus. ELSE. IF wa_finaltstatus = '@09@'. "Technical value for a Processing request MOVE yellow TO wa_tstat-tstatus. ELSE. IF wa_final-tstatus = '@0A@'. "Technical value for a Failed request MOVE red TO wa_tstat-tstatus. ENDIF. ENDIF. ENDIF. APPEND wa_tstat TO it_tstat.
ENDLOOP.
ENDFORM.
" it_tstat
*&---------------------------------------------------------------------* *& Form it_time *&---------------------------------------------------------------------* * Convert UTC timestamp to Server date & time *----------------------------------------------------------------------* FORM it_time . TYPES: BEGIN OF time_stamp,
begin_ts TYPE timestamp, end_ts TYPE timestamp,
END OF time_stamp.
DATA:dat TYPE sy-datum, b_tim TYPE sy-uzeit, e_tim TYPE sy-uzeit, tz TYPE ttzz-tzone. *Populate Server timezone from table ttzz into variable tz.
tz = 'MSTNO'.
LOOP AT it_tstat INTO wa_tstat. MOVE:wa_tstat-object TO wa_time-object, wa_tstat-icube TO wa_time-icube, wa_tstat-txtlg TO wa_time-txtlg, wa_tstat-source TO wa_time-source, wa_tstat-logdpid TO wa_time-logdpid, wa_tstat-rnr TO wa_time-rnr, wa_tstat-tstatus TO wa_time-tstatus, wa_tstat-records TO wa_time-records, wa_tstat-req_insert TO wa_time-req_insert, wa_tstat-timestampbegin TO wa_ts-begin_ts, wa_tstat-timestamp TO wa_ts-end_ts.
CONVERT TIME STAMP wa_ts-begin_ts TIME ZONE tz INTO DATE dat TIME b_tim. CONVERT TIME STAMP wa_ts-end_ts TIME ZONE tz INTO TIME e_tim.
MOVE: dat TO wa_time-datum, b_tim TO wa_time-uzeit, e_tim TO wa_time-tuzeit. APPEND wa_time TO it_time. CLEAR wa_time.
ENDLOOP. ****To View results in SAP, uncomment the write statement.*** *WRITE:'DAILY LOAD STATUS' COLOR 5,/ .
*LOOP AT it_time INTO wa_time. * * WRITE: wa_time-object, * wa_time-icube, * wa_time-txtlg, * wa_time-source, * wa_time-logdpid, * wa_time-rnr, * wa_time-tstatus, * wa_time-datum, * wa_time-uzeit, * wa_time-tuzeit, * wa_time-records, * wa_time-req_insert,/. * *ENDLOOP. ENDFORM. " it_time
*&---------------------------------------------------------------------* *& Form get_physical_filename *&---------------------------------------------------------------------* * Get physical path using the logical path *----------------------------------------------------------------------* FORM get_physical_filename USING path1 TYPE filename-fileextern CHANGING p_filename LIKE work-filename.
IMPORTING
file_name = p_filename.
ENDFORM.
" get_physical_filename
*&---------------------------------------------------------------------* *& Form download *&---------------------------------------------------------------------* * Insert Column headings and download file *----------------------------------------------------------------------* FORM download . TYPES:BEGIN OF it_fieldnames,
column TYPE dd03d-ddtext,
END OF it_fieldnames.
wa_col-column = 'INFOPROVIDER DESC.'(003). APPEND wa_col TO it_col. CLEAR wa_col. wa_col-column = 'INFOSOURCE'(004). APPEND wa_col TO it_col. CLEAR wa_col.
wa_col-column = 'INFOPACKAGE'(005). APPEND wa_col TO it_col. CLEAR wa_col. wa_col-column = 'REQUEST'(006). APPEND wa_col TO it_col. CLEAR wa_col. wa_col-column = 'REQUEST STATUS'(007). APPEND wa_col TO it_col. CLEAR wa_col. wa_col-column = 'START DATE'(008). APPEND wa_col TO it_col. CLEAR wa_col. wa_col-column = 'START TIME'(009). APPEND wa_col TO it_col. CLEAR wa_col.
wa_col-column = 'END TIME'(010). APPEND wa_col TO it_col. CLEAR wa_col. wa_col-column = 'TRANSFERRED RECORDS'(011). APPEND wa_col TO it_col. CLEAR wa_col. wa_col-column = 'UPDATED RECORDS'(012). APPEND wa_col TO it_col. CLEAR wa_col.
*Download to Presentation Server IF p_phys = 'X' AND path <> ' '. *Concatenating current system date and .xls extension to the file name. CONCATENATE path '\Load Status'(013) ' - '
sy-datum
wa-file = file.
*Function Module to download data to Presentation server in excel format CALL FUNCTION 'GUI_DOWNLOAD' EXPORTING
filename = wa-file filetype write_field_separator trunc_trailing_blanks dat_mode = 'ASC' = 'X' = 'X' = 'X'
* IMPORTING TABLES
data_tab fieldnames . = it_time = it_col
IF sy-subrc = 0. MESSAGE s899(s1) WITH 'File Transferred'(014) '' '' ''. ENDIF. *Download to Application Server ELSEIF p_log = 'X' AND path1 <> ' '. *Concatenate Current system date and .csv file extension to the file name. CONCATENATE work-filename ' - '
sy-datum
'.csv' INTO file. TRANSLATE file TO LOWER CASE. CLEAR work-filename. work-filename = file. *Creating output file in Application server in .csv format OPEN DATASET work-filename FOR OUTPUT IN TEXT MODE ENCODING DEFAULT. CLEAR wa_file. REFRESH it_file. IF sy-subrc = 0.
APPEND wa_file TO it_file. ENDLOOP. LOOP AT it_file INTO wa_file. CLEAR work-buffer. CONCATENATE
wa_file-object wa_file-icube wa_file-txtlg wa_file-source wa_file-logdpid wa_file-rnr wa_file-tstatus wa_file-datum wa_file-uzeit wa_file-tuzeit wa_file-records wa_file-req_insert
INTO work-buffer SEPARATED BY p_sep. TRANSFER work-buffer TO work-filename. IF sy-subrc = 0. MESSAGE s899(s1) WITH ' File Transferred'(014) '' '' ''. ENDIF.
ENDIF.
ENDFORM.
" download
STEP 2: Populate Server Time Zone Populate field tz = Required Server time zone from table ttzz Example: tz = MSTNO where value MSTNO represents Mountain standard time. STEP 3: Creation of Text elements Create the following Text elements and activate. We can also create text elements by double clicking on the serial number assigned to the text in the program which would take us to the Text elements screen.
Text Symbols:
Selection Texts:
STEP 4: Create and Assign Logical File to Physical Path Create a Logical file name and assign a physical path from Application server. Example: - Logical file 'Z_DAILY_LOAD_STATUS' is assigned a physical path
' /SAP/erp/dataload/ ' in the program.
STEP 5: Execution of Program Activate the program and Text elements. Provide required selections and Execute the program.
Note: To view results on your SAP screen remove Write statement from comments. This program is primarily for BW 3.5 environment. I shall be posting Program for BI 7.0 version shortly.