How to close a modal popup window when pressing the escape key - abap

I have an ABAP Z-report which shows a modal popup window(screen). Is it possible to close it when user presses an escape key?
I'm showing the popup using the next screen call
call screen 0100 STARTING AT 10 10 ENDING AT 110 30.
The screen has the next PAI module:
MODULE USER_COMMAND_0100 INPUT.
clear gv_ok.
case sy-ucomm.
when 'BTN_OK'.
gv_ok = 'X'.
LEAVE TO SCREEN 0.
when 'BTN_CANC'.
perform clean.
LEAVE TO SCREEN 0.
endcase.
ENDMODULE. " USER_COMMAND_0100 INPUT
But the PAI module is not called whe the user presses an escape key.
The flow logic section is
PROCESS BEFORE OUTPUT.
MODULE STATUS_0100.
*
PROCESS AFTER INPUT.
MODULE USER_COMMAND_0100.
module exit at exit-command.
Nothing from PAI modules is called while Esc key is being pressed.

Here is what you have to check in the GUI status:
The escape key is assigned automatically to this, you only need to assign the command (BUT_CANC, it is ZCANC in my example).

Related

How to hide conditionally custom fields in screen exit? (CMOD)

My task is to customize the Header Details Screen of the ME33K transaction, the goal is to add a box with new fields that should appear only if the Agreement type is the one I defined by using the transaction SPRO (ex: Agreement type ABC).
I started making an enhancement to that screen by using the CMOD transaction, I created a dummy box and field with some hard-coded input value and it's working fine.
My next step would be to make these new fields appear only if the Agreement is of type ABC, but I cannot find the correct approach.
I tried doing some Screen-Loop programming and deactivating the box and/or fields, but the only ones that get deactivated are the standard ones that exist already, the ones I added with the enhancement are not affected.
EDIT :
The enhancement I used was 'MM06E005'.
I wrote the following Screen-Loop code in the include provided in the 'EXIT_SAPMM06E_006' user exit :
loop at screen.
if screen-name = 'CUSTOM_FIELDS'.
screen-active = 0.
modify screen.
endif.
endloop.
The enhancement MM06E005 refers to the subscreen SAPLXM06 0101, that you have created with a box with all your custom screen fields.
To hide your custom screen fields, you must:
Call a PBO (Process Before Output) module, to be done in the flow logic of your subscreen (the one which contains the screen fields):
PROCESS BEFORE OUTPUT.
...
MODULE modify_screen_field_attributes.
...
PROCESS AFTER INPUT.
...
In the include LXM06O01 (preferrably), do this:
MODULE modify_screen_field_attributes OUTPUT.
LOOP AT SCREEN.
IF screen-name = 'CUSTOM_FIELDS'. " name of one screen field
screen-active = 0. " hide the screen field
MODIFY SCREEN.
ENDIF.
ENDLOOP.
ENDMODULE.

Calling a search help function module for a field on a screen

