Extract Dataset?

Hi
I have written the following sample code using extract dataset.But i am not getting my expected o/p.Kindly correct me where iam wrong..
report z_test_extract.
data: begin of wa1,
        eno type i,
        ename(20) type c,
        sal type i,
      end of wa1,
      begin of wa2,
        sno type i,
        sname(20) type c,
      end of wa2.
field-groups: fs1,
              fs2,
              header.
insert wa1 into fs1.
insert wa2 into fs2.
insert wa1-eno wa1-ename wa1-sal into header.
wa1-eno = 1000.wa1-ename = 'abdul hakim'.wa1-sal = 10000.extract fs1.
wa1-eno = 2000.wa1-ename = 'abdul aleem'.wa1-sal = 20000.extract fs1.
wa1-eno = 3000.wa1-ename = 'sayyed'.wa1-sal = 30000.extract fs1.
wa1-eno = 4000.wa1-ename = 'abdul'.wa1-sal = 40000.extract fs1.
wa2-sno = 1000.wa2-sname = 'Mr.xyz'.extract fs2.
wa2-sno = 2000.wa2-sname = 'Mr.zyx'.extract fs2.
sort by wa1-sal.
loop.
    at end of wa1-sal.
      write:/ 'Sum:',Sum(wa1-sal).
    endat.
    at last.
      write:/ 'Gross:',sum(wa1-sal).
    endat.
endloop.
<b>Current Output:</b>
Sum:10000
Sum:20000
Sum:30000
Sum:120000
Gross:180000.
<b>Expected Output:</b>
Sum:10000
Sum:20000
Sum:30000
Sum:40000
Gross:100000.
Thanks,
Abdul Hakim

Hi,
   The HEADER field symbol has wa1-eno,wa1-ename,
wa1-sal as the fields. While storing the values for FS2, the values for the header is filled up with the last value of FS1.
(i.e) wa1-eno = 4000.wa1-ename = 'abdul'.wa1-sal = 40000.
so, it is finding the summation for three times.
The only way is to fill up the header details , while filling up FS2. Otherwise put the statements which fill up details for FS2 before filling for FS1.
I have modified the code as shown below
data: begin of wa1,
eno type i,
ename(20) type c,
sal type i,
end of wa1,
begin of wa2,
sno type i,
sname(20) type c,
end of wa2.
field-groups: fs1,
fs2,
header.
insert wa1 into fs1.
insert wa2 into fs2.
insert wa1-eno wa1-ename wa1-sal into header.
*Fill up before filling up FS1
wa2-sno = 1000.wa2-sname = 'Mr.xyz'.extract fs2.
wa2-sno = 2000.wa2-sname = 'Mr.zyx'.extract fs2.
wa1-eno = 1000.wa1-ename = 'abdul hakim'.wa1-sal = 10000.extract fs1.
wa1-eno = 2000.wa1-ename = 'abdul aleem'.wa1-sal = 20000.extract fs1.
wa1-eno = 3000.wa1-ename = 'sayyed'.wa1-sal = 30000.extract fs1.
wa1-eno = 4000.wa1-ename = 'abdul'.wa1-sal = 40000.extract fs1.
sort by wa1-sal.
loop.
at end of wa1-sal.
write:/ 'Sum:',Sum(wa1-sal).
endat.
at last.
write:/ 'Gross:',sum(wa1-sal).
endat.
endloop.
Regards,
M.Saravanan

