cancel
Showing results for 
Search instead for 
Did you mean: 

How to handle error messages occured witin a FM?

Former Member
0 Kudos

Hi all,

here is the scenario:

I'm writing a program which post some kind of documents into SAP based on a flat input file with data. To post the document I'm using a complex function module. Results from post are tracked into some log-file.

Problem is:

Sometimes, due to incorrect input data, function module returns an error messages directly into a system line, but not in an output message from the FM. That brokes my flow and I'm unable to proceed with next record from my flat file.

Question is:

Is it possible to prevent error message occurance into a system line? I would like to get the error, if possible, and to pass it to my log-file instead.

Any help would be highly appreciated.

Many thanks in advance.

Regards,

Ivaylo

Accepted Solutions (0)

Answers (3)

Answers (3)

former_member534411
Participant
0 Kudos

Anand:

Pleae mail to me also.

id : suresh_karan@rediffmail.com

Thanks in Advance

Suresh Babu Karanam

nablan_umar
Active Contributor
0 Kudos

You might want to try calling that function module in background task or in separate task. Otherwise, I don't think you can skip that error messages that does not raise exception in the function module you call.

Former Member
0 Kudos

Nablan,

thanks for the suggestion. This would also broke my scenario, isn't it? I'm in a loop, and I need some step finished before to start the next one - which is not possible in case of NEW or BACKGROUND TASK.

Furthermore, FM has a CHANGING parameters - RC (returnCode) - which couldn't be accessed in case of NEW TASK or BACKGROUND TASK - there is no possibility to get CHANGING parameters in such type of CALL. So how would I get the result from the FM - means operation?

Ok, scenario seems to be not so clear. That's the way I fould until now. Perhaps I should deal with own FM which calls the original one in some way, or so... don't have a clear idea how to proceed in different way.

Any suggestions?

Thanks in advance.

Regards,

Ivaylo

Former Member
0 Kudos

If it raises an exception you can catch it.

cx_root is the root class for exceptions.

DATA: ex TYPE REF TO CX_ROOT.

TRY.

call fm.

...

CATCH cx_root INTO ex.

ENDTRY.

message = cx_root->get_text( ).

-


If it helps please give points.

Former Member
0 Kudos

Hi,

Sorry to say, CX_ROOT is missing in our system (4.6C). Furthermore, there is no any CX_... class in the repository.

Perhaps any similar?

Ivaylo

Former Member
0 Kudos

the old code is

CATCH SYSTEM-EXCEPTIONS except1 = rc1 ... exceptn = rcn.

....

ENDCATCH.

But it only catches the exceptions in current level. So

if you call any FM between catch - endcatch it will not catch the exception.

As far as I know there is no exception class in (4.6C) .

It is a new concept and works in (4.7)

Sorry I cannot help

Peter_Inotai
Active Contributor
0 Kudos

Exactly the same scenario explained in the 'A Programmer's Guide to the New Exception Handling Concept in ABAP' article, which available in SDN. You can find it via Search.

If you lucky the FM returns with a message table, like BAPIs, otherwise it will dump. This is the problem with the classical error handling, this is why class-based exception handling is much more flexible. The mentioned CX_.. class is an exception class.

You can find all the details in the article.

Regards,

Peter

Former Member
0 Kudos

Peter, unfortunately the link:

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/documents/a1-8-4/abap_exce...

returns error: 404 Die angeforderte Ressource ist nicht verfügbar.

which perhaps means document unavailable. I've found one more link, it's also broken.

Could you please pass me here a working link?

Thanks,

Ivaylo

Former Member
0 Kudos

Hi Ivaylo,

You are right, this link does not seem to be working any longer. I have downloaded this document sometime back and can email it to you.

Regards,

Anand Mandalika.

Former Member
0 Kudos

Hello Anand,

Would be great if u can pass on that document to me too.

Alternatively u can send that document to

balaji_sravan@yahoo.com.

Regards,

- PSK

Former Member
0 Kudos

Hi Anand,

thanks for the proposal. Could you please pass it to me at:

ivaylo.mutafchiev@vbs.bg

Thanks in advance.

Ivaylo

P.S. Forget it! The article is accessible at SapPro Journal (www.sappro.com) web site and I just downloaded it.

(for those who are interested, this site needs subscription)

Thanks.

Ivaylo

Message was edited by: Ivaylo Mutafchiev

eddy_declercq
Active Contributor
0 Kudos

Maybe a stupid remark, but if the FM is yours, why doesn't you simply do the error handling within the FM and generate exception which are handled in the calling report.

eg

call function 'FM'

EXPORTING

..

IMPORTING

..

EXCEPTIONS

ERROR = 1

OTHERS = 2.

if sy-subrc gt 0.

...

endif.

Former Member
0 Kudos

Eddy,

It's not stupid remark at all for me

Unfortunately, the FM I'm calling is not mine, but a 'native' IS-Oil one (in fact, there are two of them I'm calling in my program, named 'OIGI_LOADING_CREATE' and 'OIGI_DEL_CONF_CREATE') and, as I mentioned in the root of this thread, they are complex enough - in some cases they even poped-up some screen(s) - like QCI Controle, etc...

Sorry, your proposal is not an option in this case...

Thanks anyway.

Regards,

Ivaylo

ramki_maley
Active Contributor
0 Kudos

Are these FMs released for customer? We had a similar situation in a BAPI where a message statement is used for an error condition instead of returning to the calling program. We created an OSS message and SAP corrected the error.

Former Member
0 Kudos

Ramki --

well, these FMs are part of the FuGr 'OIGI > TD RFC Create/change Shipment', part of a dev.class 'OIG > TD Transport and Distribution',

application component 'IS-OIL-DS-TD > Transportation and Distribution',

software component 'IS-OIL > IS-OIL 46C'.

It seems it is released for customer, isn't it? As I mentioned (or not? it doesn't behave as a 'normal' BAPI - there are lots of error messages tracked into a system message line instead of FM-interface, and there is even a situation, when in some mess in an input data, pop-up screen/s occurs.

Perhaps that's the way I should follow - to open a customer message at oss.

Thanks,

Ivaylo