Sunteți pe pagina 1din 11

Create Generic Extractor from SAP R/3

Step
Step
Step
Step

1
2
3
4

Create an Infoset in SAP R/3


Create a Generic Data Source in SAP R/3
Test a Generic Data Source in SAP R/3
Replicate and Use Generic Data Source in SAP BW

Extractor Data Model


SAP R/3 Data Source "Purchasing data"
EKKO (Purchase Document Header)
EKPO (Purchase Document Item)
\
DataSources
Create Infoset on table EKKO
Add new table EKPO and join two tables (Edit->Insert Table) //Delete Link join
Select fields for extraction
Remove text fields (Infoset->More functions->Delete Text Fields)
Generate Infoset
Create Extractor based on Infoset (RSO2, Appl. Component: SAP->SAP/R3->MM, Ext
raction from Query, Infoset: ZIS_PO_TRAN, Save, Marked Selection Fields, Save, [
Generic Delta] )
Create delta option (marked Calend.Day, select AEDAT006, Save)
Test the Extractor (RSA3, ZDS_PO_TRAN)
Replicate to BW (RSA1, DataSources, SAP/R3->MM, Right Click: Replicate Metadat
a,
select: this and following 1 as DataSource)
, DataSources Assign InfoSource ->Create
SAP BW tutorial - SAP BW EXTRACTION (GENRIC VIEW, FUNCTION MODULE)
https://www.youtube.com/watch?v=P_2EgwInR44
SAP BIBW ECC Extraction training class
Saponline Training classes in usa,canada,india
https://www.youtube.com/watch?v=QwqoRG7bqI0
SQ01 SQ02
http://sapboard.ru/forum/viewtopic.php?p=358509
, .
:

- SQ02, . .
(SQ01) .
, -
- . ?
HR580 .
SD . -. -.
SAP Query :
http://sapboard.ru/forum/viewtopic.php?f=17&t=56870&p=355404
, .
, .

SAP Query ADA.


SAMRR = ANEPV-NAFAV + ANEPV-NAFAL.
1. ( ABAP).
2. , DATA.

