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: 

"Number of fields in selection lists in unions must be the same"

former_member186444
Participant
0 Kudos

me again!

I'm getting this error in a CDS View in which I'm using a 'UNION ALL' and I can't figure out why I'm getting it.

I have the same number of fields in both selection lists (that is the Projection List, right?) and their types are all the same. The help says you don't have to call them the same thing but I have anyway.

Although the fields are of the same type, they come from different tables - that can't be the reason surely?

I've even debugged this and taken a look at the xml but that hasn't thrown up anything.

Any ideas please?

Thanks again,

Malcolm.

1 ACCEPTED SOLUTION

thomasgauweiler
Active Participant
0 Kudos


Dear Malcolm,

the fact that the fields come from different tables does not matter and should not end in this error.

It is just, that the fields have to be in same order...

Can you post your view?

Best regards, Thomas

5 REPLIES 5

lbreddemann
Active Contributor
0 Kudos

Mind providing your view definition and the exact error message?

thomasgauweiler
Active Participant
0 Kudos


Dear Malcolm,

the fact that the fields come from different tables does not matter and should not end in this error.

It is just, that the fields have to be in same order...

Can you post your view?

Best regards, Thomas

0 Kudos

I forgot to mention, I tried stripping it back to one field only on each and that didn't work either.

@AbapCatalog.sqlViewName: 'ZV_ADMIS'

@EndUserText.label: 'Admissions'

define view Zcdsv_Admis //with parameters p_fac: abap.char(12),

  as select from zcdsv_crsinfacs as facs

 

  inner join hrp1000 as course on

    course.plvar = '01' and

    course.otype = 'CS' and

    course.istat = '1' and

    course.endda = '99991231' and

    course.langu = 'E' and

    facs.crs_desc = course.mc_short

   

  inner join hrp1001 as stcs on

    stcs.otype = 'CS' and

    stcs.plvar = '01' and

    course.objid = stcs.objid and

    stcs.rsign = 'B' and

    stcs.relat = '530' and

    ( stcs. istat = '1' or

    stcs.istat = '2' ) and

    stcs.begda >= '20100101' and

    stcs.sclas = 'ST'

   

  inner join hrpad530 as pad530 on

    stcs.adatanr = pad530.adatanr   

   

  inner join hrp1795 as sche

    on stcs.sobid = sche.objid

      

  inner join hrp9500 as ach

    on ach.plvar = '01' and

       ach.otype = 'ST' and

       stcs.sobid = ach.objid

      

  inner join hrp1783 as decrep

   on decrep.plvar = '01' and

      decrep.otype = 'ST' and

      stcs.sobid = decrep.objid

  inner join hrt1783 as decrep2

   on decrep2.tabnr = decrep.tabnr and

      decrep2.institution = 'N21' and

      decrep2.course = crs_desc

     

     

  inner join hrp1706 on

      hrp1706.plvar = '01' and

      hrp1706.otype = 'ST' and

       stcs.sobid = hrp1706.objid

{

    fac_objid as faculty_objid,     

    sch_objid as school_objid,     

    cgroup as cgroup,        

    crs_desc as course_code,      

    ach.zachieve_level as offer_level,   

    concat( decrep2.decision, decrep2.reply ) as decreply,

    hrp1706.stfeecat as stfeecat,     

    stcs.sobid as student_objid,    

    quota,

    target

 

}

where

      ( stfeecat = '01' or stfeecat = '04' ) and

      ( ( decrep2.decision = 'U' and decrep2.reply = 'F' ) or

           ( decrep2.decision = 'U' and decrep2.reply = 'I' ) or

           ( decrep2.decision = 'C' and decrep2.reply = 'F' ) or

           ( decrep2.decision = 'C' and decrep2.reply = 'I' ) or

           ( decrep2.decision = 'C' and decrep2.reply = 'E' ) or

           ( decrep2.decision = 'T' and decrep2.reply = 'E' ) )

union all

select from zugadm_clearing as clearing

  join zcoursegrouping on

       clearing.course = zcoursegrouping.course

  join zgroupquotas on

       zgroupquotas.cgroup = zcoursegrouping.cgroup

{

  zcoursegrouping.faculty as faculty_objid,

  zcoursegrouping.school as school_objid,

  zgroupquotas.cgroup as cgroup,

  clearing.course as course_code,

  case clearing.achievement_level

    when 'Core' then '2'

    else '1'

  end as offer_level, 

 

  case clearing.process

    when 'Clearing' then 'CE'

    else 'TE'

  end as decreply,   

      

  ' '  as stfeecat, 

  ' ' as student_objid,

  quota,

  target

}

where del_rec = ''

0 Kudos

Hi Malcolm,

are all used views and tables client-dependent?

Regards, Thomas

0 Kudos

well they are now! One of them wasn't but adding the client has solved the problem.

I'm not really sure I understand why though.

Brilliant - thanks very much Thomas. Appreciate it.