2020 Nov 02 10:12 AM
Hello,
I have a selection screen (N° 0300) in my programm, it contains 3 checkboxes (one of them is named Enable) plus an input text field, I made them on screen painter. And in PAI I put DYNP_VALUES_READ, to read which checkboxes are checked, so in that way after enabling/disabling the text field (according to if "Enable" is checked or not) which is working very well now. But the problem is that after PAI and PBO, my selection screen is " recreated " I think because all checkboxes lost their values 'X' after this. I tried to update in PBO the field values based on valuess that I get in my PAI thanks to FM : DYNP_VALUES_READ, and for this I used a lot of FM like RS_SELECTIONSCREEN_UPDATE , DYNP_UPDATE_FIELDS , DYNP_VALUES_UPDATE but nothing is working for me, can you please help me on this ?
Best regards,
2020 Nov 02 3:45 PM
sandra.rossi Thank you so much, it works now perfectly, I just created Global variables with the same name as my checkboxes.
Thank you also Jānis B, your answer is write, the PAI do the work automatically we just have to put gv with same names.
2020 Nov 02 11:59 AM
Have you created corresponding variables in your program and tried assigning value to variables directly in PBO?
2020 Nov 02 12:37 PM
Hello essaouira
Why are you trying to do that the hard way?
You should use
AT SELECTION-SCREEN OUTPUT.
LOOP AT SCREEN.
ENDLOOP.to modify the selection screen. See SAP Help for an example: AT SELECTION-SCREEN OUTPUT
Best regards
Dominik Tylczynski
2020 Nov 02 1:02 PM
Hello 3a9e4ce873a94034b33dc62b0ce600ee,
Thank you for your comment, but the screen on which we loop doesn't have an attribute for the value that we want to give. He has only the attribute 'name'. Am I missing something ?
2020 Nov 02 1:06 PM
The term "selection screen" for a screen designed with the "Screen Painter" is incorrect.
By definition, a "selection screen" is designed with ABAP statements, not with the Screen Painter.
Now, back to your question, please post your code, it's probably very short if I correctly evaluate your question.
2020 Nov 02 1:32 PM
Ok thanks for the clarification sandra.rossi ... Here is my code
****************** In PAI
Case sy-ucomm
WHEN 'HIDE'.
IF gv_checkbox IS INITIAL.
gv_checkbox = abap_true. "To enable the input text
ELSE.
CLEAR gv_checkbox. " To disable the input text
ENDIF.
"Read screen 300
LOOP AT SCREEN.
IF screen-name IS NOT INITIAL.
PERFORM read_screen300 USING screen-name. (*****"Here I use CALL FUNCTION 'DYNP_VALUES_READ' To get the values of the fields and I append them to this table gt_update_selectionscreen*************)
ENDIF.
ENDLOOP.
WHEN OTHERS.
ENDCASE.
****************************** In PBO
LOOP AT SCREEN.
IF screen-name = 'P_HIDE_FIELDS'.
IF gv_checkbox IS NOT INITIAL. "enable the input text
screen-input = '1'.
* screen-active = '0'.
screen-output = '0'.
* screen-required = '1'.
ELSE. "disable la saisie
screen-input = '0'.
* screen-active = '0'.
screen-output = '1'.
screen-required = '0'.
ENDIF.
MODIFY SCREEN.
EXIT.
ENDIF.
ENDLOOP.
CALL FUNCTION 'RS_SELECTIONSCREEN_UPDATE'
EXPORTING
program = sy-repid
dynnr = '300'
TABLES
updatevalues = gt_update_selectionscreen
EXCEPTIONS
no_high_field = 1
OTHERS = 2.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
MODIFY SCREEN.
CLEAR gt_update_selectionscreen.
But this is not working at the end the input text is enabled/disabled once I check the checkbox that has "HIDE" as a function code, but once this is done the other checkboxes loose their values if they are checked before. And that's what I want to keep after this action. I hope I was clear by describing the issue.
2020 Nov 02 1:39 PM
Please attach the dynpro flow logic and include the name(s) of PBO/PAI module(s).
Please use the CODE button to format your code so that it's shown in a more user-friendly format (colorized).
NB: you need DYNP_VALUES_READ or RS_SELECTIONSCREEN_UPDATE (a wrapper of DYNP_VALUES_READ valid only for Selection Screens, so not for your general dynpro) only from F1 and F4 helps.
2020 Nov 02 2:06 PM
sandra.rossi sorry, my bad. Actually it is a selection screen (N° 0300) that appears after clicking on a button in another alv. Here you can find what you asked me for. Thank you
Just a small remark (DYNP_VALUES_READ works fine "I saw this with debugger" but the update FM is not working)

MODULE status_0300 OUTPUT.
IF gv_init_screen300 IS INITIAL.
SET PF-STATUS 'MAIN300'.
SET TITLEBAR 'OPTIONS'.
ENDIF.
LOOP AT SCREEN.
IF screen-name = 'P_HIDE_FIELDS'.
IF gv_checkbox IS NOT INITIAL.
screen-input = '1'.
screen-output = '0'.
ELSE.
screen-input = '0'.
screen-output = '1'.
screen-required = '0'.
ENDIF.
MODIFY SCREEN.
EXIT.
ENDIF.
ENDLOOP.
IF gv_flag_update300 IS NOT INITIAL.
CALL FUNCTION 'RS_SELECTIONSCREEN_UPDATE'
EXPORTING
program = sy-repid
dynnr = '300'
TABLES
updatevalues = gt_update_selectionscreen
EXCEPTIONS
no_high_field = 1
OTHERS = 2.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
MODIFY SCREEN.
CLEAR gt_update_selectionscreen.
ENDMODULE.
MODULE user_command_0300 INPUT.
CASE sy-ucomm.
WHEN 'BACK'.
CLEAR gv_new_fcat.
CLEAR gv_init_screen300.
CALL SCREEN 100.
WHEN 'HIDE'.
gv_init_screen300 = abap_true.
CLEAR gv_flag_update300.
IF gv_checkbox IS INITIAL.
gv_checkbox = abap_true.
ELSE.
CLEAR gv_checkbox.
ENDIF.
"Read screen 300
LOOP AT SCREEN.
IF screen-name IS NOT INITIAL.
PERFORM read_screen300 USING screen-name.
ENDIF.
ENDLOOP.
IF gt_update_selectionscreen IS NOT INITIAL.
gv_flag_update300 = abap_true.
ENDIF.
WHEN OTHERS.
ENDCASE.
ENDMODULE.
FORM read_screen300 USING p_fieldname.
dynpfields300_tmp-fieldname = p_fieldname.
APPEND dynpfields300_tmp.
CALL FUNCTION 'DYNP_VALUES_READ'
EXPORTING
dyname = sy-repid
dynumb = '0300'
TABLES
dynpfields = dynpfields300_tmp
EXCEPTIONS
invalid_abapworkarea = 1
invalid_dynprofield = 2
OTHERS = 11.
IF p_fieldname = 'ZEBRA' OR p_fieldname = 'CWIDTH_OPT' OR p_fieldname = 'NO_TOOLBAR' OR p_fieldname = 'HIDE_FIELDS'.
gs_update_selectionscreen-name = p_fieldname.
gs_update_selectionscreen-fieldvalue = dynpfields300_tmp-fieldvalue.
APPEND gs_update_selectionscreen TO gt_update_selectionscreen.
ENDIF.
REFRESH dynpfields300_tmp.
ENDFORM.

2020 Nov 02 2:22 PM
Again, your screen is a general screen, not a screen of type Selection Screen. You must not use RS_SELECTIONSCREEN* function modules for general dynpros, it's non-sense.
In your case, the global variables NO_TOOLBAR, HIDE_FIELDS and others should be automatically initialized when you select the checkbox "Hide Fields" or any other function key (provided that it's a function type " " as is currently the case for "Hide Fields"). I don't understand why it's not the case. You shouldn't need DYNP_VALUES* function modules (with maybe the special case if you want to read them while you handle "system" events from the ALV).
Eventually, make sure that "next screen" is set as 300 in the properties of the screen 300, and that you don't change it dynamically with SET SCREEN.
NB: you must always execute SET PF-STATUS and SET TITLEBAR in the PBO, do not condition them.
2020 Nov 02 2:44 PM
sandra.rossi aah ok I see what you say. Thanks.
That's write I used DYNP_VALUES_READ because I need these values for other screen (It's like on screen 300 user will check the options of fieldcatalog/layout that he wants to be applied for screen 200). Ok, I understand that I shouldn't use this FM but it was just an attempt because before I tried FM DYNP_UPDATE_FIELDS , DYNP_VALUES_UPDATE but no one is working, always the checkboxes are initialized after clicking of the one with function module.
2020 Nov 02 2:53 PM
sandra.rossi Do you have an idea please on how to keep the checked ones with the mark 'X' even after clicking on the "HIDE FIELDS" ?
2020 Nov 02 3:07 PM
I just created a new program, with a screen with 2 checkboxes, and it works fine, I don't understand what problem you have.
REPORT.
DATA cb1 TYPE flag.
DATA cb2 TYPE flag.
CALL SCREEN 100.
MODULE status_0100 OUTPUT.
ENDMODULE.
MODULE user_command_0100 INPUT.
ENDMODULE. " <==== breakpoint hereEach time I click a checkbox, the breakpoint is reached and the global variables CB1 and CB2 automatically reflect the state of the checkboxes.
2020 Nov 02 3:12 PM
In debug, add watchpoints on the global variables to understand at what moment their values are changed.
2020 Nov 02 3:15 PM
@essaouira Is the name of the Dynpro field that has function HIDE attached to it 'GV_CHECKBOX'?
If yes, them this bit:
IF gv_checkbox IS INITIAL.
gv_checkbox = abap_true.
ELSE.
CLEAR gv_checkbox.
ENDIF.would just clear it during PAI, once you have clicked it...
You don't need to do anything to transfer the Dynpro field values to program memory - ABAP runtime environment does it during PAI. Just make sure the the variable GV_CHECKBOX is defined in the program.
cheers,
Janis
2020 Nov 02 3:17 PM
sandra.rossi Ok and your two checkboxes do they still checked at the end or are they initialized ? Because for me too, everything is initialized at the end. But I am wondering if they still checked in your example ? Thank you in advance
2020 Nov 02 3:19 PM
2020 Nov 02 3:20 PM
Just do it. It takes 2 minutes to create the test from scratch.
2020 Nov 02 3:28 PM
sandra.rossi Ok Thank you I will debug and I will see, but how can we assign a checkbox that we put on screen painter, to a variable like you did ? (Because that's why I used FM Dynp_values*).
@Jānis B : No it is not this, gv_checkbox is just to enable or disable the input text, but the one with function code is 'HIDE_FIELDS'
2020 Nov 02 3:30 PM
You define global variables with the same names. See my code.
2020 Nov 02 3:36 PM
Hello essaouira
Each field on the selection screen is defined with either PARAMETERS or SELECT-OPTIONS. Each implicitly defines a global variable. The value of a selection screen field is stored in this variable and is accessible in PAI of the selection screen i.e. in AT SELECTION-SCREEN event.
Also you wrote:
I have a selection screen (N° 0300) in my programm, it contains 3 checkboxes (one of them is named Enable) plus an input text field, I made them on screen painter.
That's contradictory as you don't define selection screens with screen painter! Selection screen is always defined with ABAP commands like PARAMETERS, SELECT-OPTIONS, SELECTON-SCREEN.
Best regards
Dominik Tylczynski
2020 Nov 02 3:51 PM
Thank you 3a9e4ce873a94034b33dc62b0ce600ee, It is my fault, I said selection screen but actually it is a standard screen.
Thank you for the clarification.
2020 Nov 02 3:45 PM
sandra.rossi Thank you so much, it works now perfectly, I just created Global variables with the same name as my checkboxes.
Thank you also Jānis B, your answer is write, the PAI do the work automatically we just have to put gv with same names.