Application Development 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: 

How to concat two columns in where condition in sap ABAP

Former Member
0 Kudos

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

3 REPLIES 3

former_member185054
Active Participant
0 Kudos

Hi, i think its not possible.  retrieve data and use dynamic select query.

With regards,

sampath kumar.

harshil_shah
Explorer
0 Kudos

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

kilian_kilger
Active Participant

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.