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: 

How to "catch" ERROR_MESSAGE

Former Member
0 Kudos

Hello,

i´ve written a FM which also calls SAP FM´s.

Somewhere there is this statement:

else.

message w207(m7) with ymcha-charg ymcha-matnr.

endif.

This line throws an error... Because the FM is used in a job, this job aborts.

What can i do? I dont want to change the sap code?

10 REPLIES 10

Former Member
0 Kudos

Hi

All the standard SAP FM's have a return structure where the errors get stored. All u have to do is to pass internal table to it and then catch the error and where it is happening.

Regards,

Vishwa.

0 Kudos

Hello,

the FM i call is BAPI_BATCH_CHANGE.

This FM returns no table, it shows a naked screen with the error message

0 Kudos

Hi

Check this:

data: it_ret type standard table of bapiret2,
        wa_ret type bapiret2
CALL FUNCTION 'BAPI_BATCH_CHANGE'
  EXPORTING
    MATERIAL                 =
    BATCH                    =
*   PLANT                    =
    BATCHATTRIBUTES          =
    BATCHATTRIBUTESX         =
*   BATCHCONTROLFIELDS       =
*   INTERNALNUMBERCOM        =
*   EXTENSION1               =
*   MATERIAL_EVG             =
 IMPORTING
*   BATCHATTRIBUTES          =
 TABLES
   RETURN                   =  it_ret  " this is the table I am talking about.

Once u execute the bapi, the errors get stored in here..which can be passed onto a loop and using write can be displayed.

Loop at it_ret into wa_ret.

write: / wa_ret-message.

endloop.

0 Kudos

Are you passing the parameter RETURN of type BAPIRET2 to this bapi when you call the function ?

regards,

Advait

0 Kudos

Hello,

i do it like you described...

If the FM runs on the code line above, it immediate stopps the logic and shows a blank screen with the error message. i debuged it...

0 Kudos

Hello,

This BAPI has the return table RETURN that return all messages regarding the execution.

Regards.

0 Kudos
If the FM runs on the code line above, it immediate stopps the logic and shows a blank screen with the error message. i debuged it...

I failed to understand the reply. Does it mean your issue is resolved or

Can u please tell me where does the issue stand?

Regards,

Vishwa.

0 Kudos

No it is not resolved. The hints doesnt work. Error ist still the same.

The Calling of the FM:

CALL FUNCTION 'BAPI_BATCH_CHANGE'

EXPORTING

material = ls_bapibatchkey-material

batch = ls_bapibatchkey-batch

plant = ls_bapibatchkey-plant

batchattributes = ls_bapibatchatt

batchattributesx = ls_bapibatchattx

batchcontrolfields = ls_bapibatchcontrolfields

  • INTERNALNUMBERCOM =

  • EXTENSION1 =

IMPORTING

batchattributes = ls_bapibatchatt

TABLES

return = lt_return.

And then the steps of the program:

BAPI_BATCH_CHANGE

VB_CHANGE_BATCH

CHARGE_KLASSIFIZIEREN => here it breaks in line 69

0 Kudos

Hi,

Sorry you cannot do anything about it. It is standard code and if the job is getting cancelled, it is normal behavior of the program and it seems some config related to Batches and Classes is missing in your system. Because the message says :

For batch & of material & &, no class could be determined

So if you correct that problem, you will not get that error anymore.

regards,

Advait.

Former Member
0 Kudos

It appears to be missing configuration. Have you checked the long text for the message?

Rob