2012 Oct 18 4:56 AM
Hi,
Is the below scenario possible?
Select a~field 1
a~field 2
from ( ( table1 as a inner join table 2 as b on
a~field3 = b~field 3) inner join table 3 as c
on c~field 4 = a~field4+2(4) )
into table internal table1
where a~field 5 = 'XYZ'.
When syntax is checked, SAP return with the error a~field4 is unknown. Is this because string operation is not allowed in case of Joins or is my syntax wrong?
Thanks for the help.
2012 Oct 18 5:12 AM
Hi,
on c~field 4 = a~field4+2(4) is not allowed on inner join.
Regards,
Priyanka
2012 Oct 18 5:19 AM
Hi Krithika,
U can perform the same operation after getting all data into internal table.
Regards,
Amol
2012 Oct 18 5:57 AM
in inner join condition you cant but in where condition you can put offset specification in right hand side condition where you wrote 'XYZ', but some time it will give warning.
Standard practice is do not put offset specification in select query, do all these kind of operation in internal table.
2012 Oct 18 6:18 AM
Dear,
Try to use For All Entries as it is considered better to use FOR ALL ENTRIES than opting fo r JOIN statement
2012 Oct 18 7:18 AM
Can you explain your opinion, as from my experience JOIN get almost always better performance than FOR ALL ENTRIES as soon as there are many records in the internal tables or not de the full primary key provided, also look at some blog like excellent Rob's JOINS vs. FOR ALL ENTRIES - Which Performs Better?
Regards,
Raymond
2012 Oct 18 9:16 AM
I think you did not go through the blog properly, in the end the result the author quoted was:
There are other considerations that come into play as well:
2012 Oct 18 9:30 AM
I read this document carefully (a long time ago), but the first part of the answer was refering to my (humble) experience, then I added a reference to experience of another member of the community, no problem
Actually I mostly use FOR ALL ENTRIES when the set is of relative small size, or when I don't have other option (I dislike those cluster/pool tables, legacy from another time )
Also I became, for two years now, addict on subqueries which can habve better performance than join if data is not required but only selection criteria, also they can help balancing the load between database and application server.
Regards,
Raymond
PS: Also I mapped the '~' on my keyboard to a free key..
2016 Oct 03 8:06 AM
Hello,
I got it with new open SQL Syntax avalaible from enhancement 740.
For example:
Table ZHR_EXAMPLE_TABLE2 has the column ID_EMPLEADO with 6 characters instead of 8 like PERNR in table ZHR_EXAMPLE_TABLE1.
SELECT
T0~COLUMN1, T0~COLUMN2, T0~COLUMN3, T0~COLUM4, T1~COLUMN1 AS COLUMRESULT, T1~PERNR
FROM ZHR_EXAMPLE_TABLE1 AS T0
INNER JOIN ZHR_EXAMPLE_TABLE2 AS T1 ON SUBSTRING( T1~PERNR,3,6 ) = T0~ID_EMPLEADO
WHERE T0~IDPARTE = @ZIDPARTE AND T1~BEGDA LE T0~FECHA AND T1~ENDDA GE T0~FECHA
INTO CORRESPONDING FIELDS OF TABLE @ITAB.
IF SY-SUBRC EQ 0.
<your code with the internal table itab>
ENDIF.
Instead of "INTO CORRESPONDING FIELDS OF TABLE @ITAB" you can use "INTO TABLE @DATA(result)". With result no declarated before, the result of the select will be in the that table.
I hope it can be useful for someone.
Kind regards,
Julian.