Use of for all entries in abap

Please tell me how to use "for all entries" in linking two
tables for retrieve informations by using corresponding fields in both the tables.plz send the codings.

REPORT  YVCHIERSEQ                              .
TYPE-POOLS:SLIS.
DATA:T_VBAK TYPE STANDARD TABLE OF VBAK INITIAL SIZE 0,
     T_VBAP TYPE STANDARD TABLE OF VBAP INITIAL SIZE 0,
     W_VBAK TYPE VBAK,
     W_VBAP TYPE VBAP,
     G_VBELN TYPE VBAK-VBELN,
     W_FIELDCAT TYPE SLIS_FIELDCAT_ALV,
     T_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
     W_KEYINFO TYPE SLIS_KEYINFO_ALV.
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME.
SELECT-OPTIONS:S_VBELN FOR G_VBELN.
SELECTION-SCREEN END OF BLOCK B1.
INITIALIZATION.
CLEAR:W_VBAK,
      W_VBAP.
REFRESH:T_VBAK,
        T_VBAP.
START-OF-SELECTION.
PERFORM SUB_GET_VBAK.
PERFORM SUB_GET_VBAP.
PERFORM SUB_DISP_OUTPUT.
FORM SUB_GET_VBAK.
SELECT * FROM VBAK INTO TABLE T_VBAK WHERE VBELN IN S_VBELN.
ENDFORM.
FORM SUB_GET_VBAP.
SELECT * FROM VBAP INTO TABLE T_VBAP FOR ALL ENTRIES IN T_VBAK WHERE
VBELN = T_VBAK-VBELN.
ENDFORM.
FORM SUB_DISP_OUTPUT.
W_FIELDCAT-COL_POS = 1.
W_FIELDCAT-FIELDNAME = 'VBELN'.
W_FIELDCAT-SELTEXT_M = 'SALESORDER'.
W_FIELDCAT-TABNAME = 'VBAK'.
APPEND W_FIELDCAT TO T_FIELDCAT.
CLEAR W_FIELDCAT.
W_FIELDCAT-COL_POS = 2.
W_FIELDCAT-FIELDNAME = 'ERNAM'.
W_FIELDCAT-SELTEXT_M = 'NAME'.
W_FIELDCAT-TABNAME = 'VBAK'.
APPEND W_FIELDCAT TO T_FIELDCAT.
CLEAR W_FIELDCAT.
W_FIELDCAT-COL_POS = 3.
W_FIELDCAT-FIELDNAME = 'VBTYP'.
W_FIELDCAT-SELTEXT_M = 'SD CATEGORY'.
W_FIELDCAT-TABNAME = 'VBAK'.
APPEND W_FIELDCAT TO T_FIELDCAT.
CLEAR W_FIELDCAT.
W_FIELDCAT-COL_POS = 4.
W_FIELDCAT-FIELDNAME = 'KUNNR'.
W_FIELDCAT-SELTEXT_M = 'SOLD TO PARTY'.
W_FIELDCAT-TABNAME = 'VBAK'.
APPEND W_FIELDCAT TO T_FIELDCAT.
CLEAR W_FIELDCAT.
W_FIELDCAT-COL_POS = 5.
W_FIELDCAT-FIELDNAME = 'NETWR'.
W_FIELDCAT-SELTEXT_M = 'NET VALUE'.
W_FIELDCAT-TABNAME = 'VBAK'.
APPEND W_FIELDCAT TO T_FIELDCAT.
CLEAR W_FIELDCAT.
W_FIELDCAT-COL_POS = 1.
W_FIELDCAT-FIELDNAME = 'POSNR'.
W_FIELDCAT-SELTEXT_M = 'SALES ITEM'.
W_FIELDCAT-TABNAME = 'VBAP'.
APPEND W_FIELDCAT TO T_FIELDCAT.
CLEAR W_FIELDCAT.
W_FIELDCAT-COL_POS = 2.
W_FIELDCAT-FIELDNAME = 'MATNR'.
W_FIELDCAT-SELTEXT_M = 'MATERIAL NO'.
W_FIELDCAT-TABNAME = 'VBAP'.
APPEND W_FIELDCAT TO T_FIELDCAT.
CLEAR W_FIELDCAT.
W_FIELDCAT-COL_POS = 3.
W_FIELDCAT-FIELDNAME = 'MATKL'.
W_FIELDCAT-SELTEXT_M = 'MAT GROUP'.
W_FIELDCAT-TABNAME = 'VBAP'.
APPEND W_FIELDCAT TO T_FIELDCAT.
CLEAR W_FIELDCAT.
W_FIELDCAT-COL_POS = 4.
W_FIELDCAT-FIELDNAME = 'NETWR'.
W_FIELDCAT-SELTEXT_M = 'NET VALUE'.
W_FIELDCAT-TABNAME = 'VBAP'.
APPEND W_FIELDCAT TO T_FIELDCAT.
CLEAR W_FIELDCAT.
W_KEYINFO-HEADER01 = 'VBELN'.
W_KEYINFO-ITEM01   = 'VBELN'.
CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'
  EXPORTING
  I_INTERFACE_CHECK              = ' '
    I_CALLBACK_PROGRAM             = SY-CPROG
  I_CALLBACK_PF_STATUS_SET       = ' '
  I_CALLBACK_USER_COMMAND        = ' '
  IS_LAYOUT                      =
    IT_FIELDCAT                    = T_FIELDCAT
  IT_EXCLUDING                   =
  IT_SPECIAL_GROUPS              =
  IT_SORT                        =
  IT_FILTER                      =
  IS_SEL_HIDE                    =
  I_SCREEN_START_COLUMN          = 0
  I_SCREEN_START_LINE            = 0
  I_SCREEN_END_COLUMN            = 0
  I_SCREEN_END_LINE              = 0
  I_DEFAULT                      = 'X'
  I_SAVE                         = ' '
  IS_VARIANT                     =
  IT_EVENTS                      =
  IT_EVENT_EXIT                  =
    i_tabname_header               =   'VBAK'
    i_tabname_item                 = 'VBAP'
  I_STRUCTURE_NAME_HEADER        =
  I_STRUCTURE_NAME_ITEM          =
    is_keyinfo                     = W_KEYINFO
  IS_PRINT                       =
  IS_REPREP_ID                   =
  I_BYPASSING_BUFFER             =
  I_BUFFER_ACTIVE                =
IMPORTING
  E_EXIT_CAUSED_BY_CALLER        =
  ES_EXIT_CAUSED_BY_USER         =
  tables
    t_outtab_header                = T_VBAK
    t_outtab_item                  = T_VBAP
