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 initialize internal table with array of strings using 'value' operator in ABAP?

0 Kudos
310

Hello Folks,

I am trying the below code to set up array of strings in internal table.

types: tt_input type standard table of string with default key.

data(gt_input) = value tt_input( ( 'string1' ) ( 'string2' ) ).

But it shows syntax error '"string1'" and the row type of "GT_INPUT" are incompatible.'

When I try to set array of integers I face no proplem.

types: tt_input type standard table of i with default key.

data(gt_input) = value tt_input( ( 1 ) ( 2 ) ).

Any thoughts please ?

1 ACCEPTED SOLUTION

FredericGirod
Active Contributor
211
types: tt_input type standard table of string with default key.
data(gt_input) = value tt_input( ( `string1` ) ( `string2` ) ).

to generate string use ` not ' (it will generate char)

6 REPLIES 6

FredericGirod
Active Contributor
212
types: tt_input type standard table of string with default key.
data(gt_input) = value tt_input( ( `string1` ) ( `string2` ) ).

to generate string use ` not ' (it will generate char)

0 Kudos
211

Thanks a lot

0 Kudos
211

Is there a way to have the mix of both integer and string ?

0 Kudos
211

Sorry, what do you mean ? having integer in the string ? or generate a type from the data you receive ... ?

0 Kudos
211

something like this [ `string1`,`string2`,100,200,'string3` ] , having an array of integers and strings in the same internal table. is it possible ?

if we have a way to generate type from the data we receive that would be great to know too.

211
types: tt_input type standard table of string with default key.

data(gt_input) = value tt_input( ( `string1` ) ( `string2` ) ( conv #( 100.00 ) ( |{ my_integer }| ) ).

the dynamic generation is not an easy task. the key words are RTTS

for example https://blogs.sap.com/2017/09/29/dynamic-programming-in-abap-part-3-an-example-abap-rtts/