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

user exit message only once

former_member576008
Active Participant
0 Likes
5,005

Hi

I am currently working on a SD requirement, in VA01 after giving sold to party details on enter it should raise a warning message comparing few conditions.

Yes it is pretty easy, i am using user exit MV45AFZZ and routine USEREXIT_MOVE_FIELD_TO_VBAK.

While testing the warning message is displaying again and again like after enter sold to party, its displaying the warning message.

again if we give any line item again the code is executed and displaying the warning message.

If we miss any header data along with that message first warning message is displayed and then missing data message is displaying.

Can some one tell me how to display this only once.

PS: I can do this using EXPORT and IMPORT a flag to memory, but is there any other better way?

Regards,

NK

Hi

I am currently working on a SD requirement, in VA01 after giving sold to party details on enter it should raise a warning message comparing few conditions.

Yes it is pretty easy, i am using user exit MV45AFZZ and routine USEREXIT_MOVE_FIELD_TO_VBAK.

While testing the warning message is displaying again and again like after enter sold to party, its displaying the warning message.

again if we give any line item again the code is executed and displaying the warning message.

If we miss any header data along with that message first warning message is displayed and then missing data message is displaying.

Can some one tell me how to display this only once.

PS: I can do this using EXPORT and IMPORT a flag to memory, but is there any other better way?

Regards,

NK

22 REPLIES 22
Read only

Former Member
0 Likes
4,103

This message was moderated.

Read only

former_member576008
Active Participant
0 Likes
4,103

Isn't it possible, please advise.

Read only

Former Member
0 Likes
4,103

Hello.

Do the validation at the moment to save the document. So the message will be showed one time.

Regards

Read only

0 Likes
4,103

Hi Miguel,

I need this on ENTER, after entering material and quantity at item level

Read only

0 Likes
4,103

Hi NK,

I don't like to use memory either but in this case I think it will be the most easy (maybe the only) way to.

But use IMPORT/EXPORT instead, this flag checking will be done in same session.

Regards,

Edgar

Read only

0 Likes
4,103

Hi Edgar,

I have created a structure with sold to party and a flag, first time after displaying the message i am exporting this to memory when it comes second time checking the flag is initial or not and also the customer is same or not. If not( for different customer) it should raise the warning message.

This was working perfectly, but in a case say, i have given the sold to party and got the warning message, instead taking a new screen went back(va01 main screen) and came in. This time again giving the same details, but message is not coming. Because the message was already raised and same customer. The session was not cleared. Though this is rare case, anyway to overcome this,

Regards,

NK

Read only

0 Likes
4,103

Hi NK,

Sorry for delay in reply, I guess we're in opposite time zones.

Okay, so whenever you move back to VA01 main screen (to start over new document?) your logic becomes to not work, right? If yes, what you would need to do is to put an initialization routine for your flag in memory and make it "marked" once again. You can do it by adding a routine to MV45AOZZ (but would also need to change screen 8309).

Regards,

Edgar

Read only

0 Likes
4,103

Hi Edgar,

right, i will try that and let you know. yeah i am in CST zone.

regards,

NK

Read only

0 Likes
4,103

Hi A N,

you don't need to add a new form or to modify screen 8309.

There is already a USER-EXIT wich is called befor each new PO: USEREXIT_REFRESH_DOCUMENT

As I already written: Instead using the IMPORT/EXPORT TO MEMORY just define a globale variable in INCLUDE MV45ATZZ. This variable should start with ZZ so you will be save, that there is no varibale defined by SAP with the name.

So your coding could look like:

INCLUDE MV45ATZZ:

* New flag, to store the information on

DATA: zz_message_soldto TYPE kunnr.

FORM USEREXIT_REFRESH_DOCUMENT

*a new PO is oppend, clear the flag here

CLEAR zz_message_soldto.

ENDFORM

FORM MOVE_FIELDS_TO_VBAK.

* Check if message needs to be raised

IF zz_message_soldto <> vbak-kunnr.

* Check your conditions here:

IF condition are full filled:

* remeber the sold-to

zz_message_soldto = vbak-kunnr.

* Raise the message

MESSAGE 'My Message' TYPE 'S' DISPLAY LIKE 'E'.

ENDIF.

ENDIF.

ENDFORM.

Regards Hendrik

Read only

0 Likes
4,103

Yep, I guess my approach was not the best one, sorry for that...

Did a quick checking in system I have and saw same kind of development there but, indeed, was not the best way to do it.

Hendrik's approach is better.

Regards,

Edgar

Read only

0 Likes
4,103

Hi Edgar & Hendrik,

Thank you for your replies, i have managed with import/export as of now. busy with other objects now, will do the suggested changes soon. thank you.

Regards,

NK

Read only

Former Member
0 Likes
4,103

Hi N K,

As Edgar said the only option is to set a flag, import and export is the only option. You may check for any counter if you find any but the best option is to set a flag and check it.

Read only

0 Likes
4,103

You could define a global variable in INCLUDE MV45ATZZ (pls. remeber the name space for gloable variable: they need to start with ZZ).

The globale variable need to be cleared within user-exit: USEREXIT_REFRESH_DOCUMENT in case of a new order.

Regards Hendrik

Read only

Former Member
0 Likes
4,103

Hi,

Fetch all sold to party details that you are entering from the import parameter of  exit and use those details in if condition stating not initial and after that write your validations and check and let me know .

Regards,

Suman

Read only

Former Member
0 Likes
4,103

Hi,

In this case you can also use a static variable and use it as a flag.The psuedo code could be like:

check l_flag is initial

...

Warning message.

BR

Nitin

Read only

0 Likes
4,103

Hi nitin,

if you use a static variable, it should not be only a flag.

When will the flag be cleared if the user save the first order and starts to work on a new order, without leaving the transaction?

You would need to store the sold-to no. in a static variable and check if the sold to no. is changed. This would give you a bit of security, but what will happen if the user work on two orders with the same sold to?

Regards Hendrik

Read only

0 Likes
4,103

Hi,

If this does not work, then there is one more way out.You can display the warning message as a status message.I think that will be displayed only once.

BR

NItin Kacker

Read only

0 Likes
4,103

Hi Nitin,

Could you let me know how to use status message to my scenario. many thanks.

Regards,
NK

Read only

0 Likes
4,103

Hi,

The idea is that you trigger a usual status message in the code , like;

message s001.

I think the message is similar in all the cases, so,in this case, the system will display it only once.This I have seen in one of the objects.

Even, if this does not work, then you can collect all the messages in a memory and then display it in the ALV_POP_UP_DISPLAY, like you get in the enjoy transactions like PO etc.You can collect all the messages and trigger the ALV at the time of save.Please try this out and let me know, if you still face any problem.

BR

Nitin

BR

NItin Kacker

Read only

Former Member
0 Likes
4,103

did u try checking some other user-exit or BADI..

Read only

Former Member
0 Likes
4,103

Hello, if you are sure that you cannot achieve this in any other exit, why not try STATICS parameter?

Read only

koolspy_ultimate
Active Contributor
0 Likes
4,103

Hi NK

Just use the below code

FORM USEREXIT_MOVE_FIELD_TO_VBAK.


statics static type i.
   static = static + 1.


if static = 1.
message 'Check Region Code of the Customer' type 'I'.  """""enter your required message

endif.


ENDFORM.

Regards,

Madhumahesh.