SlideShare ist ein Scribd-Unternehmen logo
1 von 17
Downloaden Sie, um offline zu lesen
SAP BI Generic Extraction Using a Function Module




SAP BI Generic Extraction Using a Function Module



Applies to:

SAP BI

Summary

This article demonstrates a step-by-step process for doing generic extraction from R3 into BI 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.




SAP DEVELOPER NETWORK | sdn.sap.com                    BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com

© 2007 SAP AG                                                                                                   1
SAP BI Generic Extraction Using a Function Module




Table of Contents



R3 Side............................................................................................................................... 3
   Code............................................................................................................................. 8
   Data Source Creation.............................................................................................. 10
   Checking Extraction................................................................................................. 11
   BW Side..................................................................................................................... 12
Disclaimer and Liability Notice...................................................................................... 17




SAP DEVELOPER NETWORK | sdn.sap.com                                                 BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com

© 2007 SAP AG                                                                                                                                     2
SAP BI Generic Extraction Using a Function Module




R3 Side

1. Create a structure with the necessary fields. The Currency and quantity fields must
   have reference fields also.




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.




2. In transaction SE80, Select Function group, name RSAX. Right click and Copy:




SAP DEVELOPER NETWORK | sdn.sap.com                    BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com

© 2007 SAP AG                                                                                                   3
SAP BI Generic Extraction Using a Function Module




                       1




                                      2




                                                              Give new
                                                              name of
                                                              function Group




Select only the needed function module:




SAP DEVELOPER NETWORK | sdn.sap.com       BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com

© 2007 SAP AG                                                                                      4
SAP BI Generic Extraction Using a Function Module




                                                                        Give the new
                                                                        function
                                                                        module name




The Function Module in SE37 will be like this, we have to do light modification




SAP DEVELOPER NETWORK | sdn.sap.com                    BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com

© 2007 SAP AG                                                                                                   5
SAP BI Generic Extraction Using a Function Module




No change in Import Tab.




Export, Changing No values.




SAP DEVELOPER NETWORK | sdn.sap.com   BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com

© 2007 SAP AG                                                                                  6
SAP BI Generic Extraction Using a Function Module




In TABLES tab, give the structure name.




                           Give your structure name




In Exceptions No data. In Source code Tab. Write this Code

The Code that we need to write is Placed Inside




SAP DEVELOPER NETWORK | sdn.sap.com                   BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com

© 2007 SAP AG                                                                                                  7
SAP BI Generic Extraction Using a Function Module




Code

FUNCTION ZRSAX_BIW_GET_DATA_SIMPLE4_2.
*"----------------------------------------------------------------------
*"*"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 ZNVBAK1 OPTIONAL
*" EXCEPTIONS
*"      NO_MORE_DATA
*"      ERROR_PASSED_TO_MESS_HANDLER
*"----------------------------------------------------------------------
* Example: DataSource for table SFLIGHT
  TABLES: ZNVBAK1.

* 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.
* Select ranges
* RANGES: L_R_CARRID FOR SFLIGHT-CARRID,
   •          L_R_CONNID FOR SFLIGHT-CONNID.
   •
         RANGES: SDNO FOR znvbak1-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.

       WHEN 'ZFMEDS4'.                           Name of Data source
       WHEN OTHERS.
                                                 given in RS02
        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


SAP DEVELOPER NETWORK | sdn.sap.com              BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com

© 2007 SAP AG                                                                                             8
SAP BI Generic Extraction Using a Function Module



         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 tables BW will only pass down simple selection criteria
* of the type SIGN = 'I' and OPTION = 'EQ' or OPTION = 'BT'.
*      LOOP AT S_S_IF-T_SELECT INTO L_S_SELECT WHERE FIELDNM = 'CARRID'.
*        MOVE-CORRESPONDING L_S_SELECT TO L_R_CARRID.
*        APPEND L_R_CARRID.
*      ENDLOOP.
*
*      LOOP AT S_S_IF-T_SELECT INTO L_S_SELECT WHERE FIELDNM = 'CONNID'.
*        MOVE-CORRESPONDING L_S_SELECT TO L_R_CONNID.
*        APPEND L_R_CONNID.
*      ENDLOOP.