Similar Messages

  • Use of Extract datasets

    Hello,
    Having seen various instances of the EXTRACT command in some legacy code I've got around to trying out this command but I can't get it to work properly. Here's some condensed test code I've put together:
    TABLES: VBAK, VBAP.
    FIELD-GROUPS: HEADER, TOP, DETAIL.
    INSERT: VBAK-VBELN VBAP-POSNR INTO HEADER,
                 VBAK-ERDAT VBAK-ERNAM VBAK-KUNNR INTO TOP,
                 VBAP-MATNR VBAP-CHARG VBAP-NETWR VBAP-WAERK INTO DETAIL.
    PARAMETERS P_VKORG TYPE VBAK-VKORG.
    SELECT *
      FROM VBAK
      WHERE VKORG = P_VKORG.
      EXTRACT TOP.
      SELECT *
        FROM VBAP
        WHERE VBELN = VBAK-VBELN.
            EXTRACT DETAIL.
        ENDSELECT.
    ENDSELECT.
    CLEAR: VBAK, VBAP.
    SORT.
    LOOP.
      WRITE:/ VBAK-VBELN, VBAP-POSNR, VBAK-ERDAT, VBAK-ERNAM, VBAK-KUNNR, VBAP-MATNR.
    ENDLOOP.
    OK, forget about the nested selects and other bad stuff, but how come I get the following output, and how should it be corrected:
    1360043260 000000 06.05.2008 CARTEM2 304393 <<< extraneous line that doesn't exist
    1360043260 000010 06.05.2008 CARTEM2 304393 34123376
    1360043260 000020 06.05.2008 CARTEM2 304393 50492316
    1360043260 000030 06.05.2008 CARTEM2 304393 50406766
    Use of extracts seems a bit wierd and there's not a lot out there to properly explain how to use them (apart from examples using a logical database).
    Thanks,
    Chris.

    Hi,
    When the first EXTRACT statement occurs in a program, the system creates the extract dataset and adds the first extract record to it. In each subsequent EXTRACT statement, the new extract record is added to the dataset.
    So instead of extract, modify the above code in two ways:
    1) Select-End Select, Comment out the extract statement and fetch in a work area if data is fetched in workarea append it to an internal table.
    2) Use Select into table, where in you can fetch all the data into an internal table and then use it for processing.
    For better performance, use the second method. Below is how you can change.
    SELECT *
      FROM VBAK
      INTO TABLE LT_VBAK
      WHERE VKORG = P_VKORG.
      SELECT *
        FROM VBAP
    INTO TABLE LT_VBAP
    FOR ALL ENTRIES IN LT_VBAK   
    WHERE VBELN = VBAK-VBELN.
    LOOP AT LT_VBAP INTO LS_VBAP.
    READ TABLE LT_VBAK WITH KEY VBELN = LS_VBAP-VBELN
    IF SY-SUBRC EQ 0.
      WRITE:/ LS_VBAK-VBELN, LS_VBAP-POSNR, LS_VBAK-ERDAT, LS_VBAK-ERNAM, LS_VBAK-KUNNR, LS_VBAP-MATNR.
    ENDIF.
    ENDLOOP.
    Hope this helps you
    Regards
    Shiva

  • Extract datasets?? Internal Tables??.. & Field Groups??..

    Hello Dear ABAP Ace's,
    Please let me know if what are differences between Extract datasets, Internal Tables, & Field Groups????? And what are the similarities?? Also let me know the uses of extract datasets & Field groups???
    Thanks in advance.
    Regards.
    Farooq

    Hi,
    There are two ways of processing large quantities of data in ABAP - either using internal tables or extract datasets.
    An internal table is a dynamic sequential dataset in which all records have the same structure and a key. They are part of the ABAP type concept. You can access individual records in an internal table using either the index or the key.
    Extracts are dynamic sequential datasets in which different lines can have different structures. Each ABAP program may currently only have a single extract dataset. You cannot access the individual records in an extract using key or index. Instead, you always process them using a loop.
    Check these links :
    http://help.sap.com/saphelp_nw2004s/helpdata/en/9f/db9ede35c111d1829f0000e829fbfe/frameset.htm
    http://www.geocities.com/SiliconValley/Grid/4858/sap/ABAPCode/Fieldgroups.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3ca6358411d1829f0000e829fbfe/frameset.htm
    Regards
    L Appana

  • Creating Extract Dataset

    hi,
    Sample code for Creating Extract Dataset
    thnks.

    HI,
    a program that lists the Vendors and their Accounting documents. Create extract dataset from KDF logical database. Loop through the dataset to create the required report. Don't list those vendors which has no documents
    See the code:
    report zfwr0001 no standard page heading.
    tables: lfa1, bsik.
    field-groups: header, item1, item2.
    insert lfa1-lifnr bsik-belnr into header.
    insert lfa1-land1 lfa1-name1 into item1.
    insert bsik-belnr bsik-budat into item2.
    start-of-selection.
    get lfa1.
    ....extract item1.
    get bsik.
    ....extract item2.
    end-of-selection.
    loop.
    ....at item1 with item2.
    ........skip.
    ........write:/ 'Vendor number:', 28 'Name:', 56 'City:'.
    ........write: 16 lfa1-lifnr, 33(20) lfa1-name1, 62(20) lfa1-ort01.
    ........write:/ 'Document no.', 15 'Date'.
    ....endat.
    ....at item2.
    ........write:/ bsik-belnr, 13 bsik-budat.
    ....endat.
    endloop.
    Cheers,
    Chandra Sekhar.

  • Problem in Extracting Dataset from Z FM for Zdatasource

    hi,
    I have created a Z fm of extracting data in Z datasource and i ahve written code for it.
    But everytime it returns me
    0 dataset extracted...
    i debugged it....and found  data in E_T_DTFIAR_1
    and till dat it is working fine ( wat i m assuming),
    after dat it is going to some other forms(like data transfer ) and some events.
    and finally throwing 0 data record found.
    here is the code..........can anyone tell me wat i m missing in this code...
    FUNCTION ZFIE*.
    ""Local interface:
    *"  IMPORTING
    *"     VALUE(I_DSOURCE) TYPE  SBIWA_S_INTERFACE-ISOURCE
    *"     VALUE(I_REQUNR) TYPE  SBIWA_S_INTERFACE-REQUNR 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
    *"  TABLES
    *"      I_T_SELECT TYPE  SBIWA_T_SELECT OPTIONAL
    *"      I_T_FIELDS TYPE  SBIWA_T_FIELDS OPTIONAL
    *"      E_T_DTFIAR_1 STRUCTURE  ZFIE_ (extractor structure) OPTIONAL
    *"  EXCEPTIONS
    *"      NO_MORE_DATA
    *"      ERROR_PASSED_TO_MESS_HANDLER
      TABLES:  VBREVE, ZFIE_EXT_REV, VBAK, VBRP, VBPA, KNA1..
    *....... steering flags
      STATICS: L_CURSOR           TYPE CURSOR,
               L_OPEN_CURSOR_FLAG LIKE C_OFF,
               L_LAST_DATA_FLAG   LIKE C_OFF.
    *....... PACKAGE-SIZE for SELECT-Statement
      STATICS: L_PACKAGE_SIZE   LIKE SY-TABIX.
    first call - initialization  **********************
      IF NOT ( I_INITFLAG IS INITIAL ).
       IF NOT ( G_FLAG_INTERFACE_INITIALIZED IS INITIAL ).
    **.... Invalid second initialization call -> error exit
         IF 1 = 2. MESSAGE E008(R3). ENDIF.  "only for Where-used list
         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 DataSource validity
        CASE I_DSOURCE.
          WHEN C_ISOURCE_DTFIAR_1.
          WHEN OTHERS.
            IF 1 = 2.
              MESSAGE E009(R3) WITH I_DSOURCE.  "only for Where-used list
            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.
    *.. Check for supported update mode
       CASE I_UPDMODE.
         WHEN 'F'.
         WHEN OTHERS.
           IF 1 = 2.
             MESSAGE E011(R3) WITH I_UPDMODE. "only for Where-used list
           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.
        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_DSOURCE.
        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.
    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_FIELDS.
    *.. calculate PACKAGE-SIZE for SELECT-Statement  (approximate)
        L_PACKAGE_SIZE = G_S_INTERFACE-MAXSIZE / 12.
    *.. fill selection criterias to global ranges
    second and further calls - data selection  *************
      ELSE.
    *.. clear table for export data
        CLEAR:   E_T_DTFIAR_1.
        REFRESH: E_T_DTFIAR_1.
        IF L_OPEN_CURSOR_FLAG IS INITIAL.
    *.... open cursor
          OPEN CURSOR WITH HOLD L_CURSOR FOR
          SELECT
          REFERENCE_DOC REF_DOC_ITM GL_ACCOUNT YEAR_PERIOD AMOUNT_DOC_CURR
          CURRENCY PROFIT_CENTER GL_OFFSET BUSINESS_AREA COMPANY_CODE
          REVENUE_STATUS SOLD_TO FISCAL_YEAR PERIOD DOCUMENT_TYPE
          AMOUNT_COMPANY AMOUNT_PROFT_CTR BILLING_DATE PLANT SALES_OFFICE
          SALES_GROUP SALES_DISTRICT END_USER_COUNTRY PROD_HIERARCHY
          MATERIAL MATERIAL_COST SALES_ORG DISTR_CHANNEL NUMBER_OF_NODES
          ORDER_DATE MATERIAL_GROUP AAG CONTRACT QUANTITY DAF_NUMBER
          BILLING_DATE
          FROM  ZFIE_EXT_REV
          WHERE
          RECORD_TYPE ='DEF'.
          SELECT SINGLE VBELN  FROM VBREVE INTO ITAB_REVENUE-REFDOCNR.
          L_OPEN_CURSOR_FLAG = C_ON.
        ENDIF.                             "L_OPEN_CURSOR_FLAG = C_OFF
        IF L_PACKAGE_SIZE <> 0.
    *.... fetch next package
          FETCH NEXT CURSOR L_CURSOR
                APPENDING CORRESPONDING FIELDS OF TABLE LT_DEF_REV
                PACKAGE SIZE L_PACKAGE_SIZE.
    *.... process selected data
          PERFORM PROCESS_SEL_DATA_AR1 TABLES LT_DEF_REV  E_T_DTFIAR_1.
    *.... check, if cursor has to be closed
          DESCRIBE TABLE LT_DEF_REV LINES SY-TFILL.
          IF SY-TFILL LT L_PACKAGE_SIZE.
            CLOSE CURSOR L_CURSOR.
            L_LAST_DATA_FLAG = 'X'.
          ENDIF.
       ENDIF.
    ENDIF.
    ENDFUNCTION.
           FORM PROCESS_SEL_DATA_AR1                                    *
    FORM PROCESS_SEL_DATA_AR1 TABLES SEL_DATA STRUCTURE LT_DEF_REV
                                     EXP_DATA STRUCTURE ZFIE_BIW_DEF_HIS.
    *....... local data declarations
    if not SEL_DATA[] is initial.
    move sel_data[] to exp_data[].
    SELECT  POPUPO VBELN_N POSNR_N RVAMT ACCPD PAOBJNR SAKUR SAMMG
            REFFLD ERDAT ERZET BUDAT REVFIX
            APPENDING CORRESPONDING FIELDS OF TABLE it_vbreve
    FROM VBREVE
    WHERE VBELN = ITAB_REVENUE-REFDOCNR
          AND POSNR = SEL_DATA-REF_DOC_ITM
          AND BUKRS = SEL_DATA-COMPANY_CODE
          AND BDJPOPER = SEL_DATA-YEAR_PERIOD.
    *move it_vbreve[] to exp_data[].
    *move exp_data to e_t_data.
    ENDif.
    ENDFORM.
    any help! plz..
    rdgs,
    San!

    Hi San,
    I cannot see the source of your error, but I would suggest you look at the FM RSVD_BW_GET_DATA, and merge you logic with the code from there.
    I would then test this with RSA3 to make sure you everything working correctly. Cheers! Bill

  • Extract dataset to internal table

    Hello,
    Is it possible to transfer data in an extract field group to an internal table in a loop and how?
    Thx in advance,
    Ali.

    Simply Loop at extract and move corresponding values to internal table. Example
    TABLES: spfli, sflight, sbook.
    "define extract without their structure
    FIELD-GROUPS: header,
                  travel_time,
                  flight_detail.
    "define structure of each record in extract
    INSERT: spfli-cityfrom spfli-cityto                    INTO header,       "sort by cities
            spfli-deptime spfli-arrtime                    INTO travel_time,
            sflight-carrid sflight-connid sflight-price    INTO flight_detail.
    "output table to transfer data to
    DATA    it_out_spfli TYPE TABLE OF spfli WITH HEADER LINE.
    START-OF-SELECTION.
    GET spfli.
      "fill records of extract with data
      EXTRACT: header, travel_time.
    GET sflight.
      EXTRACT flight_detail.
    END-OF-SELECTION.
      "sort the extract by the key determined in header field group
      SORT.
      LOOP.
        AT NEW spfli-cityfrom.
          WRITE: /'Connections from:', spfli-cityfrom.
        ENDAT.
        "connection must have details, flight_detail record must be found after this one
        AT travel_time WITH flight_detail.
          WRITE: /30 spfli-cityto, spfli-deptime, spfli-arrtime.
       "move data to your table
          MOVE-CORRESPONDING spfli TO it_out_spfli.
        ENDAT.
        AT flight_detail.   "if record of field-group fligth_detail reached
          WRITE: sflight-carrid, sflight-connid, sflight-price.
       "move data to your table
          MOVE-CORRESPONDING sflight TO it_out_spfli.
        ENDAT.
        AT END OF spfli-cityfrom.
          WRITE: /80'Total cities travel', cnt(spfli-cityto).
          ULINE.
        ENDAT.
        APPEND it_out_spfli.
      ENDLOOP.
    You need also make sure that all fields in IT_OUT_SPFLI are correcly provided. In my example there are some gaps but this is just a matter of supplying rest of the fields.
    Regards
    Marcin

  • Extracts in ABAP

    Hi
    I executed the following code.
    NODES: spfli, sflight.
    FIELD-GROUPS: header, flight_info, flight_date.
    INSERT: spfli-carrid spfli-connid sflight-fldate
            INTO header,
            spfli-cityfrom spfli-cityto
            INTO flight_info.
    START-OF-SELECTION.
    GET spfli.
      EXTRACT flight_info.
    GET sflight.
      EXTRACT flight_date.
    Now, my question is where is the data stored internally. The size of the Internal Table is restricted to size of the App Server. Hence we go for Extracts to process Large Data. How is the Data stored and Managed internally in Extracts.

    Hi,
    Once you have declared the possible record types as field groups and defined their structure, you can fill the extract dataset using the following statements:
    EXTRACT <fg>.
    When the first EXTRACT statement occurs in a program, the system creates the extract dataset and adds the first extract record to it. In each subsequent EXTRACT statement, the new extract record is added to the dataset.
    Each extract record contains exactly those fields that are contained in the field group <fg>, plus the fields of the field group HEADER (if one exists). The fields from HEADER occur as a sort key at the beginning of the record. If you do not explicitly specify a field group <fg>, the
    EXTRACT
    statement is a shortened form of the statement
    EXTRACT HEADER.
    When you extract the data, the record is filled with the current values of the corresponding fields.
    As soon as the system has processed the first EXTRACT statement for a field group <fg>, the structure of the corresponding extract record in the extract dataset is fixed. You can no longer insert new fields into the field groups <fg> and HEADER. If you try to modify one of the field groups afterwards and use it in another EXTRACT statement, a runtime error occurs.
    By processing EXTRACT statements several times using different field groups, you fill the extract dataset with records of different length and structure. Since you can modify field groups dynamically up to their first usage in an EXTRACT statement, extract datasets provide the advantage that you need not determine the structure at the beginning of the program.
    Check this link,
    <u>http://help.sap.com/saphelp_erp2004/helpdata/en/9f/db9f0535c111d1829f0000e829fbfe/frameset.htm</u> Hope it helps u.
    Thanks&Regards,
    Ruthra.R

  • Using Extracts in Reports

    How to use extracts in report Programming?

    Writes all fields of the field group fg (see FIELD-GROUPS) as one record to a sequential dataset (paging). If a field group HEADER has been defined, its fields prefix each record to form a sort key. You can then sort this dataset using SORT and process it with LOOP ... ENDLOOP. After this, EXTRACT cannot be executed again.
    As soon as the first dataset for a field group has been extracted with EXTRACT, the field group cannot be expanded using INSERT. The field group HEADER, in particular, cannot be expanded after the first EXTRACT (regardless of field group).
    Large extract datasets are not kept in main memory; instead, they are written to an external help file. You can specify the directory in which this file is to be stored using the SAP profile parameter DIR_EXTRACT. By default, the system uses the SAP file directory SAP profile parameter DIR_DATA).
    Filling an Extract with Data
    Once you have declared the possible record types as field groups and defined their structure, you can fill the extract dataset using the following statements:
    EXTRACT <fg>.
    When the first EXTRACT statement occurs in a program, the system creates the extract dataset and adds the first extract record to it. In each subsequent EXTRACT statement, the new extract record is added to the dataset.
    Each extract record contains exactly those fields that are contained in the field group <fg>, plus the fields of the field group HEADER (if one exists). The fields from HEADER occur as a sort key at the beginning of the record. If you do not explicitly specify a field group <fg>, the
    EXTRACT
    statement is a shortened form of the statement
    EXTRACT HEADER.
    When you extract the data, the record is filled with the current values of the corresponding fields.
    As soon as the system has processed the first EXTRACT statement for a field group <fg>, the structure of the corresponding extract record in the extract dataset is fixed. You can no longer insert new fields into the field groups <fg> and HEADER. If you try to modify one of the field groups afterwards and use it in another EXTRACT statement, a runtime error occurs.
    By processing EXTRACT statements several times using different field groups, you fill the extract dataset with records of different length and structure. Since you can modify field groups dynamically up to their first usage in an EXTRACT statement, extract datasets provide the advantage that you need not determine the structure at the beginning of the program.
    Assume the following program is linked to the logical database F1S.
    REPORT demo_extract_extract.
    NODES: spfli, sflight.
    FIELD-GROUPS: header, flight_info, flight_date.
    INSERT: spfli-carrid spfli-connid sflight-fldate
            INTO header,
            spfli-cityfrom spfli-cityto
            INTO flight_info.
    START-OF-SELECTION.
    GET spfli.
      EXTRACT flight_info.
    GET sflight.
      EXTRACT flight_date.
    There are three field groups. The INSERT statement assigns fields to two of the field groups. During the GET events, the system fills the extract dataset with two different record types. The records of the field group FLIGHT_INFO consist of five fields: SPFLI-CARRID, SPFLI-CONNID, SFLIGHT-FLDATE, SPFLI-CITYFROM, and SPFLI-CITYTO. The first three fields belong to the prefixed field group HEADER. The records of the field group FLIGHT_DATE consist only of the three fields of field group HEADER. The following figure shows the structure of the extract dataset:

  • Extract Statement

    Hi experts!!!
    Can you please tell me
    What does an extract statement do in the ABAP program? 
    Thanks in Advance,
    Logu

    Hi,
    Once you have declared the possible record types as field groups and defined their structure, you can fill the extract dataset using the following statements: EXTRACT . When the first EXTRACT statement occurs in a program, the system creates the extract dataset and adds the first extract record to it. In each subsequent EXTRACT statement, the new extract record is added to the dataset EXTRACT HEADER. When you extract the data, the record is filled with the current values of the corresponding fields. As soon as the system has processed the first EXTRACT statement for a field group , the structure of the corresponding extract record in the extract dataset is fixed. You can no longer insert new fields into the field groups and HEADER. If you try to modify one of the field groups afterwards and use it in another EXTRACT statement, a runtime error occurs. By processing EXTRACT statements several times using different field groups, you fill the extract dataset with records of different length and structure. Since you can modify field groups dynamically up to their first usage in an EXTRACT statement, extract datasets provide the advantage that you need not determine the structure at the beginning of the program.
    give the logical database name as F1S in the attributes of the program
    NODES: spfli, sflight.
    FIELD-GROUPS: header, flight_info, flight_date.
    INSERT: spfli-carrid spfli-connid sflight-fldate
            INTO header,
            spfli-cityfrom spfli-cityto
            INTO flight_info.
    START-OF-SELECTION.
    GET spfli.
      EXTRACT flight_info.
    GET sflight.
      EXTRACT flight_date.
    end-of-selection.
    loop.
    write:/ spfli-carrid,spfli-connid,sflight-fldate.
    endloop.
    rgds,
    bharat.

  • Extract s/m

    Hi,
    What does an extract statement do in the ABAP program?
    Rai...

    Hi,
    Once you have declared the possible record types as field groups and defined their structure, you can fill the extract dataset using the following statements:
    EXTRACT <fg>.
    When the first EXTRACT statement occurs in a program, the system creates the extract dataset and adds the first extract record to it. In each subsequent EXTRACT statement, the new extract record is added to the dataset.
    Each extract record contains exactly those fields that are contained in the field group <fg>, plus the fields of the field group HEADER (if one exists). The fields from HEADER occur as a sort key at the beginning of the record. If you do not explicitly specify a field group <fg>, the
    EXTRACT
    statement is a shortened form of the statement
    EXTRACT HEADER.
    When you extract the data, the record is filled with the current values of the corresponding fields.
    As soon as the system has processed the first EXTRACT statement for a field group <fg>, the structure of the corresponding extract record in the extract dataset is fixed. You can no longer insert new fields into the field groups <fg> and HEADER. If you try to modify one of the field groups afterwards and use it in another EXTRACT statement, a runtime error occurs.
    By processing EXTRACT statements several times using different field groups, you fill the extract dataset with records of different length and structure. Since you can modify field groups dynamically up to their first usage in an EXTRACT statement, extract datasets provide the advantage that you need not determine the structure at the beginning of the program.
    Assume the following program is linked to the logical database F1S.
    REPORT demo_extract_extract.
    NODES: spfli, sflight.
    FIELD-GROUPS: header, flight_info, flight_date.
    INSERT: spfli-carrid spfli-connid sflight-fldate
            INTO header,
            spfli-cityfrom spfli-cityto
            INTO flight_info.
    START-OF-SELECTION.
    GET spfli.
      EXTRACT flight_info.
    GET sflight.
      EXTRACT flight_date.
    There are three field groups. The INSERT statement assigns fields to two of the field groups. During the GET events, the system fills the extract dataset with two different record types. The records of the field group FLIGHT_INFO consist of five fields: SPFLI-CARRID, SPFLI-CONNID, SFLIGHT-FLDATE, SPFLI-CITYFROM, and SPFLI-CITYTO. The first three fields belong to the prefixed field group HEADER. The records of the field group FLIGHT_DATE consist only of the three fields of field group HEADER
    with regards,
    sowjanyagosala

  • Extract

    hi,
    What does an extract statement do in the ABAP program?
    thnks.

    HI,
    Once you have declared the possible record types as field groups and defined their structure, you can fill the extract dataset using the following statements:
    EXTRACT .
    When the first EXTRACT statement occurs in a program, the system creates the extract dataset and adds the first extract record to it. In each subsequent EXTRACT statement, the new extract record is added to the dataset
    EXTRACT HEADER.
    When you extract the data, the record is filled with the current values of the corresponding fields.
    As soon as the system has processed the first EXTRACT statement for a field group , the structure of the corresponding extract record in the extract dataset is fixed. You can no longer insert new fields into the field groups and HEADER. If you try to modify one of the field groups afterwards and use it in another EXTRACT statement, a runtime error occurs.
    By processing EXTRACT statements several times using different field groups, you fill the extract dataset with records of different length and structure. Since you can modify field groups dynamically up to their first usage in an EXTRACT statement, extract datasets provide the advantage that you need not determine the structure at the beginning of the program.
    Cheers,
    Chandra Sekhar.

  • Extract program

    Hi all,
    Please provide me the basic program on extract that we can start working in extract
    Thanks and Regards
    rahul singh

    An extract is a sequential dataset in the memory area of the program. You can only address the entries in the dataset within a special loop. The index or key access permitted with internal tables is not allowed. You may only create one extract in any ABAP program. The size of an extract dataset is, in principle, unlimited. Extracts larger than 500 KB are stored in operating system files. The practical size of an extract is up to 2 GB, as long as there is enough space in the file system.
    An extract dataset consists of a sequence of records of a predefined structure. However, the structure need not be identical for all records. In one extract dataset, you can store records of different length and structure one after the other. You need not create an individual dataset for each different structure you want to store. This fact reduces the maintenance effort considerably.
    In contrast to internal tables, the system partly compresses extract datasets when storing them. This reduces the storage space required. In addition, you need not specify the structure of an extract dataset at the beginning of the program, but you can determine it dynamically during the flow of the program.
    Have a look at below link:
    [Extracts|http://help.sap.com/saphelp_nw70/helpdata/en/9f/db9f3935c111d1829f0000e829fbfe/frameset.htm]
    REPORT demo_extract_extract.
    NODES: spfli, sflight.
    FIELD-GROUPS: header, flight_info, flight_date.
    INSERT: spfli-carrid spfli-connid sflight-fldate
            INTO header,
            spfli-cityfrom spfli-cityto
            INTO flight_info.
    START-OF-SELECTION.
    GET spfli.
      EXTRACT flight_info.
    GET sflight.
      EXTRACT flight_date.
    There are three field groups. The INSERT statement assigns fields to two of the field groups. During the GET events, the system fills the extract dataset with two different record types. The records of the field group flight_info consist of five fields: spfli-carrid, spfli-connid, sflight-fldate, spfli-cityfrom, and spfli-cityto.
    The first three fields belong to the prefixed field group header. The records of the field group flight_date consist only of the three fields of the header field group.
    You will find examples as well in above link.
    I hope it helps.

  • Extract statement and insert statement

    can anyone explain me the use of this insert statement and extract statement.
    INSERT lfa1-name1 INTO fg01
    extract fg01.
    thanks
    phyrose

    Hi,
           From f1 help....
    EXTRACT
    Basic form
    EXTRACT fg.
    Effect
    Writes all fields of the field group fg (FIELD-GROUPS) as an entry in asequential dataset. If you have defined a field group HEADER,its fields precede each entry as a sort key. Afterwards, you canuse SORT and LOOP ... ENDLOOP to sort or process the datasetrespectively. No further EXTRACT statements are possible afterthis.
    Notes
    General:
    As soon as you have extracted a dataset using EXTRACT, you canno longer extend the field group using INSERT. In particular, you cannot change the HEADERfield group at all after the first EXTRACT (regardless of thefield group to which it applied).
    Large extract datasets are not stored in main memory. Instead, theyare kept in an external auxiliary file. You can set the directory inwhich this file is created using the SAP profile parameterDIR_EXTRACT. The default directory is the SAP data directory(SAP profile parameter DIR_DATA).
    Notes
    Runtime errors:
    EXTRACT_AFTER_SORT/LOOP: EXTRACT after SORT, orLOOP. EXTRACT_BUFFER_NO_ROLL: Unable to create the required main
    EXTRACT_FIELD_TOO_LARGE: Occupied length of a field is toolarge.
    EXTRACT_HEADER_NOT_UNIQUE: Field group HEADER wasmodified after an EXTRACT statement.
    EXTRACT_OPEN_EXTRACTFILE_OPEN:
    Error opening the external extract dataset file.
    EXTRACT_RESOURCEHANDLER_FAILED: Error deleting the externalextract dataset file.
    EXTRACT_TOO_LARGE: Total length of the entry for extraction(including HEADER fields) is too large.
    Additional help
    Filling anExtract with Data
    Extracts
    Since internal tables have fixed line structures, they are not suited to handle data sets with varying structures. Instead, you can use extract datasets for this purpose.
    An extract is a sequential dataset in the memory area of the program. You can only address the entries in the dataset within a special loop. The index or key access permitted with internal tables is not allowed. You may only create one extract in any ABAP program. The size of an extract dataset is, in principle, unlimited. Extracts larger than 500KB are stored in operating system files. The practical size of an extract is up to 2GB, as long as there is enough space in the filesystem.
    An extract dataset consists of a sequence of records of a pre-defined structure. However, the structure need not be identical for all records. In one extract dataset, you can store records of different length and structure one after the other. You need not create an individual dataset for each different structure you want to store. This fact reduces the maintenance effort considerably.
    In contrast to internal tables, the system partly compresses extract datasets when storing them. This reduces the storage space required. In addition, you need not specify the structure of an extract dataset at the beginning of the program, but you can determine it dynamically during the flow of the program.
    You can use control level processing with extracts just as you can with internal tables. The internal administration for extract datasets is optimized so that it is quicker to use an extract for control level processing than an internal table.
    Procedure for creating an extract:
    Define the record types that you want to use in your extract by declaring them as field groups. The structure is defined by including fields in each field group.
    Defining an Extract
    Fill the extract line by line by extracting the required data.
    Filling an Extract with Data
    Once you have filled the extract, you can sort it and process it in a loop. At this stage, you can no longer change the contents of the extract.
    Processing Extracts
    INSERT Statement
    The INSERT statement is used to insert values into a single database table.
    <insert statement> ::= INSERT INTO <table name> <insert column list> <insert source>.
    <insert source> ::= VALUES '(' <value> ( ',' <value> )* ')'
                                | <query specification>.
    <value> ::= <value expression>
                    | <dynamic parameter specification>
                    | NULL.
    <insert column list> ::= '(' <column name> ( ',' <column name> )* ')'.
    In Open SQL the <insert column list> is not optional.
    You cannot specify string literals as values for CLOB columns. Hex literals are not supported in Open SQL.
    Examples
    INSERT INTO employees (employee_id, employee_name)
                  VALUES (4711, 'John Smith')
    Inserting Values. A new row is inserted into the table employees with the values 4711 and 'John Smith' for the columns employee_id and employee_name respectively.
    INSERT INTO well_paid_employees (employee_id, salary)
                 SELECT employee_id, salary
                                FROM employees
                                WHERE salary > ?
    Inserting the Result of a Query.  The employee_idand the salaryof all employees from table employeeswith a salary exceeding a certain value are inserted into the table well_paid_employees.
    Regards

  • What is the Extract statement? Please give me some sample code.?

    What is the Extract statement? Please give me some sample code.?

    Hello ,
    Once you have declared the possible record types as field groups and defined their structure, you can fill the extract dataset using the following statements: EXTRACT . When the first EXTRACT statement occurs in a program, the system creates the extract dataset and adds the first extract record to it. In each subsequent EXTRACT statement, the new extract record is added to the dataset EXTRACT HEADER. When you extract the data, the record is filled with the current values of the corresponding fields. As soon as the system has processed the first EXTRACT statement for a field group , the structure of the corresponding extract record in the extract dataset is fixed. You can no longer insert new fields into the field groups and HEADER. If you try to modify one of the field groups afterwards and use it in another EXTRACT statement, a runtime error occurs. By processing EXTRACT statements several times using different field groups, you fill the extract dataset with records of different length and structure. Since you can modify field groups dynamically up to their first usage in an EXTRACT statement, extract datasets provide the advantage that you need not determine the structure at the beginning of the program.
    Sample program:
    REPORT  ZSPFLI  LINE-SIZE 132 LINE-COUNT 65(3)
                                                 NO STANDARD PAGE HEADING.
    TABLES:SPFLI,SCARR, SFLIGHT, SBOOK.
    SELECT-OPTIONS: MYCARRID FOR SPFLI-CARRID.
    FIELD-GROUPS: HEADER, SPFLI_FG, SFLIGHT_FG, SBOOK_FG.
    INSERT:
            SPFLI-CARRID
            SPFLI-CONNID
            SFLIGHT-FLDATE
            SBOOK-BOOKID
           INTO HEADER,
            SPFLI-CARRID
            SPFLI-CONNID
            SPFLI-CITYFROM
            SPFLI-AIRPFROM
            SPFLI-CITYTO
            SPFLI-AIRPTO
            SPFLI-DEPTIME
            SCARR-CARRNAME
          INTO SPFLI_FG,
            SFLIGHT-FLDATE
            SFLIGHT-SEATSMAX
            SFLIGHT-SEATSOCC
            SFLIGHT-PRICE
          INTO SFLIGHT_FG,
            SBOOK-BOOKID
            SBOOK-CUSTOMID
            SBOOK-CUSTTYPE
            SBOOK-SMOKER
           INTO SBOOK_FG.
    SELECT * FROM SPFLI WHERE CARRID IN MYCARRID.
      SELECT SINGLE * FROM SCARR WHERE CARRID = SPFLI-CARRID.
      EXTRACT SPFLI_FG.
      SELECT * FROM SFLIGHT
       WHERE CARRID = SPFLI-CARRID AND  CONNID = SPFLI-CONNID.
        EXTRACT SFLIGHT_FG.
        SELECT * FROM SBOOK
               WHERE CARRID = SFLIGHT-CARRID AND
               CONNID = SFLIGHT-CONNID AND FLDATE = SFLIGHT-FLDATE.
          EXTRACT SBOOK_FG.
          CLEAR SBOOK.
        ENDSELECT.
        CLEAR SFLIGHT.
      ENDSELECT.
      CLEAR SPFLI.
    ENDSELECT.
    SORT.
    LOOP.
      AT SPFLI_FG.
        FORMAT COLOR COL_HEADING.
        WRITE: / SCARR-CARRNAME,
                 SPFLI-CONNID, SPFLI-CITYFROM,
                 SPFLI-AIRPFROM, SPFLI-CITYTO, SPFLI-AIRPTO, SPFLI-DEPTIME.
        FORMAT COLOR OFF.
      ENDAT.
      AT SFLIGHT_FG.
        WRITE: /15 SFLIGHT-FLDATE, SFLIGHT-PRICE, SFLIGHT-SEATSMAX,
                   SFLIGHT-SEATSOCC.
      ENDAT.
      AT SBOOK_FG.
        WRITE: /30 SBOOK-BOOKID, SBOOK-CUSTOMID,
                     SBOOK-CUSTTYPE, SBOOK-SMOKER.
      ENDAT.
    ENDLOOP.

  • Extracts

    What is meant by extracts

    HI
    An extract is a sequential dataset in the memory area of the program. Greater than 500 KB are stored on O/s
    Writes all fields of the field group fg (see FIELD-GROUPS) as one record to a sequential dataset (paging). If a field group HEADER has been defined, its fields prefix each record to form a sort key. You can then sort this dataset using SORT and process it with LOOP ... ENDLOOP. After this, EXTRACT cannot be executed again.
    As soon as the first dataset for a field group has been extracted with EXTRACT, the field group cannot be expanded using INSERT. The field group HEADER, in particular, cannot be expanded after the first EXTRACT (regardless of field group).
    Large extract datasets are not kept in main memory; instead, they are written to an external help file. You can specify the directory in which this file is to be stored using the SAP profile parameter DIR_EXTRACT. By default, the system uses the SAP file directory SAP profile parameter DIR_DATA).
    Filling an Extract with Data
    Once you have declared the possible record types as field groups and defined their structure, you can fill the extract dataset using the following statements:
    EXTRACT <fg>.
    When the first EXTRACT statement occurs in a program, the system creates the extract dataset and adds the first extract record to it. In each subsequent EXTRACT statement, the new extract record is added to the dataset.
    Each extract record contains exactly those fields that are contained in the field group <fg>, plus the fields of the field group HEADER (if one exists). The fields from HEADER occur as a sort key at the beginning of the record. If you do not explicitly specify a field group <fg>, the
    EXTRACT
    statement is a shortened form of the statement
    EXTRACT HEADER.
    When you extract the data, the record is filled with the current values of the corresponding fields.
    As soon as the system has processed the first EXTRACT statement for a field group <fg>, the structure of the corresponding extract record in the extract dataset is fixed. You can no longer insert new fields into the field groups <fg> and HEADER. If you try to modify one of the field groups afterwards and use it in another EXTRACT statement, a runtime error occurs.
    By processing EXTRACT statements several times using different field groups, you fill the extract dataset with records of different length and structure. Since you can modify field groups dynamically up to their first usage in an EXTRACT statement, extract datasets provide the advantage that you need not determine the structure at the beginning of the program.
    Assume the following program is linked to the logical database F1S.
    REPORT demo_extract_extract.
    NODES: spfli, sflight.
    FIELD-GROUPS: header, flight_info, flight_date.
    INSERT: spfli-carrid spfli-connid sflight-fldate
    INTO header,
    spfli-cityfrom spfli-cityto
    INTO flight_info.
    START-OF-SELECTION.
    GET spfli.
    EXTRACT flight_info.
    GET sflight.
    EXTRACT flight_date.
    There are three field groups. The INSERT statement assigns fields to two of the field groups. During the GET events, the system fills the extract dataset with two different record types. The records of the field group FLIGHT_INFO consist of five fields: SPFLI-CARRID, SPFLI-CONNID, SFLIGHT-FLDATE, SPFLI-CITYFROM, and SPFLI-CITYTO. The first three fields belong to the prefixed field group HEADER. The records of the field group FLIGHT_DATE consist only of the three fields of field group HEADER. The following figure shows the structure of the extract dataset:
    You can have only one extract per program
    Check this out -
    http://help.sap.com//saphelp_470/helpdata/EN/9f/db9ed135c111d1829f0000e829fbfe/content.htm
    Regards Rk
    Message was edited by:
            Rk Pasupuleti

Maybe you are looking for

  • How do I copy the string portion of an enum into the string portion of a cluster?

    I want to do this for the an entire array of clusters.  I'm trying to use a for loop.  Can't figure out how to parse the string portion of the enum into the string portion of the cluster. Alternatively, I'd be happy if I could figure out some way to

  • Maxl - .bat ERROR

    This maxl script works perfectly when run within EAS maxl editor (minus the login and spool), when we run it via a .bat file the calculation will run but nothing else. Any help please????? thanks!!!!!!! Here's the maxl script: login '*****' '******'

  • External hard drives compatible with time capsule generation 3

    I am trying to connect a little 160Gb HP hard drive to my time capsule via a hub which also connects successfully a non wireless printer. This particular hard drive uses two usb in's to connect. Once i plug it into time capsule, it powers up, thinks

  • Photo album duplicates on iphone

    I created a folder with the pictures I want to store on the iPhone. I then selected this folder to sync in iTunes. However, now on my iPhone, the folder is duplicated, so I have the same 61 photos in a album called Photo Library, and an album called

  • IPhoto crashes when I try to enter a name in Faces

    iPhoto crashes when I try to enter a name in Faces