‎2013 Nov 12 9:29 AM
Hello all,
I was creating a report in which i have 2 plants(werks) fields on my selection screen .one was parameter and other is select-option, Now i want to validate it . Instead of selecting t001w database table 2 times , i want to validate these fields by only one select on datbase table , can it be possible?? if yes pls give me the idea..
Thanks and regards
Nitin
‎2013 Nov 13 6:17 AM
Dear Nitin,
Fetch from DB table and store in internal table.
Then make a range table with the values from internal table in low and validate against the range table.
I hope this helps!
Regards,
Sheetal.
‎2013 Nov 12 9:33 AM
Select Werks from T001w where werks = p_werks and werks in s_werks.
Arivazhagan
‎2013 Nov 13 4:35 AM
i have tried this but its not working?? my requirement is if any of the entered plant in the select option is incorrect , then it shows error but in this case it only checks the parameter one..
‎2013 Nov 13 6:34 AM
Try like this
REPORT yram_52.
TABLES : t001w.
DATA : it_final TYPE TABLE OF t001w,
wa_final type t001w.
RANGES: r_werks FOR t001w-werks.
PARAMETERS : p_werks TYPE t001w-werks.
SELECT-OPTIONS : s_werks FOR t001w-werks.
START-OF-SELECTION.
r_werks-sign = 'I'.
r_werks-option = 'EQ'.
r_werks-low = p_werks.
r_werks-high = space.
APPEND r_werks TO s_werks.
SELECT *
FROM t001w
INTO TABLE it_final
WHERE werks IN s_werks.
Loop at it_final into wa_final.
write :/ wa_final-werks.
endloop.
‎2013 Nov 12 10:01 AM
Nitin,
Just do this thing:
Take all the plants in a internal table and then take them in a range. And just check with your parameter and selection option. If it not contain in any case, then gave error.
Regards
Vivek
‎2013 Nov 13 4:47 AM
‎2013 Nov 12 10:27 AM
Use this code:
SELECT werks
FROM t001w
INTO TABLE t_werks.
LOOP AT t_werks ASSIGNING <w_werks>.
r_werks-sign = 'I'.
r_werks-option = 'EQ'.
r_werks-option-low = <w_werks>-werks.
APPEND r_werks.
ENDLOOP.
IF S_WERKS NOT IN R_WERKS.
* GAVE ERROR.
ENDIF.
IF P_WERKS NOT IN R_WERKS.
* GAVE ERROR.
ENDIF.
Regards
Vivek
‎2013 Nov 13 6:12 AM
Hi Nithin ,
I am putting a code that i tested ,i hope it is working to your requirement .
TABLES :t001w .
TYPES :
BEGIN OF ty_werks ,
werks TYPE werks_d ,
END OF ty_werks .
DATA :
t_werks TYPE TABLE OF ty_werks ,
x_werks TYPE ty_werks ,
l_check_param TYPE c ,
v_lines TYPE i .
SELECTION-SCREEN BEGIN OF BLOCK b1 .
PARAMETERS p_werk TYPE werks_d .
SELECT-OPTIONS s_werk FOR t001w-werks.
SELECTION-SCREEN END OF BLOCK b1.
AT SELECTION-SCREEN ON BLOCK b1 .
SELECT werks
FROM t001w
INTO TABLE t_werks
WHERE werks EQ p_werk OR werks IN s_werk .
LOOP AT t_werks INTO x_werks WHERE werks = p_werk .
l_check_param = abap_true .
ENDLOOP .
IF l_check_param NE abap_true. "checking whether parameter is valid
MESSAGE 'error msg for parameter' TYPE 'E' .
ENDIF.
DESCRIBE TABLE t_werks LINES v_lines .
IF v_lines = 1 AND l_check_param = abap_true . "to check whether internal table contains parameter werks
MESSAGE 'error msg for select option' TYPE 'E' .
ELSE .
LOOP AT t_werks INTO x_werks WHERE werks NOT IN s_werk.
IF x_werks-werks NE p_werk .
MESSAGE 'error msg for select option' TYPE 'E' .
EXIT.
ENDIF .
ENDLOOP.
ENDIF .
‎2013 Nov 13 5:14 AM
Hi Nitin,
Try like this,
TYPES: BEGIN OF ty_werks,
werks TYPE werks_d,
END OF ty_werks.
DATA: v_werks TYPE werks_d.
PARAMETERS : p_plant TYPE werks_d.
SELECT-OPTIONS : s_werks FOR v_werks.
DATA : t_werks TYPE STANDARD TABLE OF ty_werks.
DATA: x_werks LIKE LINE OF s_werks.
START-OF-SELECTION.
x_werks-sign = 'I'.
x_werks-option = 'EQ'.
x_werks-low = p_plant.
x_werks-high = space.
APPEND x_werks TO s_werks.
SELECT werks
FROM t001w
INTO TABLE t_werks
WHERE werks IN s_werks.
IF sy-subrc EQ 0.
MESSAGE 'Success' TYPE 'S'.
ENDIF.
Regards,
Riju Thomas.
‎2013 Nov 13 6:17 AM
Dear Nitin,
Fetch from DB table and store in internal table.
Then make a range table with the values from internal table in low and validate against the range table.
I hope this helps!
Regards,
Sheetal.
‎2013 Nov 13 8:46 AM
Hi,
As Sheetal said,
Fetch the data into an ITAB from DB Table.
Read the Internal table with the parameters and select options value for the validation.
Try it.
Thanks
Pavan.N