cancel
Showing results for 
Search instead for 
Did you mean: 

How to Concatenate to make a dynamic variable

bhargav_007
Explorer
0 Kudos

Hello Guru's/Experts,

I would want to make the where clause of the loop to be dynamic. Hence i am using the below logic to concatenate my workarea with a string. However this is not working since after concatenating i am getting maktl = xxxx while i need to get a result like maktl = 'XXX' . The preceding and the succeeding literal (') is missing.

Currently it goes to dump :While parsing the logical expression, the system could not interpret token "Z10-11523" in row 0, column 10.

CONCATENATE 'matkl = ' '' lw_mara-matkl'' INTO matkl RESPECTING BLANKS.

LOOP AT <it_dyn> ASSIGNING <lw_dyn> WHERE (matkl).

Endloop.

Could you please help me to get this resolved will be rewarded with points.

Regards,

Bhargav.

matt
Active Contributor

"Rewarded with points?". How very 2010.

Accepted Solutions (1)

Accepted Solutions (1)

former_member186746
Active Contributor

Hi,

You have to use '''' to concatenate a single apostrophe.

There might be a new command available now that I'm unaware of, so if this is the case please enlighten me.

Kind regards, Rob Dielemans

Answers (3)

Answers (3)

ArthurParisius
Contributor

Your concatenate should be.

CONCATENATE 'matkl = ' '''' lw_mara-matkl '''' INTO matkl RESPECTING BLANKS. 
DoanManhQuynh
Active Contributor
0 Kudos

you should wrap your condition in string type...:

lv_con = `field = 'aa'`.

or:

lv_con = |field = 'aa'|.
loyd_enochs3
Participant
0 Kudos

Bhargav,

I'm on an older version so I would suggest not putting lw_mara-matkl in quotes. You want the value of the variable, not the name of the variable.

Instead just use:

CONCATENATE 'matkl = '

lw_mara-matkl

INTO matkl RESPECTING BLANKS.

I'm sure the fancy new ABAP has all kinds of tools to help with this though.

bhargav_007
Explorer
0 Kudos

Hello Loyd,

Thank-you for responding . I have tried that as well but it does not work unfortunately 😞 .

Regards,

Bhargav