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

Causing error in query using 3 tables?

himanshu_gupta13
Product and Topic Expert
Product and Topic Expert
0 Likes
1,028

With Respect Gurus,

I have a problem in a query using 3 table tables with inner join...

SELECT a~DIVID a~DPTID b~SFTCD c~FRMTM c~TOTTM

         INTO (YEMPMST-DIVID, YEMPMST-DPTID, YESHTMST-SFTCD,

               YSHIFTM-FRMTM, YSHIFTM-TOTTM)

         FROM yempmst as a

         INNER JOIN YESHTMST as b

         on  b~ADRNR = a~ADRNR

         AND b~EMPCD = a~EMPCD

         AND b~untno = a~untno

         AND b~FRMDT <= YATNDENT-PCHDT

         AND b~TODAT >= YATNDENT-PCHDT

         INNER JOIN YSHIFTM as c

         on  c~untno = b~untno

         AND c~sftcd = b~sftcd

         WHERE a~EMPCD = YATNDENT-EMPCD

           AND a~UNTNO = YEMPMST-UNTNO.

ENDSELECT.

Error is:

The list "(YEMPMST-DIVID, YEMPMST-DPTID, YESHTMST-SFTCD,

YSHIFTM-FRMTM, YSHIFTM-TOTTM)" after "INTO" is not of the the form (f1,

...,fn), or contains an undefined field. the form (f1, ...,fn), or

contains an undefined field or contains an

But here all the fields are in correct order ..

Kindly give me suggestion...

Many Thanks / Himanshu Gupta

1 ACCEPTED SOLUTION
Read only

custodio_deoliveira
Active Contributor
0 Likes
982

Hi Himansh,

Probably one or more of the destination fields are not well defined (or not defined at all). But you really should go to INTO TABLE instead of SELECT/ENDSELECT.

Cheers,

Custodio

7 REPLIES 7
Read only

Former Member
0 Likes
982

Hi!

Just to see where exactly your problem lies, why dont you first make an internal table with columns

'YEMPMST-DIVID', 'YEMPMST-DPTID', 'YESHTMST-SFTCD',

               'YSHIFTM-FRMTM', 'YSHIFTM-TOTTM'

And if error persists you would know problem is in your condition else in 'into' statement. Most likely 1 of the column is not declared in the internal table or there is size/ data type mismatch.

Regards,

KS

Read only

former_member217544
Active Contributor
0 Likes
982

Hi,

It generally comes when one the fields are not available in that work area. Cross check the field names if you have mapped to proper tables. If still not found, then check by keeping only variable and removing others. if it is correct, then keep addign one by one and check which is causing the issue..

Thanks & Regards,
Swarna

Read only

Former Member
0 Likes
982

Dear,
Try to use FOR ALL ENTRIES and test.

Regards

Danny

Read only

Former Member
0 Likes
982

Hi Himanshu,

Instead of using like

SELECT a~DIVID a~DPTID b~SFTCD c~FRMTM c~TOTTM

         INTO (YEMPMST-DIVID, YEMPMST-DPTID, YESHTMST-SFTCD,

               YSHIFTM-FRMTM, YSHIFTM-TOTTM)

you can make an internal table with these fields or you can make variables. Try once i guess this will resolve your problem.

Read only

arindam_m
Active Contributor
0 Likes
982

Hi,

You cannot put the values directly to the columns of an internal table. You can use local variables such as lv_DIVID, lv_DPTID and then pass them on. Or you can also do into corresponding fields of and have a internal table defined with the fields.

Cheers,

Arindam

Read only

custodio_deoliveira
Active Contributor
0 Likes
983

Hi Himansh,

Probably one or more of the destination fields are not well defined (or not defined at all). But you really should go to INTO TABLE instead of SELECT/ENDSELECT.

Cheers,

Custodio

Read only

himanshu_gupta13
Product and Topic Expert
Product and Topic Expert
0 Likes
982

Dear All,

Very very thank you to all for your suggestions.

I got it, sometimes some small things get skip of mind .

I didn't defined that YSHIFTM uder TABLES that's why it was causing..

Many Thanks / Himanshu Gupta