Vous êtes sur la page 1sur 5

Hi,

I am trying to join a db table with dynamic db table. But i am getting syntax error.
DATA g_viewname(30) type c.
g_viewname = 'V_EQUI'.
*Select Query
SELECT * into table i_equi FROM (g_viewname)
INNER JOIN jest
ON (g_viewname)~objnr eq jest~objnr.
Thanks in advance.
Regards,
Asokan.
Back to top
Google
Sponsor

Posted: Fri Nov 26, 2004 10:30 am

Post subject: Advertisement

Back to top
Raju Chitae
Guest

Posted: Tue Nov 30, 2004 5:56 am

Post subject:

HI,
Can you just post the exact code so that it can be investigated.
Regards
Raju Chitale
Back to top
Asokan
Guest

Posted: Thu Dec 02, 2004 4:44 am


Where

Post subject: Re: Dynamic Table Join -

Hi,
Thank you for the reply. I am posting the source code and the exact error msg i am
getting.
Report zdemo.
Tables: vbrk,
vbrp.
Data g_tablename(30) type c.
Types: Begin of ty_equi,
vbeln like vbrk-vbeln,
end of ty_equi.
Data: i_equi
type Standard table of ty_equi
with header line.
g_tablename = 'VBRK'.
* Below commented code working fine
*SELECT vbrk~vbeln
* into table i_equi
* FROM vbrk
* inner join vbrp
* on vbrk~vbeln EQ vbrp~vbeln.
* Above Commented code working fine
* Dynamic table selection in Select Query
SELECT * into corresponding fields of table i_equi
FROM (g_tablename)
INNER JOIN VBRP
ON (g_tablename)~VBELN eq VBRP~VBELN.
Loop at i_equi.
write :/ i_equi-vbeln.
endloop.
*end of program zdemo
SYNTAX ERROR
Program ZDEMO
Wrong expression "INNER" in FROM clause. WHERE condition.
Includes ZDEMO

After "(G_TABLENAME)",there must be a space or equivalent character


(":",",",".").
Reagards,
Asokan
Back to top
Catman

Joined: 16 Apr 2003


Posts: 258
Location: :noitacoL
Posted: Thu Dec 02, 2004 7:40 am

Post subject:

Ashokan,
As far as i know a dynamic table name specification is not possible for inner joins.
Back to top
VLozano

Joined: 13 Sep 2004


Posts: 2310
Location: Idioci-ty
Posted: Thu Dec 02, 2004 8:39 am

Post subject:

Humm... try to approach it through a macro, maybe it works... You will not be able to
debug it but debug an SQL sentence is useless.
Something like
Code:
DEFINE myJoin.
SELECT *
FROM &1 INNER JOIN mytab
ON &1~field = mytabl~field.
END-OF-DEFINITION.

As any of my codes, it's not checked, and will not be checked (almost by me).
_________________
Brief History of the Tuly Idiots
Bad advices, wrong answers, bigotism
sapfans GD

Ad by Viiiiiic

Back to top
Asokan
Guest

Posted: Thu Dec 02, 2004 9:39 am


Where

Post subject: Re:Dynamic Table Join -

Hi all,
Thank you all for the reply's and special thanks to Vlozano. I have added the code for ur
reference and let me know if any other simple method available instead of macro. The
below code working fine.
Report zmademo.
DEFINE myJoin.
Data : begin of i_int occurs 0,
vbeln like vbrp-vbeln,
end of i_int.
SELECT * into corresponding fields of table i_int
FROM &1 INNER JOIN vbrp
ON &1~vbeln = vbrp~vbeln.
Loop at i_int.
write:/ i_int-vbeln.
endloop.
END-OF-DEFINITION.
DATA vbrk(4) TYPE C VALUE 'VBRK'.
myjoin vbrk.

Regards,
Asokan
Back to top
VLozano

Joined: 13 Sep 2004


Posts: 2310
Location: Idioci-ty
Posted: Thu Dec 02, 2004 9:49 am

Post subject:

I'm happy to be helpful. Now a hint and a petition:


The hint
Be careful declaring variables in a macro. If you call the macro more than once, the
system will check your macro code at compiling and you will get a duplicate definition
error.
The petition
If you think your problem is solved (more or less), edit the subject of your topic. People
with a problem like yours will find easyly a solution using the search if they see a
"solved" topic. Thanks in advance.
Best luck,
Vic
_________________
Brief History of the Tuly Idiots
Bad advices, wrong answers, bigotism
sapfans GD
Ad by Viiiiiic

Back to top

Vous aimerez peut-être aussi