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: 

help requiered

Former Member
0 Kudos

hi all

i am facin one prblm..

i have an item in output like;

0010

0020

0030

.

.

0100

i have to delete the zero and to write the utput like:

1,2,3,,,10

can anyone please suggest..itw ill be great help

thanks

1 ACCEPTED SOLUTION

Former Member
0 Kudos

hi maheswari,

if u r goin to display that in report, you can simple make use of offset concept.

item = '0100'.

write item+0(3).//to avoid the trailing zero.

to avaoid even the leading zeroes,

write item+1(2).

Lemme know it soleved ur problem.

with regards,

praveen.

5 REPLIES 5

Former Member
0 Kudos

hi maheswari,

if u r goin to display that in report, you can simple make use of offset concept.

item = '0100'.

write item+0(3).//to avoid the trailing zero.

to avaoid even the leading zeroes,

write item+1(2).

Lemme know it soleved ur problem.

with regards,

praveen.

0 Kudos

hi praveen

thanks for reply but i have to avoid both the trailing and the leading zeros .for ex;

if item is:

00100.

then output should be like: 1.

And if item is 0100.

the output should be like:10

any sugesstion plz.

thanks

0 Kudos

Hi Anu,

Divde by 10 and remove zero's from begining.

Rgds,

Mano Sri

0 Kudos

another way.

shift <item> left deleting leading '0'.

shift <item> right deleting trailing '0'.

write:/ item .

Regards

Raja

Former Member
0 Kudos

Hi Anu,

Although the question has been marked answered,I would still like to add this to the list of solutions. You might also try something more straight forward provided by SAP, in case you wish to remove the leading zeroes.

There is a variant of WRITE statement:-

<b>WRITE <i><variable></i> NO-ZERO.</b>

If the contents of <i><variable></i> are equal to zero, only blanks are output; if <i><variable></i> is of type C or N, leading zeros are replaced by blanks.

Try the following code, see if the second list matches your desired list.

DATA: BEGIN OF itab OCCURS 0,
        c(5),
      END OF itab.

itab-c = '0010'.
APPEND itab.
itab-c = '0020'.
APPEND itab.
itab-c = '0030'.
APPEND itab.
itab-c = '0040'.
APPEND itab.
itab-c = '0050'.
APPEND itab.
itab-c = '0060'.
APPEND itab.
itab-c = '0070'.
APPEND itab.
itab-c = '0080'.
APPEND itab.
itab-c = '0090'.
APPEND itab.
itab-c = '0100'.
APPEND itab.
itab-c = '0110'.
APPEND itab.

LOOP AT itab.
  WRITE 😕 itab.
ENDLOOP.

ULINE.

LOOP AT itab.
  WRITE 😕 itab NO-ZERO.
ENDLOOP.

Hope this helps,

Best Regards,

Sanyam