0% found this document useful (0 votes)
28 views5 pages

BW - Tracking Zero Record Loads

Uploaded by

Marcelo Otranto
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views5 pages

BW - Tracking Zero Record Loads

Uploaded by

Marcelo Otranto
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Tracking Zero Record Loads

Applies To:
SAP BW 3.0 and Above.

Summary
Sometimes when we extract data from source systems such as R3, flat files, or databases, we see the load
finish successfully but deliver no new records to BW. Such loads may fail to bring records from the data
source because of problems in that source system such as a database refresh not happened or for other
reasons. Tracking these “zero record” loads is difficult because someone needs to manually examine the
logs in the process chain. In these cases, it is useful to include the code sample provided below as an ABAP
program in your process chains. This program automatically detects zero record loads and sends detailed
mail to an administrator, so that he or she becomes aware of potential problems in the source system. You
can include this program in a process chain after the Info Package load with the details of that Info Package
as variant.

By: Pradeep Choudhari Yalamanchili

Company: HCL Technologies

Date: 20 Feb 2006

Table of Contents
Applies To:........................................................................................................................................1

Summary ..........................................................................................................................................1

Table of Contents .............................................................................................................................1

Code Sample....................................................................................................................................1

Author Bio.........................................................................................................................................5

Disclaimer & Liability Notice .............................................................................................................5

Code Sample
Where you see blue text, for example ******, in the code below please use your SAP login ID as
sender_address and list mail_ids of the persons to receive alert mail in the i_receivers-receiver value.

<html>
<head>

<title>SDN - The SAP Developer Network</title>

© 2006 SAP AG The SAP Developer Network: http://sdn.sap.com


1
Tracking Zero Record Loads

*&---------------------------------------------------------------------*
*& Report ZEROREC_LOAD_MAIL_NOTIFY
*&---------------------------------------------------------------------*
*-----------------------------------------------------------------------
* DESCRIPTION # Zero record loads mail notification
* SPEC-OWNER # Pradeep C Yalamanchili
* CODED BY # Pradeep C Yalamanchili
*-----------------------------------------------------------------------
* This program is used to findout the Loads which are loading zero *
* records and send mail to the list of monitor users regarding the *
* status useful to include in Process chains after the data loads *
* wherever neccesary to track the zero record loads. *
*-----------------------------------------------------------------------

REPORT ZEROREC_LOAD_MAIL_NOTIFY message-id zbw.

* Tables
Tables:RSREQDONE.

*Constants
CONSTANTS: c_head(30) type c value 'ZERO records Loaded for'.

* Email text
DATA: t_email_txt LIKE soli OCCURS 0 WITH HEADER LINE,
t_line LIKE TABLE OF sy-lisel.

DATA: v_syuname type syuname.

* Internal Tables
DATA: Begin of i_record occurs 0,
RNR type RSREQUNR,
LOGDPID type RSLOGDPID,
TSTATUS type RSSTATUS,
TDATUM type SYDATUM,
TUZEIT type SYUZEIT,
end of i_record.

selection-screen begin of block b1.


Parameters:p_ipak type RSLOGDPID,
p_text(50) type c,
p_date type sydatum.
selection-screen end of block b1.

****************************************************************
*** INITIALIZATION **
****************************************************************

INITIALIZATION.

* Initialize date adjusting to GST


if p_date is initial.
move sy-datum to p_date.
p_date = p_date - 1.
endif.

******************************************************************

© 2006 SAP AG The SAP Developer Network: http://sdn.sap.com


2
Tracking Zero Record Loads

*** START-OF-SELECTION ***


******************************************************************

START-OF-SELECTION.

* Call to send mail function


Perform sub_send_mail.

*&---------------------------------------------------------------------*
*& Form sub_send_mail
*&---------------------------------------------------------------------*
FORM sub_send_mail .
DATA: i_packing_list LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE,
i_receivers LIKE somlreci1 OCCURS 0 WITH HEADER LINE,
s_doc_data LIKE sodocchgi1, " Document data
v_sender LIKE soextreci1-receiver,
w_lines TYPE i.

Select RNR LOGDPID TSTATUS TDATUM TUZEIT


