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: 

Why does MESSAGE not work?

Former Member
0 Kudos

Hello, experts!

I put my code in BADI ME_PROCESS_PO_CUST's method CLOSE() and did some enhancement. I add MESSAGE 'test' TYPE 'I'. without any judgement, but nothing happened. Could you tell me what is wrong with my code?

Thanks a lot!

1 ACCEPTED SOLUTION

Sougata
Active Contributor
0 Kudos

The doco of the CLOSE( ) method clearly states:

Functionality

The CLOSE method enables you to reset your own programs.

This method is invoked either directly after posting (POST method) or before the next document is opened (OPEN method).

Parameters

The following parameters are available:

  • IM_HEADER - Document header
    The interface reference is of the type IF_PURCHASE_ORDER_MM.

Notes

Under no circumstances make any changes to the database within this method. On no account use Commits.

And that's exactly what you are doing i.e. by coding MESSAGE statement directly in the BAdI you are generating implicit commits to interrupt the update work process.

There are no parameters in this (or any other methods) in this BAdI to transfer messages back to the system - so why are you doing this anyway?

15 REPLIES 15

Former Member
0 Kudos

Hi,

Try to put a hard break-point and check, whether this line is getting executed????

This BADI will store messages in logs. So you might get your test message in log generated while saving.

0 Kudos

Hi, Sumit! I'm sure that this line is executed. And could you tell me how  to check the logs you pointed in the second paragraph?

Former Member
0 Kudos

Since it is a BADI you should only use "S" (successor) messages and "E" (error) messages.

This is a general rule.

"S" messages are displayed on the next available screen,when processing stops or is interrupted.

"E" messages terminate the BADI completely. And if not cached (via TRY .. ENDTRY) terminates also the program.

Regards,

Robbie.

0 Kudos

Hi, Robbie! I tested "S" and "E" messages just now, but they didn't work either...

0 Kudos

Hi Shelwin

Basically you are trying to create inbound delivery even when the PO is still locked or being generated. I dont think it will allow you to. You will haev to use other options.

  • Add your creation triggering via output type.
  • Or creation on event

Nabheet

0 Kudos

Hi, Nabheet! Thank you for your directions!

I debugged and found that PO had been created physically because I can searched it out by PO number in EKKO and EKPO when going into COLSE( ). And after execution of CLOSE( ) which contains my enhancement code, inbound delivery for PO can be truly created.

But my problem here is that I cannot give an error message if the FM falied to create inbound delivery. I tried 3 methods:

1) ABAP key word 'MESSAGE';

2) CALL FUNCTION 'MESSAGE_STORE'
     EXPORTING
       arbgb                         = 'ZTEST'
       exception_if_not_active       = 'X'
       msgty                         = 'E'
       msgv1                         = lv_po_num
*     MSGV2                         = ' '
*     MSGV3                         = ' '
*     MSGV4                         = ' '
       txtnr                         = '000'
*     ZEILE                         = ' '
*   IMPORTING
*     ACT_SEVERITY                  =
*     MAX_SEVERITY                  =
    EXCEPTIONS
      message_type_not_valid        = 1
      not_active                    = 2
      OTHERS                        = 3.

Message Class 'ZTEST':

000 Failed to create inbound delivery for purchase order &.

After execution of this FM, sy-subrc = 2.

But my message in message class is saved and message class is in active state.


3) MESSAGE e000(ztest) WITH lv_po_num INTO lv_dummy.
  mmpur_message_enaco sy-msgty sy-msgid sy-msgno
                                       sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

However, no message showed out...

0 Kudos

Hi Shelwin

You can not throw messages here.. Is it called in update mode..? The best thing will be to send an email in case of any error to concerned person

Nabheet

Former Member
0 Kudos

Hi Shelwin,

Just a guess, is the BADI called in update mode i.e. after pressing Save button. If so then i think you will not be able to see messages.

As suggested debug is best option.

BR.

0 Kudos

Hi, Ankit! It is executed in ME21N after pressing Save button, and in debug mode I found it is indeed executed. By the way, why can't I see the messages in update mode please?

0 Kudos

Shelwin Wei wrote:

By the way, why can't I see the messages in update mode please?

Because it is running in an Update Work Process - there is no GUI available to the system at that point in time!! How do you expect to "see" the message?

0 Kudos

Hi Shelwin,

As mentioned by Sougata, in update mode no GUI is available to the user for interaction. Update mode means the processing which happens post SAVE and sort of in background mode. So it basically violates the idea of associating a session with it where you can see messages and act accordingly. Update work processes are mostly non interactive and do not expect any user intervention/response.

BR.

Sougata
Active Contributor
0 Kudos

The doco of the CLOSE( ) method clearly states:

Functionality

The CLOSE method enables you to reset your own programs.

This method is invoked either directly after posting (POST method) or before the next document is opened (OPEN method).

Parameters

The following parameters are available:

  • IM_HEADER - Document header
    The interface reference is of the type IF_PURCHASE_ORDER_MM.

Notes

Under no circumstances make any changes to the database within this method. On no account use Commits.

And that's exactly what you are doing i.e. by coding MESSAGE statement directly in the BAdI you are generating implicit commits to interrupt the update work process.

There are no parameters in this (or any other methods) in this BAdI to transfer messages back to the system - so why are you doing this anyway?

Former Member
0 Kudos

Thank you for your directions, Sougata!

I'm really fresh to SAP and ABAP development. What you said is a great help to me.

The reason why I use MESSAGE in this BADI is that I want to call a function module (BBP_INB_DELIVERY_CREATE, to create inbound delivery according to the new created PO) inside method CLOSE( ) of this BADI, and I should give a message if the inbound delivery creating process failed. So I want to test if MESSAGE is OK in CLOSE( ). However, the MESSAGE line is really executed in debug mode and nothing happened.

Could you tell me how to solve it? Many thanks!

Sougata
Active Contributor
0 Kudos

You cannot - the parameter of the BAdI Method CLOSE( ) do not allow this - as a result the system simply ignores it when you force a direct MESSAGE statement.

Remember that you are dealing with an Object here; which is the BAdI and its implementing class (which you have used to implement the method CLOSE ). It is not procedural like a Function Group (which are used to implement a classic/CMOD User-Exit) that one can code a MESSAGE statement anywhere in the function exit to display a message to the user.

You are bound by the parameters of this Object (i.e. the BAdI) so you can send messages to the user if only the parameters of the Method allow you to do so.

I recommend you read up on some basic OO concepts from SAP Help.

Sougata.

0 Kudos

I feel Close() method will call as like a refreshing of the transaction. so whatever message we will give will replaced with the sap standard messages those are executed after your messages.

Try Debugging with MESSAGE statement in debug mode (Using F9 in debug enter MESSAGE ABAP command)