Skip to Content

Introduction

This tool has been created to check the status of broadcasts in the system and list out the broadcasts errors. It works by reading the table BALHDR(already maintained in the system ), which actually stores the broadcast status .This program can be used to simplify the task of broadcast monitoring as it displays broadcast errors for the selected number of days in a single go. The program can be used in two ways : either we can manually execute the tool to display erroneous broadcasts in ALV List format or we can schedule it to run daily or periodically to send email notifications in case of broadcast errors to a list of predefined users.

Purpose

The broadcast programs that are added in a process chain complete successfully even if there is an issue like Pre-calculation server offline or any other issue with broadcast technical setting. So we can’t just rely on the status of the process chain to know whether the broadcast is actually sent or not. Here we need to manually check TCODE SOST (to see if the emails are sent) or Broadcast logs using program RSRD_BROADCAST_LOG, which involves periodic manual intervention after completion of Broadcast jobs.

So, in this scenario we should have some way to find out the broadcast errors. This tool helps to monitor the broadcast logs and send an alert email to the monitoring team to take appropriate action if there are any errors in the broadcast.

  • Default option available to check Broadcast status

We also have options available in the system to check broadcast status, this method also reads the data from table BALHDR, but it displays status of all the

broadcasts whether successful or erroneous at a go and it gets really difficult to check for the broadcast errors.

Go to RSA1->Administration

We will get the below screen, then click on Broadcasting and then go to log display.

Broadcasting->Log Display

/wp-content/uploads/2012/04/1_91279.png

Enter the date in the below screen for which you want to check the broadcast status.

/wp-content/uploads/2012/04/2_91319.png

When we click on Execute, it will give us the list of all the broadcasts in the system for the entered dates both successful and erroneous.

  • Output

/wp-content/uploads/2012/04/3_91320.png

This tool also uses the same concept as this broadcast option to read broadcast status data from table BALHDR but it selects and displays the broadcast data only for error broadcasts.

Technical Process

Step by Step Solution

1. Creating a Program

Go to SE38 and create a Z report program as below.

2. Program

REPORT  Z_BW_REP_BROADCASTCHECK MESSAGEID 00.
************************************************************************ Program ID          : Z_BW_REP_BROADCASTCHECK             ** Program Title       : Program to check status of Broadcasts                      ** Author                  : Sapna Gupta                                                               ** Date                     : 30.1.2012                                                                    ** Development ID  : XXXXXXXXXXXXXXXX                                               ** Description          : The program is used to check the status of the           ** Broadcasts for the number of days in the selection, object, alprog and    ** Message Client blank has been hardcoded.The program can Display or ** Email the Broadcast status for the no. of days in the selection.                ** The program displays the Broadcasts status using ALV List Display.       **=====================================================================**&——————————————————————–***& Report*&*&———————————————————————*
* Including table containing broadcast details.tables : BALHDR.* Used for creating ALV list display.TYPE-POOLS : SLIS.
* Broadcast status data.types : begin of ty_bd,
      lognumber
type BALHDR-LOGNUMBER,
      aldate
type BALHDR-ALDATE,
      altime
type BALHDR-ALTIME,
      alprog
type BALHDR-alprog,
      aluser
type BALHDR-aluser,
      alchuser
type BALHDR-alchuser,
 
end of ty_bd.
data : I_BRODCST type standard table of ty_bd WITH HEADER LINE.data : gv_aldate type BALHDR-ALDATE.data : gv_title(255).
* Email dataDATA: v_recv              LIKE somlreci1 OCCURS 1 WITH HEADER LINE,
      v_document_data    
LIKE sodocchgi1.DATA: object_id           LIKE  sofolenti1-object_id,
      objcont            
LIKE  soli OCCURS 10 WITH HEADER LINE,
      OBJECT_HEADER      
like  SOLISTI1 OCCURS 1 WITH HEADER LINE.DATA: gv_receiver TYPE somlreci1-receiver.
* ALV list display dataDATA : IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
       LN_FIELDCAT
TYPE SLIS_FIELDCAT_ALV.
DATA: WA_ALV_EVENT TYPE SLIS_ALV_EVENT,
      WA_LISTHEADER
TYPE SLIS_LISTHEADER,
      WA_LAYOUT
TYPE SLIS_LAYOUT_ALV.DATA: IT_ALV_EVENT TYPE SLIS_T_EVENT,
      IT_LISTHEADER
TYPE SLIS_T_LISTHEADER,
      LN_SORTCAT