,
SQ01 Local Field
SAP Query BC405, BC407. BC407 .
How to create the extractor (extract data)
Every extractor has : the structure and functional module
1. We must create a structure of our extractor. Go to se11, choose Data type - Z
ST1_TEST2 - create - Structure
On the table - parameters of structure (of course it's only sample)
COMP_CODE
/BI0/OICOMP_CODE
CALMONTH
/BI0/OICALMONTH
CALYEAR
/BI0/OICALYEAR
FISCPER3
/BI0/OIFISCPER3
AMOUNT
RSBCTMA_OD_MONET_AMOUNT
CUR
BAPIBP_BAL_CUR
2. Create fm ( more detail about fm I'll write later)
FM - it's very important and specific step. My skills in ABAP are near the zero
an absolutely zero I'll try to describe in detail
ATTENTION: I must create fucnction group and include with data types in se80 for
fm import parameters. se80 - Function Group -Enter - Yes
Change the include LZ_ZLOBINTOP
FUNCTION-POOL Z_ZLOBIN.
TYPE-pools SBIWA.
TYPE-pools SRSC.
TYPE-pools ZBCST.
TYPE-pools RSD.
2.1 se37 - ZST1_TEST
Import parameters
I_REQUNR
SBIWA_S_INTERFACE-REQUNR
Request number

"MESSAGE-ID ..

I_DSOURCE
SBIWA_S_INTERFACE-ISOURCE
Source name
I_MAXSIZE
SBIWA_S_INTERFACE-MAXSIZE
Max size of the package
I_INITFLAG
SBIWA_S_INTERFACE-INITFLAG
Initial flag
Tables
I_T_SELECT
SBIWA_T_SELECT
Data for processing
I_T_FIELDS
SBIWA_T_FIELDS
Field restrictions
E_T_DATA
ZST1_TEST2
Out table (type of our structure (look 1)
ABAP code we will view later.
3. The create of data sourse. Go to rso2 and fill the fields as in picture
Now press Save and mark the selections ( I_T_FIELDS in fm)
Press Save - goto rsa1 - DataSources and in the required system Replicate metada
ta

Ofcourse you need to create FM to get real data.


Imagine, that we have table ZST1_TEST

CALMONTH
COMPCODE
CUR
AMOUNT
1
201301

2014
RUB
1 000,0000
2
201301
4011
RUB
6 000,0000
3
201301
5011
RUB
1 000,0000
4
201301
7007
USD
5 600,0000
5
201302
2014
RUB
2 000,0000
6
201302
5011
RUB
44 000,0000

7
201303
2014
RUB
3 000,0000
8
201303
6010
RUB
6 000,0000
9
201304
2014
RUB
4 000,0000
10
201304
3011
RUB
5 000,0000
11
201305
6987

987 654,0000

we need to exctract data as

CALMONTH
COMPCODE
CUR
AMOUNT
FISCPER3
CALYEAR

if space then USD

YYYYMM->0MM
YYYYMM->YYYY

In FM- extractor I single out 3 steps:

1. Initialization infosousre and define the limits


2. Data processing - the work with data for extract
3. Work with out table

This is my FM ( i'm the greatest ABAP master ) with comments


********************************************************************************
****
FUNCTION ZST1_TEST.
*"---------------------------------------------------------------------*"*" :
*" IMPORTING
*"

REFERENCE(I_REQUNR) TYPE SBIWA_S_INTERFACE-REQUNR

*"

REFERENCE(I_DSOURCE) TYPE SBIWA_S_INTERFACE-ISOURCE

*"

REFERENCE(I_MAXSIZE) TYPE SBIWA_S_INTERFACE-MAXSIZE

*"

REFERENCE(I_INITFLAG) TYPE SBIWA_S_INTERFACE-INITFLAG

*" TABLES
*"

I_T_SELECT TYPE SBIWA_T_SELECT OPTIONAL

*"

I_T_FIELDS TYPE SBIWA_T_FIELDS OPTIONAL

*"

E_T_DATA STRUCTURE ZST1_TEST2 OPTIONAL

*" EXCEPTIONS
*"

NO_MORE_DATA

*"

ERROR_PASSED_TO_MESS_HANDLER

*"---------------------------------------------------------------------* Structure for request parameters


*
STATICS: S_S_IF TYPE SRSC_S_IF_SIMPLE.
* Statics variables counter and table for storage data between calls
* .
STATICS: S_COUNTER_DATAPAKID LIKE SY-TABIX,
t_data_temp like ZST1_TEST occurs 0 with header line,
tab type ZST1_TEST occurs 0.
* Ranges for selections
*
RANGES: L_R_CALMONTH FOR ZST1_TEST-CALMONTH,
L_R_COMPCODE FOR ZST1_TEST-COMPCODE.

DATA: L_S_SELECT LIKE I_T_SELECT,


idx LIKE sy-tabix,
wa_E_T_DATA LIKE E_T_DATA,
n TYPE I,
calmonth type /BI0/OTCALMONTH.
* >>>>>>>>>> 1. Initialisation and identifying restrictions
*
if I_INITFLAG = 'X'.

CLEAR S_COUNTER_DATAPAKID.

* Check DataSource validity


CASE I_DSOURCE.
WHEN 'ZST1_TEST'.
WHEN OTHERS.
RAISE ERROR_PASSED_TO_MESS_HANDLER.
ENDCASE.
ELSE.

* >> Read data only in first call


*
IF S_COUNTER_DATAPAKID = 0.
* >>>>>> Select data
* >>>>>>
LOOP AT I_T_SELECT INTO L_S_SELECT
WHERE FIELDNM = 'CALMONTH'.
MOVE-CORRESPONDING L_S_SELECT TO L_R_CALMONTH.
APPEND L_R_CALMONTH.
ENDLOOP.

LOOP AT I_T_SELECT INTO L_S_SELECT


WHERE FIELDNM = 'COMP_CODE'.
MOVE-CORRESPONDING L_S_SELECT TO L_R_COMPCODE.
APPEND L_R_COMPCODE.
ENDLOOP.
* <<<<<< Select data

*>>>>> 2.Operations with selected data restrictions


* From table ZST1_TEST select data according restrictions to the table (L_R_CO

MPCODE and L_R_CALMONTH)


*
select * into corresponding fields of table tab from ZST1_TEST where CALMONTH in
L_R_CALMONTH and COMPCODE in L_R_COMPCODE.

endif.
*<<< IF S_COUNTER_DATAPAKID = 0.
*<<<<< 2. Operations with selected data restrictions

*>>>>> 3. Data processing


* Refresh table between calls
Refresh E_T_DATA.

*
DO I_MAXSIZE TIMES. " reading in the amount of maxsize of records
idx = S_COUNTER_DATAPAKID * I_MAXSIZE + sy-index. " set index to the u
ntreated record in table
* each call of extractor idx increases on S_COUNTER_DATAPAKID * I_MAXSIZE
READ TABLE tab INTO t_data_temp INDEX idx. " read record from table to
the hader line
IF SY-SUBRC <> 0. " index NOT table - exit!
EXIT.
ELSE.
* write line of out table
wa_E_T_DATA-COMP_CODE = t_data_temp-COMPCODE.
wa_E_T_DATA-CALMONTH = t_data_temp-CALMONTH.
CONCATENATE '0' t_data_temp-CALMONTH+4(2) into wa_E_T_DATA-FISCPER3.
wa_E_T_DATA-CALYEAR = t_data_temp-CALMONTH(4).
if t_data_temp-cur is INITIAL.
wa_E_T_DATA-cur = 'USD'.
else.
wa_E_T_DATA-cur = t_data_temp-cur.

ENDIF.
wa_E_T_DATA-amount = t_data_temp-amount.
* append line to out table
APPEND wa_E_T_DATA TO E_T_DATA.

ENDIF.
ENDDO.

DESCRIBE TABLE E_T_DATA LINES N. " Count records in out table. If n = 0 - N


O MORE DATA!
IF SY-SUBRC <> 0 AND N = 0.
RAISE NO_MORE_DATA.
ENDIF.
* Increase the counte befor next call
*


S_COUNTER_DATAPAKID = S_COUNTER_DATAPAKID + 1.

endif.

ENDFUNCTION.
********************************************************************************
****

Let's debug this process. Goto rsa3. In table ZST1_TEST we have only 11 records
, that's why set this parameters of extractor
(3 calls on 2 records)

Data Records / Calls


2
Display Extr. Calls

Set the limits

===========================
SAP BW BI LO Extraction.pdf
===========================
With this option, you avoid pulling from R/3 directly as we need to bring field
values from multiple tables. You
can see the data in the setup tables. Setup table name will be extract structure
name followed by SETUP.
Set up table names starts with 'MC' followed by application component '01'/'02'
etc and then last digits of the
Data source name and then followed by SETUP
Also we can say the communication structure (R/3 side, you can check it in LBWE
also) name followed by
'setup'
example: MC13VD0HDRSETUP
?
If you want to check data in set up tables you better look at the transaction NP
RT here you
can see the table name from which data is picking.
?
Setup tables are cluster tables and are used to extract the data from R/3 Tables
.(LO
Extractors)
?
Basically, for entire application like SD-Billing we have got it's own setup Tab
les...so while
filling the set-up tables, we usually fill for the entire application.
Ex: OLI7BW is for filling setup Tables for SD application.
OLI9BW T-code is for Billing Application,
?
When u fill the setup Tables, the data from different tables..VBAK, VBAP, VBRK,
VBRP...etc
will come through communication Structures and saved in Setup Tables...
?
The main advantage of having setup Tables is, we can read the data in different
levels..Header level as well as Item level.
?
when we run init load or Full load in BW, the data will be read from Setup Table
s for the first
time( Entire data will be read).... and the delta records will be updated to Del
ta Queue once
the v3 job runs... and we can extract the delta records from Delta Queue.
?
Once we successfully run the init, we can delete setup Tables.
?
Filling up the set up tables depends on the Datasource.

S-ar putea să vă placă și