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: 

Display of info

Former Member
0 Kudos
68

Hi All,

I have a field declared as CHAR3 . I get the data into this field from a file which has value like '30 days' or '265 days' or '3 days'.

Now I am grabbing the value from the file as below: field = field+0(3).

so the result is '30 ' or '265' or '3 d'. Here, if you observe, the value 'd' in the last result is an error.

Could someone help me that I display the correct value?

Thanks,

points assured.

1 ACCEPTED SOLUTION

Former Member
0 Kudos
37

Hi Raja,

Did you try using the keuword SPLIT functionality? You can use this to split up a string into multiple variables.

Here in your case, you can split the source string into 2 variables at space.

SPLIT field AT ' ' INTO field1 field1.

This way, you will have the number in field1.

Hope this helps,

Sumant.

4 REPLIES 4

Former Member
0 Kudos
37

Hi Raja,

Try this

REPORT YCHATEST.

DATA : V_CHAR(3),

V_STR TYPE STRING.

V_STR = '3 days'.

V_CHAR = V_STR+0(3).

IF V_CHAR CO '0123456789'.

ELSE.

CLEAR V_CHAR+1(2).

ENDIF.

WRITE : V_CHA

Former Member
0 Kudos
37

Hi,

Include a conditon like

If Field3 CN '0123456789'.

field3 = field3 + 0(2).

Endif.

Pra

Former Member
0 Kudos
38

Hi Raja,

Did you try using the keuword SPLIT functionality? You can use this to split up a string into multiple variables.

Here in your case, you can split the source string into 2 variables at space.

SPLIT field AT ' ' INTO field1 field1.

This way, you will have the number in field1.

Hope this helps,

Sumant.

former_member156446
Active Contributor
0 Kudos
37

split field at space into f1 and f2

f1 will the required output u expect.