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

LEAVE SCREEN Code

Former Member
0 Likes
2,531

Dear Experts,

In following code , LEAVE SCREEN statement is not working. When I check the EXIT CHKBOX, EXIT contains the "X", but it does not leave the screen. It goes back to input field.

Can anyone has idea.


tables :zekko.

data : EXIT(1) TYPE C
data : wa_ekko like zekko.


*&---------------------------------------------------------------------*
*&      Module  INIT_SCREEN_100  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE INIT_SCREEN_100 OUTPUT.

  MOVE-CORRESPONDING WA_EKKO TO ZEKKO.
  CLEAR WA_EKKO.
*  CLEAR WA_EKKO.

ENDMODULE.                 " INIT_SCREEN_100  OUTPUT

*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_0100  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE USER_COMMAND_0100 INPUT.

  move zekko-ebeln to wa_ekko-ebeln.
  SELECT SINGLE
      EBELN BUKRS BSART LOEKZ AEDAT ERNAM LIFNR
      INTO CORRESPONDING FIELDS OF WA_EKKO
      FROM EKKO
      WHERE EBELN eq WA_EKKO-EBELN.

  IF EXIT NE SPACE.  "zekko-mark = 'X'.
    LEAVE SCREEN.
  ENDIF.

ENDMODULE.                 " USER_COMMAND_0100  INPUT
 

Maverick

15 REPLIES 15
Read only

Former Member
0 Likes
2,041

try LEAVE PROGRAM instead of leave screen

Read only

Former Member
0 Likes
2,041

Hi

Try like this.

SET SCREEN 0.

LEAVE SCREEN.

CLEAR screen.

if it is also not working means...use Pf-status..

Read only

Former Member
0 Likes
2,041

Maverick, for your code to work, use the following alternatives if your intention is to leave the current screen sequence.

1) Go to the attributes of screen 100, and change the 'NEXT SCREEN' attribute from 100 to 0. Activate the screen.

OR

2) Instead of LEAVE SCREEN, say LEAVE TO SCREEN 0.

Otherwise, if your intention is to exit the program, use LEAVE PROGRAM.

Regards,

Arun

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
2,041

Hello,

Time to read the online help for LEAVE SCREEN also check the demo program SAPMDEMO_SCREEN_FLOW on how the screen sequences behave.

As suggested just change the LEAVE SCREEN to LEAVE TO SCREEN 0 (you can also use SET SCREEN 0. LEAVE SCREEN if you want to )

BR,

Suhas

Edited by: Suhas Saha on Mar 3, 2010 11:48 AM

Read only

Former Member
0 Likes
2,041

Hi,

MODULE USER_COMMAND_0100 INPUT.
 
  move zekko-ebeln to wa_ekko-ebeln.
  SELECT SINGLE
      EBELN BUKRS BSART LOEKZ AEDAT ERNAM LIFNR
      INTO CORRESPONDING FIELDS OF WA_EKKO
      FROM EKKO
      WHERE EBELN eq WA_EKKO-EBELN.
 
Make sure the Screen field name should be EXIT then only data transfer takes place. or move explicitly

Change this and Check.
 move ZEKKO-MARK  to EXIT." This moves the value ZEKKO-MARK to EXIT.

  IF  EXIT NE SPACE 
    LEAVE SCREEN.
" LEAVE TO SCREEN 0.
" LEAVE PROGRAM.
" LEAVE TO TRANSACTION etc
  ENDIF.
 
ENDMODULE.                 " USER_COMMAND_0100  INPUT

Cheerz

Ram

Read only

0 Likes
2,041

Hi Ram

I hv set the NEXT SCREEN 0 of screen atributes.

and tired LEAVE SCREEN and SET SCREEN 0.

Now the prob is hen i press ENTER it leaves the screen even without checking the EXIT chkbox.

Can u suggest.

Maverick

Read only

0 Likes
2,041

Hi Maverik44,

I think you should check the value of "EXIT" variable using debugger.

I would suggest you to apply a "break point" on the line

IF  EXIT NE SPACE 

and check the value of "EXIT" by double clicking the variable in the debugger (it will automatically open, once you execute)

there is a probably that the value of "EXIT" being not equal to SPACE and hece the code gets executed automatically.

also, I suggest you to use the code


  IF  EXIT NE SPACE 
 LEAVE TO SCREEN 0.
  ENDIF.

ByTheWay.................

is the the actual code of our MODULE or the trimmed version??

because I cannot see any CASE STATEMENT or OK_CODE code correspondence of the button .

Regards,

Shravan Parepalli.

Read only

0 Likes
2,041

Hi Shravan

Thanks for ur reply.

I hv not used any button. I hv used a CHKBOX instead. and checking the vale of same.

And as u suggested, i used break-point, and found EXIT is equal to SPACE. But still the prob is same. Program is exiting unexpedtly.

