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.
Showing results for 
Search instead for 
Did you mean: 

remove leading zeros of parameter


how to delete only the first two zeros of a parameter.

for example the value of the parameter is equal to '0000' I want it to become equal to '00' I cannot make the assignment (parameter = 00) because by default it puts the other zeroes in front. how can I do?


Active Contributor

What have you done or tried already? What is the underlying data type/domain, is it custom or standard, character, numerical? I assume you are only trying to change the display of the "parameter" and not how the "parameter" is handled internally. And by calling it "parameter", I also assume you are taking about a Report you most likely have created? I also assume you have only values with relevant information in the last two characters of the four characters available and the first two values are 'always' zeros.

Depending on your setup, you have several options, but without knowing anything else yet, I would go with a conversion-exit for your domain, where the output function takes the first two zeros away and the input function adds missing zeros:

output = input. 
do 2 times. 
replace first occurrence of '0' in output with space.
condense output.

Active Contributor
0 Kudos

It would be good to know why "something" transfers four zeroes, and why your program should remove the two first zeroes...

Without more information, the obvious classic "substring" seems to be the solution...

0 Kudos

Hi nick,

Try below code to remove leading two zeros from the left.

DATA: str   TYPE string,
      f2(2) TYPE c,
      len   TYPE i.

str = '000123'.

len = strlen( str ).
f2 = str+0(2).
IF f2 = '00'.
  len = len - 2.
  str = str+2(len).

WRITE: str.

Active Contributor
0 Kudos

nick.reyan, please follow up on your open question.

  • comment answers or your question if there are still open issues.
  • otherwise mark an answer as accepted if it helped you solve your problem
  • or post an answer of yourself and accept it if you found another useful solution yourself
  • or redirect your question to another question that is related and was useful to solve your problem
  • in the end, close your question