Innovative Way to Create a BW Extractor
I wrote couple of posts for ABAPers and this one is the first one for BW guys. First of all why my post is different from others? There are many, in fact infinite articles, blogs, tips and tricks regarding BW extractors. You can search for them on SCN Redirecting… too.
So, here is an idea! I got one requirement from BW guys and I never worked on extractors because it was my first time.
BW guys goes!
Here is the requirement:
We need a BW extractor based on a Z ABAP ALV report and it should give us the exact output as it’s giving in ECC (isn’t it simple?). Wow! I was like shocked then I thought it should be easy! 😀 But it was like a biggest challenge for me and problem’s queue was waiting for me.
Requirement was simple but the challenge was to call ALV report without making a copy of that so SUBMIT came into play but whenever we submit it first shows us the ALV then it comes back with the result. ALV was never required because RSA3 has it’s own ALV to show the data.
What I did were the basic steps for creating an extractor (you already know):
1. Copy RSAX_BIW_GET_DATA_SIMPLE from Function Group RSAX to my desired name.
2. Make changes according in the extractor to fulfill my requirement.
3. Put in the RANGES to filter the data and pass it to the ALV report.
4. Handle the packages accordingly.
5. Create a Datasource.
6. Create an Extract Structure.
Simple? Yeah! It is. 🙂
Now here is the trick! I used SET method of Class CL_SALV_BS_RUNTIME_INFO and I switched ON only one parameter that is DATA because I don’t need MetaData and Display ALV.
EXPORTING DISPLAY = ABAP_FALSE
METADATA = ABAP_FALSE
DATA = ABAP_TRUE ).
This will set the Memory ID for ALV Report. Now call the Z ABAP report or standard one by SUBMIT button and Clear the memory.
WITH P_EMAIL = S_EMAIL–LOW
WITH P_MARERR = ‘0’
WITH P_MODE = ‘0’
WITH P_SORG = WA_ORGS_CODE–VKORG
WITH S_CUST IN S_CUST
WITH S_DATE IN S_DATE
WITH S_SORD IN S_SORD
Now you need to get the data ALV returned for that purpose following code can be used:
IMPORTING R_DATA = LR_DATA ).
ASSIGN LR_DATA->* TO <LT_DATA>.
Here LR_DATA is declared as TYPE REF TO Data and <LT_DATA> is FIELD_SYMBOL of TYPE ANY.
Major steps done you fetched the data and put in your desired table. Final step is to give it to BW. For that purpose I have created a transparent table with same same structure as the Extract Structure. Why I did it? Because OPEN CURSOR can not fetch data without a transparent table.
OPEN CURSOR WITH HOLD S_CURSOR FOR
SELECT * FROM ZBWINVTAB.
FETCH NEXT CURSOR S_CURSOR
APPENDING TABLE E_T_DATA
PACKAGE SIZE S_S_IF–MAXSIZE.
IF SY–SUBRC <> 0.
CLOSE CURSOR S_CURSOR.
Same will be done for every package.
To summarize, there are two major steps. Call standard class to SUBMIT report and get data back, 2nd: Create a transparent table.
I haven’t seen this approach anywhere on the internet. Believe me or not it’s working like a charm. Whole source-code is attached.
Let me know in your comments what you feel about this one!
Interesting, good one!!!
This is something that comes up every once in a while so this is quite helpful.
One question though: why the Z-table? As I understand the cursorization is primarily used to avoid over-burdening the ECC system with an extractor lifting too much data at a time. But in this example, the ECC system already generates all the data in the original report, so the data is available to be sent.