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

Reading multiple values from screen field

Former Member
0 Likes
1,514

Hi All,

I need to implement a logic where in i should be able to read multiple values seperated by commas which are entered in an input/ output field on a screen.

need pointers to implement the logic.

Thanks & Regards,

SriLalitha.

1 ACCEPTED SOLUTION
Read only

former_member196651
Contributor
0 Likes
1,164

Hi SriLatha,

As all the above suggested, you can use the SPLIT statement. But there an issue will arise. How many TO fields needs to be declared and how many of them needs to be used in the SPLIT statements. Means, these can be dynamic.

So I will suggest you can go with the following logic for SPLIT statement.

DATA :  gt_str TYPE TABLE OF tdline.

SPLIT IP_TEXT AT ',' INTO TABLE gt_str.

So this will split all the values into a table and this will be dynamic.

Regards,

Abijith

6 REPLIES 6
Read only

Former Member
0 Likes
1,164

Hi Sri Lalitha,

I believe you can use the below mentioned code to fulfill your need

data strng1 type string value 'aaa, bbbb, cc, dddddd, bbb,cccccc,dd,eee'.

data strng2 type string.

data strng3 type string.

data : begin of fs,

col1(20) type c,

col2(20) type c,

col3(20) type c,

col4(20) type c,

end of fs.

data itab like table of fs.

string2 = string.

while string2 <> space.

split string2 at ',' into fs-col1 fs-col2 fs-col3 fs-col4 string2.

append fs to itab.

clear fs.

endwhile.

loop at itab into fs.

write / fs.

endloop.

Let me know in case you require any further inputs.

BR/Thanks

Pranav Agrawal

Read only

0 Likes
1,164

Pranav,

my requirement is that - i have an i/o field on a screen. here i enter aaa, bbb. so how can i read aaa and bbb seperately so that i need to pass these values to seperate variables

Thanks & Regards,

SriLalitha

Read only

0 Likes
1,164

Hi,

You can use the SPLIT statement for your requirement. Check for SPLIT statement , use different variable to get the value .

Regards

Sivaganesh

Read only

0 Likes
1,164

Hi Sri Latha,

Below is the answer to your further query.

Suppose screen parameter is string2.

Then you enter string2 = aaa, bbb.

     split string2 at ', ' into stg1 stg2.

The corresponding values in string2 variable will go in stg1 and stg2 i.e.

stg1 = aaa and stg2 =bbb.

Please validate the same at your end as well.

BR/Thanks

Pranav Agrawal

Read only

former_member196651
Contributor
0 Likes
1,165

Hi SriLatha,

As all the above suggested, you can use the SPLIT statement. But there an issue will arise. How many TO fields needs to be declared and how many of them needs to be used in the SPLIT statements. Means, these can be dynamic.

So I will suggest you can go with the following logic for SPLIT statement.

DATA :  gt_str TYPE TABLE OF tdline.

SPLIT IP_TEXT AT ',' INTO TABLE gt_str.

So this will split all the values into a table and this will be dynamic.

Regards,

Abijith

Read only

former_member223133
Active Participant
0 Likes
1,164

Hi,

If your requirement is to read the screen field value of any standard screen and to pass the values to separate variables, follow the below code.

  • Declare a field symbol of type field required to be read.
  • Use assign statement to read the value of field.

    For example:


        "Field Symbols
        FIELD-SYMBOLS: <fs_vbak> TYPE vbak.


        "Read the VBAK structure populated for SO
        ASSIGN ('(SAPMV45A)VBAK'TO <fs_vbak>.
        IF <fs_vbak> IS ASSIGNED.

          "Put logic required

        ENDIF.

Regards

Gangadhar