Is it possible to call the function MAT1_F4_HELP_EXIT in the PBO module of the screen to trigger search help for a material field on a custom screen (assigning the search help using se11 and search help exit is not working).
I am confused regarding the parameters that are being passed in the function.
Edit (taken from discussion)
I have a field called material, and I want to trigger a search help (MAT1). I have assigned it the table field and it is not letting the user do it automatically. So, I want to call it explicitly.
I have reproduced the issue (cf minimal code and screen at the bottom).
Steps to reproduce :
start the program (-> ALV displayed)
double click one line of the ALV (-> screen 0100 displayed)
press F4 on screen field defined with search help (-> popup 'abnormal situation' instead of search help!)
Reason: the active GUI status reassigns the F4 function key a classic function key behavior instead of calling the search help and as you didn't set a GUI status in your screen, the one of the previous screen is used again.
Solution: define your own GUI status and set it in the PBO of the screen (and don't redefine F4 of course!)
Rule of thumb : always define your own buttons and menus for every screen (why would you display buttons and menus from other screens which make no sense).
Minimal code:
REPORT.
SELECT * FROM sflight INTO TABLE #DATA(flights).
" does a CALL SCREEN which does SET PF-STATUS 'STANDARD_FULLSCREEN' (in program SAPLKKBL)
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid
i_callback_user_command = 'USER_COMMAND'
i_structure_name = 'SFLIGHT'
TABLES
t_outtab = flights
EXCEPTIONS
OTHERS = 2.
FORM user_command
USING
r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
IF r_ucomm = '&IC1'.
CALL SCREEN 100.
ENDIF.
ENDFORM.
MODULE pbo OUTPUT.
" missing part !! ==> create GUI status 0100 and do SET PF-STATUS '0100'
ENDMODULE.
MODULE pai INPUT.
CASE sy-ucomm.
WHEN '&F03'.
SET SCREEN 0.
WHEN '&F4'.
" corresponds to F4 key inherited from ALV GUI status 'STANDARD_FULLSCREEN'
MESSAGE 'abnormal situation -> define your own GUI status !' TYPE 'I'.
ENDCASE.
ENDMODULE.
Screen 0100 :
Any field with search help (same as you did)
Flow logic of screen 0100 :
PROCESS BEFORE OUTPUT.
MODULE pbo.
PROCESS AFTER INPUT.
MODULE pai.

Buttons Back, Leave and Cancel are inoperative in Hierarchical ALV

I display a hierarchical ALV. When I click the BACK or LEAVE or CANCEL buttons (in the toolbar), I'm supposed to go back or leave the program or cancel .
But when I click one of those buttons an additional row appends in the ALV hierarchy.
Any help ?
Check yor PBO/PAI moduls.
EXAMPLE:
IN PBO i said
module status_0100 output.
set pf-status 'GUI_STATUS_0100'.
" and some other code
" and some other code
endmodule.
IN PAI i said
module user_command_0100 input.
case sy-ucomm.
when 'CANCEL' or 'BACK'.
set screen 0.
when 'EXIT'.
leave program.
endcase.
endmodule.
In GUI_STATUS_0100 i told about buttons that i used
It might help you. Good luck!
There must be event(s) trigger along side with BACK, LEAVE and CANCEL.
Double check the function code of 3 buttons, ensure they only appears in Exit-command and when triggered, ensure there is no other subroutines inside/next to the LEAVE, RETURN... statement
If possible, please post some code.

Disable enter in module pool sap abap

I have created a function module pool in sap abap. How can I make it possible when the user presses enter the values in input field not to disappear?
MODULE user_command_0200 INPUT.
CASE ok_code.
WHEN 'EXIT'.
LEAVE PROGRAM.
WHEN 'BACK'.
CALL SCREEN 100.
WHEN 'DISPLAY' .
SELECT SINGLE * FROM ekpo
WHERE ebeln = ekpo-ebeln AND ebelp = ekpo-ebelp.
ssn = 400.
ENDCASE.
CLEAR: ekpo-ebeln ,ekpo-ebelp.
CLEAR ok_code.
ENDMODULE.
What Am I missing.If I remove CLEAR: ekpo-ebeln ,ekpo-ebelp even if I change screens the fields remain filled.
How to keep the values in the field and even if the user presses enter nothing should happen.
here you go buddy:
WHEN 'BACK'.
CLEAR: ekpo-ebeln ,ekpo-ebelp.
ssn = '500'.
While the accepted answer solves the apparent problem in Dynpro 0200, this is not the best event to do it.
It appears to me you want to control the initial value of the fields for the next time dynpro 0200 appears.
Do clear/set the fields in the PAI of the Dynpro that calls Dynpro 0200.
(sometimes PBO of Dynpro 0200 also is a good place, but probably not in your case).

Find out all program dynpro screens?

I am new to ABAP and I want to make a program with multiple screens and an initial home screen where one can see the list of all program screens. I understand that I can hardcode them but there should be a better way.
If there is any what kind of field/area do I need to make this list clickable (to go to screen). So far I have made an initial screen and when the GO button is pressed it leads to the next screen
REPORT Z_UZD_1_LOCAL.
CALL SCREEN 1001.
MODULE STATUS_1000 OUTPUT.
* SET PF-STATUS 'ZMENU'.
* SET TITLEBAR 'ZMENU_PAINTER'.
CASE SY-UCOMM.
WHEN 'EXIT'.
LEAVE PROGRAM.
WHEN 'BACK'.
LEAVE PROGRAM.
WHEN 'GO'.
CALL SCREEN 1001.
ENDCASE.
ENDMODULE.
MODULE STATUS_1001 OUTPUT.
* SET PF-STATUS 'ZMENU'.
* SET TITLEBAR 'ZMENU_PAINTER'.
CASE SY-UCOMM.
WHEN 'GO2'.
CALL SCREEN 1000.
ENDCASE.
ENDMODULE.
It looks like this:
Go to Personas button leads to the next screen, and I would like to have a list of all the screens under the find button.
You can read the table D020S and its text-table D020T with the key program = sy-repid, which should give you all dynpros which belongs to this program (sy-repid is your actual program).
Is this what you want?