06-11-2015 6:10 AM
Hello All,
I wanted to know How to write an Select Statement in SAP ABAP which contain the concatenation of multiple column in where condition.
For e.g. in MS SQL we write the query as per below
select Field1 from Table1 where Field1+Field2 = '505771'
Similarly How we can write such where condition in SAP ABAP.
My final goal is to extract the data from SAP using the RFC_READ_TABLE.
In this function module we have to pass the where condition in "OPTIONS" table parameter.
Thanks,
Shailesh
06-11-2015 6:54 AM
Hi, i think its not possible. retrieve data and use dynamic select query.
With regards,
sampath kumar.
06-11-2015 9:26 AM
Hello Shailesh,
Concatenating two columns and fetching result is not possible using Select query in SAP ABAP.
However, you can use alternative statements like SELECT ....ENDSELECT, SELECT + LOOP statements to retrieve data and inside the loop use some logic to get your final result.
Warm Regards,
Harshil Shah
06-11-2015 9:44 AM
Hi Sailesh,
in the next ABAP release it will be possible directly (*). So stay tuned!
What you can do in 740 SP08 is to create a CDS view on top of your table and create a new calculated column in this CDS view containing CONCAT( field1, field2 ) in the SELECT list. You can then filter according to this calculated column in Open SQL. The database optimizer shrinks those two steps into one and you will get the same performance as if you had been writing the above mentioned query.
So it is indeed possible in Open SQL, if you are in >= 740 SP08.
In the projection list, you can concatenate two columns since 740 SP05 already. The syntax is like follows:
SELECT column1 && column2 FROM table ...
Best regards,
Kilian.
(*) the usual legal disclaimer applies.