Skip to Content

How to discover field size and increase it?

Hello Experts,

I've an issue concerning size fields in abap routine.

I need to have a output with 4 characteres always. I'll increase with 0.

Examples:


input 1 = output: 0001

input 01 = output: 0001

input 001 = output: 0001

input 0001 = output: 0001

So, I need a abap that first check the field size, then increase with one, two or three 0 (zeros) according the needing.

Could you please help me?

Thanks,

Flávio Thomazetti

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • Best Answer
    Posted on Jul 14, 2016 at 12:54 PM

    are you talking about a characteristic of a key figure?

    for chars you have the option to add the alpha conversion.

    M.

    Add a comment
    10|10000 characters needed characters exceeded

    • I've another specifis requiriments to consider...

      My final code that works:

      var5_SERIE = '000'.
      SPLIT lv_DOCUMENT AT '-' INTO var1_SERIE var2_SERIE.
      var3_SERIE = var2_SERIE.
      SHIFT var3_SERIE LEFT DELETING LEADING '0'.
      IF var3_SERIE IS INITIAL.
      var3_SERIE = '00'.
      RESULT = var3_SERIE.
      ELSEIF var3_SERIE IS NOT INITIAL.
      CONCATENATE var5_SERIE var3_SERIE INTO var4_SERIE.
      IF var4_SERIE EQ var4_SERIE(4).
      var4_SERIE = var4_SERIE+2(2).
      RESULT = var4_SERIE.
      ELSEIF var4_SERIE EQ var4_SERIE(5).
      var4_SERIE = var4_SERIE+3(2).
      RESULT = var4_SERIE.
      ELSEIF var4_SERIE EQ var4_SERIE(6).
      var4_SERIE = var4_SERIE+3(3).
      RESULT = var4_SERIE.
      ENDIF.

      ENDIF.


      Thanks,

      FThomazetti

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.