LOOP AT S_S_IF-T_SELECT INTO L_S_SELECT WHERE FIELDNM = 'VBELN'.

MOVE-CORRESPONDING L_S_SELECT TO      SDNO.

APPEND SDNO.

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
*      SELECT (S_S_IF-T_FIELDS) FROM SFLIGHT
*                               WHERE CARRID IN L_R_CARRID AND
*                                     CONNID IN L_R_CONNID.

SELECT VBAK~VBELN VBAK~ERDAT VBAK~NETWR VBAP~MATNR
VBAP~POSNR
FROM VBAK
INNER JOIN VBAP on VBAK~VBELN = VBAP~VBELN
WHERE VBAK~VBELN IN SDNO.

     ENDIF.                               "First data package ?

* Fetch records into interface table.
*   named E_T_'Name of extract structure'.


SAP DEVELOPER NETWORK | sdn.sap.com                  BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com

© 2007 SAP AG                                                                                                 9
SAP BI Generic Extraction Using a Function Module



     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.

Now Save, Activate the function module .

Goto SE80 -> Select Function Group, Activate the Function Group.


Note:

If you do not activate function Group, You will not be able to create data source in RS02


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




SAP DEVELOPER NETWORK | sdn.sap.com                     BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com

© 2007 SAP AG                                                                                                   10
SAP BI Generic Extraction Using a Function Module




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 | sdn.sap.com                 BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com

© 2007 SAP AG                                                                                               11
SAP BI Generic Extraction Using a Function Module




                                                         Give max value to get
                                      2                  the correct value
                                                         extracted




BW Side.

    1. RSA1 ->Source system , Src sys -> Rt Click, Data source Over view, Appl Comp, Rt click,
       Replicate.
    2. RSA1 - > Info source - > Create Appl comp -> Rt clk , Assign Data source - > Src Sys




Some Blank Value will come in Info object; just press F4 and select, same field option



SAP DEVELOPER NETWORK | sdn.sap.com                    BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com

© 2007 SAP AG                                                                                                  12
SAP BI Generic Extraction Using a Function Module




Then Press <- and save, Activate Data source.




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 | sdn.sap.com                    BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com

© 2007 SAP AG                                                                                                  13
SAP BI Generic Extraction Using a Function Module




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 | sdn.sap.com                     BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com

© 2007 SAP AG                                                                                                   14
SAP BI Generic Extraction Using a Function Module




Now Schedule the Extraction




The final data will be like this in Monitor




SAP DEVELOPER NETWORK | sdn.sap.com           BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com

© 2007 SAP AG                                                                                         15
SAP BI Generic Extraction Using a Function Module




SAP DEVELOPER NETWORK | sdn.sap.com   BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com

© 2007 SAP AG                                                                                 16
SAP BI Generic Extraction Using a Function Module




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.




SAP DEVELOPER NETWORK | sdn.sap.com                       BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com

© 2007 SAP AG                                                                                                     17

Weitere ähnliche Inhalte

Was ist angesagt?

Maintaining comment fields directly in planning layouts using the transaction...
Maintaining comment fields directly in planning layouts using the transaction...Maintaining comment fields directly in planning layouts using the transaction...
Maintaining comment fields directly in planning layouts using the transaction...Janakiram Yelike
 
Customer exit variables in sap
Customer exit variables in sapCustomer exit variables in sap
Customer exit variables in sapsaborhade
 
Hbm new features
Hbm new featuresHbm new features
Hbm new featureslasselante
 
Attain Superior Sales Performance Through Insight Driven Oracle Sales Analytics
Attain Superior Sales Performance Through Insight Driven Oracle Sales AnalyticsAttain Superior Sales Performance Through Insight Driven Oracle Sales Analytics
Attain Superior Sales Performance Through Insight Driven Oracle Sales AnalyticsJerome Leonard
 
Axel uhl sap@md-day2011
Axel uhl sap@md-day2011Axel uhl sap@md-day2011
Axel uhl sap@md-day2011MDDAY11
 