TYPE SLIS_SORTINFO_ALV,
      IT_SORTCAT
TYPE SLIS_T_SORTINFO_ALV.
INITIALIZATION.clear gv_title.Concatenate ‘****’ sy-sysid ‘Broadcast errors****’ into gv_title SEPARATED BY space.

SELECTION-SCREEN BEGIN OF BLOCK B.PARAMETERS: p_days(3) TYPE n DEFAULT 1.
PARAMETERS: RB_DSPLY RADIOBUTTON GROUP USER,
            RB_EMAIL
RADIOBUTTON GROUP USER.SELECT-OPTIONS: s_mail FOR gv_receiver LOWER CASE NO INTERVALS.
SELECTION-
SCREEN end of block B.
AT SELECTION-SCREEN.* check that reciever’s email id should be entered
 
IF RB_EMAIL = ‘X’.
   
READ TABLE s_mail INDEX 1.
   
IF sy-subrc <> 0.
     
MESSAGE e001 WITH ‘Please enter at least one email address’.
   
ENDIF.
 
ENDIF.
* Reciever’s email Id should be valid
 
LOOP AT s_mail.
   
IF NOT s_mail-high IS INITIAL.
     
MESSAGE e001 WITH s_mail-high ‘is not valid. Please enter with no intervals’.
   
ENDIF.
 
ENDLOOP.

gv_aldate = sy-datum – p_days.

START-OF-SELECTION.* Select data from the Broadcast table for the selection
 
PERFORM Z_BW_FIN_SELECTDATA.ENDOF-SELECTION.
*&———————————————————————**&      Form  Z_BW_FIN_SELECTDATA*&———————————————————————**       text*———————————————————————-**  –>  p1        text*  <–  p2        text*———————————————————————-*form Z_BW_FIN_SELECTDATA.
SELECT LOGNUMBER aldate alprog altime aluser alchuser INTO CORRESPONDING FIELDS OF TABLE I_BRODCSTfrom BALHDR where object = ‘RSRD’ and ( aldate le sy-datum and aldate ge gv_aldate ) and
msg_cnt_e <> space
and alprog = ‘RSRD_BROADCAST_STARTER’.
IF sy-subrc = 0.* Display the headings in case of ALV Display
 
PERFORM Z_BW_FIN_EVENTS.* Display data of Broadcast status
 
PERFORM Z_BW_FIN_DISPLAY.ELSEIF sy-subrc <> 0.MESSAGE s001 WITH ‘No Broadcast Errors Occurred.’.ENDIF.
endform.                    ” Z_BW_FIN_SELECTDATA

*&———————————————————————**&      Form  Z_BW_FIN_DISPLAY*&———————————————————————**       text*———————————————————————-**  –>  p1        text*  <–  p2        text*———————————————————————-*form Z_BW_FIN_DISPLAY .
* Display Broadcast status as a list.
 
IF RB_DSPLY = ‘X’.
   
REFRESH IT_FIELDCAT.
   
CLEAR IT_FIELDCAT.
   
PERFORM FIELDCAT USING ‘1’   ‘LOGNUMBER’ ‘I_BRODCST’ ‘Log Number’ ’30’ .
   
PERFORM FIELDCAT USING ‘2’   ‘ALDATE’    ‘I_BRODCST’ ‘Date’ ’20’ .
   
PERFORM FIELDCAT USING ‘3’   ‘ALTIME’    ‘I_BRODCST’ ‘Time’ ’12’ .
   
PERFORM FIELDCAT USING ‘4’   ‘ALPROG’    ‘I_BRODCST’ ‘Program Name’ ’40’ .
   
PERFORM FIELDCAT USING ‘5’   ‘ALUSER’    ‘I_BRODCST’ ‘User’ ‘8’ .
   
PERFORM FIELDCAT USING ‘6’   ‘ALCHUSER’  ‘I_BRODCST’ ‘User that Changed the Log’ ’50’ .

    CALL FUNCTION ‘REUSE_ALV_LIST_DISPLAY’
     
EXPORTING
      I_CALLBACK_PROGRAM             = SY-REPID
      IT_FIELDCAT                    = IT_FIELDCAT
      IT_EVENTS                      = IT_ALV_EVENT
     
TABLES
      t_outtab                       = I_BRODCST.
   
IF sy-subrc <> 0.* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
   
ENDIF.
* Send Broadcast Status as Email
 
ELSEIF RB_EMAIL = ‘X’.
    OBJECT_HEADER-
