How to select multiple ranges for a parameter WITHOUT first filling all other required parameters? - abap

I'd want to be able to have multiple range selections for "Sales order no."
Problem is: when i press the button marked with green, i get the error "Fill in all required entry fields".
I put my main processing block at the START-OF-SELECTION event.
What to do to not have this happen? It seems to me that i should be able to add multiple selections without all the hassle of first filling every other mandatory field.

With parameters/select-options set to OBLIGATORY, this won't work. I had the very same problem some time ago, and had no chance to fill the OBLIGATORY input parameters with useful values by default, so I did the following:
Remove the OBLIGATORY option from all select-options and parameters
Handle the check for obligatory input yourself in cases no F4,help, F1 help or the button next to any select option is pressed:
Code:
AT SELECTION-SCREEN ON s_reswk.
IF sy-ucomm(1) <> '%' AND " sel screen action request
sy-ucomm(1) <> '_' AND " scope option
s_reswk IS INITIAL. " Obligatory input missing
MESSAGE text-e01 TYPE 'E'. " Error message
ENDIF.

Here's what i found that completely reproduces the behavior set by the OBLIGATORY addition:
1:Take OUT the "OBLIGATORY" addition.
2:at PBO:
LOOP AT SCREEN.
IF screen-name cs 'name-of-your-select-options-or-parameter'.
screen-required = 2.
MODIFY SCREEN.
ENDIF.
3: at PAI:
if sscrfields-ucomm = 'ONLI'.
if 'name of your select-option-or-parameter' is initial.
clear sscrfields.
message 'Fill in all required fields.'(009) type 'E'.
endif.
endif.
Notice the first if statement contains a 'cs' logical operator. That's cuz the name of your control will contain other weird stuff as well. For instance %_P_MATNR_%SCREEN%% (where your parameter was p_matnr).
Also, the declaration : TABLES sscrfields. is necessary.

Related

Listbox error "Entry is too long for the field"

After selecting a value in a dropdown listbox field, there is this error message:
Entry is too long for the field
(it's the message number 00092)
I created one text field TXTOPENV as Listbox with key value, set value using VRM_SET_VALUES in PBO section.
Here is the screenshot of screen painter:
Screen flow logic:
PROCESS BEFORE OUTPUT.
MODULE status_0210.
ABAP code:
DATA txtopenv TYPE c LENGTH 1.
MODULE status_0210 OUTPUT.
SET PF-STATUS 'ST210'.
SET TITLEBAR 'T210'.
PERFORM GetVacancy.
ENDMODULE.
FORM GetVacancy.
TYPES: BEGIN OF ty_vacancy,
plans TYPE t528t-plans,
plstx TYPE t528t-plstx,
END OF ty_vacancy.
DATA: wa_vacancy TYPE ty_vacancy.
LOOP AT it_vacancyid INTO wa_vacancyid.
SELECT plans plstx
FROM t528t
INTO wa_vacancy
WHERE plans = wa_vacancyid-ty_objid.
ENDSELECT.
field_id = wa_vacancy-ty_plans.
value = wa_vacancy-ty_plstx.
APPEND value TO values.
CLEAR wa_vacancy.
ENDLOOP.
CALL FUNCTION 'VRM_SET_VALUES'
EXPORTING
id = 'TXTOPENV'
values = values
EXCEPTIONS
id_illegal_name = 1
OTHERS = 2.
ENDFORM.
The error "Entry is too long for the field" is not specifically related to the listbox fields, but may occur with all types of screen fields, so I will first answer the general case, and then explain why you were mistaken .
The error happens when the screen field is defined with a "definition length" which is larger than the length defined for the eponym global variable in the ABAP program (eponym: the name has to be the same so that to allow the transfer of values between screen and program, back and forth), and when the input value is larger than the length of the ABAP program.
In your case, the key of the selected value in the listbox is probably larger than 1 character which is the length of the global variable.
The solution in your case is to set the variable to 8 characters:
DATA txtopenv TYPE t528t-plstx.
NB:
In your screenshot of the listbox field with possible values, only the texts are shown, but you can also display the key value via SAP GUI settings Interaction Design > Visualization 1 > Show keys within dropdown lists.

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).

Hide a obligatory parameter when changing radio buttons

I have some radiobuttons and when I change between them some blocks appear/disappear.
However, if I set parameters as obligatory or required they do not hide unless I fill them. I want to make parameters required but I need to hide them when I change the radiobutton option.
I guess it's a selection screen...
then loop at your screen and check the value of "YOUR_RADIO_BUTTON"
enable or disable the blocks
AT SELECTION-SCREEN OUTPUT.
LOOP AT SCREEN.
* Radio button parameter = P_RADIO
* hide the parameter named "to_hide"
IF P_RADIO EQ 'X' AND SCREEN-NAME CS 'TO_HIDE'.
SCREEN-INPUT = 0.
MODIFY SCREEN.
ENDIF.
* display the parameter named "to_hide"
IF P_RADIO <> 'X' AND SCREEN-NAME CS 'TO_HIDE'.
SCREEN-INPUT = 1.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
If you use PARAMETERS ... OBLIGATORY, this is an unconditional statement - this parameter is required regardless of the other settings. If you need a conditional check, you have to code it for yourself:
PARAMETERS p_chkbuk AS CHECKBOX.
PARAMETERS p_bukrs TYPE bukrs.
AT SELECTION-SCREEN ON p_bukrs.
IF p_chkbuk = abap_true AND p_bukrs IS INITIAL.
MESSAGE 'You need to enter something.' TYPE 'I' DISPLAY LIKE 'E'.
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.

After message type e, program doesn't return to selection-screen ABAP

I'm trying to use a message type E in my report. The thing is that when the message is triggered, the program doesn't return to the selection-screen. Can anyone help me? Here's the code I use to achieve this:
IF rb_tri IS NOT INITIAL AND p_trim-low IS INITIAL.
MESSAGE e038.
ENDIF.
Thanks :)
When I combine your question with your answer I offer another solution:
Don't make your test after starting the process (START-OF-SELECTION) but on the selection screen:
PARAMETER: p_test.
AT SELECTION-SCREEN.
IF p_test IS INITIAL.
MESSAGE e038(00).
ENDIF.
The E-message blocks the selection screen until the problem is solved.
I found the aswer. I should have used a S message and display it like a E type message. To get back to the selection-screen I had to use LEAVE LIST_PRECESSING. The code is below:
START-OF-SELECTION.
IF rb_tri IS NOT INITIAL AND p_trim-low IS INITIAL.
MESSAGE s038 DISPLAY LIKE 'E'.
Leave list-processing.
ENDIF.
Thank you anyway.
Message text-001 TYPE 'S' Display LIKE 'E'
or
At selection screen on radiobutton group rad1.
if condition
message text-001 type 'I' display like 'E'.
set screen 1000.
leave screen.
endif