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

how to exit from module pool screen if required fields are initial

Former Member
0 Likes
11,842

Hi,

  Im developing a module pool screen in which a screen is designed with certain fields and those fields are mandatory fields, and i want to exit from the screen when the mandatory fields are Initial it-self, How to achieve this

1 ACCEPTED SOLUTION
Read only

kethanuppalapati
Explorer
6,085

Hi Lokesh,

To exit from the module pool screen when the fields are mandatory you need to use At Exit Command.

Create a button or use any button in the starndard tool bar and set their function type as 'E'. Assume you gave function code as 'EXIT' Now creat a module under PAI to write your logic.

PAI.

Module  AT_EXIT_COMMAND AT EXIT-COMMAND.

MODULE AT_EXIT_COMMAND INPUT.

CASE SY-UCOMM.

   WHEN 'EXIT'.

     LEAVE PROGRAM.

   ENDCASE.

ENDMODULE.      


When you click on the button system will ignore all other conditions and will look for At exit command module and excute the code.


Regards,

Kethan

Hi Lokesh,

To exit from the module pool screen when the fields are mandatory you need to use At Exit Command.

Create a button or use any button in the starndard tool bar and set their function type as 'E'. Assume you gave function code as 'EXIT' Now creat a module under PAI to write your logic.

PAI.

Module  AT_EXIT_COMMAND AT EXIT-COMMAND.

MODULE AT_EXIT_COMMAND INPUT.

CASE SY-UCOMM.

   WHEN 'EXIT'.

     LEAVE PROGRAM.

   ENDCASE.

ENDMODULE.      


When you click on the button system will ignore all other conditions and will look for At exit command module and excute the code.


Regards,

Kethan

14 REPLIES 14
Read only

former_member188827
Active Contributor
0 Likes
6,085

You can make use of back,exit and cancel buttons to do so. Design a gui status for your module pool.

Regards

Read only

Former Member
0 Likes
6,085

Hi,

Check for the detail documentation or demo program in sap ( demo_dynpro*)

you have to handle it like below in other words

The' At Exit' is used in flow logic in module pool . When we click on back button it will bypass the required filed checks.

Code for AT EXIT-COMMAND in flow logic and in module pool program can be written as follows.

In Flow Logic:

PROCESS AFTER INPUT.

MODULE EXIT AT EXIT-COMAND.

In Module Pool Program:

MODULE EXIT.

Read only

Former Member
0 Likes
6,085

Hi,

   With out filling the mandatory fields you want to skip the screen then why you put those fields as mandatory. What is your exact requirement.

Use this function module in PBO of the particular screen.

if 'Mandatory fields ' are initial.

call function

'SAPGUI_SET_FUNCTIONCODE'

endif.

Read only

0 Likes
6,085

Hi Krishna,

The user get into transaction, But he don't want to process further and he want to exit the transaction at that time if he press the back button it has to go back to initial screen, due to the mandatory field it will not process any PAI, and it will throw error as fill required fields, it's not a good user interface .

To avoid this SAP provide an option AT-EXIT command and we can create icon or user command as type 'E'.

If the user press the exit commands then the AT-EXIT module will be processed automatically without checking the mandatory fields.In which we can write our logic to exit the screen or to process for next screens.

Regards,

KK

Read only

0 Likes
6,085

Hi,

   Try with this function module.

CALL FUNCTION 'SAPGUI_SET_FUNCTIONCODE'

                             EXPORTING

                               FUNCTIONCODE                 'Exit function code'

*                            EXCEPTIONS

*                              FUNCTION_NOT_SUPPORTED       = 1

*                              OTHERS                       = 2

                                      .

                            IF sy-subrc <> 0.

* Implement suitable error handling here

                            ENDIF.

Read only

arivazhagan_sivasamy
Active Contributor
0 Likes
6,085

Hi Lokesh,

If you want to avoid automatic input check(Mandatory, foreignkey value and proper field format) in standard toolbar, please make that icon as type 'E'.

Then in flow logic,

After the PAI event.

Module mod at exit-command.

Arivazhagan S

Read only

sivaganesh_krishnan
Contributor
0 Likes
6,085

Hi lokesh,

Consider that if your screen has mandatory fields and if you press enter or any other key the error message keeps on coming . So to avoid this you can code your exit code in special modules .

In the opening screen of our custom screen in PAI , create a module like

Module exit at exit-command.

after that double click on the exit , and write your normal coding for exit like Leave to screen 0 or etc., )

you can also alter the code as you wish .

Regards,

Sivaganesh

Read only

kethanuppalapati
Explorer
6,086

Hi Lokesh,

To exit from the module pool screen when the fields are mandatory you need to use At Exit Command.

Create a button or use any button in the starndard tool bar and set their function type as 'E'. Assume you gave function code as 'EXIT' Now creat a module under PAI to write your logic.

PAI.

Module  AT_EXIT_COMMAND AT EXIT-COMMAND.

MODULE AT_EXIT_COMMAND INPUT.

CASE SY-UCOMM.

   WHEN 'EXIT'.

     LEAVE PROGRAM.

   ENDCASE.

ENDMODULE.      


When you click on the button system will ignore all other conditions and will look for At exit command module and excute the code.


Regards,

Kethan

Read only

0 Likes
6,085

Nice Kethan, don't forget that in PF-STATUS the function code EXIT has to be defined with function type 'E'

Read only

nabheetscn
SAP Champion
SAP Champion
0 Likes
6,085

Please use MODULE at exit-command in PAI

Read only

Former Member
0 Likes
6,085

Use AT EXIT-COMMAND command..

See this thread

Read only

atul_mohanty
Active Contributor
0 Likes
6,085

Create a module with AT EXIT Command in the  PROCESS AFTER INPUT of the screen that you are designing,

Example - Program SAPMV45A Screen no -101 for transcation VA01

   MODULE FUNKTION_AUSFUEHREN AT EXIT-COMMAND.

Read only

sivaprasad_paruchuri
Active Participant
0 Likes
6,085

hi lokesh,

Double click on the back , cancel logoff icons and maintain function codeas and  Function type AS 'E'.

after that In PAI ... create a module..

module <modulename> at-exitcommand.

Regards,

Siva

Read only

ajay_rajareddy
Explorer
0 Likes
6,085

you have to design PF-Status with exit button has to be defined with function type E and

you have write module module module_name at-exit command(key word).

then write logic

if sy-ucomm = 'EXIT'.

                            leave screen.

                         endif.