You are on page 1of 17
SAP BI Generic Extraction Using a Function Module Summary This article demonstrates a step-by-step process for doing generic extraction from R3 into Bl using a Function Module. Author(s): P Renjith Kumar. Company: Pricol Technologies Created on: 14 February 2007 Author Bio P. Renjith Kumar is SAP BI Consultant with PRICOL Technologies. He has extensive cross- functional experience and has been with end-to-end SAP implementations as an ABAP Consultant. D007 SAPAG i SAP BI Generic Euracion Using a nction Modula Table of Contents Data Source Creation.. Checking Extraction... BW Side. Disclaimer and Liability Notice. SAP DEVELOPER NETWORK | sdnsap.com [BUSINESS PROCESS EXPERT COMMUNITY | bpcsap com TAT EAPAT 3 R3 Side 1. Create a structure with the necessary fields. The Currency and quantity fields must have reference fields also. [ss Coe ome OneD Enos pray struct sett fieenes tes] Neer ay nena ee eS Se ee ee ee NETWR is a currency field so it must have reference field that is in the base table. Click Currency / Quan and give that field name Lt Ce Oke Snes OH Om Dictio isplay Structure | SD) i | 1a | | [Herre Asoo Srvc (SIeaisHLs|__ (oi sesennome a Bel (De ee "| Gow | eer feer | owl por lee Seen] (ONES a 2. In transaction SE80, Select Function group, name RSAX. Right click and Copy: DRT SAPAG 3 SAP, ef, Cee BNR ona) _O8 Object Navigator S| BG emoner [Bhai heron [econo itomatn ten ae Ww a al nw & Gioitonetses change > Eitweoe cane > Grose % > Biseoe a . 3 > Bircies sep 2 ata ee ae oe wane] (Dem Bvt «fpf aw gS mealle On wIGwe,| (OWNS sma Ep SP ne comenn NOs ORO Onject Nevigator Se cena [Genes = isco Bios Give new, ——— name of _———— za function Group ee SS a aoe = a= el ea al Funcen magus > arene . > Grcucee ie © : : ofa cae Te Bsm| (Ae F”) Oo foie oir | sow er lfeon See) |OWMSS TaN Select only the needed function module: DRT SAPAG a Ey 7 Object Navigator 29 Ba corona [Bro rercaor Beiseon [2trensr|[oxeuneon moos nae. ise unsionmesus name. Botan Font av of DATR IRSGH_ MIERARCNY CATALOG snc _toEh_pLenanc CATAL Fe RSGH_HIGRARGHY_TRONGFER_Pshe 2608 FIERARGHT_ TRANSFER SE_AIERARCAY_CATALOG_RELASS_ SRE ATERARCRY- CATALOG LASS EAIERAROIY_TRARSFER HOLASS SA HICPARCNY= TRANSFER. NAS RG Bi¥_SET_ OAT TAROT PREEMENT AFTER TRON enc CVERT_0FTER-TwORT coor BEB al 3 fon) eee ee Se SO Se [OWS sen En a. Seren ever © | BEG Enon (Bent nesoaon [Berwen [ZTtend.: | [cusuneton mule nave Tew uncion mesic rane (Dato a DSN 08 SAX_GEN_HIERAROHY CATALOG RAK SEN HIERARCHY CATALOG GOSER-HIERAROH_TRANSFER_ ASNSER_MIERARCAT TRANSFER HE G10 GET_OATA VITH ARCHIVE RERE_61V-GET DATA WITH ARCH AEBIW_GETOATA.SINPLE_ASAX_BIV_GET_OATA.SIRPLE Give the new SCEYENT_AFTERLIMPORT —— ASAE_EVENT_AFTER IMPORT function module name 7 coor) BA |2) 2 [rar S000 ‘Gaal Be @ Ow. [Ou [ow | am eee feon Shown | (OME vm The Function Module in SE37 will be like this, we have to do light modification SAP BI Generic Extraction Using @ Fiction Made ED Function Builder: Change ZRSAX_GIW_CET DATA SIMPLES 2 5 | a | 3 a | | Pn | PrP | Funston module documentation i ; Shon Femptaa: berspungvon Seweounasdai ‘No change in Import Tab. L868 D088 BE) Function Builder: Change ZRSAX_6IW_GET_DATA_SIMPLE4 2 S|) Si |B | BB BB) Pati || Presy Prine | Funetonmdie documentation RoC_6_1F_SINP pence C6 1F_SIP IMTTFLAg C6 FSI IC RenoTE_CALL BWA FLAS oCals|s\s\s\5) OCiols|sieisi\s) Bolo} cic} Export, Changing No values, SAP DEVELOPER NETWORK | edn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bp sp com DRT SAPAG SAP BI Generic Extraction Using @ Fiction Made Function Builder: Change ZRSAX_SIW_GET_DATA_SIMPLE4_2 SS) PS ST | en reer romeermeru domme In TABLES tab, give the structure name. _ 88 eee: 8 5Hoo Function Builder: Change ZRSAX_BIW_GET_DATA_SIMPLE4_2 (| 2) wi a) Ss | BW | (Wat Press ine | Funeton male documentation TRSIK_BIV.SET ATA STWPLES 2 Tobie ann "aeouKT Give your structure name io a I a Bom] Ao wm” ew [oor our | som |asoe fern Steee | /OwWe rar In Exceptions No data. In Source code Tab. Write this Code ‘The Code that we need to write is Placed Inside SAP DEVELOPER NETWORK | edn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bp sp com DRT SAPAG 7 Code FUNCTION ZRSAX_BIW_GET_DATA SINPLE4_2 Local inter "IMPORTING VALUE(I_REQUNR) TYPE SRSC_S_IF_SINPLE-REQUNR VALUE(I_DSOURCE) TYPE SRSC_S IF SINPLE-DSOURCE OPTIONAL VALUE(I_MAXSIZE) TYPE SRSC_S_IF_SINPLE-NAXSIZE OPTIONAL VALUE (ILINITFLAG) TYPE SRSC_S_IF_SIMPLE- INTTFLAG OPTIONAL VALUE(I-READ_ONLY) TYPE SRSC_S_TF SIMPLE-READONLY OPTIONAL VALUE(I-REMOTE CALL) TYPE SBIWA FLAG DEFAULT SBIWA_C_FLAG OFF TABLES TTSELECT TYPE SRSC_S_IF_SIMPLE-T_SELECT OPTIONAL ICTIFIELDS TYPE SRSC_S_IF_SIMPLE-T FIELDS OPTIONAL ELTDATA STRUCTURE ZNVBAK? OPTIONAL EXCEPTIONS NO_HORE_DATA ERROR_PASSED_TO_MESS_HANDLER ce Exanple: DataSource for table SFLIGHT TABLES: ZNVBAKT Auxiliary Selection criterta structure DATA: L_S_SELECT TYPE SRSC_S_SELECT + Maximum number of Tines for DB table STATICS: $_$_IF TYPE SRSC_S IF SINPLE, counter §_COUNTER_DATAPAKID LIKE SY-TABIX, * cursor S_CURSOR TYPE CURSOR Select ranges + ORANGES: L_R-CARRID FOR SFLIGHT-CARRID . L-RCONNID FOR SFLIGHT-CONNID. RANGES: SDNO FOR 2nvbakt -VBELN Initialization moce (Tirst call by SAPI) or data transter node (fotlowing calis) ? IF L_LINITFLAG = SBINA_( = FLAG_ON Initialization: check input parameters butfer input paraneters prepare data selection Check DataSource valicity CASE T_DSOURCE WHEN ‘2FHEDSS" > | Name of Data source WEN OTHERS given in RSO2 IF 1 = 2. HESSAGE E008(R3). ENDIF this is a typical log call. Please write every error message Tike this Log_WRITE 'E* "message type "3" "message clase "609" message nunber T_DSOURCE “message variable 1 ~ "message variable 2 DRT SAPAG 3 RAISE ERROR PASSED_TO_NESS_HANDLER ENDCASE APPEND LINES OF SELECT To $_$_IF-T_SELECT + F111 paraneter buffer for data extraction calls $8 IF-REQUNR T_REQUNR. S IF-DSOURCE = T_DSOURCE, SIF-MAXSIZE = 1_NAXSIZE + FIN THetd list table for an optimized select statenent + (in case that there is no 1:1 relation between InfoSource fields and database table Tields this may be tar trom beeing trivial) APPEND LINES OF I_T_FIELDS TO $_S_IF-T_FIELDS ELSE “Initialization mode or data extraction ? + Data transfer: First call OPEN CURSOR + FETCH : Fo Ts FETC * First data package -> OPEN CURSOR IF $ COUNTER DATAPAKIO = 6. * F111 range tables BN will only pass down simple selection criteria + of the type SIGN = 'I' and OPTION = 'EO" or OPTION = 'BT” NOVE-CORRESPONDING L_S SELECT TO L_R CONNID ‘APPEND L_R_CONNID ENDLOOP : LooP AT SS IF-T SELECT INTO L_S SELECT WHERE FIELONM = ‘CARRID® : NOVE-CORRESPONDING L_S SELECT TO L_R CARRID : APPEND L_R_CARRID. : ENDLOGP : Loop AT SS IF-T SELECT INTO L_S SELECT WHERE FIELONM = ‘CONNID® LOOP AT $_S_IF.T_SELECT INTO L_S_SELECT WHERE FIELONY =| 'VBELN’ NOVE-CORRESPONDING L_S_SELECT To [SDN APPEND [S0NO. ENDLOOP "Determine number of database records to be read per FETCH statement + from input parameter IMAXSIZE. 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 $_CURSOR FOR : ‘SELECT (3-5 IF-T FIELDS) FROM SLIGHT : WHERE CARRID IN L_R CARRID AND . CONNID IN L_RCONNID. SELECT VBAK-VBELN VBAK-ERDAT VBAK-NETAR VBAP-NATNR VBAP~POSNR. FROM VBAK’ INNER JOIN VBAP cn VBAK~VBELN = VBAP-VBELN WHERE VBAK-VBELN IN SONO ENDIF Firet data package 7 + Fetch records into intertace table + “named ET_'Name of extract structure’ TAPAS 3 SAP BI Generic Euracion Using a nction Modula FETCH NEXT CURSOR S_CURSOR APPENDING CORRESPONDING FIELDS OF TABLE E T_DATA PACKAGE SIZE §_S_IF-MAXSIZE. IF SY-SUBRC <> 6. CLOSE CURSOR S_CURSOR. RAISE NO_MORE_DATA. ENDIF. S_COUNTER_DATAPAKID = $_COUNTER_DATAPAKTO + 1. ENDIF “Initialization nose or data extraction ? ENDFUNCTION ‘Now Save, Activate the function module Goto SES0 -> Select Function Group, Activate the Function Group. Note: Ifyou do not activate function Group, You will not be able to create data source in RSO2 Data Source Creation Then you have to create the data source, the data source name must be the name given in the source code of the Function module. RSO2-> Create aa | || on | year | eysar | awe | gh sar fren SAP DEVELOPER NETWORK | sin sap-com [BUSINESS PROCESS EXPERT COMMUNITY | bpcsap com TAT EAPAT 10 SAP BI Generic Euracion Using a nction Modula Select Extr By Fun Module, Give name of Appl comp, Function Module, Extract Structure, save Checking Extraction ‘Now give the selection Conditions and save. RSA3 ->Give data source name and check extraction SAP DEVELOPER NETWORK | sin sap-com [BUSINESS PROCESS EXPERT COMMUNITY | bpcsap com TRWTSAPAG i SAP BI Generic Euracion Using a nction Modula Give max value to get the correct value extracted mien) | || ow. | green. | eysar | so wef gh | Bawe,| | BW Side, 1, RSAI Source system , Src sys > Rt Click, Data source Over view, Appl Comp, Rt click, Replicate. 2. RSAI -> Info source - > Create Appl comp > Rt clk , Assign Data source - > Sre Sys Infosource ZFMEI ‘change 7 [Sm | OMWSe wis Some Blank Value will come in Info object; just press F4 and select, same field option SAP DEVELOPER NETWORK | sdnsap.com [BUSINESS PROCESS EXPERT COMMUNITY | bpcsap com TAT EAPAT B SAP BI Generic Euracion Using a nction Modula Decrees [2] 7 [sy Then Press <- and save, Activate Data source. Sieh Biicoovect Bleouee oeteme| Bros ‘Then From Info area, Create Info cube , Assign the Info source name created to char and Key fig of Cube ‘Cube will have no char in Char tab or on any other tab, Press Info source icon in Cube. SAP DEVELOPER NETWORK | sdnsap.com [BUSINESS PROCESS EXPERT COMMUNITY | bpcsap com TAT EAPAT 5 SAP BI Generic Euracion Using a nction Modula " | BISE [tamer] ea ewe “ted Fm Ona ener fiz (Tea JE Jes Pa [a eee | ma fea If you double click that info source, every char. Key fig from that info source will come automatically into cube, just assign Dimension to Cube and save and activate. (Create Update Rule for the Cube based on the info source SAP DEVELOPER NETWORK | edn.sap.com [BUSINESS PROCESS EXPERT COMMUNITY | bpcsap com TAT EAPAT rd SAP BI Generic Euracion Using a nction Modula "EXD 1 be ye Fur Esra saa | || oe Bsa | Spee | 30 fa | ree ana | ‘Now Schedule the Extraction astchaned GAPUGER ate LON EDT) Tine 694° ‘The final data will be like this in Monitor SAP DEVELOPER NETWORK | sdnsap.com [BUSINESS PROCESS EXPERT COMMUNITY | bpcsap com TAT EAPAT 5 SAP BI Generic Euracion Using a nction Modula SAP DEVELOPER NETWORK | sin sap-com [BUSINESS PROCESS EXPERT COMMUNITY | bpcsap com TRWTSAPAG 76 Disclaimer and Liability Notice This document may discuss sample coding or other information that does not include SAP official interfaces and therefore is not supported by SAP. Changes made based on this information are not supported and can be overwritten during an upgrade. SAP will not be held liable for any damages caused by using or misusing the information, code or methods suggested in this document, and anyone using these methods does so at his/her own risk. SAP offers no guarantees and assumes no responsibility or liability of any type with respect to the content of this technical article or code sample, including any liability resulting from incompatibility between the content within this document and the materials and services offered by SAP. You agree that you will not hold, or seek to hold, SAP responsible or liable with respect to the content of this document. T

You might also like