line = gv_title.
   
append OBJECT_HEADER.
    objcont-
line = ‘Broadcast Status Check.’.
   
APPEND objcont.
    objcont-
line = ‘Please check and take appropriate action!’.
   
APPEND objcont.
   
WRITE: sy-uline(66) TO objcont-line.
   
APPEND objcont.
   
CONCATENATE sy-vline ‘LOGNUMBER’ sy-vline ‘ALDATE ‘ sy-vline
   
‘ALTIME’ sy-vline ‘ALPROG ‘ sy-vline ‘ALUSER’ sy-vline ‘ALCHUSER’ INTO objcont-line.
   
APPEND objcont.
   
WRITE: sy-uline(66) TO objcont-line.
   
APPEND objcont.

    REFRESH v_recv.
   
CLEAR v_recv.
   
LOOP AT s_mail.* receivers
      v_recv-receiver = s_mail-low.                   
“recipient
      v_recv-express =
‘X’.
      v_recv-rec_type =
‘U’.                           “internet email
     
APPEND v_recv.
   
ENDLOOP.

    LOOP AT I_BRODCST.
     
WRITE: sy-uline(66) TO objcont-line.
     
CLEAR objcont.
     
CONCATENATE sy-vline I_BRODCST-lognumber(20) sy-vline
               I_BRODCST-aldate(
8) sy-vline
               I_BRODCST-altime(
6) sy-vline
             I_BRODCST-alprog(
10) sy-vline  I_BRODCST-aluser(10) sy-vline I_BRODCST-alchuser(10) into objcont-line.
     
APPEND objcont.
   
ENDLOOP.
* document data – description is subject line
    v_document_data-obj_name  =
‘Broadcast Status Check’.
    v_document_data-obj_descr = gv_title.
* send mail message
   
CALL FUNCTION ‘SO_NEW_DOCUMENT_SEND_API1’
     
EXPORTING
        document_data              = v_document_data
        document_type              =
‘RAW’
        put_in_outbox              =
‘X’
        commit_work                =
‘X’
     
IMPORTING
        new_object_id              = object_id
     
TABLES
        OBJECT_HEADER              = OBJECT_HEADER
        object_content             = objcont
        receivers                  = v_recv
     
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.
     
MESSAGE s001 WITH ‘Email was not sent’.
   
ELSE.
     
MESSAGE s001 WITH ‘Email was successfully sent’.
   
ENDIF.

  ENDIF.
endform.                    ” Z_BW_FIN_DISPLAY

*&———————————————————————**&      Form  Z_BW_FIN_EVENTS*&———————————————————————**       text*———————————————————————-**  –>  p1        text*  <–  p2        text*———————————————————————-*form Z_BW_FIN_EVENTS .

  CLEAR   WA_ALV_EVENT.
 
REFRESH IT_ALV_EVENT.
  WA_ALV_EVENT-NAME  = 
‘TOP_OF_PAGE’.
  WA_ALV_EVENT-
FORM  =  ‘F005_ALV_HEADER’.
 
APPEND WA_ALV_EVENT TO IT_ALV_EVENT.

  WA_LISTHEADER-TYP = ‘H’.
  WA_LISTHEADER-
KEY = .
  WA_LISTHEADER-INFO = gv_title.
 
APPEND WA_LISTHEADER TO IT_LISTHEADER.

  WA_LISTHEADER-TYP = ‘S’.
  WA_LISTHEADER-
KEY = .
  WA_LISTHEADER-INFO =
‘Broadcast Status Check’.
 
APPEND WA_LISTHEADER TO IT_LISTHEADER.
endform.                    ” Z_BW_FIN_EVENTS

*&———————————————————————**&      Form  F005_ALV_HEADER*&———————————————————————**       text*———————————————————————-*FORM F005_ALV_HEADER.

  CALL FUNCTION ‘REUSE_ALV_COMMENTARY_WRITE’
   
EXPORTING
      IT_LIST_COMMENTARY = IT_LISTHEADER.

ENDFORM.                    “F005_ALV_HEADER*&———————————————————————**&      Form  FIELDCAT*&———————————————————————**       text*———————————————————————-**      –>P_0313   text*      –>P_0314   text*      –>P_0315   text*      –>P_0316   text*      –>P_0317   text*      –>P_0318   text*      –>P_0319   text*      –>P_0320   text*      –>P_0321   text*———————————————————————-*FORM FIELDCAT USING VALUE(COL_POS)
                   
