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: 

System exception - Field symbol - Initial check

0 Kudos

Hi everyone,

I'm assigning a component of a structure to a field symbol. Component "LIEFERTERMIN" is type N(6).

Now I get a wrong value from my source structure. <fs_check> is now "R12022". This will cause a short dump on any arithmetic operation, of course. But first of all I'm checking if the value of the field symbol is initial. This however also results in a short dump (CONVT_NO_NUMBER) which is also ok.

ASSIGN COMPONENT 'LIEFERTERMIN' OF STRUCTURE <fs_filecontent> TO <fs_check>.

TRY.

IF <fs_check> IS INITIAL.

.....

ENDIF.

ENDTRY.

However, I can neither catch this short dump with a

TRY.

...

CATCH CX_SY_CONVERSION_NO_NUMBER into OREF.

ENDTRY.

block nor with a

CATCH SYSTEM-EXCEPTIONS conversion_errors = 1.

ENDCATCH.

Any ideas on how to catch this exception?

King regards,

Alex

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Try this


  DATA: lv_packed_number     TYPE p.                        "#EC NEEDED
  CATCH SYSTEM-EXCEPTIONS convt_no_number = 1.
    lv_packed_number = <fs_check>.
  ENDCATCH.
  IF sy-subrc NE 0.
" Not a number
  ENDIF.

5 REPLIES 5

Former Member
0 Kudos

Try this


  DATA: lv_packed_number     TYPE p.                        "#EC NEEDED
  CATCH SYSTEM-EXCEPTIONS convt_no_number = 1.
    lv_packed_number = <fs_check>.
  ENDCATCH.
  IF sy-subrc NE 0.
" Not a number
  ENDIF.

0 Kudos

Hi,

in the rest of the program I have several other assignments like this one and I cannot be sure where the error will happen. What I know is that it will be a conversion error. Is there a possibility to catch the <fs_check> is initial - Exception (CONVT_NO_NUMBER) globally or do I have to use this part of your code for every single other assignment statement.

So basically use

CATCH SYSTEM-EXCEPTIONS convt_no_number = 1.

ASSIGN COMPONENT 'C1' OF STRUCTURE <fs_filecontent> TO <fs_check>.

IF <fs_check> IS INITIAL.

...

ASSIGN COMPONENT 'C2' OF STRUCTURE <fs_filecontent> TO <fs_check>.

IF <fs_check> IS INITIAL.

...

ASSIGN COMPONENT 'C3' OF STRUCTURE <fs_filecontent> TO <fs_check>.

IF <fs_check> IS INITIAL.

...

ENDCATCH.

0 Kudos

You can do a TRY - CATCH on a whole coding block containing several assignments but that would also mean that exception will be raised the moment a conversion error occurs and none of other statements subsequent to statement causing conversion error till ENDTRY will be executed.

If you don't want that to happen and would want to continue with rest of coding then you have to call this routine for each new numeric field that may contain non numeric characters

May be you can create a form or macro, to make the test more appealing

You need to use the logical expression [IS ASSIGNED|http://help.sap.com/abapdocu_702/en/abenlogexp_assigned.htm] instead of the IS INITIAL. More over, you should start using the [Class Based exceptions|http://help-abap.zevolving.com/2011/12/class-based-exception/] instead of using the System Exceptions.


TRY.
   ASSIGN COMPONENT 'C1' OF STRUCTURE <fs_filecontent> TO <fs_check>.
   IF <fs_check> IS ASSIGNED.
   
   ENDIF.
  CATCH CX_SY_CONVERSION_ERROR into lo_exc.
      data: lv_String type string.
      lv_String = lo_Exc->get_text( ).
      message lv_String type 'S'
ENDTRY.

Regards,

Naimesh Patel

0 Kudos

Hi everyone,

thanks for your replies. I actually found the problem with help of a colleague and I realized, I didn't copy and paste a vital part of the problem to this question. All your answers actually would have helped thus I'm assigning points to everyone.

The code check was:

IF <fs_check> IS INITIAL or <fs_check> EQ ''.

...

ENDIF.

Now if <fs_check> of type N(6) contains wrong data like 'R12022' the second check (EQ '') will dump and can't be catched. As the second check actually is not needed I just removed it from the program.

Thanks anyway,

Alex