AUTOMATION OF SCHEDULED JOBS LINKING TO BO REPORTS
CURRENT
SCENARIO:
If
BOBJ reports are scheduled to run on daily recurrence and for some reason if BW
loads get delayed or failed, BOBJ report will not show the latest data.
PROPOSED
SOLUTION:
To
overcome the current scenario we are going to have BO reports scheduled based
on file events. The file will be created based on the successful completion of
BW data loads/process chains. This would make sure the report is generated and
sent to users only if the process chain completes successfully.
In
BW, we have created an ABAP program to create a test file on application
server. This directory, where the file is created, is mounted on both BW server
as well as BOBJ server. BOBJ reports will be scheduled prior to this file
creation in BW. In BOBJ once the schedules starts, Event will continuously
search for the file. In case the file is available prior to BOBJ report
schedule time, Event doesn’t process. It will internally check with timestamp
of BOBJ report schedule and file creation. So, we are deleting the old
file and replacing it with a new file after BW data loads.
Below is high
level summary of the steps involved:
- Create a share drive in
BW and mount it to BOBJ server so that it can be accessed by both BW and
BOBJ server. This is required so that file can be created in BW side and
read in BOBJ side.
- Create an ABAP Program
to delete the previously created file
- Create an ABAP program
to create a sample test file on Application server
- Create the File based
Event on the BOBJ side and assign this event to the desired Report for
scheduling
BENEFITS:
DETAILED STEPS:
Creating a shared file path at OS level:
Create a share
drive in BW and mount it to BOBJ server so that can be accessed by BW system
and BOBJ system with full rights with an admin user. For example, \\AZSXX2120\data\BOBJ\
is directory that we created in BW where test file will be written. This file
can be read from the BOBJ side. This step is done by our BASIS team.
BW Steps
We have created
two ABAP program to delete and create the test file. We included these two
program in a process chain and attached the process chain with our
transactional data load process chain. This helped to create the file only at
the end of all transactional data load.
File deletion ABAP code:
*&---------------------------------------------------------------------*
*& Report ZBO_ORDERS_DELETE_TEST
*&
*&---------------------------------------------------------------------*
*&
*& Sample Testing. This program will delete a file from Application *& Server
*&---------------------------------------------------------------------*
REPORT ZBO_ORDERS_DELETE_TEST.
data: p_s_path type pathextern. " Complete filepath
data: p_s_file type pathextern." File name
data: p_s_dir type pathextern. " Directory
p_s_file ='Orders.csv'. "file name to be deleted
p_s_dir = '\AZSXX2120\data\BOBJ\'. " Path from where file will be deleted
concatenate p_s_dir p_s_file into p_s_path.
condense p_s_path.
open dataset p_s_path for input in text mode encoding default.
if sy-subrc = 0.
close dataset p_s_path.
delete dataset p_s_path.
if sy-subrc eq 0.
write: 'File Deleted Succesfully', p_s_path.
else.
write: 'No Authorization to delete or no file exists', p_s_path.
endif.
else.
write: p_s_path, 'File does not exist'.
endif.
File Creation ABAP code:
*&---------------------------------------------------------------------*
*& Report ZBO_ORDERS_CREATE_TEST
*& Program will create a file and place it at application server
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ZBO_ORDERS_CREATE_TEST.
tables: rlgrap.
data: lv_file_str type string . "file Path For Application server file
data: lv_msg_text(50),
lv_filename type localfile.
data l_lines type i.
data ls_split type string.
data lt_split like table of ls_split.
data lp_file type localfile.
data lp_fil2 like rlgrap.
lp_file = 'Orders.csv'. "file name to be created
lp_fil2 = '\AZSXX2120\data\BOBJ'. " Path where file will be created
at line-selection.
call transaction 'AL11' .
*———————————————————————-*
* Start of selection
*———————————————————————-
start-of-selection.
split lp_file at '.' into lv_file_str lv_filename .
translate lv_filename to upper case .
if lv_filename = 'CSV' .
clear : lv_filename .
split lv_file_str at '\' into table lt_split.
describe table lt_split lines l_lines.
* file name
loop at lt_split into ls_split.
if sy-tabix eq l_lines.
lv_filename = ls_split.
endif.
endloop.
lv_file_str = lp_file .
if lv_file_str is not initial.
perform write_file .
else.
message 'File Path Needed .' type 'W'.
endif.
else.
message '.CSV File Needed .' type 'W'.
endif.
free :lv_filename ,lt_split ,l_lines ,lv_file_str.
*&———————————————————————*
*& Form write_file – This will create a file at Application Server
*&———————————————————————
form write_file .
concatenate lp_fil2 lv_filename '.csv' into lv_filename .
condense lv_filename no-gaps .
open dataset lv_filename for output in text mode
encoding default message lv_msg_text.
if sy-subrc eq 0.
write: 'File' ,lv_filename ,'created Successfully at Application server.'.
exit.
else.
write: 'File' ,lv_filename ,' cannot get created at Application server.'.
exit.
endif.
endform.
The above two program in the process chain are included in
our transactional data load chain. This ensures that file would be created only
after BW transactional load is completed. After all sequences, BW system will
write file on /data/BOBJ mount or share drive.
BOBJ Steps:
From the Business
Objects side, we will be creating file-based event and attaching the event to
the report. Once the recurrence schedule starts, the event will continuously
search for the files specified in the path. If the file occurs prior to
schedule time, event will not trigger, internally it will check with time stamp
of file creation and schedule time. In case if the file occurs then need to
delete it and write the file. Once the file placed, event will get triggered
and schedule process starts to run the report.