FUNCTIONAL MODULE AS A GENERIC EXTRACTOR

Hi,
Im looking to extract fields in from the following tables and want to create a functional module as a generic extractor for that:
BSEG
BKPF
COEP
MBEW
EINA
Could some one tell me how I can create a FUNCTIONAL MODULE AS A GENERIC EXTRACTOR for this or send me a documet at mysapsource at  gmail com
Thanks

Hi,
Please find the steps to create FM:
Step 1.
GO to transaction SE80.In the drop box list select function group enter your Z Function group name.Press enter it will ask for creating the function group.Create your function group.
OR
In SE37 transaction,in the menu bar Goto - > Function Group - > Create Group.Your Function Group will be created.
Step 2.
Go to transaction SE37.Enter your Z Function module name,your recently created function group name and the description.Press Enter.Now your FM is created.
Step 3.
Enter Export,Import parameters.In the source code tab write the code what you want to write.If any exception write in the exception tab.
Method 2:
First u have to create Function Group.
1.se37->Goto->Function Group--->Create.
2.Create FM.
3.maintain import /export parameters and tables , exceptions.
4.based on the ur requirement u have to bulid ur logic in Source Code by using there Import parameters and u can pass the results by using Export or table.
5.u can raise error by using exception.
Create Function Module:
http://help.sap.com/saphelp_nw04s/helpdata/en/9f/db98fc35c111d1829f0000e829fbfe/frameset.htm
http://help.sap.com/saphelp_nw04/helpdata/en/26/64f623fa8911d386e70000e82011b8/frameset.htm
Creating Function Modules.
Create Generic Datasource using Function Module:
Generick Extarction using Function Module.
Hope this helps u...
Regards,
KK.
Edited by: koundinya karanam on May 2, 2008 7:29 AM

