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 Concatenate in SELECT query using FOR ALL ENTRIES?

vijay_simha3
Explorer
0 Kudos

Dear Techies,

i have came across a situation, like writing a select query using new enhanced OpenSQL, here i am concatenating two sting fields into single field with for all entries as of requirement.

Example ABAP Query

SELECT kunnr, ( inco1 && inco2 ) as inco, FROM knvv INTO TABLE @<target table> FOR ALL ENTRIES IN @<base table> WHERE <condition follows>.

But I am getting error "<b> The addition or variable with ID "INCO1" is not allowed in conjunction with FOR ALL ENTRIES. </b>"

I understood that concatenation not allowed while FOR ALL ENTRIES.

My questions here are,

1. Is any alternate to concate in the query itself?

2. Want to know the reason that why not allowed concatenate using FOR ALL ENTRIES?

googled for information on above questions, unfortunately did not find satisfied solutions.

Please share information.

Thanks for Advance,.

Vijay

4 REPLIES 4

former_member1716
Active Contributor
0 Kudos

Hello Vijay Simha,

Recommend you to go through the below link for the DOs and DONTs with respect to FOR ALL ENTRIES.

FOR ALL ENTRIES

Alternate solution would be using joins of the respective tables.

Regards!

FredericGirod
Active Contributor

Could you use the "Code" button to display your code

Could you give us the statement that populates the <base_table> ?

Sandra_Rossi
Active Contributor

Minimal code to reproduce the problem:

DATA carrids TYPE TABLE OF scarr-carrid.
SELECT carrid, ( carrname && currcode ) as inco FROM scarr INTO TABLE @DATA(scarr_s) 
FOR ALL ENTRIES IN @carrids WHERE carrid = @carrids-table_line.

Error message:

The addition CARRNAME is not allowed in combination with FOR ALL ENTRIES. Use JOINs or global temporary tables instead of FOR ALL ENTRIES.

Solution: do as suggested

vijay_simha3
Explorer
0 Kudos

<base table> is a fetch on KNA1 table