Customizing sap template bex
Customizing sap template bexCustomizing sap template bex
Customizing sap template bexsubhaypce
 
Currency conversion in bi 7.0
Currency conversion in bi 7.0Currency conversion in bi 7.0
Currency conversion in bi 7.0gireesho
 
What’s New For SQL Optimization In DB2 9 And DB2 10 For z/OS
What’s New For SQL Optimization In DB2 9 And DB2 10 For z/OSWhat’s New For SQL Optimization In DB2 9 And DB2 10 For z/OS
What’s New For SQL Optimization In DB2 9 And DB2 10 For z/OSSurekha Parekh
 
Sap B1 In1 Day 30 5 2012
Sap B1 In1 Day 30 5 2012Sap B1 In1 Day 30 5 2012
Sap B1 In1 Day 30 5 2012Massimo Sala
 
Excel Audit Software Aditya Presentations In Agra
Excel Audit Software   Aditya Presentations In AgraExcel Audit Software   Aditya Presentations In Agra
Excel Audit Software Aditya Presentations In AgraCA Aditya Singhal
 

Was ist angesagt? (17)

Maintaining comment fields directly in planning layouts using the transaction...
Maintaining comment fields directly in planning layouts using the transaction...Maintaining comment fields directly in planning layouts using the transaction...
Maintaining comment fields directly in planning layouts using the transaction...
 
ERP Made Simple (preview)
ERP Made Simple (preview)ERP Made Simple (preview)
ERP Made Simple (preview)
 
Customer exit variables in sap
Customer exit variables in sapCustomer exit variables in sap
Customer exit variables in sap
 
Hbm new features
Hbm new featuresHbm new features
Hbm new features
 
Attain Superior Sales Performance Through Insight Driven Oracle Sales Analytics
Attain Superior Sales Performance Through Insight Driven Oracle Sales AnalyticsAttain Superior Sales Performance Through Insight Driven Oracle Sales Analytics
Attain Superior Sales Performance Through Insight Driven Oracle Sales Analytics
 
Bapi jco
Bapi jcoBapi jco
Bapi jco
 
Axel uhl sap@md-day2011
Axel uhl sap@md-day2011Axel uhl sap@md-day2011
Axel uhl sap@md-day2011
 
Bapi step-by-step
Bapi step-by-stepBapi step-by-step
Bapi step-by-step
 
B adi
B adiB adi
B adi
 
Customizing sap template bex
Customizing sap template bexCustomizing sap template bex
Customizing sap template bex
 
Currency conversion in bi 7.0
Currency conversion in bi 7.0Currency conversion in bi 7.0
Currency conversion in bi 7.0
 
Hadoop + Forcedotcom = Like
Hadoop + Forcedotcom = LikeHadoop + Forcedotcom = Like
Hadoop + Forcedotcom = Like
 
What’s New For SQL Optimization In DB2 9 And DB2 10 For z/OS
What’s New For SQL Optimization In DB2 9 And DB2 10 For z/OSWhat’s New For SQL Optimization In DB2 9 And DB2 10 For z/OS
What’s New For SQL Optimization In DB2 9 And DB2 10 For z/OS
 
Sap B1 In1 Day 30 5 2012
Sap B1 In1 Day 30 5 2012Sap B1 In1 Day 30 5 2012
Sap B1 In1 Day 30 5 2012
 
Excel Audit Software Aditya Presentations In Agra
Excel Audit Software   Aditya Presentations In AgraExcel Audit Software   Aditya Presentations In Agra
Excel Audit Software Aditya Presentations In Agra
 
Pswfl
PswflPswfl
Pswfl
 
Bapi jco[1]
Bapi jco[1]Bapi jco[1]
Bapi jco[1]
 

Ähnlich wie SAP BI Generic Extraction

SAP BI Generic Extraction Using a Function Module.pdf
SAP BI Generic Extraction Using a Function Module.pdfSAP BI Generic Extraction Using a Function Module.pdf
SAP BI Generic Extraction Using a Function Module.pdfKoushikGuna
 
