Skip to Content
-1

ABAP 7.5 : Union in select stament

Mar 31, 2017 at 03:06 PM

121

avatar image

Is it possible to use UNION with FOR ALL ENTRIES ?

for e.g.

    SELECT FROM table1 AS _table1
      LEFT JOIN table2 AS _table2 ON _table1~source_doc = _table2~execution_document
        LEFT JOIN table3 AS _table3 ON _table2~instrument = _table3~instrument
       FIELDS
*-- table1 part
              _table1~pricing_key          ,
              _table1~kposn                ,
              _table1~kschl                ,
              _table1~kschl_subkey         ,


*-- table2 Part
              _table2~valid_to_tst         ,
              _table2~kbetr                ,
              _table2~document             ,
              _table2~execution_document   ,
*-- table3 Part
              _table3~instrument            ,
              _table3~pricedate_to          ,
              _table3~price
        FOR ALL ENTRIES IN @lt_sel_table1
          WHERE _table1~source_doc         =   @lt_sel_table1-source_doc AND
                _table2~cgroup_cat         =   @gc_condition AND
                _table3~pricetype          =   _table2~pricetype AND
                _table3~pricedate_to       =   @gc_max


    UNION


    SELECT FROM table1 AS _table1
      LEFT JOIN table2 AS _table2 ON _table1~pricing_key = _table2~pricing_key
        LEFT JOIN table3 AS _table3 ON _table2~instrument = _table3~instrument
        FIELDS
*-- table1 part
              _table1~pricing_key          ,
              _table1~kposn                ,
              _table1~kschl                ,
              _table1~kschl_subkey         ,
*-- table2 Part
              _table2~valid_to_tst         ,
              _table2~kbetr                ,
              _table2~document             ,
              _table2~execution_document   ,
*-- table3 Part
              _table3~instrument            ,
              _table3~pricedate_from        ,
              _table3~price
         FOR ALL ENTRIES IN @lt_sel_table1
          WHERE _table1~source_doc_type    =  'BUS2028' AND
                _table2~cgroup_cat         =  @gc_contract_condition AND
                _table3~pricedate_to       =  @gc_max


		into table @data(lt_anchored_data). 

This code gives me syntax error “UNION can not be used here . is expected”. I am not sure that it is because of FOR ALL ENTRIES or some other error.

Please suggest if the issue is known to anyone.

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Best Answer
Horst Keller
Apr 01, 2017 at 07:38 AM
2

Indeed, I'm getting a little bit tired of answering please read this documentation or that documentation.

Show 1 Share
10 |10000 characters needed characters left characters exceeded
  • The addition FOR ALL ENTRIES cannot be combined with UNION.
0