Skip to Content
author's profile photo Former Member
Former Member

Enhancing a generic datasource

Hi,

I need to enhance a generic data source with fields bsart, bedat and inco1 from the table ekko.I have already appended these fields and now i need to write a code to populate these fields. Please help me out as i am new in this tech.

Regards

A

Add a comment
10|10000 characters needed characters exceeded

Related questions

5 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Apr 14, 2011 at 01:16 PM

    Hi

    I think in the previous replies you got info about how to proceed to crteate an append structure and enhance the DS. Find below a sample code which have been written to enhance 0FI_GL_4 Data Source. Below steps gives a rough idea about how to do declarations and proceed to Selectiing data from R/3 tables. Finally modifying the data to fill the enhanced fields. You can do changes as required in your code. But this code gives you a rough idea on how to proceed

    WHEN '0FI_GL_4'.

    *Structure declaration.

    TYPES: BEGIN OF s_bseg2,

    bukrs TYPE bseg-bukrs,

    belnr TYPE bseg-belnr,

    gjahr TYPE bseg-gjahr,

    buzei TYPE bseg-buzei,

    nplnr TYPE bseg-nplnr,

    aufpl TYPE bseg-aufpl,

    aplzl TYPE bseg-aplzl,

    xref1 TYPE bseg-xref1,

    xref2 TYPE bseg-xref2,

    xref3 TYPE bseg-xref3,

    matnr TYPE bseg-matnr,

    END OF s_bseg2.

    DATA: BEGIN OF s_afvc,

    vornr TYPE afvc-vornr,

    END OF s_afvc.

        • Internal Table declaration*

        DATA: it_bseg2 TYPE STANDARD TABLE OF s_bseg2.

        DATA: it_data2 TYPE STANDARD TABLE OF dtfigl_4.

        **Move the data from c_t_data to internal table it_data.

        it_data2[] = c_t_data[].

            • Sort the internal table it_data by BELNR.* SORT it_data2 BY belnr.

                • Refresh all internal tables.*

                REFRESH: it_bseg2.

                IF NOT it_data2[] IS INITIAL.

                **Select data from BSEG table for all entries in it_data table.

                SELECT bukrs belnr gjahr buzei nplnr aufpl aplzl xref1 xref2 xref3 matnr

                FROM bseg

                INTO TABLE it_bseg2

                FOR ALL ENTRIES IN it_data2

                WHERE bukrs = it_data2-bukrs AND

                belnr = it_data2-belnr AND

                gjahr = it_data2-gjahr.

                    • Check sy-subrc and sort the internal table.*

                    IF sy-subrc = 0.

                    SORT it_bseg2 BY bukrs belnr gjahr buzei.

                    DELETE ADJACENT DUPLICATES FROM it_bseg2 COMPARING ALL FIELDS.

                    ENDIF.

                    ENDIF.

                    **Now loop at the c_t_data table and modify the table fields with the values from the

                    **above internal tables.

                    CLEAR v_index2.

                    LOOP AT c_t_data INTO l_s_figl_4.

                    v_index2 = sy-tabix.

                    CLEAR wa_bseg2.

                    READ TABLE it_bseg2 INTO wa_bseg2 WITH KEY bukrs = l_s_figl_4-bukrs

                    belnr = l_s_figl_4-belnr

                    gjahr = l_s_figl_4-gjahr

                    buzei = l_s_figl_4-buzei

                    BINARY SEARCH.

                    IF sy-subrc = 0.

                    MOVE: wa_bseg2-nplnr TO l_s_figl_4-znetwork.

                    MOVE: wa_bseg2-xref1 TO l_s_figl_4-zxref1.

                    MOVE: wa_bseg2-xref2 TO l_s_figl_4-zxref2.

                    MOVE: wa_bseg2-xref3 TO l_s_figl_4-zxref3.

                    MOVE: wa_bseg2-matnr TO l_s_figl_4-zmatnr.

                    ENDIF.

                    IF wa_bseg2-nplnr IS NOT INITIAL.

                    CLEAR s_afvc.

                    SELECT SINGLE vornr INTO s_afvc FROM afvc WHERE aufpl = wa_bseg2-aufpl AND aplzl = wa_bseg2-aplzl .

                    IF sy-subrc = 0.

                    l_s_figl_4-zactivity = s_afvc.

                    ENDIF.

                    ENDIF.

                    MODIFY c_t_data FROM l_s_figl_4 INDEX v_index2.

                    CLEAR l_s_figl_4.

                    ENDLOOP.

                    *End of Additional GeneralLedger Transaction data Enhancement....

                    Add a comment
                    10|10000 characters needed characters exceeded

                  • Posted on Apr 12, 2011 at 05:19 AM

                    HI ,

                    Enhancing a Generic datsource is same same as enhancing a standard datasource , check the below

                    how to doc for reference

                    http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/302d4b15-5847-2a10-93bb-9c45d9f06b16?quicklink=index&overridelayout=true

                    let me know if you face any issues

                    regards,

                    Sathya

                    Add a comment
                    10|10000 characters needed characters exceeded

                  • author's profile photo Former Member
                    Former Member
                    Posted on Apr 13, 2011 at 05:31 PM

                    Hi,

                    you mentioned that you need to enhance a generic data source. Generic data source or standart datasource? You can add fields in the extraction table not appended in generic datasource.

                    If you have a generic data source, go to rso2, give your datasource and find the method(via function, via table or via query).

                    Give more details.

                    Add a comment
                    10|10000 characters needed characters exceeded

                  • author's profile photo Former Member
                    Former Member
                    Posted on Apr 14, 2011 at 08:53 AM

                    Hi Arpita,

                    There are three types of generic data sources :-

                    1. Based on Infoset Query

                    2. Based on DB view

                    3. Based on Function Module

                    For extarcting any new fields.....

                    The first and the common step is changing the extract structure and including the fields you need in the extraction structure...

                    After that if the Generic DS is based in a View, its easy.......just include the field there and save DS.....

                    In case of FM and Infoset Query based extraction you you have to write a code..... which will totally depend on your requirement.....

                    You can search the articles for a better idea...

                    Regards,

                    Rahul

                    Add a comment
                    10|10000 characters needed characters exceeded

                  • author's profile photo Former Member
                    Former Member
                    Posted on Apr 14, 2011 at 07:30 AM

                    Hi Arpita,

                    Below is the procedure to enhance a generic extractor:

                    RSA6Select data sourcecreate append structure( Starting with Z, which will contain all the enhanced fields along with their meta data definition)define all the structure and activatesave data sourceclick on change data source and unhide new fields if requireT- code CMOD

                    EXIT_SAPLR_SAP_001 Transaction Data

                    EXIT_SAPLR_SAP_002 Master Data Attribute

                    EXIT_SAPLR_SAP_003 Master Data Text

                    EXIT_SAPLR_SAP_004 Master Data Hierarchy

                    INCLUDE ZXRSAU01

                    USE of I_STEP

                    Variable user exit can be called in three different ways using I_STEP Code actually calls this program three separate times, code can be Added to run for one, two, or all three

                    I_STEP = 1

                    Here the code is called prior to processing of variable pop-up and for each u201Ccustomer exitu201D variables .This can be used to fill variable with default values

                    I_STEP = 2

                    Here the code is called after the processing of the variable pop-up. Only for those variables that are not marked as u201Cready for inputu201D or are set to u201Cmandatory variable entryu201D.

                    I_STEP = 3

                    Here the code is called after all variable processing and gets called only once and not per variable. Here you can validate the user entries.

                    Once the changes are done & new fields are fetched, internal table C_T_Data needs to be modified

                    accordingly. The modifications and the new fields population is then automatically transferred to the fields of

                    the datasource. The same can then be validated by executing the data source through Tcode RSA3.

                    Extraction Using 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:

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

                    4.No change in Import Tab.

                    5.Export, Changing No values.

                    6.In TABLES tab, give the structure name.

                    7.

                    In Exceptions No data.

                    In Source code Tab. Write this Code

                    *Code

                    • FUNCTION ZRSAX_BIW_GET_DATA_SIMPLE4_2.

                    *"----

                    -


                    ""Local interface:

                    *u201D 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'.

                    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

                    Name of Data source given in RS02 SAP BI Generic Extraction Using a Function Module SAP DEVELOPER NETWORK | sdn.sap.com BUSINESS PROCESS EXPERT COMMUNITY | bpx.sap.com © 2007 SAP AG 9

                    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 VBAKVBELN VBAKERDAT VBAKNETWR VBAPMATNR

                    VBAP~POSNR

                    FROM VBAK

                    INNER JOIN VBAP on VBAKVBELN = VBAPVBELN

                    WHERE VBAK~VBELN IN SDNO.

                    ENDIF. "First data package ?

                    • Fetch records into interface table.

                    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

                    Hope this will help....

                    Thanks,

                    Jitendra

                    Edited by: jitendra_kumar06 on Apr 14, 2011 9:33 AM

                  Add a comment
                  10|10000 characters needed characters exceeded

                  Before answering

                  You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
                  You must be Logged in to submit an answer.

                  Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.