Enhancing data sources with badi in SAP ABAP
Enhancing data sources with badi in SAP ABAPEnhancing data sources with badi in SAP ABAP
Enhancing data sources with badi in SAP ABAPAabid Khan
 
User exits
User exitsUser exits
User exitsanilkv29
 
Journals SAP BPC 7
Journals SAP BPC 7Journals SAP BPC 7
Journals SAP BPC 7khalimail
 
Lo extraction part 7 enhancements
Lo extraction   part 7 enhancementsLo extraction   part 7 enhancements
Lo extraction part 7 enhancementsJNTU University
 
Planning guide sap business suite 7 2013 landscape implementation
Planning guide sap business suite 7 2013  landscape implementationPlanning guide sap business suite 7 2013  landscape implementation
Planning guide sap business suite 7 2013 landscape implementationLeonardo Parpal Roig
 
ERP Magazine April 2018 Issue 1
ERP Magazine April 2018 Issue 1 ERP Magazine April 2018 Issue 1
ERP Magazine April 2018 Issue 1 Rehan Zaidi
 
ERP Magazine April 2018 - The magazine for SAP ABAP Professionals
ERP Magazine April 2018 - The magazine for SAP ABAP ProfessionalsERP Magazine April 2018 - The magazine for SAP ABAP Professionals
ERP Magazine April 2018 - The magazine for SAP ABAP ProfessionalsRehan Zaidi
 
How to write a routine for 0 calday in infopackage selection
How to write a routine for 0 calday in infopackage selectionHow to write a routine for 0 calday in infopackage selection
How to write a routine for 0 calday in infopackage selectionValko Arbalov
 
Using PHP and SOA for Situational Applications in the Enterprise
Using PHP and SOA for Situational Applications in the EnterpriseUsing PHP and SOA for Situational Applications in the Enterprise
Using PHP and SOA for Situational Applications in the Enterprisewebhostingguy
 
Backup%20 domain%20controller%20(bdc)%20step by-step(1)
Backup%20 domain%20controller%20(bdc)%20step by-step(1)Backup%20 domain%20controller%20(bdc)%20step by-step(1)
Backup%20 domain%20controller%20(bdc)%20step by-step(1)Srinivas Dukka
 
New dimensions for_reporting
New dimensions for_reportingNew dimensions for_reporting
New dimensions for_reportingRahul Mahajan
 
CO_TM_Controlling_co-om Master Data .pdf
CO_TM_Controlling_co-om Master Data .pdfCO_TM_Controlling_co-om Master Data .pdf
CO_TM_Controlling_co-om Master Data .pdfssuser878ec2
 
How to find_information_on_sap_eam
How to find_information_on_sap_eamHow to find_information_on_sap_eam
How to find_information_on_sap_eamNguyen Hai
 
Trigger bi process chain from ecc
Trigger bi process chain from eccTrigger bi process chain from ecc
Trigger bi process chain from eccObaid shaikh
 
Performance tuning in sap bi 7.0
Performance tuning in sap bi 7.0Performance tuning in sap bi 7.0
Performance tuning in sap bi 7.0gireesho
 
Creating attachments to work items or to user decisions in workflows
Creating attachments to work items or to user decisions in workflowsCreating attachments to work items or to user decisions in workflows
Creating attachments to work items or to user decisions in workflowsHicham Khallouki
 

Ähnlich wie SAP BI Generic Extraction (20)

SAP BI Generic Extraction Using a Function Module.pdf
SAP BI Generic Extraction Using a Function Module.pdfSAP BI Generic Extraction Using a Function Module.pdf
SAP BI Generic Extraction Using a Function Module.pdf
 
Enhancing data sources with badi in SAP ABAP
Enhancing data sources with badi in SAP ABAPEnhancing data sources with badi in SAP ABAP
Enhancing data sources with badi in SAP ABAP
 
User exits
User exitsUser exits
User exits
 
sap
sap sap
sap
 
Journals SAP BPC 7
Journals SAP BPC 7Journals SAP BPC 7
Journals SAP BPC 7
 
Lo extraction part 7 enhancements
Lo extraction   part 7 enhancementsLo extraction   part 7 enhancements
Lo extraction part 7 enhancements
 
