Professional Documents
Culture Documents
Table of contents
1.0 Technology Environment....................................................................4
2.0 Business Requirement Analysis.............................................................4
2.1 Problem definition.........................................................................4
2.2 Business Requirements....................................................................4
3.0 Solution Walkthrough.........................................................................5
4.0 Solution Details................................................................................7
4.1 Solution Overview..........................................................................7
4.2 Process Enhancements....................................................................7
Record of Release
As a solution, a report has been developed which picks up BDocs from Database,
groups them by BDoc State first and then by BDoc type and sends it as an email to
the specified recipients.
This report can be run in Foreground as well as in Background.
Foreground: When run in foreground, the selection parameters should be Date
Range and Time Range and the output should be in List formatn showing 3
different tables for BDocs in Error State, Intermediate State and Successful
State
Background: When run in Background, the input is only list of email ids and the
Date Range is defaulted to yesterday’s date and Time Range should be the
whole day i.e., 00:00:00 to 23:59:59. The output form is same as that in point
above
There should be a radio button available to chose execution in background
mode
3. In Output you see 3 tables; for Successful Bdocs, Error BDocs and Intermediate
BDocs. Each table will have BDoc Type and count of BDocs in a particular state. At
the end of each table, total count of BDocs in that state is mentioned.
4. Now run the report in Batch mode and provide a list of email ids
tables will have 2 columns: BDoc Type and BDoc Count. Once we have these 3
internal tables ready we format an output list and display it in case of foreground
execution. In case of batch run, we format an email and send it across to the
selected recipients.
*-----------------------------------------------------------------------------*
* Program Name : ZIPC_BDOC_PROCESSING_STATS *
* Object No : *
* Created by : Sharif Inamdar *
* Created on : 02/8/2010 *
* Transport Request No: CS1K900849, CS1K900859 *
*-----------------------------------------------------------------------------*
* Purpose : Displaying and Emailing BDOC logs *
*-----------------------------------------------------------------------------*
* Modification Logs: *
* *
* Date Programmer Change Request# Description *
* ========== =============== =============== =============== *
*-----------------------------------------------------------------------------*
*****************************************************************
* Types-Pools
*****************************************************************
TYPE-POOLS : slis, line.
*****************************************************************
* Types
*****************************************************************
TYPES: BEGIN OF t_recipient,
sign TYPE c,
option(2) TYPE c,
low TYPE ad_smtpadr,
high TYPE ad_smtpadr,
END OF t_recipient.
*****************************************************************
* Global Data Declarations
*****************************************************************
DATA: lt_error_detail TYPE TABLE OF zcond_log_tab,
ls_error_detail TYPE zcond_log_tab,
alv_fcat TYPE slis_t_fieldcat_alv WITH HEADER LINE,
alv_layout TYPE slis_layout_alv.
DATA: lv_count_e TYPE i, lv_count_i TYPE i, lv_count_s TYPE i, lv_char10 TYPE c LENGTH 10.
*****************************************************************
* Selection Screen
*****************************************************************
* Time selection
SELECTION-SCREEN BEGIN OF BLOCK date_sel WITH FRAME TITLE text-s01.
* Other selection
SELECTION-SCREEN BEGIN OF BLOCK other_sel WITH FRAME TITLE text-s16.
SELECT-OPTIONS s_sender FOR wa_recipient NO INTERVALS.
SELECTION-SCREEN END OF BLOCK other_sel.
*****************************************************************
* AT SELECTION-SCREEN
*****************************************************************
AT SELECTION-SCREEN OUTPUT.
*****************************************************************
* START-OF-SELECTION
*****************************************************************
START-OF-SELECTION.
p_tim_fr = '000000'.
p_dat_to = sy-datum - 1.
p_tim_to = '235959'.
ENDIF.
IF p_tim_to IS INITIAL.
p_tim_to = '235959'.
ENDIF.
*&---------------------------------------------------------------------*
*& Form get_count
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->T_BDOCTAB text
* -->T_COUNT text
*----------------------------------------------------------------------*
FORM get_count TABLES t_bdoctab STRUCTURE zbdoc_tab
t_count STRUCTURE zzcount.
CLEAR lv_last_count.
SORT t_bdoctab STABLE ASCENDING BY bdoc_type.
LOOP AT t_bdoctab .
AT END OF bdoc_type.
t_count-bdoc_type = t_bdoctab-bdoc_type.
t_count-count = sy-tabix - lv_last_count.
lv_last_count = sy-tabix.
APPEND t_count.
ENDAT.
ENDLOOP.
ENDFORM. "get_count
*&---------------------------------------------------------------------*
*& Form SEND_MAIL
*&---------------------------------------------------------------------*
* Module for Generating and Sending Mail *
*----------------------------------------------------------------------*
* -->LT_ERROR_DETAIL Error Detail Table
*----------------------------------------------------------------------*
FORM send_mail TABLES lt_error_count STRUCTURE zzcount
lt_inter_count STRUCTURE zzcount
lt_success_count STRUCTURE zzcount.
* Module Related Data Declaration.
DATA: v_email_desc TYPE so_obj_des VALUE 'BDOC Processing Statistics',
v_date(10) TYPE c,
v_tmp_str TYPE string,
* Class Declaration
DATA: send_request TYPE REF TO cl_bcs,
document TYPE REF TO cl_document_bcs,
sender_id TYPE REF TO if_sender_bcs,
recipient TYPE REF TO if_recipient_bcs,
bcs_exception TYPE REF TO cx_bcs.
* Email Subject
CONCATENATE sy-sysid ':' INTO lv_dummy.
CONCATENATE lv_dummy v_email_desc INTO v_email_desc SEPARATED BY space.
CONCATENATE v_email_desc 'on' v_date INTO v_email_desc SEPARATED BY space.
* Email Sender
CONCATENATE sy-sysid v_sender INTO v_sender.
* Mail Body
* Sending the Duration
WRITE p_dat_fr TO v_binterval_date DD/MM/YYYY.
WRITE p_tim_fr TO v_binterval_time USING EDIT MASK '__:__:__'.
WRITE p_dat_to TO v_einterval_date DD/MM/YYYY.
WRITE p_tim_to TO v_einterval_time USING EDIT MASK '__:__:__'.
** Header line
* wa_html = '<b>BDOC Processing Statistics:</b><br/>'.
* APPEND wa_html TO i_html.
* wa_html = '<br />'.
***************************************************************************************
* Fill Table for Processed BDocs *
***************************************************************************************
* Title line
CLEAR: wa_html.
wa_html = '<b>BDOC Statistics – Processed State:<b><br />'.
APPEND wa_html TO i_html.
ENDIF.
***************************************************************************************
* Fill Table for Error BDocs *
***************************************************************************************
* Title line
CLEAR: wa_html.
wa_html = 'BDOC Statistics – Error State: <br />'.
APPEND wa_html TO i_html.
ENDIF.
***************************************************************************************
* Fill Table for Intermediate BDocs *
***************************************************************************************
* Title line
CLEAR: wa_html.
wa_html = 'BDOC Statistics – Intermediate State: <br/>'.
APPEND wa_html TO i_html.
ENDIF.
***************************************************************************************
* Start Send Request *
***************************************************************************************
TRY.
CLEAR send_request .
send_request = cl_bcs=>create_persistent( ).
CLEAR document .
document = cl_document_bcs=>create_document(
i_type = 'HTM'
i_text = i_html
i_length = v_conlengths
i_subject = v_email_desc ).
* add document to send request
CALL METHOD send_request->set_document( document ).
CLEAR sender_id .
sender_id = cl_cam_address_bcs=>create_internet_address( v_sender ).
CALL METHOD send_request->set_sender
EXPORTING
i_sender = sender_id.
ENDFORM. "send_mail
*&---------------------------------------------------------------------*
*& Form display_result
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->LT_ERROR_DETAIL text
*----------------------------------------------------------------------*
FORM display_result TABLES lt_error_count STRUCTURE zzcount
lt_inter_count STRUCTURE zzcount
lt_success_count STRUCTURE zzcount
USING lv_count_e TYPE any
lv_count_i TYPE any
LOOP AT lt_success_count.
CLEAR lv_line.
lv_line+0(1) = '|'.
lv_line+2(26) = lt_success_count-bdoc_type.
lv_line+29(1) = '|'.
lv_line+30(10) = lt_success_count-count.
lv_line+41(1) = '|'.
WRITE:/ lv_line.
NEW-LINE.
WRITE: (42) sy-uline.
ENDLOOP.
WRITE:/ 'Total Count: '. WRITE lv_count_s COLOR 5. SKIP.
*********************** DISPLAY ERROR BDOCS**************************
ULINE.
WRITE:/ 'BDOC Statistics - Error State:' COLOR 6.
WRITE:/ line_top_left_corner AS LINE NO-GAP,
'----------------------------',
30 line_top_middle_corner AS LINE NO-GAP,
'------------',
42 line_top_right_corner AS LINE.
CLEAR lv_line.
lv_line+0(1) = '|'.
lv_line+2(26) = 'BDOC Type'.
lv_line+29(1) = '|'.
lv_line+30(10) = 'BDOC Count'.
lv_line+41(1) = '|'.
WRITE:/ lv_line+(42) INTENSIFIED COLOR 1 .
NEW-LINE.
WRITE: (42) sy-uline.
LOOP AT lt_error_count.
CLEAR lv_line.
lv_line+0(1) = '|'.
lv_line+2(26) = lt_error_count-bdoc_type.
lv_line+29(1) = '|'.
lv_line+30(10) = lt_error_count-count.
lv_line+41(1) = '|'.
WRITE:/ lv_line.
NEW-LINE.
WRITE: (42) sy-uline.
ENDLOOP.
WRITE:/ 'Total Count: '. WRITE lv_count_e COLOR 6. SKIP.
*********************** DISPLAY INTERMEDIATE BDOCS**************************
ULINE.
WRITE:/ 'BDOC Statistics - Intermediate State:' COLOR 7.
WRITE:/ line_top_left_corner AS LINE NO-GAP,
'----------------------------',
30 line_top_middle_corner AS LINE NO-GAP,
'------------',
42 line_top_right_corner AS LINE.
CLEAR lv_line.
lv_line+0(1) = '|'.
lv_line+2(26) = 'BDOC Type'.
lv_line+29(1) = '|'.
lv_line+30(10) = 'BDOC Count'.
lv_line+41(1) = '|'.
WRITE:/ lv_line+(42) INTENSIFIED COLOR 1 .
NEW-LINE.
WRITE: (42) sy-uline.
LOOP AT lt_inter_count.
CLEAR lv_line.
lv_line+0(1) = '|'.
lv_line+2(26) = lt_inter_count-bdoc_type.
lv_line+29(1) = '|'.
lv_line+30(10) = lt_inter_count-count.
lv_line+41(1) = '|'.
WRITE:/ lv_line.
NEW-LINE.
WRITE: (42) sy-uline.
ENDLOOP.
WRITE:/ 'Total Count: '. WRITE lv_count_i COLOR 7. SKIP. ULINE.
ENDFORM. "display_result