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

type conversion problem between string and i.

0 Likes
906

Hi friends,

i have a problem and it seems i need some conversion functionality to it but i do not know what to use for that:

i have a String like "4-1-2" and i do split it into itab at "-" so my itab now contains

4

1

2

in the next step i want to use this value from itab within a read index statement...but here it dumps.

READ t_tab INTO ... INDEX itab.

So it seems that i have to convert the value from itab into i before - but how to achieve that ?

thanks for your help - points will be awarded surely!

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
881

Hello,

WHen reading the table t_tab make this change

data: l_tabix like sy-tabix.
loop at itab.
l_tabix = itab-index. " Say Index is the field of itab.
READ t_tab INTO ... INDEX l_tabix.. 
endloop.

Regards,

Vasanth

8 REPLIES 8
Read only

Former Member
0 Likes
882

Hello,

WHen reading the table t_tab make this change

data: l_tabix like sy-tabix.
loop at itab.
l_tabix = itab-index. " Say Index is the field of itab.
READ t_tab INTO ... INDEX l_tabix.. 
endloop.

Regards,

Vasanth

Read only

Former Member
0 Likes
881

Hi,

you can convert it, if you work with WRITE TO.

CHAR write to INT.

Regards

Nicole

Read only

Former Member
0 Likes
881

Hi,

Check the code below:

  • Reading the file internal table to get Supplier Number.

READ TABLE gt_dummy INTO gs_dummy INDEX gc_one_num.

IF sy-subrc EQ gc_zero_num.

CLEAR:gs_wa,gv_str1,gv_str2.

SPLIT gs_dummy AT gc_y INTO: gv_str1 gv_str2, TABLE gt_itab.

ENDIF.

  • Reading the second string to get the supplier number.

READ TABLE gt_itab INTO gs_wa INDEX gc_two_num.

IF sy-subrc EQ gc_zero_num.

gs_header-lifnr = gs_wa.

ENDIF.

  • Conversion for Supplier Number.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

input = gs_header-lifnr

IMPORTING

output = gs_header-lifnr.

APPEND gs_header TO gt_header.

CLEAR: gs_header,gt_itab[].

Regards

Kannaiah

Read only

Former Member
0 Likes
881
chk this 

REPORT ABC MESSAGE-ID ZZ.

DATA : V_STR(10) VALUE '4-2-1'.

DATA : BEGIN OF ITAB OCCURS 0,
         F1(5),
       END OF ITAB.

DATA : BEGIN OF ITAB1 OCCURS 0,
         F2 TYPE I,
       END OF ITAB1.

DATA : BEGIN OF ITAB3 OCCURS 0,
         F3 TYPE I,
       END OF ITAB3.

SPLIT V_STR AT '-' INTO TABLE ITAB.

LOOP AT ITAB.
  ITAB1-F2 = ITAB-F1.
  APPEND ITAB1.
  CLEAR ITAB1.
ENDLOOP.

LOOP AT ITAB1.
  READ TABLE ITAB3 INDEX ITAB1-F2.
ENDLOOP.
Read only

Former Member
0 Likes
881

Please post ur entire code.

Read only

dev_parbutteea
Active Contributor
0 Likes
881

move itab-field to <b>integer_variable.</b>

READ t_tab INTO ... INDEX <b>integer_variable</b>.

Regards,

Sooness.

Read only

Former Member
0 Likes
881

Hi,

The following code does not dump.

DATA itab TYPE TABLE OF n WITH HEADER LINE.

SPLIT '4-1-2' AT '-' INTO TABLE itab.

DATA : sflight TYPE STANDARD TABLE OF sflight.

SELECT * FROM sflight INTO TABLE sflight.

LOOP at itab.

READ TABLE sflight INDEX itab TRANSPORTING NO FIELDS.

ENDLOOP.

Hope this helps.

You just need to make your internal table of TYPE N.

Message was edited by:

Shailesh Velaparambil

Read only

Former Member
0 Likes
881

Hi celmens,

Presently it is giving dump bcoz u r give INDEX itab. here u have to give sy-index like field.

secondly, u can conver char to i using :

1. write char_var to int_var.

2. int_var = char_var.

Jogdand M B