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

Check a file type numeric

ronaldo_aparecido
Contributor
0 Likes
1,808

Good Morning Gurus.

I Have a Dump , this dump occurs because  my program Check a variable numeric but in this variable have a value with letters ,then occurs dump.


  STATICS: v_catly TYPE zcatly,

            v_msgtx TYPE zmensagem_t.

   IF v_catly IS INITIAL OR v_catly = ' '.

     EXIT.

   ENDIF.



v_catly is type numeric ,but when check  " IF v_catly IS INITIAL OR v_catly = ' '."  it has the value '   BEA-3 .


The beter solution is?


1- check if variable have letters with 'CS, CA' ,if yes move to variable char or exist other way.


ERROR:


An exception occurred that is explained in detail below.

This exception cannot be caught in the context of the current statement.

The reason for the exception is:

The program attempted to interpret the value "BEA-3" as a number, but

since the value contravenes the rules for correct number formats,

this was not possible.



Thanks

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,777

Hi Ronaldo,


REPORT zao.

START-OF-SELECTION.

*-----------------------

  DATA: v_catly(8) TYPE n VALUE 78213970.

  IF v_catly CO '0123456789'.

    WRITE: 'numbers'.

  ENDIF.

*----------------------

  DATA: lv_str TYPE string.

  lv_str = '782g13970'.

  FIND FIRST OCCURRENCE OF REGEX '([a-zA-Z])' IN lv_str.

  IF sy-subrc = 0.

    WRITE:/ 'letter'.

  ENDIF.

9 REPLIES 9
Read only

nabheetscn
SAP Champion
SAP Champion
0 Likes
1,777

You can define  zcatly as NUMC

Nabheet

Read only

0 Likes
1,777

HI Nabheet

zcatly is  NUMC , it is a data element and is numc


Read only

0 Likes
1,777

Then simply move this value to a char variable and compare stuff

Read only

Former Member
0 Likes
1,777

What is its domain?

Neal

Read only

0 Likes
1,777

Hi Neal.

Don´t have domain I use incorporated type .

Read only

0 Likes
1,777

Hi Ronaldo,

Keep a temporvary Character variable and use it for check or any other purpose. In temporvary character variable you can pass numeric values also.

So what you do is assign that numeric variable value to that temporvary variable of type character and then do the process.

I hope this helps you. If there is any issues please revert back to me i will help you.

Regards,

Sri Hari Anand Kumar

Read only

Former Member
0 Likes
1,778

Hi Ronaldo,


REPORT zao.

START-OF-SELECTION.

*-----------------------

  DATA: v_catly(8) TYPE n VALUE 78213970.

  IF v_catly CO '0123456789'.

    WRITE: 'numbers'.

  ENDIF.

*----------------------

  DATA: lv_str TYPE string.

  lv_str = '782g13970'.

  FIND FIRST OCCURRENCE OF REGEX '([a-zA-Z])' IN lv_str.

  IF sy-subrc = 0.

    WRITE:/ 'letter'.

  ENDIF.

Read only

0 Likes
1,777

Very elegant Luis .I will try.

Read only

RaymondGiuseppi
Active Contributor
0 Likes
1,777

Try to code a MOVE or [UN]PACK statement in a TRY/ENDTRY block catching CX_SY_CONVERSION_NO_NUMBER.


Regards,

Raymond