You are on page 1of 7

Task : Use a DataSource based on a function module to extract data into BW.

Data must respect


the parameters given by the user in a ABAP Programm.
Example : select whatever fields you wish from both BKPF and BSEG tables

Step 1 : Create a “Z” structure to based on which you will extract data.
1. Go to transaction “SE11”.
2. Select “Data type” and give a “Z” name

3. In the next screen make sure you select the “Structure” option
4. Complete the “Short description” box and insert the fields that you want your structure to have.

5. Go to ABAP Workbench (SE80) and select the RSAX Function Group. Create a copy of your own
and select the FM that you want to use. In this case only RSAX_BIW_GET_DATA_SIMPLE.
6. In the Import, Export and Changing tabs we don’t have to change anything. We have to change
only in the Tables. The extracted data is stored in the E_T_DATA table, therefore it must have
the “Z” structure that you have defined earlier.

7. In the source code tab you have to modify the source code according to your needs:
a. Tables : the tables from which you retrieve your data. In this case you will write the
BKPF and BSEG instead of SFLIGHT.
b. The ranges refer to the parameters of data selection. (Looking a bit in the future this
ranges are read from the InfoPackage in BW, whatever the method of selection : direct
method in the InfoPackage’s interface or by ABAP Routine or OLAP variables)

In this case the


fields of selection in which we are interested would be :
i. BUKRS - Company Code
ii. GJAHR - Fiscal Year
iii. BLART - Document Type
iv. BUDAT - Posting Date in the Document
v. MWART - Tax Type
vi. TXJCD - Tax Jurisdiction
c. Replace the name of “I_DSOURCE” with the name of your own DataSource. If you don’t
replace this text the DataSource will not work

d. Adding of data filters : replace “FIELDNM” with the name of the field by which you want
to filter, and then replace the name of the range with the one of the range that you
have defined earlier. You must do this for each of the filters that you want to use.

e. Next you have to select your data, therefore replace the market source code with your
selection code.
Take note that S_S_IF-T_FIELDS is useful only if you retrieve all the fields of a table, and
if that would be the case, it would be much easier to create an extractor based on the
table. Back to the task in discussion your selection code should look like this :

SELECT
dbtab~fldname1 dbtab~fldname2 dbtab~fldname3
dbtab2~fldname4 dbtab2~fldname5
FROM dbtab
JOIN dbtab2 on
Dbtab1~fldname0 = dbtab2~fldname0
INTO CORRESPONDING FIELDS OF TABLE E_T_DATA
WHERE condition.

This is the simplest case, if that would be the case, the FM would be ready, no
more work. But when we need more than that, a selection on multiple tables, call of
functions etc. that is not enough. Therefore we need to do something more interesting,
like below.

First of all we need an internal table for the header information, to know how to combine the
headers with the items etc.
To do that we need to take a look in the “Display Object List”. In the “Includes” folder you
should have an include named by the concatenation of “L”, the name of the function group you created
and at the end “TOP” (it is highlighted in the screen capture below)
Double click on it and start editing : define your type of header, and declare an internal table
and if it is necessary also a working area. Save and activate, then return to the function module source
code. The select written earlier will have to be a little altered : the “INTO…” clause will be followed by
the name of the internal table declared in the “TOP” include.
Create the “ELSE” branch of the “IF” with “RAISE NO_MORE_DATA”. On the “ELSE” side write:

When we create the form, choose to create it in a new include, so the


PERFORM
code won’t get hard to read. In form_name
the newly TABLES
created include theE_T_DATA.
form will appear like :

Replace “zstructure” with the name of the dictionary structure that you
FORM form_name  TABLES   p_e_t_data STRUCTURE  zstructure
declared “E_T_DATA” in the “Tables” tab.
After you have done that, you can make any further processing you may need, including calling
of other FM.

Remember that after all the processing is finished


your data must be in the p_e_t_data, otherwise your
FM will not return any data.

You might also like