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

Mass validations in selection screen

Former Member
0 Likes
511

Hello experts,

I have a simple requirement to check "if atleast one of the fields on selection screen is filled or not".

If all the fields are initial, i'll raise a message.

    • I dont want to check all the fields one by one using ANDs.

The closest I got was-

loop at screen.

field = screen-name.

see if the field is empty.

if yes, increment the counter.

endif.

check if the counter is still zero. That means all fields are empty. Raise message.

The problem here is, in "screen-name", i'll get the name of screen field. How do I read it? How to find the value in a varible that is stored in another variable? I tried paranthesis ( screen-field ) = value. But it doesnt work. If that can be done, my problem's solved.

Thanks in advance!

Sumit Nene.

3 REPLIES 3
Read only

ThomasZloch
Active Contributor
0 Likes
469

How many select-options do you have? It would be much easier and transparent to just chain a few ANDs rather than trying to come up with a dynamic complexity that even you will not understand any more after doing something else for two months, let alone other developers that will have to work with your code in the future.

Thomas

Read only

rajesh_paruchuru
Active Participant
0 Likes
469

This should be a good start, if you still persist to move ahead with your initial approach inspite of Thomas's suggestion.


TABLES:
  mara.

SELECT-OPTIONS:
  s_matnr FOR mara-matnr.

PARAMETERS:
   p_test1 TYPE char10,
   p_test2 TYPE char10.

DATA:
   count TYPE i.

FIELD-SYMBOLS:
  <fs> TYPE ANY.

AT SELECTION-SCREEN.
  IF sy-ucomm = 'ONLI'.
    CLEAR count.
    LOOP AT SCREEN.
      CHECK: screen-input  = 1,
             screen-active = 1.
      ASSIGN (screen-name) TO <fs>.
      IF <fs> IS ASSIGNED AND
         <fs> IS NOT INITIAL.
        ADD 1 TO count.
        UNASSIGN <fs>.
      ENDIF.
    ENDLOOP.
  ENDIF.

-Rajesh

Edit

P.S : I haven't tested the above solution thoroughly, if for any reasons you find issues with the above approach, as an alternative you can consider using the FM 'RS_REFRESH_FROM_SELECTOPTIONS' to read the selection screen contents. But as already suggested, it would be easy to query the fields individually, you don't want to perform a simple validation with a complicated processing...

Edited by: Rajesh Paruchuru on Jul 12, 2011 10:03 AM

Read only

Former Member
0 Likes
469

A case of "penny wise but pound foolish". It would be much simpler to check the fields individually.

If you insist on complexity, you can keep the idea of the counter, but use it when checking if the filed is empty; don't use the loop at screen. You could also use a DO with an EXIT if an entry is found.

Rob