Similar Messages

  • Function Module in a Generic Function Module Extractor

    I want to use a generic function module (ZFM_CONNECTION_DETAIL) in a Generic Function Module based Extractor.
    After Creating, I have checked it in RSA3... Data is showing properly on the Extractor Check.
    And replicated on BW side, after triggering the extractor using infopackageu2026 only one record is coming on the target side (BW).
    And one job is running endless on the source system.
    Generic extractor on the normal code is working properly on both sides.
    But problem occurs while I was using Function Module in the Generic function Module extractor.
    Waiting for a Reply with solution...........
    Hi Siegfried Szameitat,
    I have searched a lot to find out the solution of my Question (Problem). But there is no solution for the problem I have.
    Please let me to find out a proper solution of my issue....
    Thanks

    FUNCTION zcrm_questionnaire.
    Its a full Load...
    Codes are as followed..........
      DATA:lv_times     TYPE i.
      DATA:lv_datapakid TYPE numc4.
      CLEAR:lv_datapakid,lv_times .
      STATICS: s_s_if TYPE srsc_s_if_simple,
               sd_no_more_data  TYPE flag.
      DATA: l_s_select TYPE srsc_s_select.
      DATA :  s_counter_datapakid LIKE sy-tabix,
              s_cursor TYPE cursor.
      RANGES :  date  FOR  zresult_lt-date.
      DATA: lv_count TYPE i VALUE 1.
      IF i_initflag = sbiwa_c_flag_on.
    Initialization: check input parameters
                    buffer input parameters
                    prepare data selection
    Check InfoSource validity
        CASE i_dsource.
          WHEN 'ZCRM_QUESTIONNAIRE'.
          WHEN OTHERS.
            IF 1 = 2. MESSAGE e009(r3). ENDIF.
            log_write 'E'                  "message type
                      'R3'                 "message class
                      '009'                "message number
                      i_dsource            "message variable 1
                      ' '.                 "message variable 2
            RAISE error_passed_to_mess_handler.
        ENDCASE.
        APPEND LINES OF i_t_select TO s_s_if-t_select.
        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.
      ELSE.                 "Initialization mode or data extraction
        IF NOT sd_no_more_data IS INITIAL.
          RAISE no_more_data.
        ENDIF.
        LOOP AT s_s_if-t_select INTO l_s_select .
          MOVE-CORRESPONDING l_s_select TO date.
        ENDLOOP.
        DATA : v_questionire  TYPE  crm_svy_db_sid.
        DATA : itab_questionire TYPE zsurveyid.
        DATA : e_tt_data_get TYPE  zresult_lt OCCURS 10.
        v_questionire = 'CALL CENTER'.
        APPEND v_questionire TO itab_questionire.
        v_questionire = 'METER INSTALLATION TEAM'.
        APPEND v_questionire TO itab_questionire.
        v_questionire = 'METER READING & BILLING'.
        APPEND v_questionire TO itab_questionire.
        v_questionire = 'NO SUPPLY'.
        APPEND v_questionire TO itab_questionire.
        v_questionire = 'CASH COLLECTION CENTER'.
        APPEND v_questionire TO itab_questionire.
        v_questionire = 'STREET LIGHT'.
        APPEND v_questionire TO itab_questionire.
        v_questionire = 'CONSUMER CARE CENTER'.
        APPEND v_questionire TO itab_questionire.
        v_questionire = 'WEBSITE'.
        APPEND v_questionire TO itab_questionire.
        DATA : counter TYPE i,
              high  LIKE sy-datum,
               low LIKE sy-datum.
        CONCATENATE
        l_s_select-high+6(4)
        l_s_select-high+3(2)
        l_s_select-high+0(2)
        INTO
        high.
        CONCATENATE
        l_s_select-low+6(4)
        l_s_select-low+3(2)
        l_s_select-low+0(2)
        INTO
        low.
        BREAK-POINT.
       do i_maxsize times.
        CALL FUNCTION 'ZCRM_SURVEY_REPORTING'
          EXPORTING
            e_date_frm    = low
            e_date_to     = high
            e_questionire = itab_questionire
          CHANGING
            it_result     = e_tt_data_get.
        IF sy-subrc IS INITIAL.
          e_t_data[] = e_tt_data_get[].
          APPEND e_t_data.
        ELSE.
          EXIT.
        ENDIF.
         sd_no_more_data = 'X'.
      ENDIF.              "Initialization mode or data extraction ?
    ENDFUNCTION.
    lk

  • FUNCTION MODULE CREATION FOR GENERIC DATA SOURCE

    Hi BI gurus,
    I am creating function module for generic datasource. For that I followed below mentioned steps
    Steps
    1.     Created s structure with the fields that needed.
    2. Created FM by copying the standard Function module
    " RSAX_BIW_GET_DATA_SIMPLE " and Give a New name starting With
    Y or Z .
    3. IN SE37 ->Your Function module name -> Change, In table tab given structure
    name by deleting the associated type given in “E_T_DATA “.
    And inserted the required code given below
          PROGRAM 'ZHU_BALANCE'.
    *& Report  ZHU_BALANCE
    TABLES: VEKP, VEPO.
    DATA: BEGIN OF T_DISPLAY,
          DATE   LIKE SY-DATUM,
          EXIDV  LIKE VEKP-EXIDV,
          LGORT  LIKE VEPO-LGORT,
          WERKS  LIKE VEKP-WERKS,
          END OF T_DISPLAY.
    DATA: ITAB_DISPLAY LIKE TABLE OF T_DISPLAY.
    DATA: WA_ITAB_DISPLAY LIKE LINE OF ITAB_DISPLAY.
    SELECT VEKPEXIDV VEPOLGORT VEPO~WERKS
           INTO CORRESPONDING FIELDS OF TABLE ITAB_DISPLAY
           FROM VEKP AS VEKP INNER JOIN VEPO AS VEPO
             ON  VEKPVENUM = VEPOVENUM
             AND VEKPWERKS = VEPOWERKS
           WHERE VEKP~VSTEL = SPACE
             AND VEKP~VEGR1 = '401'
             AND VEKP~VPOBJ = '12'
             AND VEKP~STATUS = '0020'
             AND VEPO~VEPOS = '000001'.
    LOOP AT ITAB_DISPLAY INTO WA_ITAB_DISPLAY.
    WA_ITAB_DISPLAY-DATE = SY-DATUM.
    MODIFY ITAB_DISPLAY FROM WA_ITAB_DISPLAY TRANSPORTING DATE.
    ENDLOOP.
    WRITE:/ 'DATE', 20 'EXIDV', 40 'LGORT', 60 'WERKS'.
    ULINE.
    LOOP AT ITAB_DISPLAY INTO WA_ITAB_DISPLAY.
    WRITE:/ WA_ITAB_DISPLAY-DATE, 20 WA_ITAB_DISPLAY-EXIDV , 40 WA_ITAB_DISPLAY-LGORT, 60 WA_ITAB_DISPLAY-WERKS.
    ENDLOOP.
    While checking the function module it’s populating the syntax error as
    THE TYPE “SRSC_S_IF_SIMPLE” IS UNKOWN. (Though this is commented in program)
    So pls suggest
    Regards,
    praful

    hi indira,
    thanx for ur reply we have created the funcion module successfuly it is also showing the output correct. But when we put that function module in the generic data source and try to extract data in RSA3 it shows the correct output of function module but with the msg ' 0 entries found in customer enhancement' and therfore zero records in the display list.
    is there any correction or steps to be followed in data extraction
    pls suggest
    regards,
    praful

  • Counter logic  in Function module of the generic extraction

    Hi,
    I had like to add this counter field which can be used in reporting..
    As this extraction logic is bit different, i cannot include it in transformations with 1 as a constant..
    so i am wrtiting this logic in Function Module..
    in the main table loop i had assigned this counter as 1 and after appending it i am clearing the counter field...
    is it a correct way or is there any thing that needs to be taken care?

    Hi,
    it will put 1 for every record.
    Can you share your coding ? please copy past your coding
    Regards,
    G

  • Generick Extarction using Function Module.

    Hi,
    Give me the steps Generic Extraction using function module.Thanks for your help.
    Thanks & Regards,
    Suresh.

    Hi,
    Check the below threads:
    Using function module as the generic extractor
    Generic Delta Update using Function Module
    Document regarding R/3 extractors using function module/user exits
    Generic extractors using FM
    Also refer the document:
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/d3219af2-0c01-0010-71ac-dbb4356cf4bf
    Reg
    Pra

  • How to create Geniric data source using the SAP FUNCTION MODULE

    Hi,
    I want to create genric data source using function module
    MD_STOCK_REQUIREMENTS_LIST_API (delivered by sap)
    for this function module where I can find  Extract Structer
    or I have to create ?
    How can i use this ?
    Thanks in Advance

    Hi Shilpa,
                  Check here..........
    Using function module as the generic extractor
    Generic Delta Update using Function Module
    Document regarding R/3 extractors using function module/user exits
    Generic extractors using FM

  • Generic RFC function modules

    Hello,
    assume you have a Web AS and a mySAP ERP-system which are connected to each other. On the ERP system there's a table "A" and you need parts/columns of the table on the Web AS, furthermore "A" could not be known on the Web AS.
    Is there a way to create a function module which has generic importing/exporting parameters to transfer the structure of "A" to the Web AS via RFC?
    Thanks in advance.
    Daniel

    Hello Daniel
    One already exists - RFC_READ_TABLE.
    However, making an RFC call every time you want to read a table record or two doesn't necessarily scale very well in a client-server environment.
    Cheers
    Dom

  • BW - R/3: get systemid of caller in the function module of a gen. datasoure

    Hello,
    we are creating a generic datasource in R/3 based on a function module. It will be used by several WI systems. Does anyboddy know a simple way how to find out the systemid of the calling BW system inside the function module of the generic datasource ?
    We'd like to do some BW-specific codeing in the R/3 generic datasource.
    Also, is there a way to pass a parameter to the remote R/3 system from the BW system which uses the infopackage?
    Thanks,
    Irmgard
    Edited by: Irmgard Polifka on Sep 8, 2011 9:48 AM
    Edited by: Irmgard Polifka on Sep 8, 2011 9:52 AM

    Have a look at this thread
    Extract data into two BW systems
    The solution suggested there is to use 2 different extraction users from the 2 BW systems accessing the same ERP system.
    So BW1 would use user BWREMOTE1 in the ERP system and BW2 would use BWREMOTE2 (instead of using BWREMOTE as the user from both BW1 and BW2).
    This way you can make decisions using SY-UNAME in your extractor exit coding that defer by the calling BW system.

  • Extraction by functional module

    Hi all,
              I create a functional module for making generic data source but when i import my functional module name in rso2 and enter my functional module name  and my structure name   it shows one error
    Error :TABLES-paramter E_T_DATA for extractor ZMM_SLO_MOV is missing
    hear ZMM_SLO_MOV = my functional module name please can any body tell me how can i remove that error and create my data source.
    thanks

    Hi Ankit,
    YOur function module should be in line with Function Module RSAX_BIW_GET_DATA_SIMPLE in the table parameter of the function modules E_T_DATA should of type structure you give in RSO2 below the FUNCTION Module name.
    Correction to Reddy advice it should be extract structure name instead of Datasource
    Hope this helps.
    Best Regards,
    PV
    Edited by: USERPV on Dec 20, 2007 10:00 AM

  • Delta Extraction Using Function Module ( Customization )

    Dear Experts,
    I want a sample code for Delta Extraction using Function Module ( If it is customized already working code very helpful ), I have already created Function Module but Full update is happening. If I give delta update again it is retrieving all records. It is very urgent, if you have please send me to the following mail ID.
    [email protected]
    Best Regards,
    SGK.

    Hi SGK,
    I've done this for a delta based on a timestamp and it's actually pretty easy.  The basic steps are:
    1) Create an extract structure in SE11.  Make sure the structure has a date or timestamp field in it that you can use for delta.  You'll need to include the field twice if you also want to extract it to BW/BI since once it's chosen as the delta field then it will be hidden in the interface.
    2) Create the extractor function module in SE37.  You can use RSAX_BIW_GET_DATA_SIMPLE as a template.  Make sure your logic restricts the data it retrieves according to the selections that are passed in I_T_SELECT, including restrictions on the delta field.
    3) Create a generic DataSource in RSO2.  Click Extraction by FM then fill in your extract structure and function module.  Click Generic Delta and pick your delta field and the appropriate radio button (time stamp or calendar day).  If your delta field is a timestamp field then be sure to set the upper and lower safety limits to -86400 and 86400 respectively.  This might not be necessary on your version of SAPI but on mine there is a bug where it doesn't translate between system time and UTC (GMT) correctly so this was necessary.
    You don't need to program any special delta handling logic in your function module as long as you restrict the data you retrieve based on the delta field (I_T_SELECT).  This is because the SAPI takes care of catching the init, delta and repeat requests, translating them to the appropriate delta field values, and then passing them to your function module as if it was a full extraction for a specific date or timestamp range.
    Hope this helps!
    Jason

  • Function module based Datasource

    Gurus
    I am working on creating a function module based extractor. Found some good documents for the same but wanted to check a few things:
    u2022     What I understood, I need to copy the function group RSAX as a Z function group. Wanted to check if this needs to be done every time a new FM is written or can I reuse an existing one function group.
    u2022     My extractor is on CDPOS and EKPO and I intend to use the FM RSAX_BIW_GET_DATA_SIMPLE. Is this ok or is better to use the RSAX_BIW_GET_DATA or it does not matter.
    u2022     I will have to load the historical data for the past one year and then either do a delta or do loads with selection criteria. The user does not have any preference, as currently they only need the report for the last month. But wanted to check which will be a better approach- to do daily deltas or do a periodic (monthly load) with a selection.
    Also, wanted to check this is the best approach (having function module) for creating generic DS or is there something else also.
    Thanks,
    AK

    Hi,
    u2022 What I understood, I need to copy the function group RSAX as a Z function group. Wanted to check if this needs to be done every time a new FM is written or can I reuse an existing one function group.
    You can reuse the existing or newly created group, you don't need to create function group every time you create a FM
    Even you don't need to create new function group also, you can simply use the type pool used in RSAX.
    u2022 My extractor is on CDPOS and EKPO and I intend to use the FM RSAX_BIW_GET_DATA_SIMPLE. Is this ok or is better to use the RSAX_BIW_GET_DATA or it does not matter.
    You can use RSAX_GET_DATA_SIMPLE.
    u2022 I will have to load the historical data for the past one year and then either do a delta or do loads with selection criteria. The user does not have any preference, as currently they only need the report for the last month. But wanted to check which will be a better approach- to do daily deltas or do a periodic (monthly load) with a selection.
    Actually if you do a daily extraction then data volume will be less compared to if you do a monthly extraction. So you can decide based on no. of records which are getting created/changed daily
    Also, wanted to check this is the best approach (having function module) for creating generic DS or is there something else also.
    If you simply want to extract data from these two fields then you can create a view on top of these two tables and then create a generic extractor based on view. So you need not do any coding *
    Regards,
    Durgesh.

  • Dynamic programming: send data to function module, mapping...

    Hello abappers,
    I have a requirement to be able to send a the name of a table and a table-field to a function module, it can be a table of any type, so the function module should be generic in nature, the function module receives the table name and table-field name and then selects data for the field specified from the table specified (in the import parameter of the FM). Within the function module, I want to be able to determine the fields type? and then send this field to an internal table representing a a destination table (also specified in the import parameters).
    the idea is to be able to map a field from any table to a specified field in another table, the table(source and destination) and field names will only determined at run time as specified by the user.
    any assistance will be appreciated, I am not very familiar with dynamic\generic programming.

    Hello Bijo,
    Following are the steps to implement this requirement:
    1. Create import parameter for table name i.e. TABLE_NAME
    2. Create tables parameter for fields table
    3. Define table. DATA TABLE TYPE REF TO DATA. Also create single column internal table for fields and load all fields to select from database.
    Inside function module you can implement following steps:
    4. Load all the fields name into internal table. for this you can use DD03L for field details and use TABLE_NAME as key.
    5. Once you have all the fields ready in internal table then construct fieldcatlog using these fields
    loop at internal table with all the fields.
    move it to field catalog.
    append field catalog.
    endloop.
    6. Pass this field catalog table to static method create_dynamic_table
    call method cl_alv_table_create=>create_dynamic_table
    exporting
    it_fieldcatalog = fieldcatalog_tab
    importing
    ep_table = table.
    Here table is defined with data object type.
    now assign table reference to field symbol of type table.
    ASSIGN table->* to <field-tab>.
    Also create work area <field-wa> using refrence of table.
    create data object wa LIKE LINE OF <field-tab>.
    ASSIGN wa->* to <field-wa>.
    Also define field symbol for field name.
    for e.g. <field_name>
    7. Dynamic internal table is ready
        Now using can use select as follows:
        SELECT (fields)  "--> fields is single column internal table to hold fields need to be selected
             INTO CORRESPONDING FIELDS OF TABLE <itab> "--> itab created dynamically at runtime
            FROM (TABLE_NAME) --> Table name imported
         WHERE (where_clause). --> where_clause is single column internal table with data type CHAR72.
    Select data into <itab> and use ASSIGN COMPONENT to move data from one table to another as follows:
    8. To fill this dynamic internal table using ASSIGN COMPONENT <Comp_number> OF STRUCTURE <field-wa> TO <field-name>
    So in this case if first field of structure STRUCT1 is user_id then sudo-code will be
    loop at internal table containing list of fields into field_wa
    ASSIGN COMPONENT field_wa OF STRUCTURE <field-wa> TO <field>. "Here field_wa is wa area for single column internal table holding all the fieldnames.
    Now <field-name> points to user_id field. Move some value into it as nornally we do with variables.
    move '001' to <field-name>.
    or
    <field-name> = '001'.
    endloop.
    after completing all the fields one row will be ready in <field_wa>.
    APPEND <field_wa> to <field_tab>.
    Let me know incase you face any issues!
    Hope this helps you.
    Thanks,
    Augustin.
    Edited by: Augustarian on Aug 23, 2009 7:02 PM
    Edited by: Augustarian on Aug 23, 2009 7:08 PM
    Edited by: Augustarian on Aug 23, 2009 7:09 PM

  • Function Module Changed - Selection Screen still has old values

    Hi All,
    Our data source uses a function module while extraction. (generic)
    We have changed the Text Symbols in our function module.
    In the function module we fill one particular field (master data) as per the logic.
    The changes done are reflected in the dataloads and data is fine in BW.
    our problem is the selection screen in BW and in the reports, it shows the older values as well for that particular field.
    Can anyone help us in this regard?
    thanks
    Sudeepti

    Sudeepti,
    run program
    rsdds_aggregates_maintain for the relevant infoobjects and see if the change is carried over..
    Also check if the text tables for the same refer to the older values...
    Arun
    Assign points if useful

  • Identify tables from where the function module extracts data for the ES

    Hi All,
    For the datasource, 0CRM_SALES_ORDER_I in the CRM system, we need to add a new field (in the table level). This datasource's extraction type is 'F1 - function module'. Is the extractor itself is this function module? If it is a sepeate FM, where can we find the function module name used for this datasource?
    We need to identify the tables from where the fields in this datasource fetch data from. Where can we find this information?
    To be specific, in the sales order in tcode crmd_order, if we goto conditions tab and create a new condition, in what table this will get stored?
    Thank you in advance,
    Hari

    Ignore this thread! there is another thread I have created for the same problem.
    I created only one; wonder how it became two!!

  • Delta fo Generic extractor using function module

    Hi,
    I am using the following function module for generic extractor but its always showing me extraction error.Could anyone please suggest to resolve the issue.
    Thanks in advance fo rsuggestion.
    FUNCTION Z_BW_SALESDATA_EXTRACT_CHNG2.
    ""Local interface:
    *"  IMPORTING
    *"     VALUE(I_REQUNR) TYPE  SBIWA_S_INTERFACE-REQUNR
    *"     VALUE(I_ISOURCE) TYPE  SBIWA_S_INTERFACE-ISOURCE OPTIONAL
    *"     VALUE(I_MAXSIZE) TYPE  SBIWA_S_INTERFACE-MAXSIZE OPTIONAL
    *"     VALUE(I_INITFLAG) TYPE  SBIWA_S_INTERFACE-INITFLAG OPTIONAL
    *"     VALUE(I_UPDMODE) TYPE  SBIWA_S_INTERFACE-UPDMODE OPTIONAL
    *"     VALUE(I_DATAPAKID) TYPE  SBIWA_S_INTERFACE-DATAPAKID OPTIONAL
    *"     VALUE(I_PRIVATE_MODE) OPTIONAL
    *"     VALUE(I_CALLMODE) LIKE  ROARCHD200-CALLMODE OPTIONAL
    *"     VALUE(I_REMOTE_CALL) TYPE  SBIWA_FLAG DEFAULT SBIWA_C_FLAG_OFF
    *"  TABLES
    *"      I_T_SELECT TYPE  SBIWA_T_SELECT OPTIONAL
    *"      I_T_FIELDS TYPE  SBIWA_T_FIELDS OPTIONAL
    *"      E_T_DATA OPTIONAL
    *"      E_T_SOURCE_STRUCTURE_NAME OPTIONAL
    *"  EXCEPTIONS
    *"      NO_MORE_DATA
    *"      ERROR_PASSED_TO_MESS_HANDLER
    The input parameter I_DATAPAKID is not supported yet !
    Example: InfoSource containing TADIR objects
      TABLES: VBFA,VBRK,tadir.
    Auxiliary Selection criteria structure
      DATA: l_s_select TYPE sbiwa_s_select.
    Maximum number of lines for DB table
      STATICS: l_maxsize TYPE sbiwa_s_interface-maxsize.
    user defined variables.
      DATA : X_UPDMODE(1) Type c,        " Update Type
            X_LastUpdate Like Sy-Datum. " Last Update Date
             X_LastUpdate TYPE RODELTAID. " Last Update Date   "TCS_KAP
    Select ranges
      RANGES: L_R_VBELN   FOR VBAK-VBELN,
              L_R_AUDAT   FOR VBAK-AUDAT.
    Parameter I_PRIVATE_MODE:
    Some applications might want to use this function module for other
    purposes as well (e.g. data supply for OLTP reporting tools). If the
    processing logic has to be different in this case, use the optional
    parameter I_PRIVATE_MODE (not supplied by BIW !) to distinguish
    between BIW calls (I_PRIVATE_MODE = SPACE) and other calls
    (I_PRIVATE_MODE = X).
    If the message handling has to be different as well, define Your own
    messaging macro which interprets parameter I_PRIVATE_MODE. When
    called by BIW, it should use the LOG_WRITE macro, otherwise do what
    You want.
    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
    The input parameter I_DATAPAKID is not supported yet !
    Invalid second initialization call -> error exit
        IF NOT g_flag_interface_initialized IS INITIAL.
          IF 1 = 2. MESSAGE e008(r3). ENDIF.
          log_write 'E'                    "message type
                    'R3'                   "message class
                    '008'                  "message number
                    ' '                    "message variable 1
                    ' '.                   "message variable 2
          RAISE error_passed_to_mess_handler.
          ENDIF.
    Check InfoSource validity
        CASE i_isource.
          WHEN 'Z_BW_SDDATA_CREATEON'.
          WHEN 'Y'.
          WHEN 'Z'.
          WHEN OTHERS.
            IF 1 = 2. MESSAGE e009(r3). ENDIF.
            log_write 'E'                  "message type
                      'R3'                 "message class
                      '009'                "message number
                      i_isource            "message variable 1
                      ' '.                 "message variable 2
            RAISE error_passed_to_mess_handler.
        ENDCASE.
    Check for supported update mode
       CASE i_updmode.
         WHEN 'F'.
         WHEN OTHERS.
           IF 1 = 2. MESSAGE e011(r3). ENDIF.
           log_write 'E'                  "message type
                     'R3'                 "message class
                     '011'                "message number
                     i_updmode            "message variable 1
                     ' '.                 "message variable 2
           RAISE error_passed_to_mess_handler.
       ENDCASE.
    Check for obligatory selection criteria
       READ TABLE i_t_select INTO l_s_select WITH KEY fieldnm = 'VBELN'.
       IF sy-subrc <> 0.
         IF 1 = 2. MESSAGE e010(r3). ENDIF.
         log_write 'E'                    "message type
                   'R3'                   "message class
                   '010'                  "message number
                   'PGMID'                "message variable 1
                   ' '.                   "message variable 2
         RAISE error_passed_to_mess_handler.
       ENDIF.
       APPEND LINES OF i_t_select TO g_t_select.
    Fill parameter buffer for data extraction calls
        g_s_interface-requnr    = i_requnr.
        g_s_interface-isource   = i_isource.
        g_s_interface-maxsize   = i_maxsize.
        g_s_interface-initflag  = i_initflag.
        g_s_interface-updmode   = i_updmode.
        g_s_interface-datapakid = i_datapakid.
        g_flag_interface_initialized = sbiwa_c_flag_on.
    Store Update mode in static variable...
       X_UPDMODE = I_UPDMODE.
        Select Single DELTAID
               Into   X_LastUpdate
               From   ROOSGENDLM
               Where  OLTPSOURCE = 'Z_BW_SDDATA_CREATEON'.
        If X_LastUpdate Is Initial.
          X_LastUpdate = '19800101'. " The oldest..., this should not happen
        Endif.
    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 g_t_segfields.
      ELSE.                 "Initialization mode or data extraction ?
    Data transfer: First Call      OPEN CURSOR + FETCH
                   Following Calls FETCH only
    X_UPDMODE = I_UPDMODE.
    First data package -> OPEN CURSOR
        IF g_counter_datapakid = 0.
    Fill range tables for fixed InfoSources. In the case of generated
    InfoSources, the usage of a dynamical SELECT statement might be
    more reasonable. BIW will only pass down simple selection criteria
    of the type SIGN = 'I' and OPTION = 'EQ' or OPTION = 'BT'.
          LOOP AT g_t_select INTO l_s_select WHERE fieldnm = 'VBELN'.
            MOVE-CORRESPONDING l_s_select TO L_R_VBELN.
            APPEND L_R_VBELN.
          ENDLOOP.
          LOOP AT g_t_select INTO l_s_select WHERE fieldnm = 'AUDAT'.
            MOVE-CORRESPONDING l_s_select TO L_R_AUDAT.
            APPEND L_R_AUDAT.
          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 InfoSource table lines and database entries, this is trivial.
    In other cases, it may be impossible and some estimated value has to
    be determined.
    *added by Yogesh
          DELETE FROM ZBWSALEDATA.
    *ended by Yogesh
          l_maxsize = g_s_interface-maxsize.
    Check for supported update mode
          CASE X_UPDMODE.
            WHEN 'F' Or 'I'. " Full or Init
    **get sales orders
              SELECT *
                           INTO CORRESPONDING FIELDS OF TABLE I_SALESDATA
                           FROM VBAK AS K
                           INNER JOIN VBAP AS P
                                 ON  PVBELN = KVBELN
                           WHERE K~VBELN IN L_R_VBELN
                           AND   K~AUDAT IN L_R_AUDAT
                           AND   K~VBTYP = 'C'.
              IF I_SALESDATA[] IS NOT INITIAL.
                PERFORM F_GET_DATA.                   "get data
                PERFORM F_DEL_VATCOND.                "delete vat conditions
                PERFORM F_GET_TAR_COSTUNIT.           "get tariff cost unit
                PERFORM F_GET_NETVAL TABLES IT_VBDPA1. "get net val of the item
                PERFORM F_GET_SALESDATA.
    *write perform with name F_INSERT_DB_ZBWSALEDATA.
                PERFORM F_INSERT_DB_ZBWSALEDATA.      "insert into table ZBWSALESDATA
               LOOP AT I_SALESDATA WHERE NETPR = 0.
                 MOVE-CORRESPONDING I_SALESDATA TO I_SALESDATA_FIN.
                 APPEND I_SALESDATA_FIN.
               ENDLOOP.
               SORT I_SALESDATA_FIN BY VBELN POSNR KSCHL.
               DELETE ADJACENT DUPLICATES FROM I_SALESDATA_FIN
                                               COMPARING VBELN POSNR
                                                         KSCHL.
               INSERT ZBWSALEDATA FROM TABLE I_SALESDATA_FIN.
              ENDIF.
            WHEN 'D'. " Delta
              SELECT *
                             INTO CORRESPONDING FIELDS OF TABLE I_SALESDATA
                             FROM VBAK AS K
                             INNER JOIN VBAP AS P
                                   ON  PVBELN = KVBELN
                            WHERE K~ERDAT >= X_LastUpdate
                             WHERE K~ERDAT >= X_LastUpdate+0(8)          "TCS_KAP
                             AND   K~VBTYP = 'C'.
              IF I_SALESDATA[] IS NOT INITIAL.
                PERFORM F_GET_DATA.                   "get data
                PERFORM F_DEL_VATCOND.                "delete vat conditions
                PERFORM F_GET_TAR_COSTUNIT.           "get tariff cost unit
                PERFORM F_GET_NETVAL TABLES IT_VBDPA1. "get net val of the item
                PERFORM F_GET_SALESDATA.
    *write perform with name F_INSERT_DB_ZBWSALEDATA.
                PERFORM F_INSERT_DB_ZBWSALEDATA.      "insert into table ZBWSALESDATA
               LOOP AT I_SALESDATA WHERE NETPR = 0.
                 MOVE-CORRESPONDING I_SALESDATA TO I_SALESDATA_FIN.
                 APPEND I_SALESDATA_FIN.
               ENDLOOP.
               SORT I_SALESDATA_FIN BY VBELN POSNR KSCHL.
               DELETE ADJACENT DUPLICATES FROM I_SALESDATA_FIN
                                               COMPARING VBELN POSNR
                                                         KSCHL.
               INSERT ZBWSALEDATA FROM TABLE I_SALESDATA_FIN.
              ENDIF.
            WHEN OTHERS.
              IF 1 = 2. MESSAGE E011(R3). ENDIF.
              LOG_WRITE 'E' "message type
              'R3' "message class
              '011' "message number
              I_UPDMODE "message variable 1
              ' '. "message variable 2
              RAISE ERROR_PASSED_TO_MESS_HANDLER.
          ENDCASE.
    **end get sales orders
          OPEN CURSOR WITH HOLD g_cursor FOR
          SELECT (g_t_fields) FROM ZBWSALEDATA.
         WHERE pgmid  IN l_r_pgmid AND
                                        object IN l_r_object.
        ENDIF.                             "First data package ?
    Fetch records into interface table. There are two different options:
    - fixed interface table structure for fixed InfoSources have to be
      named E_T_'Name of assigned source structure in table ROIS'.
    - for generating applications like LIS and CO-PA, the generic table
      E_T_DATA has to be used.
    Only one of these interface types should be implemented in one API !
        FETCH NEXT CURSOR g_cursor
                   APPENDING CORRESPONDING FIELDS
                   OF TABLE E_T_DATA
                   PACKAGE SIZE l_maxsize.
        IF sy-subrc <> 0.
          CLOSE CURSOR g_cursor.
          RAISE no_more_data.
        ENDIF.
        g_counter_datapakid = g_counter_datapakid + 1.
      ENDIF.              "Initialization mode or data extraction ?
    Best regards,
    Yogesh

    Dear Yogesh,
    Try to debug the code by putting a break point at select statement...is the FM Syntactically correct ??
    Check the Select statements..if all fields are not required avoid using Select * , and use always for all entries rather than JOINS..
    Note : For Joins you have to specify the Fields in the Select...Dont use Select * ....
    Hope it helps..
    Thanks,
    Krish

Maybe you are looking for

  • IOS 6 has messed up my phone, what do i do?

    I've literally just plugged my Iphone 4s in opened iTunes to update it, it got to the final stages of the update when it decided to stop and tell me the phone had been reset to the factory settings and then asked if i wanted to restore it, which didn

  • I have an ipod 4th gen but my clickwheel wont work-help?

    I have tried almost everything! My clickwheel has not been working for like a year now. I have tried resetting it, restoring, and all that. What do i do? D:

  • FBL3N print settings

    Hi Experts, I want to take print out for two GL accounts in FBL3N, both accounts have nearly 10 line items only, but they are coming in three pages. Two pages for two accounts and third one is for summary amount. If I want to take print out only in o

  • Folder will not open

    Please help. Whenever I try to open a personal folder on my desktop, the whole screen blinks and nothing happens. Similarly, when I try to use Finder, and click on the folder, Finder quits and the whole screen blinks. Any thoughts appreciated.

  • Export to Quicktime bug with embedded movies

    Hi I'm having an annoying problem when having Quicktime movies inserted in slides, then recording a slideshow and exporting it to Quicktime. I do the following: 1) Create a new slideshow 1) Insert movie into first slide 2) Create another slide 3) Ins