10-23-2013 10:18 AM
HI Frnds,
Can anyone please help me on, how to completely validate parameters (optional) and parameters (mandatory).
eg 1:
Parameters : p_matnr type matnr(optional).
parameters : p_mtart type mtartoptional.
validation:??
eg 2:
Parameters : p_matnr type matnr obligatory.
parameters : p_mtart type mtart.
validation:????
10-23-2013 10:22 AM
Use AT SELECTION SCREEN* EVENTS in your program for validation..
e.g.
PARAMETER : p_vbeln TYPE vbak-vbeln.
AT SELECTION-SCREEN ON p_vbeln.
IF NOT p_vbeln IS INITIAL.
SELECT single vbeln FROM vbak into lv_vbeln WHERE vbeln EQ p_vbeln.
IF sy-subrc NE 0.
MESSAGE 'No sales doc exists', type 'E'.
ENDIF.
ENDIF.
09-01-2022 8:24 AM
SELECT single vbeln FROM vbak into lv_vbeln WHERE vbeln EQ p_vbeln.
A small mistake in This line
the word which shown in italic is - replacing - p_vbeln
Thanks,
Suggu Sandeep.
10-23-2013 10:23 AM
Hi Bala Krishna,
We have to define paramters either optional or obligatory:
1. If it is optional, then no need to specify
Parameters : P_matnr type mara-matnr.
2. If it is mandatory, then we have to specify using "OBLIGATORY".
Parameters : P_matnr type mara-matnr OBLIGATORY.
Then as usual you can do validation in At selection screen event.
Regards
Kusuma
10-23-2013 10:28 AM
What are you looking for, the only difference is that you should not code validation for an initial value of a non-obligatory field, else look Abap documentation for information on PARAMETERS and AT SELECTION-SCREEN ON.
Regards,
Raymond
10-23-2013 12:48 PM
hi Bala,
If the field is mandatory, you directly need to check the value of that field in the database table for validation under AT SELECTION-SCREEN on <field>. If user skips this entry, system will pop a message for mandatory field.
If the field is not mandatory, then first check if field is not initial and then proceed with similar validation for the entered value as done in case of mandatory field( Validation req only if user entry is made).
I am still not clear with the term 'how to completely validate parameters (optional) and parameters (mandatory).' can you explain what do you expect when you say completely validate.
Regards,
DN.
10-23-2013 1:17 PM
Hii Bala,
U can validate the parameters at event called AT SELECTION SCREEN like below
DATA v_matnr TYPE matnr.
AT SELECTION-SCREEN.
IF p_matnr IS INITIAL.
set CURSOR FIELD 'P_MATNR'.
MESSAGE 'Enter the material number' TYPE 'E'.
ELSE.
SELECT SINGLE MATNR ---->to check the existence of entered materail no
FROM mara
INTO v_matnr
WHERE MATNR eq p_matnr.
IF sy-subrc <> 0.
MESSAGE 'Enter the valid material number' TYPE 'E'.
ENDIF.
ENDIF.
IF p_mtart IS INITIAL.
SET CURSOR FIELD 'P_MTART'.
MESSAGE 'Enter the description' TYPE 'E'.
ENDIF.
If u want that after selecting the matnr the mtart field should be automatically filled with respect to material number then u can achieve it like below is the simple [rogram illustrating that.
REPORT zr05_test.
PARAMETERS: p_matnr TYPE matnr, "OBLIGATORY value CHECK,
p_mtart TYPE mtart.
DATA: t_mara TYPE STANDARD TABLE OF mara,
v_matnr TYPE matnr.
DATA: t_f4 TYPE STANDARD TABLE OF mara, ----->will hold the data displayed in dynamic search help window
t_dd TYPE TABLE OF dselc, ---->for dynamic value selection
t_ft TYPE TABLE OF dfies,
t_ret TYPE TABLE OF ddshretval, ------>will hold the selected value in search help
x_dd TYPE dselc,
x_ft TYPE dfies.
FIELD-SYMBOLS <fs> TYPE mara.
AT SELECTION-SCREEN on VALUE-REQUEST FOR p_matnr.
PERFORM dynamic_f4. ----> To provide dynamic search help to matnr and mtart get automatically filled based on the matnr value
AT SELECTION-SCREEN. -------->Evenet to validate data
IF p_matnr IS INITIAL.
set CURSOR FIELD 'P_MATNR'.
MESSAGE 'Enter the material number' TYPE 'E'.
ELSE.
SELECT SINGLE MATNR
FROM mara
INTO v_matnr
WHERE MATNR eq p_matnr.
IF sy-subrc <> 0.
MESSAGE 'Enter the valid material number' TYPE 'E'.
ENDIF.
ENDIF.
IF p_mtart IS INITIAL.
SET CURSOR FIELD 'P_MTART'.
MESSAGE 'Enter the description' TYPE 'E'.
ENDIF.
START-OF-SELECTION.
SELECT *
FROM mara
INTO TABLE t_mara
UP TO 3 rows
WHERE matnr eq p_matnr
AND mtart eq p_mtart.
IF sy-subrc eq 0.
SORT t_mara by MATNR ASCENDING.
ELSE.
MESSAGE 'No Records Found for entered Value' TYPE 'I' DISPLAY LIKE 'E'.
ENDIF.
LOOP AT t_mara ASSIGNING <fs>.
WRITE:/ <fs>-matnr,
<fs>-mtart,
<fs>-ersda,
<fs>-ernam.
ENDLOOP.
*&---------------------------------------------------------------------*
*& Form DYNAMIC_F4
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM DYNAMIC_F4 .
IF t_f4 IS INITIAL.
SELECT *
FROM Mara
CLIENT SPECIFIED
INTO TABLE t_f4
UP TO 500 ROWS
WHERE mandt eq sy-mandt.
ENDIF.
REFRESH t_dd.
x_dd-fldname = 'MTART'.
x_dd-dyfldname = 'P_MTART'.
APPEND x_dd TO t_dd.
CLEAR x_dd.
REFRESH t_ft.
x_ft-tabname = 'MARA'.
x_ft-fieldname = 'MATNR'.
APPEND x_ft TO t_ft.
CLEAR x_ft.
x_ft-tabname = 'MARA'.
x_ft-fieldname = 'MTART'.
APPEND x_ft TO t_ft.
CLEAR x_ft.
IF NOT t_f4 IS INITIAL.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield = 'MATNR'
DYNPPROG = sy-repid
DYNPNR = sy-dynnr
DYNPROFIELD = 'P_MATNR'
WINDOW_TITLE = 'Search Help Selection'
VALUE_ORG = 'S'
tables
value_tab = t_f4
FIELD_TAB = t_ft
* RETURN_TAB = t_ret
DYNPFLD_MAPPING = t_dd
EXCEPTIONS
PARAMETER_ERROR = 1
NO_VALUES_FOUND = 2
OTHERS = 3.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
ENDIF.
ENDFORM. " DYNAMIC_F4
This is the example of dynamic search help and dynamic field value filled based on other field value.
regards
Syed
10-23-2013 1:46 PM
Hi Bala Krishna,
You can use "AT SELECTION-SCREEN" event for validations on Screen.
Though once you use "Obligatory" statement, system will not execute untill you pass value in parameter.
Example 1:
Parameters : p_matnr type matnr(optional).
Parameters : p_mtart type mtartoptional.
AT SELECTION SCREEN.
IF P_MATNR IS NOT INITIAL.
....<Validation Statements>....
ENDIF.
Example 2:
Parameters : p_matnr type matnr obligatory.
parameters : p_mtart type mtart.
AT SELECTION SCREEN.
IF P_MATNR IS NOT INITIAL.
....<Validation Statements>....
ENDIF.
Thanks & Regards,
Tushar Trivedi.
10-23-2013 2:08 PM
Its possible to make an field look like an obligatory field but not more with the following coding:
AT SELECTION-SCREEN OUTPUT.
LOOP AT SCREEN.
IF screen-name = '[FIELDNAME]'.
screen-required = '2'. "<-recommend = 2 obligatory = 1 optional = 0
MODIFY SCREEN.
ENDIF.
ENDLOOP.
10-25-2013 8:19 AM
10-25-2013 8:33 AM
Hi Krishna,
Sample for reference
Regards,
Rajesh
10-25-2013 8:52 AM
Hi
If you use obligatory the system itself will throw an error message if the field is left blank.
Once you enter the value and after that you want to display the message you can write it under
AT SELECTION SCREEN event so that it will dispay message at the that screen itself.
AT SELECTION SCREEN.
write the query.
if sy-subrc ne 0.
message 'type the message' type 'E' (for error) can use W for warning, S status message
With regards
Suneesh
09-01-2022 8:35 AM
hi,
We can Validate Selection Screen With the Help of the Following Events.
AT SELECTION-SCREEN ON
AT SELECTION-SCREEN ON BLOCK
AT SELECTION-SCREEN OUTPUT
AT SELECTION-SCREEN.
endif
with regards
SOWMYA.