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: 

Where condition 'Int' in 'Char' format field

rizaldy_hidayat
Explorer
0 Kudos

Hi,

I have field with 'Char' format, but i used to input an integer value. Are possible if I use that value to filter data?

Example:

IF FIELD > 70.

FIELD2 = 'More than 70'.

Thank you.

6 REPLIES 6

Former Member
0 Kudos

You can.. Just move your char data to a int variable.

Sample:

DATA: v_char TYPE char10,

       v_int  TYPE i.

v_char = 71.

MOVE v_char TO v_int.

IF v_int > 70.

   WRITE: 'More than 70'.

ENDIF.

0 Kudos

Thank for the reply, but i use an internal table.

I have an internal table with it_vbkd like vbkd.

in field POSEX_E default format field is char, but i want use to filter by Integer. Can I convert field in internal table as you suggest?

0 Kudos

Yes. Just create a loop passing to work area and move the posex_e field to an integer variable then validate.

Loop at it_vkbd INTO wa_vbkd

   MOVE wa_vbkd-posex_e TO v_int.

   <add condition here>

Endloop.

0 Kudos

Hi Elzkie,

Thanks for the answer. Its work fine for me with less modify.

former_member210008
Active Participant
0 Kudos

Hi. Check abap help for comparison between different types. It will help you to understand your problem - Comparisons Between Different Data Types - ABAP Programming (BC-ABA) - SAP Library

Char and int will be compared as numbers.

So if you have data i1 type i value 123 and data c1(10) value '     123' and data c2(10) value '00000123', i1 will be equal to c1 and c2.

0 Kudos

Hi,

You can use single quote for character like IF FIELD > '70' for comparison.

Thanks.