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

Exception to stop further processing in program

Former Member
0 Likes
5,731

Hi,

I am writing enhancement in BADI SD_COND_SAVE_A for VK11 and VK12.

This BADI execute when we press save button in VK11/12.

There are some condition which i am checking by this BADI. i want to stop the save processing.

Which command should i use for it to stop processing of saving. i dont want to come out from screen just stop processing.

regards

Malik

22 REPLIES 22
Read only

surajarafath
Contributor
0 Likes
3,842

You can use

MESSAGE TYPE 'E' TO stop the saving process, it will not proceed further.

Read only

0 Likes
3,842

thanks for your reply.

when i stop the processing using message Type 'E' its bring me back to VK11 but in display mode

and i can not change the thing which cause exception.

How to handel it.

regards

Malik

Read only

Former Member
0 Likes
3,842

Hi,

check your the code as per your condidtion. If condition fails then write 'break-point' in between. so that the cursor will stop at that point. and if you want to pass any error message you can write after that.

Ram.

Read only

0 Likes
3,842

My Code is like this but its not stopping on break-point.

CALL FUNCTION 'POPUP_TO_DECIDE'
  EXPORTING
*   DEFAULTOPTION           = '1'
    TEXTLINE1               = 'Validity Period is more than 30 Days'
    TEXTLINE2               = 'Do You Want To Change Validty Period'
*   TEXTLINE3               = ' '
    TEXT_OPTION1            = 'Yes'
    TEXT_OPTION2            = 'No'
*   ICON_TEXT_OPTION1       = ' '
*   ICON_TEXT_OPTION2       = ' '
    TITEL                   = 'Validity Warning'
*   START_COLUMN            = 25
*   START_ROW               = 6
*   CANCEL_DISPLAY          = 'X'
 IMPORTING
    ANSWER                  =  v_answer
          .
if v_answer = '1'.
  break-point.
*MESSAGE 'Further Processing are stopped'  TYPE 'E'.
endif.

Read only

0 Likes
3,842

Do You want to stop the process at POP UP itself ???

Read only

0 Likes
3,842

Yes. If use choose Yes but means button Number 1 it should stop the process and bring me back to vk11

screen to check and change the validty period.

If use choose NO Button (Button Number 2 ) then it should go for further processing without stopping.

Regards

Malik

Read only

0 Likes
3,842

Hi Malik,

I Just now seen the documentation of 'POPUP_TO_DECIDE' FM

SAP suggested not to use this FM, its Obsolete, instead of this FM, use FM

POPUP_TO_CONFIRM

Read only

0 Likes
3,842

Hi Malik,

Above code will triggers one POPUP Screen with YES, NO, CANCEL options.

If you press YES then only your BREAK-POINT will trigger.

Regards,

Surya

Read only

0 Likes
3,842

Also Try,..(not sure)

if v_answer = '1'.

LEAVE TO SCREEN 0.

LEAVE SCREEN.

*break-point.

*MESSAGE 'Further Processing are stopped' TYPE 'E'.

endif.

Read only

0 Likes
3,842

Dear if i put message type E statement its stopped and go to the screen.

But now the problem is its come back in display mode and if i press enter button its give me a message

$$00000001 in function Group

and program is terminated.

Regards

Malik

Read only

0 Likes
3,842

Hi,

Try using 'LEAVE to TRANSACTION vk11' statement on clicking 'Yes'.

Read only

0 Likes
3,842

Following error is comming while compiling the code.

Field "VK11" is unknown. It is neither in one of the specified tables

nor defined by a "DATA" statement . . . . . . . . . .

Read only

0 Likes
3,842

You use FM POPUP_TO_CONFIRM instead of POPUP_TO_DECIDE

and test.

For Message TYPE 'E'.. You use

MESSAGE TYPE 'S' DISPLAY LIKE 'E'.. 
RETURN.

test..

Read only

0 Likes
3,842

no its did not stop the process. its saved the record.

Read only

0 Likes
3,842

Did you check the F1 documentation for the correct format of this statement, but still let me write it for you:-

LEAVE TO TRANSACTION 'VK11'.

Read only

0 Likes
3,842

May be this is not the right BADI to include your custom validation,

Rgds,

Antony

Read only

surajarafath
Contributor
0 Likes
3,842

I think there is no other way to stop the processing in this case expect

"MESSAGE TYPE 'E' "

You should do something after it happens. (***

or else...

you use

**WHILE v_answer NE '1'.**
**<....yOUR fm IS HERE ...>**
**ENDWHILE.**

it will not stop the loop untill other than option 1 .

Read only

kesavadas_thekkillath
Active Contributor
0 Likes
3,842

You can see this badi getting called in function SD_CONDITION_SAVE_EXIT which is a update function( Reason why the debugger is not stopping, activate update debugging). You should not raise message inside it.

when i stop the processing using message Type 'E' its bring me back to VK11 but in display mode

And i wonder how this happens to you. It should abort the screen

Kesav

Read only

0 Likes
3,842

Then where i can put validation for vk11.

while SD_COND_SAVE_A is update badi.

any help will be higly appricated.

Regards

Malik

Read only

0 Likes
3,842

Have a look into 00503305 [Dynamic Field Check in Condition Maintenance|http://help.sap.com/saphelp_470/helpdata/en/08/c81b18e83511d2ace30000e8a5bd28/content.htm]

Read only

0 Likes
3,842

Hi Malik,

After calling POPUP_TO_CONFIRM in case YES is chosen, you could use POPUP_TO_GET_ONE_VALUE in a WHILE loop and force the user to enter a valid period. Then update the data by using a field symbol reference...

Altough this is not a really glamourous solution, I'm pretty sure this should work...

Kr,

Manu.

Read only

Former Member
0 Likes
3,842

Hi,

Try this.

IF sy-subrc = 0.

CALL FUNCTION 'MESSAGES_INITIALIZE'. "clear the buffer messages

CALL FUNCTION 'MESSAGE_STORE' "add your message

EXPORTING

arbgb = 'ZZZZ' "Message class

msgty = 'E' "Message type

txtnr = '094'. "Message number

CALL FUNCTION 'MESSAGES_SHOW'.

CALL FUNCTION 'MESSAGES_INITIALIZE'.

MESSAGE ' ' TYPE 'E' RAISING error.

EXIT.

ENDIF.

Thanks,

Anitha A