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

Charater to string

Former Member
0 Likes
668

Hi Friends,

I am capturing the numbers in selection screen parameter. eg: 10.

Later I am using this value concatenating with some word. Eg. Test.

The result i am getting is '010 Test'.

How to get the result as '10 Test'. (The '0' appearing before to 10 should be avoided).

Also how I can add 1 to parameter value. (10 + 1 = 11).

Eg. 11 Test.

Could u pls guide me.

TIA.

Regards,

MARK K

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
642

HI Mark

How about using SHIFT Left statement before concatenating.

Eg:

   shift <fld1> left deleting leading '0'.
   concantenate <fld1> 'Test' into <fld2> separated by space.

Also have a look at PACK/UNPACK statements.

Kind Regards

Eswar

5 REPLIES 5
Read only

anversha_s
Active Contributor
0 Likes
642

hi,

try to use,

Fm -> CONVERSION_EXIT_ALPHA_OUTPUT (removing zeros)

rgds

anver

Message was edited by: Anversha s

Read only

Former Member
0 Likes
643

HI Mark

How about using SHIFT Left statement before concatenating.

Eg:

   shift <fld1> left deleting leading '0'.
   concantenate <fld1> 'Test' into <fld2> separated by space.

Also have a look at PACK/UNPACK statements.

Kind Regards

Eswar

Read only

0 Likes
642

Hi Eswar,

Removing '0' is solved. But, how I can increment the value by 1. ie., I have to change the character type to integer. How to do that.

Regards,

Read only

0 Likes
642

Hi,

Try this function <b>CONVERT_STRING_TO_INTEGER</b>

check the below code which will convert character to integer..

DATA NO1(10) TYPE C VALUE '1234567890'.

DATA NO2 TYPE I.

NO2 = NO1.

WRITE NO2.

the foll code will convert the <b>string</b> to interger.

DATA NO1 TYPE STRING.

DATA NO2 TYPE I.

NO1 = '1234567890'.

NO2 = NO1.

WRITE NO2.

hope this helps

Regards

Alfred

Read only

0 Likes
642

Hi Mark

No need of conversion to integer if we declare the initial variable of <b>type 'N'</b>.

Please see this example for some understanding:

data: l_num(3) type n value '010'.
data: l_text(20) type c.

  perform print using l_num.
  l_num = l_num + 1.
  perform print using l_num.

  form print using l_num.
    shift l_num left deleting leading '0'.
    concatenate l_num 'Test' into l_text separated by space.
    write:/ l_text.
  endform.

Am not on SAP, so please bear if there are any syntax errors.

Kind Regards

Eswar