Datasource as a function module

hi,
  I am looking for a sample code to use function module as a datasource.
  Is there any document which i can use for this ?
Thanks in advance.

Hi
Please have a look into the following link.
https://www.sdn.sap.com/irj/sdn/advancedsearch?cat=sdn_all&query=genericdatasourcefromfunction+module&adv=false&sortby=cm_rnd_rankvalue
hope it helps
Thanks,
Teja

Similar Messages

  • Error with quantity field:Datasource Creation Using Function Module method

    Problem with DATASOURCE Creation using Function Module method :
    I have created a datasource ZSTANDARD_COST_PRICE using Function Module method . The datasource creation is successfull when I remove the quantity field from the Z table . If I dont remove the quantity field from my Z table it gives an error as "Units Field WAERS for field STPRS of datasource ZSTANDARD_COST_PRICE is hidden". I am not able to remove this error . Please someone guide.
    Let me know if my explanation is not clear enough.
    Thanks in advance,
    Neha.
    Z table definition is as below :
    MATNR MATNR CHAR 18 0 Material Number
    BWKEY BWKEY CHAR 4 0 Valuation area
    LFGJA LFGJA NUMC 4 0 Fiscal Year of Current Period
    STPRS STPRS CURR 11 2 Standard Price   " Here the currency field is WAERS and table T001
    PEINH PEINH DEC 5 0 Price Unit
    VJSTP VJSTP CURR 11 2 Standard price in previous year
    VJPEI VJPEI DEC 5 0 Price unit of previous year.
    Edited by: Neha Rathi on Jan 30, 2009 3:03 PM

    Hi,
    You should add it as one of the main fields as you have added other fields and not as the currency fields...that is..it should be part of the data source and you should be able to see it in RSO2...
    Also if added as i said then it will come as new field in the data source...you can either let it be there...or hide it..
    also if you want to populate it then you will have to write the code for this fields as well.
    Thanks
    Ajeet

  • Runtime Error while extracting data by datasource based on function module

    Hi all,
    I am facing an issue while extracting data from a customised data source based on a new function module.
    The datasource is extracting data successfully for only 15000 records but after that the runtime error is displayed.
    I am not able to extract whole data from R/3 system.
    Please take a look into the details and tell me what should I have to do.
    Details of Issue:
    Runtime Error : GETWA_NOT_ASSIGNED
    What happened?                                                                               
    Error in the ABAP Application Program                                                        
    The current ABAP program "SAPLZ_99Z_BW_SD_PRICING"had to be terminated because  it has  come across a statement that unfortunately cannot be executed.
    Error analysis                                                                               
    You attempted to access an unassigned field symbol                                          
        (data segment 32790).                                                                               
    This error may occur if                                                                   
        - You address a typed field symbol before it has been set with                               
          ASSIGN                                                                               
    - You address a field symbol that pointed to the line of an                              
          internal table that was deleted                                                          
        - You address a field symbol that was previously reset using                           
          UNASSIGN or that pointed to a local field that no                                        
          longer exists                                                                               
    - You address a global function interface, although the                                      
      respective function module is not active - that is, is                                  
          not in the list of active calls. The list of active calls                                 
          can be taken from this short dump. 
    Edited by: anshu13 on Apr 27, 2010 10:28 AM

    The code is displayed here:
    error is in line no. 625
    Source Code Extract                                                                               
    Line SourceCde                                         
      595            <fs_fldval> = l_fieldval.
      596            APPEND <fs_dyntable> TO <it_dyntable>.                               
      597            CLEAR :l_fieldval, wa_fldcat.                                                  
      598            CLEAR l_totlength.                                                             
      599            CLEAR <fs_dyntable>.                                                        
      600         ENDIF.                                                                           
      601        ENDIF.                                                                               
    602        MOVE-CORRESPONDING <dd03l_fields> TO wa_dd03l.                                    
      603        IF <dd03l_fields>-datatype EQ 'DATS'.                                             
      604          l_fieldval = 'X'.                                                                
      605       ELSE.                                                                               
    606        SHIFT <dd03l_fields>-intlen LEFT DELETING LEADING '0'.                         
      607          IF l_totlength IS INITIAL.                                                       
      608            SHIFT l_totlength LEFT DELETING LEADING '0'.                                   
      609            l_totlength = '0'.                                                            
      610          ENDIF.                                                                           
      611          l_currlength = <dd03l_fields>-intlen.                                            
      612          CONCATENATE l_totlength '('  l_currlength ') ' INTO l_fieldval .                 
      613          l_totlength = l_totlength + l_currlength.                                        
      614        ENDIF.                                                                               
    615*** Consider both field name and domian name for checking in range list:                   
      616        IF <dd03l_fields>-fieldname IN s_fieldlist.                                        
      617          wa_fldcat-fieldname = <dd03l_fields>-fieldname.                                  
      618        ELSEIF <dd03l_fields>-domname IN s_fieldlist.                                      
      619          wa_fldcat-fieldname = <dd03l_fields>-domname.                                    
      620        ELSE.                                                                               
    621          wa_fldcat-fieldname = <dd03l_fields>-fieldname.                                  
      622        ENDIF.                                                                               
    623        ASSIGN COMPONENT wa_fldcat-fieldname                                               
      624             OF STRUCTURE <fs_dyntable> TO <fs_fldval>.                                    
    >>>>|        <fsfldval> = l_fieldval._                                                             
      626        CLEAR l_fieldval.                                                                  
      627        CLEAR l_currlength.                                                                
      628      ELSE.                                                                               
    629        IF <dd03l_fields>-datatype EQ 'DATS'.                                              
      630          l_fieldval = 'X'.                                                                
      631       ELSE.                                                                               
    632          SHIFT <dd03l_fields>-intlen LEFT DELETING LEADING '0'.                           
      633          IF l_totlength IS INITIAL.                                                       
      634            SHIFT l_totlength LEFT DELETING LEADING '0'.                                   
      635           l_totlength = '0'.                                                              
      636          ENDIF.                                                                           
      637          l_currlength = <dd03l_fields>-intlen.                                            
      638          CONCATENATE l_totlength '('  l_currlength ') ' INTO l_fieldval .                 
      639         l_totlength = l_totlength + l_currlength.                                         
      640        ENDIF.                                                                               
    641*** Consider both field name and domian name for checking in range list:                   
      642        IF <dd03l_fields>-fieldname IN s_fieldlist.                                        
    643        wa_fldcat-fieldname = <dd03l_fields>-fieldname.                                   
      644       ELSEIF <dd03l_fields>-domname IN s_fieldlist.         
    Edited by: anshu13 on Apr 27, 2010 11:33 AM

  • Selections on DataSource with a Function Module

    Hello Experts,
    I need your help, we have a DataSource with FM and this does not filter the records by the values that we select. For example: we select 01 to 03 in field Period (PERAF) in the result the extractor show all values whitout consider the filter.
    I don't know ABAP but I think it's a simple adjustment in your code.
    You can Help us

    Hi
    It is a custom function module... Then part of the code...
      134  * Fill parameter buffer for data extraction calls
      135      s_s_if-requnr    = i_requnr.
      136      s_s_if-dsource = i_isource.
      137      s_s_if-maxsize   = i_maxsize.
      138
      139  * Fill field list table for an optimized select statement
      140  * (in case that there is no 1:1 relation between InfoSource fields
      141  * and database table fields this may be far from beeing trivial)
      142      APPEND LINES OF i_t_fields TO s_s_if-t_fields.
      143
      144    ELSE.
      145
      146      LOOP AT s_s_if-t_select INTO l_s_select WHERE fieldnm = 'GJAHR'.
      147        MOVE-CORRESPONDING l_s_select TO l_r_gjahr.
      148        APPEND l_r_gjahr.
      149      ENDLOOP.
      150      LOOP AT s_s_if-t_select INTO l_s_select WHERE fieldnm = 'ZANLN1'.
      151        MOVE-CORRESPONDING l_s_select TO l_r_afijo.
      152        APPEND l_r_afijo.
      153      ENDLOOP.
      154
      155      LOOP AT s_s_if-t_select INTO l_s_select WHERE fieldnm = 'PERAF'.
      156        MOVE-CORRESPONDING l_s_select TO l_r_perz.
      157        APPEND l_r_perz.
      158      ENDLOOP.
      159
      160
      161 
      162      pyear =  l_r_gjahr-low.
      163 
      164
      165      IF s_counter_datapakid = 0.
      166
      167 
      168
      169        CLEAR: t_a_c, e_t_data, t_traslado.
      170        REFRESH: t_a_c, e_t_data, t_traslado.
      171        ayear = l_r_gjahr-low - 1.
      172 
      173 
      174 
      175
      176
      177        OPEN CURSOR WITH HOLD s_cursor FOR
      178     SELECT a~bukrs gjahr izwek anlue umwkz kansw knafa ndabj answl nafap
      179                            aanln1 aanln2 anlkl ord42 deakt gjahr afabe
      180                            ord43 aaibn1 aaibdt aktiv aibn1 aibn2
      181                            FROM anla AS a INNER JOIN anlc AS c
      182                            ON abukrs = cbukrs AND
      183                            aanln1 = canln1
      184                            AND aanln2 = canln2
      185                            WHERE a~bukrs = 'HCVN'
      186 *
      187 *
      188 *
      189 *
      190 *
      191 *
      192*
      193*
      194                               AND c~afabe = '01'
      195                               AND gjahr IN l_r_gjahr
      196                               AND a~anln1 IN l_r_afijo.
      197
      198
      199      ENDIF.
    I very much appreciate you help
    Thanks
    Egly

  • Datasource using a Function Module

    Experts,
    We have a requirement where we need to make use of FM in Datasource in order to extract text data.
    The FM is a standard module called  'READ TEXT' which outputs the CRM Objectives texts.
    Should I use the standard FM 'RSAX_BIW_GET_TEXTS' from Function group:RSAX  ?
    1.Copy the above FM to a 'Z* FM' and do the manipulations in that FM. ?
    2.Create a Generic DS from RSO2 and give the FM from step 1 ?
    Did any of you come accross such requirement?
    If so ,please let me know the appropriate steps involved in extracting Text data through FM.
    Note:I already found a good documentation on Transaction data
    Thanks in advance,
    Rgds,
    JB

    I will suggest you to go by second option, create FM from RSO2 way...
    Why don't you use and modify the tx data FM as per your requirement in CRM? I have not created one in CRM but hope the same FM can be helpful.
    Have a look at this post...
    [SDN Link|Re: Generic Delta Using Funtion Module]
    Hope it helps...
    Regards,
    Ashish

  • How to create a generic datasource from function module?

    Dear experts,
    I have created a generic datasource from function module. For this extrator, I created a function module and a structure.
    I have now some difficulties to continue:
    In this function module, i get data from different transparent tables. Then i put these data into an internal table.
    I just don't know what is the relatioin between the structure i defined and this internal table.
    I should make "iTab structure AA" in the source code?
    Thanks

    Hi..
    check this
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/84bf4d68-0601-0010-13b5-b062adbb3e33
    Generic Extraction via Function Module
    /people/siegfried.szameitat/blog/2005/09/29/generic-extraction-via-function-module
    1. Create s structure with the fields that you need from the 4 tables . Activate.
    2. Goto SE 80 Select The Function Group , Copy , Select the Function module
    " RSAX_BIW_GET_DATA_SIMPLE " and Give a New name starting With
    Y or Z .
    3. SE37 ->Your Function module name -> Change , In table tab give your structure
    name by deleting the associated type given in " XXXX " .
    4. Now select source code and Do the coding . Give Data source name in Coding .
    In your case you have to take data from more that 1 table .
    5. Activate the Function Group .
    6. In RSO2 Create the Data source , Give the Function Module Name , And Save.
    7. RSA3 -> Give data source name and Check for the Records .
    Creation of custom datasource. (Using function module)
    .Create a function group .
    . Structure ZTXXXX
    Create function module (i.e. ZTESTXXX) .
    . Create the data source using transaction (RSO2).
    . If structure exists for the table parameter of your function module then ok else create a structure for the table parameter ‘        ’.
    Test the datasource in R/3 using transaction RSA3.
    Transfer the data source to BW –System and replicate it in the BW-System.
    Message was edited by:
            shiv

  • Generating a Generic DataSource using Function Modules

    I am attempting to create a generic DataSource using a  function module.  All of our DataSources are business content or custom generated that involve views.  At least in our company this is true.  Is there any resources available to me with examples on how to do this.  I have looked at SAP's 'simple example' and would need a ABAP/BW Guru to figure it out!  Any help would be greatfull.  Thanx.  JJ

    Hi Jerry,
       The simple example should provide you with the necessary requisite. All what you need to do is to
    create your own extract structure and assign that as type for the table parameter e_t_data.
    Now you will get the selection criteria, as well as the fields selected in the datasource from the 2 incoming tables. You need to write the necessary abap code to execute a query and populate your extract struture.
    Once important peculiarity of this function module is that it is called several times, or as many times as the MAX parameter + 1. ie, once for each row fetched. Hence you will find a persistence method of using a CURSOR with HOLD property to retain the data between the function calls.
       The help in generic datasource explains the 3 modes,
    initialize, first call and the repeat call for the
    function module. The simple function module example actually provides the necessary logic to deal with these modes and the example uses the sflight table.
    Hope that is some information that could help u begin with.
    Anoop C M

  • Datasource using Function Module

    Hi Guys,
    I have two ODS objects...the first ODS has 5 fields and it gets data from flat file.
    I created a custom Datasource based on Function module and i'm extracting data from first ODS based on one of the field 'DATE'. This datasource extracts correct number of records as per my logic in RSA3.
    So i think there is no problem with Datasource.
    Now, i created Infosource and i'm trying to load data from Custom Datasource to second ODS. But when i start the infopackage, the records are not extracted completely...i can see 3 records sent( 0 records received) '0 from 3' records in the monitor...it's a yellow request...
    In status i get following message -
    No request Idoc generated in BW
    Diagnosis
    No request IDoc has been created in BW. A short dump has most probably been logged in BW.
    Procedure
    Look for the short dump belonging to your data request in the short dump overview in BW. Pay attention to the correct date and time in the selection screen.
    You can get the short dump list using the Wizard or from the monitor detail screen via the menu path "Environment -> Short dump -> Data Warehouse".
    Removing errors:
    Follow the instructions in the short dump.
    Please let me know if anyone of you have faced similar problem...
    Thanks,

    Hi,
    There are no short dumps in the system. Only the message in Bold in my first post is the help i can get and provide.
    Strange thing is, RSA3 works correctly but it's not successful in actual extraction.
    Thanks,

  • Can anybody explain me creating Generic Datasource using Function module?

    Hi,
    can anybody explain me creating Generic Datasource using Function module?
    Thax in advance,
    Ravi.

    Generic Extraction via Function Module
    /people/siegfried.szameitat/blog/2005/09/29/generic-extraction-via-function-module
    1. Create s structure with the fields that you need from the 4 tables . Activate.
    2. Goto SE 80 Select The Function Group , Copy , Select the Function module
    " RSAX_BIW_GET_DATA_SIMPLE " and Give a New name starting With
    Y or Z .
    3. SE37 ->Your Function module name -> Change , In table tab give your structure
    name by deleting the associated type given in " E_T_DATA " .
    4. Now select source code and Do the coding . Give Data source name in Coding .
    In your case you have to take data from more that 1 table .
    5. Activate the Function Group .
    6. In RSO2 Create the Data source , Give the Function Module Name , And Save.
    7. RSA3 -> Give data source name and Check for the Records .
    Creation of custom datasource. (Using function module)
    <b>is an example</b>
    1.Create a function group .
    2. Structure ZTEST123
    ZMATNR MATNR CHAR 18 0 Material Number
    ZMTART MTART CHAR 4 0 Material type
    ZMBRSH MBRSH CHAR 1 0 Industry sector
    ZMATKL MATKL CHAR 9 0 Material group
    ZBISMT BISMT CHAR 18 0 Old material number
    ZMAKTX MAKTX CHAR 40 0 Material description
    3. Create function module (i.e. ZTEST….) .
    FM - YMARA_DATA_TRNS
    FUNCTION YMARA_DATA_TRNS.
    ""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
    *" 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 ZTEST123 OPTIONAL
    *" EXCEPTIONS
    *" NO_MORE_DATA
    *" ERROR_PASSED_TO_MESS_HANDLER
    data : ZTEST123 type ZTEST123 occurs 0 with header line.
    Maximum number of lines for DB table
    STATICS: S_S_IF TYPE SRSC_S_IF_SIMPLE,
    S_COUNTER_DATAPAKID LIKE SY-TABIX.
    DATA: begin of t_mara occurs 0,
    ZMATNR type MATNR,
    ZMTART type MTART,
    ZMBRSH type MBRSH,
    ZMATKL type MATKL,
    ZBISMT type BISMT,
    end of t_mara.
    DATA: begin of t_makt occurs 0,
    ZMATNR type MATNR,
    ZMAKTX type MAKTX,
    end of t_makt.
    Initialization mode (first call by SAPI) or data transfer mode
    (following calls) ?
    IF I_INITFLAG = SBIWA_C_FLAG_ON.
    Check DataSource validity
    CASE I_DSOURCE.
    WHEN 'ZZMARA_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.
    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.
    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.
    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.
    select MATNR
    MTART
    MBRSH
    MATKL
    BISMT
    from mara up to 10 rows
    into table t_mara.
    if not t_mara[] is initial.
    select MATNR
    maktx
    from makt
    into table t_makt
    for all entries in t_mara
    where matnr = t_mara-zmatnr.
    endif.
    loop at t_mara.
    read table t_makt with key zmatnr = t_mara-zmatnr.
    ZTEST123-zmatnr = t_mara-zmatnr.
    ZTEST123-ZMTART = t_mara-ZMTART.
    ZTEST123-ZBISMT = t_mara-ZBISMT.
    ZTEST123-ZMBRSH = t_mara-ZMBRSH.
    ZTEST123-ZMATKL = t_mara-ZMATKL.
    ZTEST123-zmaktx = t_makt-zmaktx.
    append ZTEST123.
    clear ZTEST123.
    endloop.
    clear E_T_DATA.
    refresh E_T_DATA.
    E_T_DATA[] = ZTEST123[].
    ENDIF.
    S_COUNTER_DATAPAKID = S_COUNTER_DATAPAKID + 1.
    ENDIF. "Initialization mode or data extractio
    ENDFUNCTION.
    3. Create the data source using transaction (RSO2).
    4. If structure exists for the table parameter of your function module then ok else create a structure for the table parameter ‘E_T_DATA’.
    5. Test the datasource in R/3 using transaction RSA3.
    6. Transfer the data source to BW –System and replicate it in the BW-System.

  • For a function module how can I find its assigned data source name?

    Hi BW Gurus,
    If i know the data source name then the  assigned fn. module/Table/Infoset I could find from RSO2. But for function module How do I know its assigned data source name?
    Thanks a lot for the response.
    Regards
    Ven

    Hi Ram,
    In SE16, enter the table name as ROOSOURCE and in contents choose field EXTRACTOR for selection and enter the name of the function module.
    It will return the list of datasources where the function module has been used.
    Best Regards,
    Ankit Agrawal

  • Generic datasource by function module to fetch data from multiple tables?

    I'm writing a function module to fetch price, for generic datasource.
    At first, extract test is OK. But InfoPackage never stop  when loading data to PSA in BW.
    And I find the example codes:
         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.
        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.
    There using Cursor to fetch data package by package, and raise exception NO_MORE_DATA to stop the loading process.
    Now I fetch data from multiple tables, I don't think I can use Cursor.
    Then How can I handle this?  
    Thanks a lot.

    Thanks
    IF IT_999[] IS INITIAL.
        SELECT A~KNUMH A~MATNR A~KSCHL VKORG VTWEG A~DATBI A~DATAB KBETR KMEIN KPEIN C~MTART APPENDING CORRESPONDING FIELDS OF
          TABLE TP_DATA
            FROM A999 AS A
              INNER JOIN KONP AS B
                  ON A~KNUMH = B~KNUMH
              INNER JOIN MARA AS C
                 ON A~MATNR = C~MATNR
    *          FOR ALL ENTRIES IN IT_999
                    WHERE
    *      A~KNUMH = IT_999-KNUMH  AND
           ( ( A~KSCHL = 'ZPRC' AND VKORG = 'Z000' AND VTWEG = 'Z1' ) OR
                          ( A~KSCHL = 'ZPRD' AND VKORG = 'A000' AND VTWEG = 'Y3' ) ) AND
    *                      A~DATBI >= SY-DATUM AND
                          LOEVM_KO = ''.
        SELECT A~KNUMH A~MATNR A~KSCHL VKORG VTWEG A~DATBI A~DATAB KBETR AS KHETR  KMEIN KPEIN C~MTART APPENDING CORRESPONDING FIELDS OF
          TABLE TP_DATA
            FROM A999 AS A
              INNER JOIN KONP AS B
                  ON A~KNUMH = B~KNUMH
              INNER JOIN MARA AS C
                 ON A~MATNR = C~MATNR
    *          FOR ALL ENTRIES IN IT_999
                    WHERE
    *      A~KNUMH = IT_999-KNUMH AND
          A~KSCHL = 'ZPR3' AND A~VKORG = 'I000' AND
    *                      DATBI >= SY-DATUM AND
                          LOEVM_KO = ''.
      ENDIF.
      IF IT_997[] IS INITIAL.
        SELECT A~KNUMH A~MATNR A~KSCHL VTWEG A~DATBI A~DATAB KBETR AS KHETR KMEIN KPEIN C~MTART APPENDING CORRESPONDING FIELDS OF
          TABLE TP_DATA
            FROM A997 AS A
              INNER JOIN KONP AS B
                  ON A~KNUMH = B~KNUMH
              INNER JOIN MARA AS C
                 ON A~MATNR = C~MATNR
    *          FOR ALL ENTRIES IN IT_997
                    WHERE
    *      A~KNUMH = IT_997-KNUMH      AND
          A~KSCHL = 'ZPRA' AND VTWEG = 'Y1' AND
    *                      DATBI >= SY-DATUM AND
                      LOEVM_KO = ''.
      ENDIF.
      IF IT_996[] IS INITIAL.
        SELECT A~KNUMH A~MATNR A~KSCHL A~DATBI A~DATAB KBETR AS KHETR KMEIN KPEIN C~MTART APPENDING CORRESPONDING FIELDS OF
           TABLE TP_DATA
             FROM A996 AS A
               INNER JOIN KONP AS B
                   ON A~KNUMH = B~KNUMH
               INNER JOIN MARA AS C
                  ON A~MATNR = C~MATNR
    *          FOR ALL ENTRIES IN IT_996
                    WHERE
    *      A~KNUMH = IT_996-KNUMH AND
          A~KSCHL = 'ZPRB' AND
    *                       DATBI >= SY-DATUM AND
          LOEVM_KO = ''.
      ENDIF.
      SELECT   MATNR     "u7269u6599u53F7u7801
               MEINH     "u4ED3u50A8u5355u4F4Du7684u5907u7528u8BA1u91CFu5355u4F4D
               UMREZ     "u57FAu672Cu8BA1u91CFu5355u4F4Du8F6Cu6362u5206u5B50
               UMREN     "u8F6Cu6362u4E3Au57FAu672Cu8BA1u91CFu5355u4F4Du7684u5206u6BCD
          FROM MARM
          INTO CORRESPONDING FIELDS OF TABLE IT_MARM
           FOR ALL ENTRIES IN TP_DATA
         WHERE MATNR = TP_DATA-MATNR AND  MEINH = TP_DATA-KMEIN.
      LOOP AT TP_DATA.
        IF TP_DATA-KPEIN NE 0.
          TP_DATA-KBETR =  TP_DATA-KBETR / TP_DATA-KPEIN.
          TP_DATA-KHETR =  TP_DATA-KHETR / TP_DATA-KPEIN.
        ENDIF.
        IF TP_DATA-KSCHL = 'ZPRA'.
    *       TP_DATA-MEINH = 'ZI'.
    *      TP_DATA-KSCHL = 'B4'.
          IF TP_DATA-KMEIN = 'ZI'.
            TP_DATA-KBETR = TP_DATA-KHETR / '1.17'.
          ELSE.
            READ TABLE IT_MARM INTO WA_MARM1 WITH KEY MATNR = TP_DATA-MATNR MEINH = TP_DATA-KMEIN.
    *           READ TABLE IT_MARM INTO WA_MARM2 WITH KEY MATNR = TP_DATA-MATNR MEINH = 'CT'.
            TP_DATA-KHETR = TP_DATA-KHETR * WA_MARM1-UMREN / WA_MARM1-UMREZ.
    *           * WA_MARM2-UMREZ / WA_MARM2-UMREN.
            TP_DATA-KBETR = TP_DATA-KHETR / '1.17'.
          ENDIF.
        ELSEIF TP_DATA-KSCHL = 'ZPRB'.
    *      TP_DATA-KSCHL = 'L0'.
    *       TP_DATA-MEINH = 'ZI'.
          IF TP_DATA-KMEIN = 'ZI'.
            TP_DATA-KBETR = TP_DATA-KHETR / '1.17'.
          ELSE.
            READ TABLE IT_MARM INTO WA_MARM1 WITH KEY MATNR = TP_DATA-MATNR MEINH = TP_DATA-KMEIN.
    *           READ TABLE IT_MARM INTO WA_MARM2 WITH KEY MATNR = TP_DATA-MATNR MEINH = 'BAG'.
            TP_DATA-KHETR = TP_DATA-KHETR * WA_MARM1-UMREN / WA_MARM1-UMREZ.
    *           * WA_MARM2-UMREZ / WA_MARM2-UMREN.
            TP_DATA-KBETR = TP_DATA-KHETR / '1.17'.
          ENDIF.
        ELSEIF TP_DATA-KSCHL = 'ZPRC' OR TP_DATA-KSCHL = 'ZPRD'.
    *       TP_DATA-MEINH = 'ZI'.
          IF TP_DATA-KMEIN = 'ZI'.
            TP_DATA-KHETR = TP_DATA-KBETR * '1.17'.
          ELSE.
            READ TABLE IT_MARM INTO WA_MARM1 WITH KEY MATNR = TP_DATA-MATNR MEINH = TP_DATA-KMEIN.
    *           READ TABLE IT_MARM INTO WA_MARM2 WITH KEY MATNR = TP_DATA-MATNR MEINH = 'WZI'.
            TP_DATA-KBETR = TP_DATA-KBETR * WA_MARM1-UMREN / WA_MARM1-UMREZ.
    *           * WA_MARM2-UMREZ / WA_MARM2-UMREN.
            TP_DATA-KHETR = TP_DATA-KBETR * '1.17'.
          ENDIF.
        ELSEIF TP_DATA-KSCHL = 'ZPR3'.
    *      TP_DATA-KSCHL = 'B2'.
          IF TP_DATA-KMEIN = 'ZI'.
            TP_DATA-KBETR = TP_DATA-KHETR / '1.17'.
          ELSE.
            READ TABLE IT_MARM INTO WA_MARM1 WITH KEY MATNR = TP_DATA-MATNR MEINH = TP_DATA-KMEIN.
    *           READ TABLE IT_MARM INTO WA_MARM2 WITH KEY MATNR = TP_DATA-MATNR MEINH = 'BAG'.
            TP_DATA-KHETR = TP_DATA-KHETR * WA_MARM1-UMREN / WA_MARM1-UMREZ.
    *           * WA_MARM2-UMREZ / WA_MARM2-UMREN.
            TP_DATA-KBETR = TP_DATA-KHETR / '1.17'.
          ENDIF.
        ENDIF.
        TP_DATA-MEINH = '01'.
        MODIFY TP_DATA.
    E_T_DATA-MATNR =   TP_DATA-MATNR.
    E_T_DATA-KSCHL =   TP_DATA-KSCHL.
    E_T_DATA-KHETR =   TP_DATA-KHETR.
    E_T_DATA-KBETR =   TP_DATA-KBETR.
    E_T_DATA-KMEIN =   TP_DATA-KMEIN.
    E_T_DATA-DATAB =   TP_DATA-DATAB.
    E_T_DATA-DATBI =   TP_DATA-DATBI.
    APPEND E_T_DATA.
        CLEAR WA_MARM1.
        CLEAR WA_MARM2.
      ENDLOOP.
    Edited by: Shen Peng on Oct 20, 2010 10:09 AM

  • Function Module in Generic DataSources in BI

    Hi,
    I appreciate your answer about the Function Module in Generic DataSources in BI.
    These are the steps I followd on R/3 side.
    1) Create a structure with the R/3 table fileds based on the requirement.
    2) Create a function module by copying RSAX (Function Group) and RSAX_BIW_GET_DATA_SIMPLE (Functin Module) into our own function group & Function Module (name starting with Y /Z). And use the structure(ex: ZSPMT) created in the reference data of 'Tables' tab (ex: E_T_DATA LIKE ZSPMT).
    3) Use the structure name & function module name in the Generic DataSource
    Finally when I want to use the Generic DataSource, do i need to insert the records myself in the table (or structre) I created  ZSPMT? (which is used in Function Module)
    If I need to insert the data into table ZSPMT myself, what is use of function module?
    Can't I use the view of this table (ZSPMT) directly in Generic DataSource?
    Is the function module used to filter/restrict the data based on client need?
    Thank you in advance for you answers
    It will help undderstand the difference among View, InfoSet Query & Function Module
    used in  creating Generic DataSource.
    Regards,
    Lakshmi

    hi,
    why did you prefered function module?
    if the table ZSPMT egts the data that you enter automatically then no need to use FM.
    directly extract with tables/if more than one table then use views.
    if you need especially the FM that could solve ur complex requirmnet.
    http://help.sap.com/saphelp_nw04/helpdata/en/3f/548c9ec754ee4d90188a4f108e0121/content.htm
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/84bf4d68-0601-0010-13b5-b062adbb3e33
    Ramesh

  • How to debug a function module using in the generic datasource?

    Hi all,
    We have created a generic data source using function modulle and have been extracting the data for a single customer it contains single records but it has pulled out more than 10,000 records. how to debug the function module used in the data source.
    since we schedule for extraction in bi and back ground job gets triggered in ecc for extraction,
    i know in se37 we can select the function module name and then debug but still need to check while the bacground job is trigered through bi.
    Thanks

    Yes you can debug the Function Module.
    Open the function module in SE37 and put a break point in the code where you want to check from, then come to RSA3 and give the datasource name and check the Debug check box on this screen, once you click on the start button it will take you the place where you have placed the break point in the FM, by pressing F5 you can see the flow of the FM.
    Let me know whether this solves your issue.

  • BW/ABAP- Function module is called infinitely by Datasource Extractor.

    Hi All,
    A quick ABAP question related to Function Modules and BW data source extractors.
    I’ve written a function module to select data from a database and simply output the data as a table. I then created a text Datasource using transaction rso2 and set it to Extraction by Function Module.
    When I test this using transaction rsa6, I can manipulate the number of calls to my function module using the Display Extra Calls field.
    However, when I test this using transaction rsa1, my function module seems to be called infinite times. So, the number of records being retrieved is increasing exponentially and finally ends with a dump.
    My question: Do I need to include something in my code such that the Function Module by itself will only be called once?
    Or is there some configuration for the Datasource that will limit my function module call to once only.
    Tried so far
    • Introducing a static variable in the function module that exits as soon as the value is greater than 1.
    o Is there another way out?
    Regards,
    Preethi.

    You need to raise the EXEPTION NO_MORE_DATA afte the last record is populated in the output table. Otherwise the program goes into an infinite loop.
    * From now on records get fetched from the database or gets read from the internal table
        FETCH NEXT CURSOR v_cursor
                   APPENDING CORRESPONDING FIELDS
                   OF TABLE <internal table>
                   PACKAGE SIZE i_s_if-maxsize.
        IF sy-subrc <> 0.
          CLOSE CURSOR v_cursor.
          RAISE no_more_data.
        ENDIF.
    * Populate the Output Data Structure into table E_T_DATA and you need to raise the EXEPTION NO_MORE_DATA and close the cursor to avoid any memory leaks

  • Function Module as Datasource loading error

    Hi,All
      I use function module as datasource and create a fm in function group: RSAX
      But when i loading data from the DS , it display :
      Error occurred in the data selection
    Code:
    DATA: l_s_select type srsc_s_select,.
    statics: s_s_if type srsc_s_if_simple,
             s type i.
    if i_initflag = 'X'.  " determine the selection fields and values
      append lines of i_t_select to s_s_if-t_select.
      s_s_if-requnr = i_requnr.
      s_s_if-dsource = i_dsource.
      s_s_if-maxsize = i_maxsize.
      append lines of i_t_fields to s_s_if-t_fields.
      append lines of i_t_fields to s_s_if-t_fields.
    else. "fill the result as e_t_data
      if s = 0.
    add one line to the itab for test
             E_T_DATA-KOKRS = 'HT01'.
             append E_T_DATA.
             s = s + 1.
      else.
         raise no_more_data.
      endif.
    endif.
    ENDFUNCTION.
    The function is all right i think

    Hi, Chivukula
       haha , i forgot to select the passvalue in table tab , after check, it's Ok
      Thanks for your time
    Terry Ni
    Kind Regards

