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

Handling runtime exceptions

Former Member
0 Likes
1,449

Experts,

I encountered a runtime exception while executing a program.

The error was:

An exception occurred that is explained in detail below.

The exception, which is assigned to class 'CX_SY_IMPORT_MISMATCH_ERROR', was

not caught and

therefore caused a runtime error.

The reason for the exception is:

During import the system discovered that the target object has

a different length than the object to be imported.

And it was occurring at this code line


 IMPORT RU-VERSION TO ORU_VERSION
             CRT
        FROM DATABASE PCL2(RU) ID RX_KEY.

Can somebody please explain how to handle such an exception.

Thanks in advance.

Goldie.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,261

You need to use CATH-EXCEPTIONS...


REPORT Z_ATG_DUMMY.

DATA: RESULT TYPE P DECIMALS 3,

NUMBER TYPE I VALUE 11.

CATCH SYSTEM-EXCEPTIONS ARITHMETIC_ERRORS = 5.
  DO.
    NUMBER = NUMBER - 1.
    RESULT = 1 / NUMBER.
    WRITE: / NUMBER, RESULT.
  ENDDO.
ENDCATCH.

SKIP.

IF SY-SUBRC = 5.
  WRITE / 'Division by zero!'.
ENDIF.

Check for what exception you need to use...

Greetings,

Blag.

8 REPLIES 8
Read only

Former Member
0 Likes
1,261

Please do not duplicate or cross post.

Rob

Read only

0 Likes
1,261

Sorry rob,

Thought this question would be better answered in ABAP objects forum.

Can I delete a thread?

Sincerely,

goldie

Read only

0 Likes
1,261

I don't think so, but you can mark one of them as solved (without assigning points).

Rob

Read only

Former Member
0 Likes
1,261

Hello everyone,

I added the addition ACCEPTING TRUNCATION to the above statement and the current runtime error has been solved.

But now a new runtime error came up.'CONNE_IMPORT_WRONG_OBJECT_TYPE' of exception 'CX_SY_IMPORT_MISMATCH_ERROR'

This is because there is a type conflict between the structured objects.

The defn of CRT is like this


DATA:  BEGIN OF CRT .
        INCLUDE STRUCTURE PC22Y.  "Cumulated result table (USA)
DATA:  END   OF CRT.

but I dont know where the mismatch is occuring in the data cluster.

Infact I am very much confused with the data cluster structure.

How do I resolve this issue?

Any insights would be appreciated.

Goldie.

Read only

Former Member
0 Likes
1,263

You need to use CATH-EXCEPTIONS...


REPORT Z_ATG_DUMMY.

DATA: RESULT TYPE P DECIMALS 3,

NUMBER TYPE I VALUE 11.

CATCH SYSTEM-EXCEPTIONS ARITHMETIC_ERRORS = 5.
  DO.
    NUMBER = NUMBER - 1.
    RESULT = 1 / NUMBER.
    WRITE: / NUMBER, RESULT.
  ENDDO.
ENDCATCH.

SKIP.

IF SY-SUBRC = 5.
  WRITE / 'Division by zero!'.
ENDIF.

Check for what exception you need to use...

Greetings,

Blag.

Read only

0 Likes
1,261

Hi Blag,

Thanks for the tip.

But how can I correct if I encounter the exception in my case.

I dont know what is the structure of the cluster.

Can you please explain me what this code does?


IMPORT RU-VERSION TO ORU_VERSION
             CRT
        FROM DATABASE PCL2(RU) ID RX_KEY
        accepting truncation.

goldie.

Read only

0 Likes
1,261

Should be something like this...


CATCH SYSTEM-EXCEPTIONS IMPORT_MISMATCH_ERRORS = 5.
IMPORT RU-VERSION TO ORU_VERSION
             CRT
        FROM DATABASE PCL2(RU) ID RX_KEY.
ENDCATCH.
 
SKIP.
 
IF SY-SUBRC = 5.
  WRITE / 'Import Error!'.
ENDIF.

Greetings,

Blag.

Read only

0 Likes
1,261

Thank you Blag.

I figured out a way with your help.

But I am still a lil bit hazy about the data clusters concept.

Do you have any links/material where I can read about this?

Goldie.