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: 

[NEW SYNTAX] ABAP: In a FOR () in () INDEX INTO [2 digits]

rachidroughi
Explorer
0 Kudos
542

Dear,

I am reading a table with an INDEX INTO tabix, but I would like to have 2 digits in my LV_TABIX.

    DATA(lt_tree) = VALUE wdy_key_value_list(
FOR ls_data IN gi_data
INDEX INTO lv_tabix ( key = lv_tabix ) ) .

Currently, my KEY contains : 1,2,3,4,5

and I would like formatted values like this: 01, 02, 03, 04, 05.

Any idea ?

Thank you in advance.

Best regards,

Rachid


1 ACCEPTED SOLUTION

rachidroughi
Explorer
459

Resolved by creating a DDIC Type Numc on 2 digits.

4 REPLIES 4

rachidroughi
Explorer
460

Resolved by creating a DDIC Type Numc on 2 digits.

459

You should avoid creating DDIC types when it's only for internal ABAP processing.

You may use a String Template with the formatting options WIDTH, ALIGN, PAD.

Minimal reproducible example:

DATA(lt_tree) = VALUE string_table(
                FOR lv_tabix = 1 WHILE lv_tabix <= 3
                ( |{ lv_tabix WIDTH = 2 ALIGN = RIGHT PAD = '0' }| ) ) .
ASSERT lt_tree = VALUE string_table( ( `01` ) ( `02` ) ( `03` ) ).<br>

459

you could even use

( |{ lv_tabix WIDTH = 2 ALPHA = IN }| )

0 Kudos
459

Hello,

And even if I delete ALPHA=IN, the result is "1" not "000000000000000000000001".

Best regards,