And u can refer the full code in my post. (question).

Maverick

Read only

venkat_o
Active Contributor
0 Likes
2,041

Hi, <li> I think that you are using only one screen. You have one check box and checking and pressing ENTER i believe. I don't know where do you want to leave by writing 'LEAVE SCREEN'. <li>If you want to leave the program by checking the check box , write below code .

IF EXIT NE SPACE.  "zekko-mark = 'X'.
    LEAVE PROGRAM. "It comes out of the program . 
  ENDIF.
Thanks Venkat.O

Read only

Former Member
0 Likes
2,041

Hi,

In case if you returned your code exact code which is working in irrelavant events such as PBO or PAI you need to check that properly.

IF you are using function exit for the exit button try changing the value to 'E' instead of 'X' play with those things and it will get exited.

Try and change these options when using LEAVE TO SCREEN statements in Module programming.

Regards,

~Sakthi.

Read only

Former Member
0 Likes
2,041

Dear Maverick,

See your PAI will trigger only after any user action.

If you press enter then your PAI will trigger and your code executes and its exiting.

control with usercommand (sy-ucomm). create an function code in menu painter for enter key and in your PAI check the condition as

IF SY_UCOMM = 'ENTER'.

if CH_BOX = 'X'.

leave to screen 0. or whatelse u need.

endif.

endif.

Hope this will help you.

If not please explain me the requirement clearly i will give u the solution.

Read only

Former Member
0 Likes
2,041

Dear All

Thanks alot for ur guidence.

The prob was I had set the NEXT SCREEN 0 ( as suggested) and using the leave screen statement.

I supposed to set the NEXT SCREEN 0100 and use LEAVE PROGRAM statement ( as i m using single screen only).

Now its working fine.

Thanks alot once again.

Maverick

Read only

0 Likes
2,041

Maverick,

please don't forget the forum rules about how to say thank you to those people who helped you significantly.

As I see that you finally used LEAVE PROGRAM, which is not really a good practice for leaving a screen, I try to explain how it works, I hope that you'll change your mind

1) You display the first screen by using CALL SCREEN dynpro_number. It starts what is called a screen sequence.

2) The PBO logic is executed, then the screen is displayed

3) After you pressed a key, the PAI logic is executed

4) After the last PAI module has been executed, SAP displays the next dynpro number defined in the dynpro definition.

5) Dynpro number 0 has a special meaning, it means that the current screen sequence (initiated by CALL SCREEN) has to terminate, i.e. the CALL SCREEN terminates.

You may use these statements to change the logic:

- [SET SCREEN dynpro_number|http://sandraros.free.fr/abap_docu.htm?url=ABAPSET_SCREEN.htm]: it overrides the next dynpro number defined statically in the dynpro. Note: it is taken into account only when the PAI logic is left.

- [LEAVE SCREEN|http://sandraros.free.fr/abap_docu.htm?url=ABAPSET_SCREEN.htm]: jumps immediately to the end of the last PAI module

- LEAVE TO SCREEN dynpro_number = exactly SET SCREEN dynpro_number followed by LEAVE SCREEN

For more information, see [Screen Sequences|http://sandraros.free.fr/abap_docu.htm?url=ABENDYNPRO_FLOW_ABEXA.htm]

Read only

0 Likes
2,041

Sandra Rossi

Thanks alot for ur explanation for LEAVE PROGRAM and LEAVE SCREEN statement.

"please don't forget the forum rules about how to say thank you to those people who helped you significantly."

I think from the above statement u mean I should give points to relevant answer.

I do take care for this but none of answers were rite.

Let me explain.

I m using only one scree.

I hv 5 button on screen and one I/O field..

When I press any button its get displayed in I/O field. AND when I press EXIT BUTTON (the 5th one) It should exit the program.

But what was happening, If I set the NEXT SCREEN 0 and write LEAVE SCREEN statement, it just leave the program even I press any button except EXIT. Its doe not wait to display the result in I/O fields.

AND when i set the NEXT SCREEN 100 and use LEAVE PROGRAM it works fine.

I dont hv much idea about screen programming. I just learning by my own with the help of experts like u.

Thanks alot once again.

Maverick

Read only

0 Likes
2,040

> But what was happening, If I set the NEXT SCREEN 0 and write LEAVE SCREEN statement, it just leave the program even I press any button except EXIT. Its doe not wait to display the result in I/O fields.

I guess the EXIT button was defined as type E, which means that screen values are not transferred to the variables. So, change the button type to space.

If you define dynpro attribute "next screen" as being 0, it means that the screen will always close except if you use SET SCREEN <your dynpro number>. I advise you to let "next screen" attribute equal to the dynpro number, and use SET SCREEN 0 when the exit field is X.

> AND when i set the NEXT SCREEN 100 and use LEAVE PROGRAM it works fine.

you don't need to set the next screen if you use LEAVE PROGRAM