Planning guide sap business suite 7 2013 landscape implementation
Planning guide sap business suite 7 2013  landscape implementationPlanning guide sap business suite 7 2013  landscape implementation
Planning guide sap business suite 7 2013 landscape implementation
 
ERP Magazine April 2018 Issue 1
ERP Magazine April 2018 Issue 1 ERP Magazine April 2018 Issue 1
ERP Magazine April 2018 Issue 1
 
ERP Magazine April 2018 - The magazine for SAP ABAP Professionals
ERP Magazine April 2018 - The magazine for SAP ABAP ProfessionalsERP Magazine April 2018 - The magazine for SAP ABAP Professionals
ERP Magazine April 2018 - The magazine for SAP ABAP Professionals
 
How to write a routine for 0 calday in infopackage selection
How to write a routine for 0 calday in infopackage selectionHow to write a routine for 0 calday in infopackage selection
How to write a routine for 0 calday in infopackage selection
 
SAP BOBJ Rapid Marts Overview I
SAP BOBJ Rapid Marts Overview ISAP BOBJ Rapid Marts Overview I
SAP BOBJ Rapid Marts Overview I
 
Using PHP and SOA for Situational Applications in the Enterprise
Using PHP and SOA for Situational Applications in the EnterpriseUsing PHP and SOA for Situational Applications in the Enterprise
Using PHP and SOA for Situational Applications in the Enterprise
 
Backup%20 domain%20controller%20(bdc)%20step by-step(1)
Backup%20 domain%20controller%20(bdc)%20step by-step(1)Backup%20 domain%20controller%20(bdc)%20step by-step(1)
Backup%20 domain%20controller%20(bdc)%20step by-step(1)
 
New dimensions for_reporting
New dimensions for_reportingNew dimensions for_reporting
New dimensions for_reporting
 
Process chain
Process chainProcess chain
Process chain
 
CO_TM_Controlling_co-om Master Data .pdf
CO_TM_Controlling_co-om Master Data .pdfCO_TM_Controlling_co-om Master Data .pdf
CO_TM_Controlling_co-om Master Data .pdf
 
How to find_information_on_sap_eam
How to find_information_on_sap_eamHow to find_information_on_sap_eam
How to find_information_on_sap_eam
 
Trigger bi process chain from ecc
Trigger bi process chain from eccTrigger bi process chain from ecc
Trigger bi process chain from ecc
 
Performance tuning in sap bi 7.0
Performance tuning in sap bi 7.0Performance tuning in sap bi 7.0
Performance tuning in sap bi 7.0
 
Creating attachments to work items or to user decisions in workflows
Creating attachments to work items or to user decisions in workflowsCreating attachments to work items or to user decisions in workflows
Creating attachments to work items or to user decisions in workflows
 

