You are on page 1of 16

Site:

http://saptechnical.com/Tutorials/BI/Datastore/Index.htm

Inputs:
Function group: Function module: Structure: Generic Data source: ZZRSAX ZZRSAX_BIW_GET_DATA_SIMPLE ZZVTTPLIKP ZZ_SHIPMENT_DATA

Upload Data from R/3 System using a Function Module in Generic Extraction 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.

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 new function group & then copy only the function module RSAX_BIW_GET_DATA_SIMPLE as ZZRSAX_BIW_GET_DATA_SIMPLE as shown below:

Now go to the Tables tab for the FM ZZRSAX_BIW_GET_DATA_SIMPLE & change the Associated Type for the parameter E_T_DATA as ZZVTTPLIKP (Extract Structure that we have created using SE11 in step 1) as shown below:

Now go to the source code of the FM & do the below change & then Save & Activate the FM Group and the 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 table STATICS: 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 this LOG_WRITE 'E' "message type 'R3' "message class '009' "message number I_DSOURCE "message variable 1 ' '. "message variable 2 RAISE 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

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 table LOOP 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~ERNAM LIKP~ERDAT LIKP~VKORG LIKP~LFDAT LIKP~KUNNR LIKP~KUNAG VTTP~TKNUM VTTP~TPNUM from 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 FIELDS OF 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 FM i.e., ZZ_SHIPMENT_DATA & as we are uploading transactional data so select the radiobutton for Transaction data as shown below:

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 & then click on Save:

Give the selection condition & click on save:

STEP 4: Go to t code RSA3, enter the name of our DataSource & click on Start Extractor to check the data in the datasource using Extractor:

STEP 5: Go to t code RSA1 in our BI system, here go to DataSources, right click on application component Sales and Distribution & Replicate data as shown below:

Click on Continue & proceed as shown below:

Double click on the DataSource & Activate it as shown;

STEP 6: In RSA1 click on InfoProvider in the right hand panel, create an InfoArea & then create a DataStore Object in it as shown below:

Select the content for the DSO & Activate it:

STEP 7: In RSA1 click on DataSources in the right hand panel, go to our DataSource ZZ_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 have created in Step 6 as shown:

Create the Transformation & Activate it:

STEP 8: Go to DataSource ZZ_SHIPMENT_DATA right click on it & create InfoPackage as shown below:

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

STEP 9: Right click on the DataStore Object ZDEMODSO & Create Data Transfer Process as shown below:

Click on Continue, Activate it & then click on Execute:

Click on Yes as shown below to continue:

STEP 10: Right click on the DataStore Object ZDEMODSO & click on Manage to check the result:

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:

You might also like