Disable enter in module pool sap abap - 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).

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.

How to change input fields disregard of mandatory fields?

I have a dynpro with several mandatory fields. Now, I want to implement a button that prefills those fields with suggested values. Further, another button should deactive certain input fields.
My problem is that the button actions are stopped by the empty mandatory fields. Is there a way to skip those validations, if a certain button has been pressend and acces the PAI - PBO handling?
You must execute your action before the mandatory checks bloc other changes.
Instead of
MODULE ... INPUT
you can try
MODULE ... AT EXIT-COMMAND
Normally the AT EXIT-COMMAND allows you to leave the screen, even if the values are missing. But you can use it also to fill mandatory fields.
After filling the mandatory field I would call again the screen to process PBO/PAI again. So the user can see the new changed values.
One question: Could you also fill the values during PBO?
Something like:
MODULE ... OUTPUT.
IF field is initial.
field = default_value.
ENDIF.

Double clicking a row and column in ALV Grids

Currently I have an ALV grid and I can double click to call transaction IE03 and pass the information in the first column (which is eqkt-equnr). However, this transaction is called regardless of what column you click on. This wouldn't be so bad, but I need to be able to call IW33 if you click on the 3rd column and pass along the equz-J_3GEIGNER value there.
My current double click code is as follows. t_report is my struct and matnr is the equnr part of it. maktx is the J_3GEIGNER part of it.
FORM user_command USING r_ucomm
wa_selrow TYPE slis_selfield.
IF r_ucomm = '&IC1'.
READ TABLE t_report INDEX wa_selrow-tabindex.
IF sy-subrc = 0.
SET PARAMETER ID 'EQN' FIELD t_report-matnr.
CALL TRANSACTION 'IE03' AND SKIP FIRST SCREEN.
ENDIF.
ENDIF.
ENDFORM.
Use the field wa_selrow-fieldname to determine which column was clicked. Be aware that you may have to switch the grid from row selection mode to cell selection mode - since you didn't show us how you created the grid in the first place, I can't tell you how to do this in your case. Take a look at the SEL_MODE property, it might help.