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

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.

Related

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.

Dynamically update row contents via dialog screen

I need some help with the following problem. I currently have one dialog screen with a field in which a user can type a number. This number corresponds with an ID field in a database table I've made (using se/11). I want to display the contents of all fields (so only one row of the table) with the corresponding ID on a second screen. The user should also be able to edit the information in the fields and, after saving, those changes should be visible in the table itself. What it comes down to is that I want to dynamically change the contents of the returned row through the dialog screen. I know I have to use a Table Control, but apart from that I'm at a loss (I'm pretty new to ABAP).
Here's the table
Screen 1 where a user can input a number that corresponds to SEQNR in the table
When pressing F8 on Screen 1, I want to go to a second screen with the information of the person with SEQNR = 1, in other words, only this row should appear:
The user should be able to edit the information in this row. When he clicks "Save", the edited information should be updated in the table itself.
So far, I only made a standard second screen in which I added a Table Control for the above table in Screen Painter. I added this control to my DIALOG_TOP:
PROGRAM TAAK1.
DATA: OK_CODE TYPE sy-ucomm,
ls_table TYPE TABEL1,
SEQNR_TEXTFIELD TYPE i,
TXT_STATUS(25) TYPE c,
it_table LIKE TABEL1 OCCURS 0 WITH HEADER LINE.
TABLES: TABEL1.
CONTROLS: TABLE_CONTROL TYPE TABLEVIEW USING SCREEN 200.
I have no code for screen 2, other than the standard PBO and PAI Modules.
The code for screen 1 looks like this.
MODULE USER_COMMAND_0100 INPUT.
CASE OK_CODE.
WHEN 'CHECKID'.
SELECT SINGLE * FROM TABEL1 WHERE SEQNR EQ SEQNR_TEXTFIELD.
IF sy-subrc EQ 0.
TXT_STATUS = 'ID BESTAAT'.
ELSE.
TXT_STATUS = 'ID BESTAAT NIET'.
ENDIF.
IF TXT_STATUS = 'ID BESTAAT'.
SELECT * FROM TABEL1 INTO ls_table WHERE SEQNR EQ SEQNR_TEXTFIELD.
ENDSELECT.
ENDIF.
WHEN 'EXEC'.
CLEAR OK_CODE.
SET SCREEN 200.
LEAVE SCREEN.
WHEN 'BACK' OR 'EXIT' OR 'CANCEL'.
LEAVE PROGRAM.
ENDCASE.
ENDMODULE.
I basically check if the Seqnr exists in the table. If it does, I store the corresponding row in a local structure which I've defined in the DIALOG_TOP.
It's probably easier and less time consuming to use an SM30 view. You can create a custom transaction to maintain the correct authorizations. Additionally you can adjust the screens (see the code of the generated function group) to your liking's.
More info here:
https://help.sap.com/saphelp_nw73ehp1/helpdata/en/cf/21ed2d446011d189700000e8322d00/content.htm
https://archive.sap.com/discussions/thread/851998
http://saptechnical.com/Tutorials/ABAP/TableMaintenance/demo.htm

Deleted Table Control leads to run time error

I have a screen with one table control which displayed values from my internal db.
It worked out flawlessly.
I added another table control which didn't worked out the way i wanted.
I deleted the control CONTROLS: tc_two TYPE TABLEVIEW USING SCREEN 9000.
And now I'm getting a runtime error CONTROL-Variable not found.
Q: What happens if i declare new Controls? Where do they get implemented?
I tried to debug my code and the error appears at CALL SCREEN 9000.
Here is the full code:
REPORT zsch_test.
CONTROLS: tc_one TYPE TABLEVIEW USING SCREEN 9000.
DATA: it_uebung TYPE TABLE OF zsch_uebung,
ok_code TYPE sy-ucomm,
fill TYPE i.
TABLES zsch_uebung.
DATA: lines TYPE i,
limit TYPE i.
SELECT * FROM zsch_uebung INTO CORRESPONDING FIELDS OF TABLE it_uebung WHERE status = '1'.
CALL SCREEN 9000.
MODULE status_9000 OUTPUT.
SET PF-STATUS 'STATUS9000'.
* SET TITLEBAR 'xxx'.
DESCRIBE TABLE it_uebung LINES fill.
tc_one-lines = fill.
ENDMODULE.
MODULE fill_table_control OUTPUT.
READ TABLE it_uebung INTO zsch_uebung INDEX tc_one-current_line.
ENDMODULE.
MODULE cancel INPUT.
LEAVE PROGRAM.
ENDMODULE.
MODULE read_table_control INPUT.
lines = sy-loopc.
MODIFY it_uebung FROM zsch_uebung INDEX tc_one-current_line.
ENDMODULE.
MODULE user_command_9000 INPUT.
ok_code = sy-ucomm.
CASE ok_code.
WHEN 'EXIT'.
LEAVE PROGRAM.
WHEN OTHERS.
ENDCASE.
ENDMODULE.
Screen 9000:
PROCESS BEFORE OUTPUT.
MODULE STATUS_9000.
LOOP WITH CONTROL TC_ONE.
MODULE fill_table_control.
ENDLOOP.
PROCESS AFTER INPUT.
MODULE cancel AT EXIT-COMMAND.
LOOP WITH CONTROL TC_ONE.
MODULE read_table_control.
ENDLOOP.
MODULE USER_COMMAND_9000.
Thanks!
sadly it's in german
From the fact that the problem disappeared apparently without further action, one might assume that this was either a buffer issue (which is why you should re-start the entire transaction when testing a changed program) or you accidentally failed to activate the entire program (and, for example activated only the report source, but not the screen definition).

Event for back button after AT LINE SELECTION in ABAP list report?

I have a list report that uses the event block AT LINE SELECTION (and HIDE).
AT LINE-SELECTION.
WRITE: 'Testline'.
* and some more things
When I double click on a line in the main list, AT LINE SELECTION is processed, and the main list is replaced with a list that consists of the text 'Testline'.
When I klick on the green back button, the main list is shown again.
Everything works as espected.
Now to my question:
Is there some way how the report can be notified when the user clicks on the green back button to go from the detail list to the main list?
The obvious solution AT USER-COMMAND is not called.
This is the event where I want to SUBMIT the same report again to update the list.
(I know I could do this with an ALV report, but is this possible with a simple list report?)
When you check the documentation you will find the following information:
The function codes PICK and PF## ("##" stands for 01 to 24) do not cause the event AT USER-COMMAND, but the events AT LINE-SELECTION and AT PF##.
All function codes that start with the character "%" are interpreted as system functions and do not cause the event AT USER-COMMAND. The system functions for lists are listed in the following table 1.
The function codes in the following table 2, likewise, do not cause the event AT USER-COMMAND, but are handled by the list processor.
table 2 includes BACK (that's the default code for the green arrow).
What you can do: Write your own status.
REPORT ytest.
DATA pf_exclude TYPE TABLE OF sy-ucomm WITH HEADER LINE.
START-OF-SELECTION.
SET PF-STATUS 'LIST'. "<--- here
WRITE: / 'Hello World'.
AT LINE-SELECTION.
WRITE: 'Testline'.
* and some more things
AT USER-COMMAND.
BREAK-POINT.
CASE sy-ucomm.
WHEN 'MYBACK'.
ENDCASE.
Now you can define your own status:
Don't forget to define PICK - or the double click will not work.
Define your own back-function.

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.