Application Development and Automation 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: 
Read only

How to initialize internal table with array of strings using 'value' operator in ABAP?

0 Likes
2,788

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
Read only

FredericGirod
Active Contributor
2,689
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
Read only

FredericGirod
Active Contributor
2,690
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)

Read only

0 Likes
2,689

Thanks a lot

Read only

0 Likes
2,689

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

Read only

0 Likes
2,689

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

Read only

0 Likes
2,689

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.

Read only

2,689
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/