Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic SELECT with FOR ALL ENTRIES IN: take 2

Former Member
0 Kudos

Hello Xperts,

we are now having a bit of new trouble with the following SELECT ... special thanks to Raul and Suhas for their previous contributions.


...
FIELD-SYMBOLS:
        <itab1>      TYPE standard table. 
 
  ASSIGN ATTR_T_I->* TO <itab1>.
 
    select
      FIELD1
      FIELD2
    from DBTAB1
    into CORRESPONDING FIELDS OF table <itab1>
    FOR ALL ENTRIES IN <itab1>
    where
       (condition).
...

ATTR_T_I is a static attibute of type table containing 10 records where all records have FIELD1 and FIELD2 empty.

The select finds in DBTAB1 entries fulfilling the 'condition' for 8 of the above 10 records in ATTR_T_I.

Hence, after the select 8 of the 10 records in ATTR_T_I have the fields FIELD1 and FIELD2 filled (ie not empty).

So far so good!

BUT: the 2 remaining records (i.e. those without entries in DBTAB1 fullfilling 'condition') have been deleted! Why? This is not what we want nor expected.

Any ideas out there how to fix this?

Thanx!

4 REPLIES 4

Former Member
0 Kudos

Hi Martin,


FIELD-SYMBOLS:
        <itab1>      TYPE standard table. 
 
  ASSIGN ATTR_T_I->* TO <itab1>.
 
    select
      FIELD1
      FIELD2
    from DBTAB1
    into CORRESPONDING FIELDS OF table <itab1>
    FOR ALL ENTRIES IN <itab1>
    where
       (condition).

What I feel, when you are assigning the object ATTR_T_I to <ITAB1>,

whatever changes you do with <ITAB1> will be reflected to ATTR_T_I (Pointer concept).

Since your new table <ITAB1> will have 8 rec after your query, same will be reflected to ATTR_T_I

Thanks,

Anmol

SuhaSaha
Advisor
Advisor
0 Kudos

Hello Martin,

Are you selecting all the key fields of the table? This is because FAE deletes the duplicate records before filling the data in the target internal table.

Read the online documentation of [FOR ALL ENTRIES|http://help.sap.com/abapdocu_702/en/abenwhere_logexp_itab.htm] for further details.

BR,

Suhas

Former Member
0 Kudos

Thanx for your answer Suhas.

Yes, 'condition' contains all the key fields of DBTAB1.

0 Kudos

> Yes, 'condition' contains all the key fields of DBTAB1.

Hi Martin,

It's not the Where condition fields i was talking about. I was referring to the Select fields, you have to SELECT all the keyfields when using FAE. Something like this:

SELECT key1 key2 ... keyn "all the key fields of the table 
field1 field2 ... fieldn 
FROM table
INTO CORRESPONDING FIELDS OF it_data
FOR ALL ENTRIES IN <itab>
WHERE (condition).

You can search in the forums for further details. It has been discussed many a times.

BR,

Suhas