Maybe you are looking for

  • Issue in cancelling the GR for PO

    Hi All, I have an issue where for a PO, im creating a GR for some amount say 10 USD simultaneously a Service entry sheet also gets created for 10 USD. Then im doing partial invoice for above GR say for amount 8.00. Then i reversed the invoice for 8.0

  • How much memory can I install in my mac book pro?

    Mac book pro 2.4 GHz late 2011 i7....How much memory can I install? Currently have 4Gb but want to run Win 7 on VMware and want to make sure my user has enough

  • Why is Safari/Mac breaking this site?

    What can we do to make Safari/Mac view this site without errors? http://apcinternet.com/edenvale/ Site markup is 100% correct http://validator.w3.org/check?uri=http%3A%2F%2Fapcinternet.com%2Fedenvale%2F&cha rset=%28detect+automatically%29&doctype=Inl

  • System not started after installing grid control

    HI, I have installed grid control 10.2.0.1 on 11g r2 on rhel5.After installing grid control, whenever system get booted, it got hanged and saying after starting up the listener           sql>ora-01078: failure in processing system parameters LRM-0010

  • BW Default System

    I have entered my Measures into our BW DEV box and transported to our BW PRD box.  This is transaction UMK_MB.  When I try to look at this in BW PRD, I get this: No default BW system has been defined for the Measure Builder Do you want to maintain de