FROM RSREQDONE
INTO TABLE I_RECORD
WHERE LOGDPID = P_IPAK AND
TDATUM = P_DATE AND
TSTATUS = '@08@'.
IF SY-SUBRC = 0.
SORT I_RECORD BY TUZEIT DESCENDING.

ENDIF.

READ TABLE I_RECORD INDEX 1.

* set up text message


CLEAR t_email_txt.
concatenate 'zero records for' i_record-logdpid
'and ReqID' i_record-rnr
into t_email_txt-line separated by space.
APPEND t_email_txt.

concatenate 'Report Date:' sy-datum into t_email_txt-line


separated by space.
APPEND t_email_txt.

move p_text to t_email_txt.


append t_email_txt.

* check how many lines are in the email


DESCRIBE TABLE t_email_txt LINES w_lines.
W_LINES = 5.
* if w_lines < 4.
* message i000 with 'No Data to send.'.
* exit.
* endif.
*

© 2006 SAP AG The SAP Developer Network: http://sdn.sap.com


3
Tracking Zero Record Loads

* IF w_lines ge 4 .
CLEAR i_packing_list.
i_packing_list-transf_bin = 'X'.
i_packing_list-head_start = 1.
i_packing_list-head_num = 1.
i_packing_list-body_start = 1.
i_packing_list-body_num = w_lines.
i_packing_list-doc_type = 'RAW'.
i_packing_list-obj_descr = 'PKTERROR'.
i_packing_list-doc_size = w_lines * 255.
APPEND i_packing_list.
* ENDIF.

* set up the recievers distribution list


i_receivers-receiver = ‘[email protected]’.
i_receivers-rec_type = 'U'.
i_receivers-express = 'X'.
APPEND i_receivers.

* subject of email
s_doc_data-obj_name = '???'.
Concatenate c_head p_ipak into s_doc_data-obj_descr.

* sender of email
MOVE SY-UNAME TO v_sender.

move sy-uname to v_syuname.


translate v_syuname to upper case.
* send the email
CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
EXPORTING
document_data = s_doc_data
sender_address = 'USERID'
TABLES
packing_list = i_packing_list
contents_bin = t_email_txt
contents_txt = t_email_txt
receivers = i_receivers
EXCEPTIONS
too_many_receivers = 1
document_not_sent = 2
document_type_not_exist = 3
operation_no_authorization = 4
parameter_error = 5
x_error = 6
enqueue_error = 7
OTHERS = 8.
IF sy-subrc <> 0.
CASE sy-subrc.
WHEN 1.
MESSAGE e000 WITH 'Too Many Receivers'.
WHEN 2.
MESSAGE e000 WITH 'Document Not sent'.
WHEN 3.
MESSAGE e000 WITH 'Document type not exist'.
WHEN 4.
MESSAGE e000 WITH 'Operation no authorisation'.

© 2006 SAP AG The SAP Developer Network: http://sdn.sap.com


4
Tracking Zero Record Loads

WHEN 5.
MESSAGE e000 WITH 'Parameter error'.
WHEN 6.
MESSAGE e000 WITH 'Error occured when sending message'.
WHEN 7.
MESSAGE e000 WITH 'Enque error'.
WHEN OTHERS.
MESSAGE e000 WITH 'Error occured when sending message'.
ENDCASE.
ENDIF.

COMMIT WORK.

message i000 with 'Report e-mailed successfully'.

ENDFORM. " sub_send_mail

</head>
<body>

Author Bio
Pradeep Choudhari is an ABAP/BW consultant working with HCL Technologies.Having over
three years of development and consulting experience in various parts of the world.

Disclaimer & Liability Notice


This document may discuss sample coding or other information that does not include SAP official interfaces
and therefore is not supported by SAP. Changes made based on this information are not supported and can
be overwritten during an upgrade.

SAP will not be held liable for any damages caused by using or misusing the information, code or methods
suggested in this document, and anyone using these methods does so at his/her own risk.

SAP offers no guarantees and assumes no responsibility or liability of any type with respect to the content of
this technical article or code sample, including any liability resulting from incompatibility between the content
within this document and the materials and services offered by SAP. You agree that you will not hold, or seek
to hold, SAP responsible or liable with respect to the content of this document.

© 2006 SAP AG The SAP Developer Network: http://sdn.sap.com


5

You might also like