7/31/2019 Upload Data From R3 System Using a Function Module in Generic Extraction to a DataStore Object in BI
1/16
Site: http://saptechnical.com/Tutorials/BI/Datastore/Index.htm
Inputs:
Function group: ZZRSAX
Function module: ZZRSAX_BIW_GET_DATA_SIMPLE
Structure: ZZVTTPLIKP
Generic Data source: ZZ_SHIPMENT_DATA
Upload Data from R/3 System using a Function Module in GenericExtraction to a DataStore Object in BI
By Pritam Ghosh, YASH Technologies
STEP 1: Create an Extract Structure in SE11 according to your requirement; here we will create a
structure for Shipment Item details for a
Delivery:
Here select the radio button for Structure & click on Enter.
http://saptechnical.com/Tutorials/BI/Datastore/Index.htmhttp://saptechnical.com/Tutorials/BI/Datastore/Index.htmhttp://saptechnical.com/Tutorials/BI/Datastore/Index.htm7/31/2019 Upload Data From R3 System Using a Function Module in Generic Extraction to a DataStore Object in BI
2/16
Give a Short Description for the Structure & add the necessary fields as shown below, then Save &Activated your Structure (try to maintain the Enhancement category for the structure).
STEP 2: Go to t code SE80 & copy the function group RSAX & give the name as ZZRSAX for the newfunction group & then copy only the function module RSAX_BIW_GET_DATA_SIMPLE asZZRSAX_BIW_GET_DATA_SIMPLE as shown below:
7/31/2019 Upload Data From R3 System Using a Function Module in Generic Extraction to a DataStore Object in BI
3/16
Now go to the Tables tab for the FM ZZRSAX_BIW_GET_DATA_SIMPLE & change the Associated Typefor the parameter E_T_DATA as ZZVTTPLIKP (Extract Structure that we have created using SE11 in step1) as shown below:
7/31/2019 Upload Data From R3 System Using a Function Module in Generic Extraction to a DataStore Object in BI
4/16
Now go to the source code of the FM & do the below change & then Save & Activate the FM Group andthe FM.FUNCTION ZZRSAX_BIW_GET_DATA_SIMPLE.*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING*" VALUE(I_REQUNR) TYPE SRSC_S_IF_SIMPLE-REQUNR
*" VALUE(I_DSOURCE) TYPE SRSC_S_IF_SIMPLE-DSOURCE OPTIONAL*" VALUE(I_MAXSIZE) TYPE SRSC_S_IF_SIMPLE-MAXSIZE OPTIONAL*" VALUE(I_INITFLAG) TYPE SRSC_S_IF_SIMPLE-INITFLAG OPTIONAL
*" VALUE(I_READ_ONLY) TYPE SRSC_S_IF_SIMPLE-READONLY OPTIONAL*" VALUE(I_REMOTE_CALL) TYPE SBIWA_FLAG DEFAULT SBIWA_C_FLAG_OFF
*" TABLES*" I_T_SELECT TYPE SRSC_S_IF_SIMPLE-T_SELECT OPTIONAL*" I_T_FIELDS TYPE SRSC_S_IF_SIMPLE-T_FIELDS OPTIONAL
*" E_T_DATA STRUCTURE ZZVTTPLIKP OPTIONAL
*" EXCEPTIONS
*" NO_MORE_DATA*" ERROR_PASSED_TO_MESS_HANDLER*"----------------------------------------------------------------------
* Example: DataSource for table SFLIGHT* Change the structure from sflight to ZZVTTPLIKP********
TABLES: ZZVTTPLIKP.* Auxiliary Selection criteria structure
DATA: L_S_SELECT TYPE SRSC_S_SELECT.
* Maximum number of lines for DB tableSTATICS: S_S_IF TYPE SRSC_S_IF_SIMPLE,
* counter
S_COUNTER_DATAPAKID LIKE SY-TABIX,* cursor
S_CURSOR TYPE CURSOR.* Create a range for Delivery Number
RANGES: L_R_VBELN FOR LIKP-VBELN.* Initialization mode (first call by SAPI) or data transfer mode* (following calls) ?
IF I_INITFLAG = SBIWA_C_FLAG_ON.************************************************************************
* Initialization: check input parameters
* buffer input parameters* prepare data selection
************************************************************************* Check DataSource validity
CASE I_DSOURCE.* Give the datasource a name which we will create in RSO2
WHEN 'ZZ_SHIPMENT_DATA '.
WHEN OTHERS.IF 1 = 2. MESSAGE E009(R3). ENDIF.
* this is a typical log call. Please write every error message like thisLOG_WRITE 'E' "message type
'R3' "message class
'009' "message numberI_DSOURCE "message variable 1
' '. "message variable 2RAISE ERROR_PASSED_TO_MESS_HANDLER.
ENDCASE.APPEND LINES OF I_T_SELECT TO S_S_IF-T_SELECT.
* Fill parameter buffer for data extraction calls
7/31/2019 Upload Data From R3 System Using a Function Module in Generic Extraction to a DataStore Object in BI
5/16
S_S_IF-REQUNR = I_REQUNR.
S_S_IF-DSOURCE = I_DSOURCE.
S_S_IF-MAXSIZE = I_MAXSIZE.* Fill field list table for an optimized select statement
* (in case that there is no 1:1 relation between InfoSource fields* and database table fields this may be far from beeing trivial)
APPEND LINES OF I_T_FIELDS TO S_S_IF-T_FIELDS.
ELSE. "Initialization mode or data extraction ?********************************************************************
* Data transfer: First Call OPEN CURSOR + FETCH* Following Calls FETCH only********************************************************************
* First data package -> OPEN CURSOR
IF S_COUNTER_DATAPAKID = 0.
* fill range with VBELN & change the name of range tableLOOP AT S_S_IF-T_SELECT INTO L_S_SELECT WHERE FIELDNM = 'VBELN'.MOVE-CORRESPONDING L_S_SELECT TO L_R_VBELN.
APPEND L_R_VBELN.ENDLOOP.
* Determine number of database records to be read per FETCH statement
* from input parameter I_MAXSIZE. If there is a one to one relation* between DataSource table lines and database entries, this is trivial.
* In other cases, it may be impossible and some estimated value has to
* be determined.
OPEN CURSOR WITH HOLD S_CURSOR FOR* Write your Select Query to fetch the data:
Select LIKP~VBELN
LIKP~ERNAMLIKP~ERDAT
LIKP~VKORGLIKP~LFDATLIKP~KUNNR
LIKP~KUNAG
VTTP~TKNUM
VTTP~TPNUMfrom LIKP INNER JOIN VTTP
on LIKP~VBELN = VTTP~VBELN
where LIKP~VBELN IN L_R_VBELN.ENDIF. "First data package ?
* Fetch records into interface table.* named E_T_'Name of extract structure'.
FETCH NEXT CURSOR S_CURSOR
APPENDING CORRESPONDING FIELDSOF TABLE E_T_DATA
PACKAGE SIZE S_S_IF-MAXSIZE.
IF SY-SUBRC 0.CLOSE CURSOR S_CURSOR.
RAISE NO_MORE_DATA.ENDIF.
S_COUNTER_DATAPAKID = S_COUNTER_DATAPAKID + 1.ENDIF. "Initialization mode or data extraction ?
ENDFUNCTION.
STEP 3: Go to t code RSO2 & create a DataSource with the same name that we have used in our FMi.e., ZZ_SHIPMENT_DATA & as we are uploading transactional data so select the radiobutton forTransaction data as shown below:
7/31/2019 Upload Data From R3 System Using a Function Module in Generic Extraction to a DataStore Object in BI
6/16
Select Application Component as SD & maintain the text for short, medium & long description & then click
on the tab Extraction by FM as shown below:
Now enter the name of the Extract Structure & FM that we have created in step 1 & 2 respectively & thenclick on Save:
Give the selection condition & click on save:
7/31/2019 Upload Data From R3 System Using a Function Module in Generic Extraction to a DataStore Object in BI
7/16
STEP 4: Go to t code RSA3, enter the name of our DataSource & click on Start Extractor to check thedata in the datasource using Extractor:
STEP 5: Go to t code RSA1 in our BI system, here go to DataSources, right click on applicationcomponent Sales and Distribution & Replicate data as shown below:
7/31/2019 Upload Data From R3 System Using a Function Module in Generic Extraction to a DataStore Object in BI
8/16
Click on Continue & proceed as shown below:
Double click on the DataSource & Activate it as shown;
7/31/2019 Upload Data From R3 System Using a Function Module in Generic Extraction to a DataStore Object in BI
9/16
STEP 6: In RSA1 click on InfoProvider in the right hand panel, create an InfoArea & then create aDataStore Object in it as shown below:
Select the content for the DSO & Activate it:
7/31/2019 Upload Data From R3 System Using a Function Module in Generic Extraction to a DataStore Object in BI
10/16
STEP 7: In RSA1 click on DataSources in the right hand panel, go to our DataSourceZZ_SHIPMENT_DATA & right click on it & click on Create Transformation as shown below:
In the Target of Transformation give Object Type as DataStore Object and name of DSO that we havecreated in Step 6 as shown:
7/31/2019 Upload Data From R3 System Using a Function Module in Generic Extraction to a DataStore Object in BI
11/16
Create the Transformation & Activate it:
STEP 8: Go to DataSource ZZ_SHIPMENT_DATA right click on it & create InfoPackage as shownbelow:
7/31/2019 Upload Data From R3 System Using a Function Module in Generic Extraction to a DataStore Object in BI
12/16
Give a description for the InfoPackage & click on Save:
Now go to tab Schedule & click on Start as shown below:
Now go to the Monitor
7/31/2019 Upload Data From R3 System Using a Function Module in Generic Extraction to a DataStore Object in BI
13/16
STEP 9: Right click on the DataStore Object ZDEMODSO & Create Data Transfer Process as shownbelow:
Click on Continue, Activate it & then click on Execute:
Click on Yes as shown below to continue:
7/31/2019 Upload Data From R3 System Using a Function Module in Generic Extraction to a DataStore Object in BI
14/16
STEP 10: Right click on the DataStore Object ZDEMODSO & click on Manage to check the result:
7/31/2019 Upload Data From R3 System Using a Function Module in Generic Extraction to a DataStore Object in BI
15/16
Go to the Content tab of InfoProvider Administrator screen & click on New Data as shown below:
Now click on Execute:
Final data in DataStore Object:
7/31/2019 Upload Data From R3 System Using a Function Module in Generic Extraction to a DataStore Object in BI
16/16