07-15-2008 2:45 PM
hi,
i wont to do one select instead of this both,
in every select i use 2 diff tables in from (table_selection)
one i have 2 use is dim_navatr001 and 2 dim0costcenter .
how i can do that?
Regards
SELECT (field_selection)
FROM (table_selection)
INTO TABLE <dy_actual>
FOR ALL ENTRIES IN l_tab
WHERE dim_navatr001 = l_tab-dim0costcenter
AND dim0calmonth IN g_m_a.
SELECT (field_selection)
FROM (table_selection)
INTO TABLE <dy_actual>
FOR ALL ENTRIES IN l_tab
WHERE dim0costcenter = l_tab-dim0costcenter
AND dim0calmonth IN g_m_a.
i can do that?
Regards
07-15-2008 2:47 PM
hi,
did you try on your own before posting?
WHERE ( dim_navatr001 = l_tab-dim0costcenter
OR dim0costcenter = l_tab-dim0costcenter )
AND dim0calmonth IN g_m_a.
ec
07-15-2008 2:47 PM
hi,
did you try on your own before posting?
WHERE ( dim_navatr001 = l_tab-dim0costcenter
OR dim0costcenter = l_tab-dim0costcenter )
AND dim0calmonth IN g_m_a.
ec
07-15-2008 2:51 PM
07-15-2008 2:52 PM
07-15-2008 3:04 PM
Hi Eric,
i have 2 database tables that had the same structure exactly
except one field e.g.
datb1
pernr
DIM0COSTCENTER
persg
....
datb2
pernr
DIM_NAVATR001
persg
....
the error is when i do select from datb2 :
An Open SQL clause was specified dynamically. The contained field name
"DIM0COSTCENTER" does not exist in any of the database tables from the FROM
clause.
and for select datb1
An Open SQL clause was specified dynamically. The contained field name
"DIM_NAVATR001" does not exist in any of the database tables from the FROM
clause.
Regards
07-15-2008 3:15 PM
OK, I understand it better now...
To select from 2 database tables you either make a JOIN, but I don't think it makes any sense now. The other solution is to build up a dynamic where and call the select twice:
roughly:
dyn_where = 'dim_navatr001 = l_tab-dim0costcenter AND dim0calmonth IN g_m_a'.
PERFORM select USING field_selection.table_selection dyn_where.
dyn_where = ...
PERFORM select USING field_selection.table_selection dyn_where.
FORM select USING ....
SELECT (field_selection)
FROM (table_selection)
INTO TABLE <dy_actual>
FOR ALL ENTRIES IN l_tab
WHERE (dyn_where)
ENDFORM.
07-15-2008 2:49 PM
try something like this...
SELECT (field_selection)
FROM (table_selection) as a
INNER JOIN (table_selection) as b on adim_navatr001 = bdim0costcenter
WHERE a~dim_navatr001 = l_tab-dim0costcenter
AND dim0calmonth IN g_m_a.
07-15-2008 2:51 PM
Hi,
Declare an internal table for where cond.
data: begin of wtab,
text type string,
end of wtab,
whrtab type standard table of wtab.
wtab-text = 'dim_navatr001 = l_tab-dim0costcenter AND dim0calmonth IN g_m_a'.
append wtab to whrtab.
perform select_query tables whrtab.
clear wtab.
refresh whrtab.
wtab-taxt = 'dim0costcenter = l_tab-dim0costcenter AND dim0calmonth IN g_m_a'.
append wtab to whrtab.
perform select_query tables whrtab.
form select_query tables whrtab structure wtab.
SELECT (field_selection)
FROM (table_selection)
INTO TABLE <dy_actual>
FOR ALL ENTRIES IN l_tab
WHERE (whrtab).
regards,
Subramanian
07-15-2008 3:13 PM
Hi Subramanian PL ,
i try it but i have error :
Table "WHRTAB" must have a character-like row type (data type C, N, D,T, or STRING)
Regards
07-15-2008 2:53 PM
Are both field_selection and table_selection the same in both SELECTs?
Rob
07-15-2008 3:12 PM
Hi Rob,
i have 2 database tables that had the same structure exactly
except one field e.g.
datb1
pernr
DIM0COSTCENTER
persg
....
datb2
pernr
DIM_NAVATR001
persg
....