SAP BI Generic Extraction

  • 1. SAP BI Generic Extraction Using a Function Module SAP BI Generic Extraction Using a Function Module Applies to: SAP BI Summary This article demonstrates a step-by-step process for doing generic extraction from R3 into BI 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. SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2007 SAP AG 1
  • 2. SAP BI Generic Extraction Using a Function Module Table of Contents R3 Side............................................................................................................................... 3 Code............................................................................................................................. 8 Data Source Creation.............................................................................................. 10 Checking Extraction................................................................................................. 11 BW Side..................................................................................................................... 12 Disclaimer and Liability Notice...................................................................................... 17 SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2007 SAP AG 2
  • 3. SAP BI Generic Extraction Using a Function Module R3 Side 1. Create a structure with the necessary fields. The Currency and quantity fields must have reference fields also. 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. 2. In transaction SE80, Select Function group, name RSAX. Right click and Copy: SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2007 SAP AG 3
  • 4. SAP BI Generic Extraction Using a Function Module 1 2 Give new name of function Group Select only the needed function module: SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2007 SAP AG 4
  • 5. SAP BI Generic Extraction Using a Function Module Give the new function module name The Function Module in SE37 will be like this, we have to do light modification SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2007 SAP AG 5
  • 6. SAP BI Generic Extraction Using a Function Module No change in Import Tab. Export, Changing No values. SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2007 SAP AG 6
  • 7. SAP BI Generic Extraction Using a Function Module In TABLES tab, give the structure name. Give your structure name In Exceptions No data. In Source code Tab. Write this Code The Code that we need to write is Placed Inside SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2007 SAP AG 7
  • 8. SAP BI Generic Extraction Using a Function Module Code FUNCTION ZRSAX_BIW_GET_DATA_SIMPLE4_2. *"---------------------------------------------------------------------- *"*"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 ZNVBAK1 OPTIONAL *" EXCEPTIONS *" NO_MORE_DATA *" ERROR_PASSED_TO_MESS_HANDLER *"---------------------------------------------------------------------- * Example: DataSource for table SFLIGHT TABLES: ZNVBAK1. * 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. * Select ranges * RANGES: L_R_CARRID FOR SFLIGHT-CARRID, • L_R_CONNID FOR SFLIGHT-CONNID. • RANGES: SDNO FOR znvbak1-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. WHEN 'ZFMEDS4'. Name of Data source WHEN OTHERS. given in RS02 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 SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2007 SAP AG 8
  • 9. SAP BI Generic Extraction Using a Function Module 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 tables BW will only pass down simple selection criteria * of the type SIGN = 'I' and OPTION = 'EQ' or OPTION = 'BT'. * LOOP AT S_S_IF-T_SELECT INTO L_S_SELECT WHERE FIELDNM = 'CARRID'. * MOVE-CORRESPONDING L_S_SELECT TO L_R_CARRID. * APPEND L_R_CARRID. * ENDLOOP. * * LOOP AT S_S_IF-T_SELECT INTO L_S_SELECT WHERE FIELDNM = 'CONNID'. * MOVE-CORRESPONDING L_S_SELECT TO L_R_CONNID. * APPEND L_R_CONNID. * ENDLOOP. LOOP AT S_S_IF-T_SELECT INTO L_S_SELECT WHERE FIELDNM = 'VBELN'. MOVE-CORRESPONDING L_S_SELECT TO SDNO. APPEND SDNO. 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 * SELECT (S_S_IF-T_FIELDS) FROM SFLIGHT * WHERE CARRID IN L_R_CARRID AND * CONNID IN L_R_CONNID. SELECT VBAK~VBELN VBAK~ERDAT VBAK~NETWR VBAP~MATNR VBAP~POSNR FROM VBAK INNER JOIN VBAP on VBAK~VBELN = VBAP~VBELN WHERE VBAK~VBELN IN SDNO. ENDIF. "First data package ? * Fetch records into interface table. * named E_T_'Name of extract structure'. SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2007 SAP AG 9
  • 10. SAP BI Generic Extraction Using a Function Module 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. Now Save, Activate the function module . Goto SE80 -> Select Function Group, Activate the Function Group. Note: If you do not activate function Group, You will not be able to create data source in RS02 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 SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2007 SAP AG 10
  • 11. SAP BI Generic Extraction Using a Function Module 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 | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2007 SAP AG 11
  • 12. SAP BI Generic Extraction Using a Function Module Give max value to get 2 the correct value extracted BW Side. 1. RSA1 ->Source system , Src sys -> Rt Click, Data source Over view, Appl Comp, Rt click, Replicate. 2. RSA1 - > Info source - > Create Appl comp -> Rt clk , Assign Data source - > Src Sys Some Blank Value will come in Info object; just press F4 and select, same field option SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2007 SAP AG 12
  • 13. SAP BI Generic Extraction Using a Function Module Then Press <- and save, Activate Data source. 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 | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2007 SAP AG 13
  • 14. SAP BI Generic Extraction Using a Function Module 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 | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2007 SAP AG 14
  • 15. SAP BI Generic Extraction Using a Function Module Now Schedule the Extraction The final data will be like this in Monitor SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2007 SAP AG 15
  • 16. SAP BI Generic Extraction Using a Function Module SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2007 SAP AG 16
  • 17. SAP BI Generic Extraction Using a Function Module 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. SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2007 SAP AG 17