Conditional Broadcasting
Hi Guys, recently I came across a requirement which I am not able to handle via standard way of broadcasting options present in SAP BW and developed a custom solution . Since the ask is very genuine so hereby sharing the development If this brings any value to all of you guys .
Requirement : User wants to do the broadcasting which is scheduled monthly but only when the for given selections reports contains any data . If the for the fiscal year period(one of Report selection), report do not have any data, broadcasting mails must not get triggered . Also they want the report attachment in the form of Excel so that they can simple download the attachment from the report and do there analysis.
SAP Broadcasting Ways : SAP has given the options like ‘Broadcasting Via Mail’ wherein we can send the mail thorough a customized body in the form of attachment(spreadsheet, Zipped Attachment, PDF, HTML) etc. But the this not fit to my case since in this system will send the scheduled broadcast email even if report do not contains any data i.e. a blank email (Mail without any report data) .
Also another way of thinking of the solution is to use SAP Broadcast option ‘Broadcasting Via Exception’ . For this option to use , you must have exceptions set in your Bex Report .Also using option we can send any attachment instead SAP do a summary/detail of the exceptions caught in the report & send it in the mail body itself. So this solution will also not suffice for stated requirement.
Solution proposed : To tackle the problem statement following approach & development is requirement .
- First we need to figure out If query for the given selections have any data or not. So we use the standard FM ‘RRW3_GET_QUERY_VIEW_DATA’ to check the report Output . This FM need input parameter as I_INFOPROVIDER = ‘your Info Provider which could be Infocube, Multiproviders etc’ , I_QUERY= ‘Your Query Technical Name’ & ‘I_T_PARAMETER’ which contains the query Input variables & its values . In the Export parameters if the table ‘E_CELL_DATA’ contains records means report has data , if this table output is 0 , means report is not getting any data for passed selection .
Note the I_T_PARAMETER has to be filled as displayed below for every prompts which you want to be passed as selection(in the example query has a mandate prompt of 0FISCPER so we have passed the same using the variable created over 0FISCPER.
- Now since the broadcasting is based on the output of the of table ‘E_CELL_DATA’ i.e. call the broadcaster only when if No of records in E_CELL_DATA is greater than 0.So a decision step using ABAP is required in your broadcasting Process chain . If the decision is true , then we have to pass the PC step to broadcast step else either error the processor any step, say a mail step stating to stakeholders that No broad since the report has not any data.
- Now to call the FM in the decision step , we have to implement a BADI ‘RASR_CONNECTOR’ as say ZBW_BROADCAST’ . In the class results in the implementation of BADI, we have to create a custom method( say as ‘ZGET_REPORT_RECORDS_COUNT), which took input as ‘Info Provider’ and ‘Query Name’ & output the parameter ‘Record set’ which is count of records in E_CELL_DATA of mentioned function .
- Also the method ‘GET’ of the BADI implementation class need to enhanced , so that we can segregate the above method under a separate section as shown in the formula builder screen of the decision step
BADI Implementation
Custom method’ ZGET_REPORT_RECORDS_COUNT’ created in BADI Class via editing the class in SE24.
Import & Export parameters of above Highlighted method
Code put in the method as display below
Overriding the method ‘GET’ to have above method displayed under a different section in formula screen of the decision step
When we use the decision step we can find the new section ‘C_BW_CUSTOM’ in the formula builder screen & within we find out method to be used as below
- Now if the decision step is true , we can call the Bex Broadcaster Program ‘RSRD_BROADCAST_STARTER’ using the Broadcast setting that you have created for Your Bex Reports .Broadcast Process chain using the decision step will look like as displayed below
Thanks everyone for having patience reading the document . Feel free to suggest any value add .
Really helpful
Informative, quick question E_CELL_DATA is standard table?
Regards,
Harish
Hi Harish,
As you can check the FM 'RRW3_GET_QUERY_VIEW_DATA' has a export parameter of table type which is E_CELL_DATA and contains the query data .
Regards,
Kunwar
nice and informative document