Hot Search: recover remote distribution point java excel spreadsheet konica minolta job parameters crashing Lenovo P1ma42 Specification sap rptime00 accum ne validity mick smythwood NTILE( 20 ) OVER black nutt
Home >Default > Validation of SELECT OPTIONS

Validation of SELECT OPTIONS

-0001-11-30 | Default
Advertisement
Hi Gurus,
Please let me know which is the best way to validate a select option and performance way also it must be best.
May be this is a silly question but still I was not able to find the best convincing answer in the FORUM.
Kindly validate.
Method 1:
AT SELECTION-SCREEN ON so_vbeln . " Delivery document
PERFORM validate_vbeln .
FORM validate_vbeln.
DATA : l_t_vbeln TYPE TABLE OF vbuk-vbeln WITH HEADER LINE ,
l_f_vbeln TYPE vbuk-vbeln .
RANGES ra_vbeln FOR vbuk-vbeln.
LOOP AT so_vbeln.
IF NOT so_vbeln-low IS INITIAL.
ra_vbeln-sign = 'I'.
ra_vbeln-option = 'EQ'.
ra_vbeln-low = so_vbeln-low.
APPEND ra_vbeln.
ENDIF.
IF NOT so_vbeln-high IS INITIAL.
ra_vbeln-sign = 'I'.
ra_vbeln-option = 'EQ'.
ra_vbeln-low = so_vbeln-high..
APPEND ra_vbeln.
ENDIF.
ENDLOOP .
IF NOT so_vbeln[] IS INITIAL.
SELECT vbeln INTO TABLE l_t_vbeln
FROM vbuk
WHERE vbeln IN ra_vbeln.
ENDIF.
LOOP AT so_vbeln.
IF so_vbeln-low space.
READ TABLE l_t_vbeln WITH KEY = so_vbeln-low.
IF sy-subrc 0.
SET CURSOR FIELD 'SO_vbeln-LOW'.
MESSAGE e001(vb) WITH so_vbeln-low.
ENDIF.
ENDIF.
IF so_vbeln-high space.
READ TABLE l_t_vbeln WITH KEY = so_vbeln-high.
IF sy-subrc 0.
SET CURSOR FIELD 'SO_vbeln-HIGH'.
MESSAGE e001(vb) WITH so_vbeln-high.
ENDIF.
ENDIF.
ENDLOOP.
ENDFORM. " validate_vbeln
Method 2
AT SELECTION-SCREEN ON so_werks.
PERFORM validate_plant.
FORM validate_plant.
DATA: BEGIN OF l_t_werks OCCURS 0,
werks LIKE t001w-werks,
END OF l_t_werks.
IF NOT so_werks[] IS INITIAL.
SELECT werks INTO TABLE l_t_werks
FROM t001w
WHERE werks IN so_werks.
ENDIF.
LOOP AT so_werks.
IF so_werks-low space.
READ TABLE l_t_werks WITH KEY werks = so_werks-low.
IF sy-subrc 0.
MESSAGE e892(m7) WITH so_werks-low.
ENDIF.
ENDIF.
IF so_werks-high space.
READ TABLE l_t_werks WITH KEY werks = so_werks-high.
IF sy-subrc 0.
MESSAGE e892(m7) WITH so_werks-high.
ENDIF.
ENDIF.
ENDLOOP.
ENDFORM.

Latest answer

Advertisement
Hello Raj,
For me if the SELECT-OPTION fetches atleast one record from the check table, processing should be allowed to proceed.
It's not required to check each & every records in the select-option & throw an error message for these invalid records (unlike PARAMETERs)
I would code something like this:
SELECT vbeln INTO TABLE l_t_vbeln UP TO 1 ROWS
FROM vbuk
WHERE vbeln IN so_vbeln. ENDSELECT.
IF sy-subrc NE 0.
  MESSAGE 'No valid Sales Order selected for the input range. Please check.' TYPE 'E'.
ENDIF.
BR,
Suhas

Click Ranking