EXCEPTIONS
  PROGRAM_ERROR                  = 1
  OTHERS                         = 2
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
        WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
  ENDFORM.

Similar Messages

  • What is the use of for all entries in select statement

    what is the use of for all entries in select statement

    hi,
    FOR ALL ENTRIES is an effective way of doing away with using JOIN on two tables.
    You can check the below code -
    SELECT BUKRS BELNR GJAHR AUGDT
    FROM BSEG
    INTO TABLE I_BSEG
    WHERE BUKRS = ....
    SELECT BUKRS BELNR BLART BLDAT
    FROM BKPF
    INTO TABLE I_BKPF
    FOR ALL ENTRIES IN I_BSEG
    WHERE BUKRS = I_BSEG-BUKRS
    AND BELNR = I_BSEG-BELNR
    AND BLDAT IN SO_BLDAT.
    *******************************8
    look another example
    what is the use of FOR ALL ENTRIES
    1. INNER JOIN
    DBTAB1 <----
    > DBTAB2
    It is used to JOIN two DATABASE tables
    having some COMMON fields.
    2. Whereas
    For All Entries,
    DBTAB1 <----
    > ITAB1
    is not at all related to two DATABASE tables.
    It is related to INTERNAL table.
    3. If we want to fetch data
    from some DBTABLE1
    but we want to fetch
    for only some records
    which are contained in some internal table,
    then we use for alll entries.
    1. simple example of for all entries.
    2. NOTE THAT
    In for all entries,
    it is NOT necessary to use TWO DBTABLES.
    (as against JOIN)
    3. use this program (just copy paste)
    it will fetch data
    from T001
    FOR ONLY TWO COMPANIES (as mentioned in itab)
    4
    REPORT abc.
    DATA : BEGIN OF itab OCCURS 0,
    bukrs LIKE t001-bukrs,
    END OF itab.
    DATA : t001 LIKE TABLE OF t001 WITH HEADER LINE.
    itab-bukrs = '1000'.
    APPEND itab.
    itab-bukrs = '1100'.
    APPEND itab.
    SELECT * FROM t001
    INTO TABLE t001
    FOR ALL ENTRIES IN itab
    WHERE bukrs = itab-bukrs.
    LOOP AT t001.
    WRITE :/ t001-bukrs.
    ENDLOOP.
    Hope this helps!
    Regards,
    Anver
    <i>if hlped pls mark points</i>

  • Logic of for all entrie in abap programming

    Hi !
    This is ravi, i am working as consultant i have one doubt can any body clarify it.
    what is the' logic of for all entries' statement using in the abap coding?its very urgent , can any body helps me plz
    regards,
    ravi.

    Hi,
    it is a type of outer join using ITAB.  if u r using for all entries then all records from left table will be selected and only matching records form right table will be selected and where it doesnot found the entry in right table then it will return null.
    important points while useing this clasue:
    1. u should chk itab should not be blank like: if itab[] is not null. "then process entries
    2. itab should not contain huge data as it may slowdown sql
    3. only uniques keys will be selected so ensures fileds should not be unique using fields like posnr which are differenct for each recort in fld likst
    jogdand M B

  • Using delete and FOR ALL ENTRIES

    Hi,
    We have a error message regarding the following code :
    Delete FROM TABLE FOR ALL ENTRIES IN lt_TABLE WHERE
    TABLE_KEY1  = LT_TABLE_KEY1
    Could we use the For All entries with "Select" ?
    For information, the error message is "Unable to interpret "FOR". Possible causes: Incorrect spelling or comma error.
    Thank you.

    Hi,
    Check the below syntax, if you want to delete from database
    DELETE FROM sflight
    WHERE  carrid = p_carrid AND
           fldate = sy-datum AND
           seatsocc = 0.
    Just a suggestion. May be from next time you can use F1 help for syntax:
    1. Place the cursor on the delete keword in your program and press F1 - You willl get all the possible syntax for delete statement
    2. Else open the transaction ABAPDOCU, Click Keyword Help, Enter the required keyword(delete in this case) and press cont.. You will get the syntax.
    Hope thsi will help you.
    Regards,
    Swarna Munukoti.

  • For all entries Where condition character length partilally has to be used

    Hi,
    I need to fetch all the data reocrds of one internal table into the other with the condition that in one of the field of first internal table only partial length of the character has to be used as a where condition.
    Example:
    Select xxxx
              yyyyy
              zzzzz
    into it_tab2
    for all entries in itab1
    where field2 = itab1-field1(4).
    where field1 of itab1 has length of 8 and field2 belongs to itab2.
    As it throws the error msg :
    it will ignore the length restriction mentioned in where condition of the for all entries

    Hi.
    If you are trying to fetch from any database table based on your modified table use this logic.
    Dfine another internal table same as itab1, with field one lenght as 4 char.
    ex:
    data: begin of it_tab2.
            field1(4),
    end of it_tab2.
    loop at it_tab1.
    it_tab2 = itab1+0(4).
    append it_tab2.
    clear it_tab2.
    endloop.
    now you can fetch from database table....using it_tab2.
    Select xxxx
    yyyyy
    zzzzz
    into it_tab3
    for all entries in itab2
    where field2 = itab2-field1(4).
    If you only want to move the entries form one internal table to another internal table and truncate the field1 of itab1.
    then no need to use any for all entries...
    apply this logic
    data: begin of it_tab2.
            field1(4),
    end of it_tab2.
    loop at it_tab1.
    it_tab2 = itab1+0(4).
    append it_tab2.
    clear it_tab2.
    endloop.
    Regards,
    Satish

  • I have a problem in using  for all entries

    Hi i have a problem in using <b>for all entries</b>
    i have declared the two internal tables as below
      DATA: BEGIN OF ITAB OCCURS 10,
              EBELN LIKE EKKO-EBELN,
              LIFNR LIKE EKKO-LIFNR,
              EBELP LIKE EKBE-EBELP,
              BELNR LIKE EKBE-BELNR,
    *          MATNR LIKE EKPO-MATNR,
    *          TXZ01 LIKE EKPO-TXZ01,
              VGABE LIKE EKBE-VGABE,
              GJAHR LIKE EKBE-GJAHR,
              KNUMV LIKE EKKO-KNUMV,
         END OF ITAB.
    DATA: BEGIN OF ITAB1 OCCURS 10,
              EBELN LIKE EKPO-EBELN,
              MATNR LIKE EKPO-MATNR,
              TXZ01 LIKE EKPO-TXZ01,
              WERKS LIKE EKPO-WERKS,
              NETWR LIKE EKPO-NETWR,
              MENGE LIKE EKPO-MENGE,
              MWSKZ LIKE EKPO-MWSKZ,
              LIFNR LIKE EKKO-LIFNR,
              EBELP LIKE EKBE-EBELP,
              BELNR LIKE EKBE-BELNR,
          END OF ITAB1.
    <b>and now i have tried to move the values in those internal tables using these statements</b>
       SELECT  A~EBELN A~LIFNR A~KNUMV B~VGABE B~EBELP B~GJAHR B~BELNR
            FROM  EKKO AS A
            INNER JOIN EKBE  AS B ON  B~EBELN = A~EBELN
            INTO  CORRESPONDING
            FIELDS OF TABLE ITAB WHERE B~VGABE = '2'.
       SELECT EKPO~EBELN EKPO~MATNR EKPO~TXZ01 EKPO~WERKS EKPO~NETWR
              EKPO~MENGE EKPO~MWSKZ
          FROM EKPO
          INTO CORRESPONDING FIELDS OF TABLE ITAB1
          FOR ALL ENTRIES IN ITAB
          WHERE EBELN = ITAB-EBELN.
          LOOP AT ITAB1.
           READ TABLE ITAB WITH KEY EBELN = ITAB-EBELN.
           ITAB-EBELN = ITAB1-EBELN.
           ITAB1-LIFNR = ITAB-LIFNR.
           ITAB1-EBELP = ITAB-EBELP.
           ITAB1-BELNR = ITAB-BELNR.
           ITAB1-EBELP = ITAB-EBELP.
           APPEND ITAB1.
          ENDLOOP.
    But when i was using loop then it was displaying values in debugging mode but while i was trying to execute it was taking a lot of time i thought that it was due to more information in the already declared internal table so i have tried to remove the previous entries but it was showing an error while i was removing the old entries
    and when i  remove the loop at itab1 then i'll get output directly but it was displaying the itab fields which is my 1st internal table but not the values of itab1 can u explain me what is the possible error for that
    Regards ,
    Pavan

    before using for all entries in, u need to check whether the driver internal table is empty, if it is empty, u should not enter into select statement.
    if u wont use this check means, when the driver internal table is empty, the second select will take all the entires from the tables.
    SELECT  AEBELN ALIFNR AKNUMV BVGABE BEBELP BGJAHR B~BELNR
            FROM  EKKO AS A
            INNER JOIN EKBE  AS B ON  BEBELN = AEBELN
            INTO  CORRESPONDING
            FIELDS OF TABLE ITAB WHERE B~VGABE = '2'.
    if itab[] is not initial.
       SELECT EKPOEBELN EKPOMATNR EKPOTXZ01 EKPOWERKS EKPO~NETWR
              EKPOMENGE EKPOMWSKZ
          FROM EKPO
          INTO CORRESPONDING FIELDS OF TABLE ITAB1
          FOR ALL ENTRIES IN ITAB
          WHERE EBELN = ITAB-EBELN.
    endif.
    I hope this will help u.
    else,
    Sujatha.

  • While using for all entries its ignoring details of where condition

    i am using one select statement as follows
    SELECT ORGVEND LOTNO  INTO TABLE IT_ORG
                   FROM /BAY4/IC_IN_SEED
                   FOR ALL ENTRIES IN IT_DATA
                   WHERE LOTNO = IT_DATA-CHARG+0(9).
    its showing error as below
    In the use of FOR ALL ENTRIES, the long statement fur "CHARG" in this condition is ignored.
    how to avoid that.
    and
    we are using one field called "MITTLEWERT"
    we have declared it as type P decimals 2.
    in report we are using one statement
    SHIFT MITTELWERT LEFT DELETING LEADING ' '.
    its showoing error that MITTLEWERT should be C,N,String soem thing likie that.........how to avoid that

    Hi,
    i am using one select statement as follows
    SELECT ORGVEND LOTNO INTO TABLE IT_ORG
    FROM /BAY4/IC_IN_SEED
    FOR ALL ENTRIES IN IT_DATA
    WHERE LOTNO = IT_DATA-CHARG+0(9).
    its showing error as below
    In the use of FOR ALL ENTRIES, the long statement fur "CHARG" in this condition is ignored.
    how to avoid that.
    and
    we are using one field called "MITTLEWERT"
    we have declared it as type P decimals 2.
    in report we are using one statement
    SHIFT MITTELWERT LEFT DELETING LEADING ' '.
    its showoing error that MITTLEWERT should be C,N,String soem thing likie that.........how to avoid that
    first of all you can not use offset for for all entries which you have used in select query
    SELECT ORGVEND LOTNO INTO TABLE IT_ORG
    FROM /BAY4/IC_IN_SEED
    FOR ALL ENTRIES IN IT_DATA
    WHERE LOTNO = IT_DATA-CHARG+0(9). " You can not use IT_DATA-CHARG+0(9).
    2) field MITTLEWER you have declared as type P decimals 2.
    Keep in mind that P is not character tupe it is numeric type so it will have initial values as 0 and not ' ' (space).
    try below kind of code
    REPORT  ZTEST_UM2.
    DATA: a TYPE p DECIMALS 2 VALUE 000123 ,
          lv_with_zeros(15) TYPE c.
    WRITE: a to lv_with_zeros.
    WRITE lv_with_zeros.
    Hope above will help u.
    Regards,
    Umang mehta

  • Use HR_READ_INFOTYPE or select (for all entries)

    Hi
    As I have understood the difference between FM HR_READ_INFOTYPE and a select directly from PA0001 (as example) is that the FM take the authorization into account. (please correct me if I am wrong).
    My problem is that I need to select from the infotype for a lot of pernr, so I would use this statement:
        SELECT * FROM pa0001 INTO CORRESPONDING FIELDS OF TABLE wt_pa0001
          FOR ALL ENTRIES IN wt_pernr
             WHERE pernr = wt_pernr-pernr
              AND begda LE pn-endda
              AND endda GE pn-begda.
    but then I don't get the authorization check.
    For the FM HR_READ_INFOTYPE I can't use the "FOR ALL ENTRIES".
    Can I do it in an easy way, or do need to do the select, and then use an authority check after the select from each infotype?

    Calling HR_READ_INFOTYPE or selecting directly from the tables may depend on how much data you are processing.  If you only need to retrieve a few records, you could process the PERNR records you need in a loop and call HR_READ_INFOTYPE for each.  If you're processing a larger number of records, check the authorization for the each table first and then do a SELECT for all entries.  Before you read, make sure that your "FOR ALL ENTRIES" table is not empty.  In order to make your code more generic, you may want to use function module HR_CHECK_AUTHORITY_INFTY to check the authorization for each infotype.  This is the FM that the HR_READ_INFOTYPE function module uses.
    .. Craig

  • Hi Prerequestion of using for all entries

    Hi ,
       What is the prerequestion of using For All Entries. Could you answer to me.
    Thanks & Regards
    Raghava

    Hi,
    1.First check whether the internal table which to be used in FOR ALL ENTRIES is initial or not.IF it is not initial ,then use the table.Otherwise it will go for an infinite loop.
    2.Sort the internal table.
    Go through this
    Outer join can be created using this addition to the where clause in a select statement. It speeds up the performance tremendously, but the cons of using this variation are listed below
    Duplicates are automatically removed from the resulting data set. Hence care should be taken that the unique key of the detail line items should be given in the select statement.
    If the table on which the For All Entries IN clause is based is empty, all rows are selected into the destination table. Hence it is advisable to check before-hand that the first table is not empty.
    If the table on which the For All Entries IN clause is based is very large, the performance will go down instead of improving. Hence attempt should be made to keep the table size to a moderate level.
    Not Recommended
    Loop at int_cntry.
    Select single * from zfligh into int_fligh
    where cntry = int_cntry-cntry.
    Append int_fligh.
    Endloop.
    Recommended
    Select * from zfligh appending table int_fligh
    For all entries in int_cntry
    Where cntry = int_cntry-cntry.
    Regards,
    Padmam.

  • Question about statement for all entries

    Hi Abap experts,
    I have a question concerning the ABAP statement for all entries.
    Explanations:
    Let’s say that my source package (Source table) contains 2 types of data:
    -type1
    -type2
    I would like to use the statement select from table into internal table
    For all entries in source package
    But the where statement changes depending on the data type (2 keys when data type is 1 and only 1 key when data type is 2) .
    So that would be:
    Type1:
    Select fields
    From table into internal table
    Where field1 = source_package-field1
    And field2 = source_package-field2.
    Type2:
    Select fields
    From table into internal table
    Where field1 = source_package-field1
    How can I merge them assming that the field od data type is ftype?
    Thanks.
    Amine

    Hi amine,
    i think this is helpful for you.
    there are 2 ways  to use the for all entries...
    1. with header line:  this method is old one. in this method the internal table (ITAB) is automatically create workarea (WA) with same name, this method 1 drawback is there where we can use WA and ITAB confused that's why this is come difficult.
    2. without header line : this is nowadays we can use this method. in this method we create separate ITAb and WA. very clear this method.
    EXAMPLES:
    1.WITH HEADER LINE METHOD:
    PARAMETERS p_kunnr TYPE kna1-kunnr.
    DATA:it_kna1 LIKE kna1 OCCURS 0 WITH HEADER LINE,
          it_adrc LIKE adrc OCCURS 0 WITH HEADER LINE,
          it_adr2 LIKE adr2 OCCURS 0 WITH HEADER LINE,
          it_adr6 LIKE adr6 OCCURS 0 WITH HEADER LINE.
    START-OF-SELECTION.
       SELECT * FROM kna1 INTO TABLE it_kna1
          UP TO 100 ROWS.
       IF NOT it_kna1[] IS INITIAL.
         SELECT * FROM adrc INTO TABLE it_adrc
         FOR ALL ENTRIES IN it_kna1
         WHERE addrnumber = it_kna1-adrnr.
       ENDIF.
       IF NOT it_adrc[] IS INITIAL.
         SELECT * FROM adr2 INTO TABLE it_adr2
         FOR ALL ENTRIES IN it_adrc
         WHERE  addrnumber = it_adrc-addrnumber.
       ENDIF.
       IF NOT it_adr2[] IS INITIAL.
         SELECT * FROM adr6 INTO TABLE it_adr6
         FOR ALL ENTRIES IN it_adr2
         WHERE  addrnumber = it_adr2-addrnumber.
       ENDIF.
       LOOP AT it_kna1.
         READ TABLE it_adrc WITH KEY addrnumber = it_kna1-adrnr.
         IF sy-subrc = 0.
         ENDIF.
         READ TABLE it_adr2 WITH KEY addrnumber = it_kna1-adrnr.
         IF sy-subrc = 0.
         ENDIF.
         READ TABLE it_adr6 WITH KEY addrnumber = it_kna1-adrnr.
         IF sy-subrc = 0.
         ENDIF.
         WRITE : it_kna1-kunnr, it_kna1-name1, it_adrc-city1, it_adrc-street, it_adrc-po_box_reg,
                      it_adr2-telnr_long, it_adr6-smtp_addr.
       ENDLOOP.
    2. WITH OUT HEADER LINE:
    TABLES: KNA1 , ADRC.
    DATA : IT_KNA1 TYPE STANDARD TABLE OF KNA1,
            IT_ADRC TYPE STANDARD TABLE OF ADRC,
            WA_KNA1 TYPE KNA1,
            WA_ADRC TYPE ADRC.
    DATA: BEGIN OF STRTYPE ,
           CUSTMERNO LIKE KNA1-KUNNR,
           FIRSTNAME LIKE KNA1-NAME1,
           LASTNAME  TYPE NAME2,
           CITY TYPE ORT01,
           STATE TYPE REGIO,
           COUNTRY TYPE LAND1,
           ADDRESS LIKE ADRC-ADDRNUMBER,
           END OF STRTYPE.
    DATA : IT_1 LIKE TABLE OF STRTYPE.
    SELECT-OPTIONS  K_kunnr FOR kna1-kunnr NO-EXTENSION.
    SELECT * FROM KNA1 INTO TABLE IT_KNA1 WHERE KUNNR IN K_KUNNR.
    IF NOT IT_KNA1[] IS INITIAL.
    SELECT * FROM ADRC INTO WA_ADRC FOR ALL ENTRIES IN IT_KNA1 WHERE ADDRNUMBER = IT_KNA1-ADRNR.
    ENDSELECT.
    ENDIF.
    LOOP AT IT_KNA1 INTO WA_KNA1.
       READ TABLE IT_ADRC INTO WA_ADRC WITH KEY ADDRNUMBER = WA_KNA1-ADRNR.
       IF SY-SUBRC = 0.
           STRTYPE-ADDRESS = WA_ADRC-ADDRNUMBER.
       ENDIF.
    APPEND  STRTYPE TO IT_1.
       WRITE : / WA_KNA1-KUNNR, WA_KNA1-NAME1, WA_KNA1-NAME2, WA_KNA1-ORT01, WA_KNA1-REGIO, WA_KNA1-LAND1, WA_ADRC-ADDRNUMBER.
    ENDLOOP.
    regards,
    roopa.k

  • For All Entries with two tables

    Hi All,
             Can we use FOR ALL ENTRIES with two tables. for example
    SELECT * FROM MKPF INTO TABLE T_MKPF
             WHERE BUDAT IN S_BUDAT.
    SELECT * FROM MARA INTO TABLE T_MARA
             WHERE MTART IN S_MTART AND
                            MAKTL IN S_MAKTL.
    SELECT * FROM MSEG INTO TABLE T_MSEG
           FOR ALL ENTRIES IN  "T_MKPF AND T_MARA"
                  WHERE MBLNR EQ T_MKPF-MBLNR AND
                                 MATNR EQ T_MARA-MATNR.
    can we do it like this or any other way to do this plz tell. I waitting for your responce.
    Thanks
    Jitendra

    Hi,
    u cannot do like this....chek some documentation on it..
    1. duplicate rows are automatically removed
    2. if the itab used in the clause is empty , all the rows in the source table will be selected .
    3. performance degradation when using the clause on big tables.
    Say for example you have the following abap code:
    Select * from mara
    For all entries in itab
    Where matnr = itab-matnr.
    If the actual source of the material list (represented here by itab) is actually another database table, like:
    select matnr from mseg
    into corresponding fields of table itab
    where ….
    Then you could have used one sql statement that joins both tables.
    Select t1.*
    From mara t1, mseg t2
    Where t1.matnr = t2.matnr
    And T2…..
    So what are the drawbacks of using the "for all entires" instead of a join ?
    At run time , in order to fulfill the "for all entries " request, the abap engine will generate several sql statements (for detailed information on this refer to note 48230). Regardless of which method the engine uses (union all, "or" or "in" predicates) If the itab is bigger then a few records, the abap engine will break the itab into parts, and rerun an sql statement several times in a loop. This rerun of the same sql statement , each time with different host values, is a source of resource waste because it may lead to re-reading of data pages.
    returing to the above example , lets say that our itab contains 500 records and that the abap engine will be forced to run the following sql statement 50 times with a list of 10 values each time.
    Select * from mara
    Where matnr in ( ...)
    Db2 will be able to perform this sql statement cheaply all 50 times, using one of sap standard indexes that contain the matnr column. But in actuality, if you consider the wider picture (all 50 executions of the statement), you will see that some of the data pages, especially the root and middle-tire index pages have been re-read each execution.
    Even though db2 has mechanisms like buffer pools and sequential detection to try to minimize the i/o cost of such cases, those mechanisms can only minimize the actual i/o operations , not the cpu cost of re-reading them once they are in memory. Had you coded the join, db2 would have known that you actually need 500 rows from mara, it would have been able to use other access methods, and potentially consume less getpages i/o and cpu.
    In other words , when you use the "for all entries " clause instead of coding a join , you are depriving the database of important information needed to select the best access path for your application. Moreover, you are depriving your DBA of the same vital information. When the DBA monitors & tunes the system, he (or she) is less likely to recognize this kind of resource waste. The DBA will see a simple statement that uses an index , he is less likely to realize that this statement is executed in a loop unnecessarily.
    Beore using the "for all entries" clause and to evaluate the use of database views as a means to:
    a. simplify sql
    b. simplify abap code
    c. get around open sql limitations.
    check the links
    http://www.thespot4sap.com/articles/SAPABAPPerformanceTuning_ForAllEntries.asp
    The specified item was not found.
    Regards,
    Nagaraj

  • Select for all entries

    Hi,
          I am new in abap reports. Now i want to know why we should use select for all entries in query. We can do retrieve directly by accessing the table in database dictionary.
          Experts please give me the reasons I want to know the concepts behind it.It will be better if you kindly explain this with help of code.
         With regards,
           Abir.

    HI
    GOOD
    SELECT
    Basic form
    SELECT result [target] FROM source [where] [GROUP BY fields] [ORDER BY order].
    Effect
    Retrieves an extract and/or a set of data from a database table or view (see Relational database ). SELECT belongs to the OPEN SQL command set.
    Each SELECT command consists of a series of clauses specifying different tasks:
    The SELECT result clause specifies
    whether the result of the selection is a table or a single record,
    which columns the result is meant to have and
    whether the result is allowed to include identical lines.
    The INTO target clause specifies the target area into which the selected data is to be read. If the target area is an internal table, the INTO clause specifies
    whether the selected data is to overwrite the contents of the internal table or
    whether the selected data is to be appended to the contents and
    whether the selected data is to be placed in the internal table all at once or in several packets.
    The INTO clause can also follow the FROM clause.
    You can omit the INTO clause. The system then makes the data available in the table work area (see TABLES ) dbtab . If the SELECT clause includes a "*", the command is processed like the identical SELECT * INTO dbtab FROM dbtab statement. If the SELECT clause contains a list a1 ... an , the command is executed like SELECT a1 ... an INTO CORRESPONDING FIELDS OF dbtab FROM dbtab .
    If the result of the selection is meant to be a table, the data is usually (for further information, see INTO -Klausel ) read line by line within a processing loop introduced by SELECT and concluded by ENDSELECT . For each line read, the processing passes through the loop once. If the result of the selection is meant to be a single record, the closing ENDSELECT is omitted.
    The FROM source clause the source (database table or view ) from which the data is to be selected. It also determines
    the type of client handling,
    the behavior for buffered tables and
    the maximum number of lines to be read.
    The WHERE where clause specifies the conditions which the result of the selection must satisfy. It thus determines the lines of the result table. Normally - i.e. unless a client field is specified in the WHERE clause - only data of the current client is selected. If you want to select across other clients, the FROM clause must include the addition ... CLIENT SPECIFIED .
    The GROUP-BY fields clause combines groups of lines together into single lines. A group is a set of lines which contain the same value for every database field in the GROUP BY clause.
    The ORDER-BY order clause stipulates how the lines of the result table are to be ordered.
    Each time the SELECT statement is executed, the system field SY-DBCNT contains the number of lines read so far. After ENDSELECT , SY-DBCNT contains the total number of lines read.
    The return code value is set as follows:
    SY-SUBRC = 0 At least one line was read.
    SY_SUBRC = 4 No lines were read.
    SY-SUBRC = 8 The search key was not fully qualified.
    (nur bei SELECT SINGLE ). The returned single record is any line of the solution set.
    Example
    Output the passenger list for the Lufthansa flight 0400 on 28.02.1995:
    TABLES SBOOK.
    SELECT * FROM SBOOK
      WHERE
        CARRID   = 'LH '      AND
        CONNID   = '0400'     AND
        FLDATE   = '19950228'
      ORDER BY PRIMARY KEY.
      WRITE: / SBOOK-BOOKID, SBOOK-CUSTOMID,   SBOOK-CUSTTYPE,
               SBOOK-SMOKER, SBOOK-LUGGWEIGHT, SBOOK-WUNIT,
               SBOOK-INVOICE.
    ENDSELECT.
    Note
    Performance
    In client/server environments, storing database tables in local buffers (see SAP buffering ) can save considerable amounts of time because the time required to make an access via the network is much more than that needed to access a locally buffered table.
    Notes
    A SELECT command on a table for which SAP buffering is defined in the ABAP/4 Dictionary is normally satisfied from the SAP buffer by bypassing the database. This does not apply with
    - SELECT SINGLE FOR UPDATE
    - SELECT DISTINCT in the SELECT clause ,
    - BYPASSING BUFFER in the FROM clause ,
    - ORDER BY f1 ... fn in the ORDER-BY clause ,
    - aggregate functions in the SELECT clause ,
    - when using IS [NOT] NULL WHERE condition ,
    or if the generic key part is not qualified in the WHERE-Bedingung for a generically buffered table.
    Authorization checks are not supported by the SELECT statement, so you must program these yourself.
    In dialog systems, the database system locking mechanism cannot always guarantee to synchronize the simultaneous access of several users to the same dataset. In many cases, it is therefore advisable to use the SAP locking mechanism .
    Changes to data in a database are only finalized after a database commit (see LUW ). Prior to this, any database update can be reversed by a database rollback (see Programming transactions ). At the lowest isolation level (see the section on the "uncommitted read" under Locking mechanism ), this can result in the dataset selected by the SELECT command not really being written to the database. While a program is selecting data, a second program can add, change or delete lines at the same time. Then, the changes made by the second program are reversed by rolling back the database system. The selection of the first program thus reflects only a very temporary state of the database. If such "phantom data" is not acceptable for a program, you must either use the SAP locking mechanism or at least set the isolation level of the database system to "committed read" (see Locking mechanism ).
    In a SELECT-ENDSELECT loop, the CONTINUE statement terminates the current loop pass prematurely and starts the next.
    If one of the statements in a SELECT ... ENDSELECT loop results in a database commit, the cursor belonging to the SELECT ... ENDSELECT loop is lost and the processing terminates with a runtime error. Since each screen change automatically generates a database commit, statements such as CALL SCREEN , CALL DIALOG , CALL TRANSACTION or MESSAGE are not allowed within a SELECT ... ENDSELECT loop.
    Related OPEN CURSOR , FETCH und CLOSE CURSOR
    GO THROUGH THIS LINK
    http://www.geocities.com/SiliconValley/Campus/6345/select.htm
    THANKS
    MRUTYUN

  • Loop -- Select, for all entries, HOW TO ?

    Hi,
    I have followoing code.
    LOOP AT table ASSIGNING  TO lt_all_roles_all_objects.
      ENDSELECT.
      ENDLOOP.
    How to tune this? I don´t understand how and where to use the for all entries command.
    And what will happen with my append?
    Can somebody explain me?
    Thanks

    Hi,
    First you need to know some of tips in abap so that you can give good shape to ur program according to performance wise.
    --Try to avoid the joins and use FOR ALL ENTRIES IN in place of joins.
    --Try to avoid the MOVE CORRESPONDING
    --Dont use the loop statements with in loop.
    -- Dont write the select statement with in loop.
    -- Better use the read statement in side loop intead of loop in side loop.
    -- Use alway BINARY SEARCH in READ statement- in this mandatory thing is u need to sorty the internal table a/c to with key conditions.
    etc.................  like this u need take care some of abap tips so that u can achieve good coding standards..
    coming to your coding.............
    declare an internal table "itab_agr_1250" which contain fields mandt, agr_name, object, and deleted .
    SELECT mandt agr_name object deleted
          from agr_1250
           into itab_agr_1250
        where agr_name = <cust_tab>-rolename
           and mandt in sp_mandt
           and deleted = ''.
    IF sy-subrc = 0.
    sort itab_agr_1250 by agr_name.
    ENDIF.
    loop at table assigning <cust_tab>.
    read table itab_agr_1250 with key agr_name = <cust_tab>-rolename
                                                                          BINARY SEARCH.
    final_Itab-field1 = itab_agr_1250-.....
    final_Itab-field2 = itab_agr_1250-.....
    final_Itab-field3 = itab_agr_1250-.....  { USE single filed assign or move statement  for each field instead of MOVE CORRESPONDING }
    append final_Itab.
    endloop.
    <b>Reward with points if useful</b>
    Regards,
    Vijay

  • For all entries or join

    Hi,
    please which should be used between for all entries or join????

    All abap programers and most of the dba's that support abap programmers are familiar with the abap clause "for all entries". Most of the web pages I visited recently, discuss 3 major drawbacks of the "for all entries" clause:
    1. duplicate rows are automatically removed
    2. if the itab used in the clause is empty , all the rows in the source table will be selected .
    3. performance degradation when using the clause on big tables.
    In this post I'd like to shed some light on the third issue. Specifically i'll discuss the use of the "for all entries" clause as a means to join tables in the abap code instead of in db2.
    Say for example you have the following abap code:
    Select * from mara
    For all entries in itab
    Where matnr = itab-matnr.
    If the actual source of the material list (represented here by itab) is actually another database table, like:
    select matnr from mseg
    into corresponding fields of table itab
    where �.
    Then you could have used one sql statement that joins both tables.
    Select t1.*
    From mara t1, mseg t2
    Where t1.matnr = t2.matnr
    And T2�..
    So what are the drawbacks of using the "for all entires" instead of a join ?
    At run time , in order to fulfill the "for all entries " request, the abap engine will generate several sql statements (for detailed information on this refer to note 48230). Regardless of which method the engine uses (union all, "or" or "in" predicates) If the itab is bigger then a few records, the abap engine will break the itab into parts, and rerun an sql statement several times in a loop. This rerun of the same sql statement , each time with different host values, is a source of resource waste because it may lead to re-reading of data pages.
    returing to the above example , lets say that our itab contains 500 records and that the abap engine will be forced to run the following sql statement 50 times with a list of 10 values each time.
    Select * from mara
    Where matnr in ( ...)
    Db2 will be able to perform this sql statement cheaply all 50 times, using one of sap standard indexes that contain the matnr column. But in actuality, if you consider the wider picture (all 50 executions of the statement), you will see that some of the data pages, especially the root and middle-tire index pages have been re-read each execution.
    Even though db2 has mechanisms like buffer pools and sequential detection to try to minimize the i/o cost of such cases, those mechanisms can only minimize the actual i/o operations , not the cpu cost of re-reading them once they are in memory. Had you coded the join, db2 would have known that you actually need 500 rows from mara, it would have been able to use other access methods, and potentially consume less getpages i/o and cpu.
    In other words , when you use the "for all entries " clause instead of coding a join , you are depriving the database of important information needed to select the best access path for your application. Moreover, you are depriving your DBA of the same vital information. When the DBA monitors & tunes the system, he (or she) is less likely to recognize this kind of resource waste. The DBA will see a simple statement that uses an index , he is less likely to realize that this statement is executed in a loop unnecessarily.
    In conclusion I suggest to "think twice" before using the "for all entries" clause and to evaluate the use of database views as a means to:
    a. simplify sql
    b. simplify abap code
    c. get around open sql limitations.

  • Hi guru's what is the diff between for all entries & joins

    hi guru's what is the diff between for all entries & joins

    Hi Vasu,
    Joins are used to fetch data fast from Database tables:
    Tables are joined with the proper key fields to fetch the data properly.
    If there are no proper key fields between tables don't use Joins;
    Important thing is that don't USE JOINS FOR CLUSTER tableslike BSEG and KONV.
    Only use for Transparenmt tables.
    You can also use joins for the database VIews to fetch the data.
    JOINS
    ... FROM tabref1 [INNER] JOIN tabref2 ON cond
    Effect
    The data is to be selected from transparent database tables and/or views determined by tabref1 and tabref2. tabref1 and tabref2 each have the same form as in variant 1 or are themselves Join expressions. The keyword INNER does not have to be specified. The database tables or views determined by tabref1 and tabref2 must be recognized by the ABAP Dictionary.
    In a relational data structure, it is quite normal for data that belongs together to be split up across several tables to help the process of standardization (see relational databases). To regroup this information into a database query, you can link tables using the join command. This formulates conditions for the columns in the tables involved. The inner join contains all combinations of lines from the database table determined by tabref1 with lines from the table determined by tabref2, whose values together meet the logical condition (join condition) specified using ON>cond.
    Inner join between table 1 and table 2, where column D in both tables in the join condition is set the same:
    Table 1 Table 2
    A
    B
    C
    D
    D
    E
    F
    G
    H
    a1
    b1
    c1
    1
    1
    e1
    f1
    g1
    h1
    a2
    b2
    c2
    1
    3
    e2
    f2
    g2
    h2
    a3
    b3
    c3
    2
    4
    e3
    f3
    g3
    h3
    a4
    b4
    c4
    3
    |--|||--|
    Inner Join
    A
    B
    C
    D
    D
    E
    F
    G
    H
    a1
    b1
    c1
    1
    1
    e1
    f1
    g1
    h1
    a2
    b2
    c2
    1
    1
    e1
    f1
    g1
    h1
    a4
    b4
    c4
    3
    3
    e2
    f2
    g2
    h2
    |--||||||||--|
    Example
    Output a list of all flights from Frankfurt to New York between September 10th and 20th, 2001 that are not sold out:
    DATA: DATE LIKE SFLIGHT-FLDATE,
    CARRID LIKE SFLIGHT-CARRID,
    CONNID LIKE SFLIGHT-CONNID.
    SELECT FCARRID FCONNID F~FLDATE
    INTO (CARRID, CONNID, DATE)
    FROM SFLIGHT AS F INNER JOIN SPFLI AS P
    ON FCARRID = PCARRID AND
    FCONNID = PCONNID
    WHERE P~CITYFROM = 'FRANKFURT'
    AND P~CITYTO = 'NEW YORK'
    AND F~FLDATE BETWEEN '20010910' AND '20010920'
    AND FSEATSOCC < FSEATSMAX.
    WRITE: / DATE, CARRID, CONNID.
    ENDSELECT.
    If there are columns with the same name in both tables, you must distinguish between them by prefixing the field descriptor with the table name or a table alias.
    Note
    In order to determine the result of a SELECT command where the FROM clause contains a join, the database system first creates a temporary table containing the lines that meet the ON condition. The WHERE condition is then applied to the temporary table. It does not matter in an inner join whether the condition is in the ON or WHEREclause. The following example returns the same solution as the previous one.
    Example
    Output of a list of all flights from Frankfurt to New York between September 10th and 20th, 2001 that are not sold out:
    DATA: DATE LIKE SFLIGHT-FLDATE,
    CARRID LIKE SFLIGHT-CARRID,
    CONNID LIKE SFLIGHT-CONNID.
    SELECT FCARRID FCONNID F~FLDATE
    INTO (CARRID, CONNID, DATE)
    FROM SFLIGHT AS F INNER JOIN SPFLI AS P
    ON FCARRID = PCARRID
    WHERE FCONNID = PCONNID
    AND P~CITYFROM = 'FRANKFURT'
    AND P~CITYTO = 'NEW YORK'
    AND F~FLDATE BETWEEN '20010910' AND '20010920'
    AND FSEATSOCC < FSEATSMAX.
    WRITE: / DATE, CARRID, CONNID.
    ENDSELECT.
    Note
    Since not all of the database systems supported by SAP use the standard syntax for ON conditions, the syntax has been restricted. It only allows those joins that produce the same results on all of the supported database systems:
    Only a table or view may appear to the right of the JOIN operator, not another join expression.
    Only AND is possible in the ON condition as a logical operator.
    Each comparison in the ON condition must contain a field from the right-hand table.
    If an outer join occurs in the FROM clause, all the ON conditions must contain at least one "real" JOIN condition (a condition that contains a field from tabref1 amd a field from tabref2.
    Note
    In some cases, '*' may be specified in the SELECT clause, and an internal table or work area is entered into the INTO clause (instead of a list of fields). If so, the fields are written to the target area from left to right in the order in which the tables appear in the FROM clause, according to the structure of each table work area. There can then be gaps between table work areas if you use an Alignment Request. For this reason, you should define the target work area with reference to the types of the database tables, not simply by counting the total number of fields. For an example, see below:
    Variant 3
    ... FROM tabref1 LEFT [OUTER] JOIN tabref2 ON cond
    Effect
    Selects the data from the transparent database tables and/or views specified in tabref1 and tabref2. tabref1 und tabref2 both have either the same form as in variant 1 or are themselves join expressions. The keyword OUTER can be omitted. The database tables or views specified in tabref1 and tabref2 must be recognized by the ABAP-Dictionary.
    In order to determine the result of a SELECT command where the FROM clause contains a left outer join, the database system creates a temporary table containing the lines that meet the ON condition. The remaining fields from the left-hand table (tabref1) are then added to this table, and their corresponding fields from the right-hand table are filled with ZERO values. The system then applies the WHERE condition to the table.
    Left outer join between table 1 and table 2 where column D in both tables set the join condition:
    Table 1 Table 2
    A
    B
    C
    D
    D
    E
    F
    G
    H
    a1
    b1
    c1
    1
    1
    e1
    f1
    g1
    h1
    a2
    b2
    c2
    1
    3
    e2
    f2
    g2
    h2
    a3
    b3
    c3
    2
    4
    e3
    f3
    g3
    h3
    a4
    b4
    c4
    3
    |--|||--|
    Left Outer Join
    A
    B
    C
    D
    D
    E
    F
    G
    H
    a1
    b1
    c1
    1
    1
    e1
    f1
    g1
    h1
    a2
    b2
    c2
    1
    1
    e1
    f1
    g1
    h1
    a3
    b3
    c3
    2
    NULL
    NULL
    NULL
    NULL
    NULL
    a4
    b4
    c4
    3
    3
    e2
    f2
    g2
    h2
    |--||||||||--|
    Example
    Output a list of all custimers with their bookings for October 15th, 2001:
    DATA: CUSTOMER TYPE SCUSTOM,
    BOOKING TYPE SBOOK.
    SELECT SCUSTOMNAME SCUSTOMPOSTCODE SCUSTOM~CITY
    SBOOKFLDATE SBOOKCARRID SBOOKCONNID SBOOKBOOKID
    INTO (CUSTOMER-NAME, CUSTOMER-POSTCODE, CUSTOMER-CITY,
    BOOKING-FLDATE, BOOKING-CARRID, BOOKING-CONNID,
    BOOKING-BOOKID)
    FROM SCUSTOM LEFT OUTER JOIN SBOOK
    ON SCUSTOMID = SBOOKCUSTOMID AND
    SBOOK~FLDATE = '20011015'
    ORDER BY SCUSTOMNAME SBOOKFLDATE.
    WRITE: / CUSTOMER-NAME, CUSTOMER-POSTCODE, CUSTOMER-CITY,
    BOOKING-FLDATE, BOOKING-CARRID, BOOKING-CONNID,
    BOOKING-BOOKID.
    ENDSELECT.
    If there are columns with the same name in both tables, you must distinguish between them by prefixing the field descriptor with the table name or using an alias.
    Note
    For the resulting set of a SELECT command with a left outer join in the FROM clause, it is generally of crucial importance whether a logical condition is in the ON or WHERE condition. Since not all of the database systems supported by SAP themselves support the standard syntax and semantics of the left outer join, the syntax has been restricted to those cases that return the same solution in all database systems:
    Only a table or view may come after the JOIN operator, not another join statement.
    The only logical operator allowed in the ON condition is AND.
    Each comparison in the ON condition must contain a field from the right-hand table.
    Comparisons in the WHERE condition must not contain a field from the right-hand table.
    The ON condition must contain at least one "real" JOIN condition (a condition in which a field from tabref1 as well as from tabref2 occurs).
    Note
    In some cases, '*' may be specivied as the field list in the SELECT clause, and an internal table or work area is entered in the INTO clause (instead of a list of fields). If so, the fields are written to the target area from left to right in the order in which the tables appear in the llen in der FROM clause, according to the structure of each table work area. There can be gaps between the table work areas if you use an Alignment Request. For this reason, you should define the target work area with reference to the types of the database tables, as in the following example (not simply by counting the total number of fields).
    Example
    Example of a JOIN with more than two tables: Select all flights from Frankfurt to New York between September 10th and 20th, 2001 where there are available places, and display the name of the airline.
    DATA: BEGIN OF WA,
    FLIGHT TYPE SFLIGHT,
    PFLI TYPE SPFLI,
    CARR TYPE SCARR,
    END OF WA.
    SELECT * INTO WA
    FROM ( SFLIGHT AS F INNER JOIN SPFLI AS P
    ON FCARRID = PCARRID AND
    FCONNID = PCONNID )
    INNER JOIN SCARR AS C
    ON FCARRID = CCARRID
    WHERE P~CITYFROM = 'FRANKFURT'
    AND P~CITYTO = 'NEW YORK'
    AND F~FLDATE BETWEEN '20010910' AND '20010920'
    AND FSEATSOCC < FSEATSMAX.
    WRITE: / WA-CARR-CARRNAME, WA-FLIGHT-FLDATE, WA-FLIGHT-CARRID,
    WA-FLIGHT-CONNID.
    ENDSELECT.
    And for all entries,
    this will help u.
    use of FOR ALL ENTRIES:
    1. INNER JOIN
    DBTAB1 <----
    > DBTAB2
    It is used to JOIN two DATABASE tables
    having some COMMON fields.
    2. Whereas
    For All Entries,
    DBTAB1 <----
    > ITAB1
    is not at all related to two DATABASE tables.
    It is related to INTERNAL table.
    3. If we want to fetch data
    from some DBTABLE1
    but we want to fetch
    for only some records
    which are contained in some internal table,
    then we use for alll entries.
    1. simple example of for all entries.
    2. NOTE THAT
    In for all entries,
    it is NOT necessary to use TWO DBTABLES.
    (as against JOIN)
    3. use this program (just copy paste)
    it will fetch data
    from T001
    FOR ONLY TWO COMPANIES (as mentioned in itab)
    4
    REPORT abc.
    DATA : BEGIN OF itab OCCURS 0,
    bukrs LIKE t001-bukrs,
    END OF itab.
    DATA : t001 LIKE TABLE OF t001 WITH HEADER LINE.
    itab-bukrs = '1000'.
    APPEND itab.
    itab-bukrs = '1100'.
    APPEND itab.
    SELECT * FROM t001
    INTO TABLE t001
    FOR ALL ENTRIES IN itab
    WHERE bukrs = itab-bukrs.
    LOOP AT t001.
    WRITE :/ t001-bukrs.
    ENDLOOP.
    cheers,
    Hema.

Maybe you are looking for