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: 

Separating a field value which has number and alphabet.

Former Member
0 Kudos

Dear all,

Since i am trying this for past two days i am unable to solve this requirement.

eg: in CDPOS table i have the field name called as cdfldvaln in this field i can see both text and the number according to me the number has to be displayed in a separate column and item text has to display in separate column.I have created a variable like new_value,new_value1, new_value2. new_value1 is to separate the number and alphanum for new_value2.

since this issue is new to me i am unable to separate this alphabet and number to separate column.

if any one knows how to solve this issue please guide me in this issue it will be useful to me.the logic behind this is

IF it_cdhdr IS NOT INITIAL.

SELECT objectclas

objectid

changenr

tabname

tabkey

fname

chngind

text_case

unit_old

unit_new

cuky_old

cuky_new

value_new

value_old

FROM cdpos

INTO TABLE it_cdpos

FOR ALL ENTRIES IN it_cdhdr

WHERE objectclas = it_cdhdr-objectclas

AND objectid = it_cdhdr-objectid

AND changenr = it_cdhdr-changenr.

  • AND unit_new = 'NO'.

data: HTYPE LIKE DD01V-DATATYPE.

DATA :BEGIN OF IT_IN OCCURS 0,

ALPHANUM(254),NUMBER1(254)," TYPE I,

END OF IT_IN,

INTERNAL LIKE TABLE OF IT_IN WITH HEADER LINE.

if it_cdpos[] is not initial.

loop at it_cdpos INTO WA_CDPOS.

IF WA_cdpos-VALUE_NEW CO '1234567890.'.

INTERNAL-NUMBER1 = WA_cdpos-VALUE_NEW.

WA_Cdpos-VALUE_NEW1 = wa_cdpos-VALUE_NEW.

MODIFY IT_cdpos FROM WA_Cdpos INDEX SY-TABIX.

ELSE.

INTERNAL-ALPHANUM = WA_cdpos-VALUE_NEW.

WA_cdpos-VALUE_NEW2 = WA_cdpos-VALUE_NEW.

MODIFY IT_Cdpos FROM WA_cdpos INDEX SY-TABIX.

ENDIF.

APPEND INTERNAL. "to WA_cdpos.

CLEAR INTERNAL.

ENDLOOP.

SORT it_cdpos BY tabkey changenr.

endif.

ENDIF.

ENDFORM

regards

Sekar.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Gnanasekhar reddy,

I hope this is not WD Related Question? Try to post in ABAP Form you get better replies.

You can separate your value at some point..

You can use CONCATENATE Statement.

for ex: Concatenate lv_value(4) into new_value.// assue lv_value contains text and values.

lv_value(4) from 4th you get into new variable.

Like that you can check..

Cheers,

Kris.

2 REPLIES 2

Former Member
0 Kudos

Hi Gnanasekhar reddy,

I hope this is not WD Related Question? Try to post in ABAP Form you get better replies.

You can separate your value at some point..

You can use CONCATENATE Statement.

for ex: Concatenate lv_value(4) into new_value.// assue lv_value contains text and values.

lv_value(4) from 4th you get into new variable.

Like that you can check..

Cheers,

Kris.

former_member199125
Active Contributor
0 Kudos

hi..

you can get the values like below way

for exaxmple

data: var type string,

var2 type string.

var = sw1010

    • if i want to get only sw

var2 = var+0(2). " 0 is starting position and 2 is length .( from 0 position to 2 characters )

now var2 wil have value "SW".

Regards

Srinivas