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

abap code

Former Member
0 Likes
474

i want an abap code which when a user enters an ID number all the other characters except numbers and letterrs will only be ignored.in other words i want to store the ID number containing only numbers and letters. Our ID numbers contain spaces, forward slashes and hyphens and i want these ignored when returning the ID number

3 REPLIES 3
Read only

Former Member
0 Likes
451

Hi Willard,

I will give the logic and with this you can write the code.

First you store all your special symbols in one constant like forward slashes , spaces and etc.

First findout the length of your id. take an temp variable which is of the same type of ID. Now read single character of the ID using the offset( +0(1) )from back to end. if it has the special symbol, don't put that in your temp varilable otherwise place it in to your temp. Once the loop is over then you temp varible contains required information.

Logic:

1. Finout the length of the string = n

2. Do loop n times

if ID+n(1) containts any space, forward slashes, hyphens

Continue.

else.

TEMP+n(1).

endif.

ENDloop.

This will solve your problem.

Warm Regards,

Vijay

Warm Regards,

Vijay.

Read only

Former Member
0 Likes
451

hI..

<b>this will solve ur prob...just paste this code..</b>

DATA:

W_ID(20) TYPE C VALUE '123 >?ABC# XYZ',

w_len type i,

w_actual(20) type c,

w_off type i.

w_len = strlen( w_id ).

do w_len times.

w_off = sy-index - 1.

<b>if ( w_id+w_off(1) ca sy-abcde ) <b>or</b>

( w_id+w_off(1) ca '0123456789' ) .</b>

concatenate w_actual w_id+w_off(1) into w_actual.

endif.

enddo.

write: w_actual.

Message was edited by:

Rammohan Nagam

Read only

Former Member
0 Likes
451

willard,

REPORT ZTEST11 .

DATA : v_str type String,

V_len type i,

v_num type i,

V_TOT(60),

V_NUM2 TYPE I.

PARAMETERS : P_ID(30).

start-of-selection.

v_len = strlen( P_ID ).

concatenate '0123456789' sy-abcde into v_tot.

condense v_tot no-gaps.

v_num = v_num + 1.

do V_LEN TIMES.

if P_ID+V_NUM2(v_num) na v_tot.

REPLACE P_ID+V_NUM2(v_num) WITH space INTO p_id.

endif.

v_num2 = v_num2 + 1.

enddo.

CONDENSE P_ID NO-GAPS.

write P_ID.

Don't forget ot reward if useful..