Application Development and Automation 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: 
Read only

Problem with subselect in from clause

Former Member
0 Likes
403

Hi experts,

I am facing a problem with a subselect in the from clause in a select statement.

I executed the statement on my DB2 database and everything works fine. But in ABAP I get an error message.

'( is not table or view' when writing subselect in the from clause.


SELECT tpm03~/bic/zsbetr_nr
               tpm03~/bic/zsbetteil
               tpm03~/bic/zsverszw
               tpm03~calyear
               SUM( tpm03~/bic/zs_kpi_19 )
           FROM /bic/az3_tpm0300 AS tpm03
           JOIN
           ( SELECT /bic/zsbetr_nr                                                                <--------     error
                    /bic/zsbetteil
                    /bic/zsverszw
                    calyear
                    /bic/zsumvcod
                    MAX( /bic/zsglbnr )
             FROM /bic/az3_tpm0300
             WHERE /bic/zsumvcod = 3
             GROUP BY /bic/zsbetr_nr /bic/zsbetteil /bic/zsverszw calyear /bic/zsumvcod )  AS tpm03_max
             ON tpm03~/bic/zsbetr_nr = tpm03_max~/bic/zsbetr_nr AND
                tpm03~/bic/zsbetteil = tpm03_max~/bic/zsbetteil AND
                tpm03~/bic/zsverszw  = tpm03_max~/bic/zsverszw AND
                tpm03~calyear        = tpm03_max~calyear AND
                tpm03~/bic/zsumvcod  = tpm03_max~/bic/zsumvcod AND
                tpm03~/bic/zsglbnr   = tpm03_max~/bic/zsglbnr
          INTO CORRESPONDING FIELDS OF TABLE tpm03_it
          GROUP BY tpm03~/bic/zsbetr_nr
                   tpm03~/bic/zsbetteil
                   tpm03~/bic/zsverszw
                   tpm03~calyear.

Please can anyone give me some help.

Thank you in advance

Peter

Edited by: Matt on Feb 8, 2011 3:26 PM - added tags

Hi experts,

I am facing a problem with a subselect in the from clause in a select statement.

I executed the statement on my DB2 database and everything works fine. But in ABAP I get an error message.

'( is not table or view' when writing subselect in the from clause.


SELECT tpm03~/bic/zsbetr_nr
               tpm03~/bic/zsbetteil
               tpm03~/bic/zsverszw
               tpm03~calyear
               SUM( tpm03~/bic/zs_kpi_19 )
           FROM /bic/az3_tpm0300 AS tpm03
           JOIN
           ( SELECT /bic/zsbetr_nr                                                                <--------     error
                    /bic/zsbetteil
                    /bic/zsverszw
                    calyear
                    /bic/zsumvcod
                    MAX( /bic/zsglbnr )
             FROM /bic/az3_tpm0300
             WHERE /bic/zsumvcod = 3
             GROUP BY /bic/zsbetr_nr /bic/zsbetteil /bic/zsverszw calyear /bic/zsumvcod )  AS tpm03_max
             ON tpm03~/bic/zsbetr_nr = tpm03_max~/bic/zsbetr_nr AND
                tpm03~/bic/zsbetteil = tpm03_max~/bic/zsbetteil AND
                tpm03~/bic/zsverszw  = tpm03_max~/bic/zsverszw AND
                tpm03~calyear        = tpm03_max~calyear AND
                tpm03~/bic/zsumvcod  = tpm03_max~/bic/zsumvcod AND
                tpm03~/bic/zsglbnr   = tpm03_max~/bic/zsglbnr
          INTO CORRESPONDING FIELDS OF TABLE tpm03_it
          GROUP BY tpm03~/bic/zsbetr_nr
                   tpm03~/bic/zsbetteil
                   tpm03~/bic/zsverszw
                   tpm03~calyear.

Please can anyone give me some help.

Thank you in advance

Peter

Edited by: Matt on Feb 8, 2011 3:26 PM - added tags

1 REPLY 1
Read only

matt
Active Contributor
0 Likes
366

OpenSQL isn't as flexible as "proper" SQL. You either should simplify the query or use EXEC SQL. What you currently have is simply not part of the ABAP syntax. (as far as I can tell).

matt