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

Removing Zeros

Former Member
0 Likes
994

Hi All,

I have a field called PSPID which iam fetching from the table PROJ, the field as for the following values:

PSPID

HURT00031 00000000

HURT00031R00000000

HURT00031R01000000

HURT00031R02000000

HURT00031R03000000

HURT00031C00000000

HURT00031C02000000

HURT00031C03000000

Now my requirement is to remove the trailing zeros from that field. i have used

shift W_FINAL1-PSPID right deleting trailing '0'.

But this is not working with this shift command.

plz help me in this.

Thanks in Advance,

Neha

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
951

Hi,

Try moving the value to a character field and then use shift right deleting trailing 0.

Rgds,

HR

8 REPLIES 8
Read only

Former Member
0 Likes
952

Hi,

Try moving the value to a character field and then use shift right deleting trailing 0.

Rgds,

HR

Read only

0 Likes
951

Hi HR,

I declared it as character field only but still it is not working.

Neha

Read only

0 Likes
951

the problem is with the length , what is the length of the field W_FINAL1-PSPID , check if it matches the length of the value , if it matches only shift will work

chk this

REPORT ABC.

DATA : VAR1(18) VALUE 'HURT00031C03000000'.

SHIFT VAR1 RIGHT  DELETING  TRAILING '0'.

WRITE VAR1.

now change the length of var1 to 20 it will not work

Read only

0 Likes
951

hi,

when we check thje data type in se11 of pspid , it is character type with length of 24, so i declared w_final1-pspid of smae length i.e 24 but the value it is holding in that field is of only 18 characters, so i have written the code given below. but still it is not working.

data l_string type char18.

loop at t_final1 into w_final1.

If w_final1-pspid+17(1) = '0'.

move w_final1-posid to l_string.

shift l_string RIGHT deleting trailing '0'.

move l_string to w_final2-posid.

endif.

Read only

0 Likes
951

Hi,

Thanks a lot , it is working now

regards,

Neha

Read only

0 Likes
951

Just FYI.

here is my program to do that

REPORT ZSRIM_TEMP2.

data : v_char(50) type c.

v_char = 'HURT00031 00000000'.

condense v_char NO-GAPS.

shift v_Char left deleting leading space.

shift v_Char right deleting trailing space.

shift v_char right deleting trailing '0'.

condense v_char.

write 😕 v_char.

now this will HURT00031

Regards

Srikanth

Read only

Former Member
0 Likes
951

Hi Neha,

Move that field into a char field and then use no-zero say

data: w_temp(24) type c.

move W_FINAL1-PSPID to w_temp.

write: w_temp no-zero.

Regards,

Vidya

Read only

naimesh_patel
Active Contributor
0 Likes
951

Hello,

try this

data: l_len type i,

l_pspid(20),

l_off type i.

l_pspid = 'HURT00031 00000000'.

l_len = strlen( l_pspid ).

do.

l_off = l_len - 1.

if l_pspid+l_off(1) = '0'.

clear l_pspid+l_off(1).

else.

exit.

endif.

l_len = l_off.

enddo.

regards,

Naimesh