Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Validation

Former Member
0 Likes
1,935

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

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,895

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.

10 REPLIES 10
Read only

arivazhagan_sivasamy
Active Contributor
0 Likes
1,895

Select Werks from T001w where werks = p_werks and werks in s_werks.

Arivazhagan

Read only

0 Likes
1,895

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

Read only

0 Likes
1,895

Hi

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.

Read only

Former Member
0 Likes
1,895

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

Read only

0 Likes
1,895

use ranges as suggested y vivek ...

Read only

Former Member
0 Likes
1,895

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

Read only

0 Likes
1,895

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 .

Read only

Former Member
0 Likes
1,895

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.

Read only

Former Member
0 Likes
1,896

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.

Read only

Former Member
0 Likes
1,895

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