VALUE(FIELDNAME)
                   
VALUE(TABNAME)
                   
VALUE(REPTEXT)
                   
VALUE(LEN)
                   
VALUE(HOTSPOT).

  LN_FIELDCAT-COL_POS = COL_POS.
  LN_FIELDCAT-FIELDNAME = FIELDNAME.
  LN_FIELDCAT-TABNAME = TABNAME.
  LN_FIELDCAT-REPTEXT_DDIC = REPTEXT.
  LN_FIELDCAT-OUTPUTLEN = LEN.
  LN_FIELDCAT-HOTSPOT = HOTSPOT.
 
APPEND LN_FIELDCAT TO IT_FIELDCAT.
 
CLEAR LN_FIELDCAT.
endform.                    ” FIELDCAT

3. Source Code Description

The program reads the data from table BALHDR based on the selection values entered by the user for number of days ,the number of days that user enters is subtracted from the current date to get the dates for which the data should be selected from the table. The select statement reads the data based on these dates, this covers all the dates between sy-datum and previous date.

There are two radio buttons created using the Parameters option to select if we want to display the list of broadcast errors or we want to email it to a list of receivers. The program asks for the email id of receivers if we select the email radio button.

The select statement reads the table BALHDR based on the value of object = ‘RSRD’, aldate le sy-datum and aldate ge gv_aldate andmsg_cnt_e  <>  space and alprog = ‘RSRD_BROADCAST_STARTER’ , here gv_aldate contains the value obtained after subtracting number of days from sy-datum.

The fields extracted from the table are passed to ALV list Display using the function ‘REUSE_ALV_LIST_DISPLAY’ to display the extracted data of error broadcasts in the form of a list if the user has requested for data display.

We pass data to the function ‘SO_NEW_DOCUMENT_SEND_API1’, if data is required to be send as an email in this case user should select radio button Email for this function to work.

Output

Go to SE38 ->Program name ->Execute ,it will display the below selection screen to the user.

Program Selection Screen :

The user is required to enter the number of days in the selection screen,the default value is 1 ,the user can change it to enter any value till 999.

1. Display Broadcast Errors

We need to enter the number of days for which we want to see the Broadcast Error Details and then we select Display Radio button it checks for the Broadcast errors from the table BALDHR and displays them on the screen in the form of ALV List Display.

The below is the list of broadcast errors that we get when we click on Execute./wp-content/uploads/2012/04/5_91331.png

2. Send Email Notifications for Broadcast Errors

We need to enter the number of days and select Email Radio button,then we have to enter the receivers email Id in the selection option Email Id.

/wp-content/uploads/2012/04/6_91332.png

When we click on execute the below screen will be displayed with a message ‘Email successfully sent’ and  the email will be send successfully to the email id entered by the user.

/wp-content/uploads/2012/04/7_91333.png

The email with the list of Broadcast error details will be sent to the receiver’s Id as shown below.

/wp-content/uploads/2012/04/8_91334.png 

Scheduling the Program

The other way we can use this program is by scheduling it to run after the Process chain for sending the Broadcasts completes successfully. This program will execute and send the list of error broadcasts if any to the list of users entered at the time of scheduling the program.

Goto SE38 -> Z_BW_REP_BROADCASTCHECK

The below screen will be displayed ,keep the number of days as one but change the radiobutton selection to Email.

/wp-content/uploads/2012/04/9_91335.png

Enter the receiver email Id,you can enter one or multiple receivers for the mail.

/wp-content/uploads/2012/04/10_91336.png

Then Goto Program ->Execute in Background.

/wp-content/uploads/2012/04/11_91347.png

Enter output device value as LP01 and press Enter.

/wp-content/uploads/2012/04/12_91348.png

Click on immediate and select periodic job check box.

/wp-content/uploads/2012/04/14_91349.png

Or to schedule the program to run after a given date and time, click on Date/Time tab, enter the date and time at which we want to schedule the program and select periodic job check box.

/wp-content/uploads/2012/04/15_91350.png

Then click on Period Values and select Daily and then click on Save and then Check.

/wp-content/uploads/2012/04/17_91351.png

Then click on Check and the program is now scheduled to run daily. It will run Daily to send the list of Broadcast errors to the email ids of the receivers entered while scheduling the program.

 

Related Content

ALV Tutorial

ALV

Sending Emails

To report this post you need to login first.

4 Comments

You must be Logged on to comment or reply to a post.

Leave a Reply