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

Field ranges

Former Member
0 Likes
1,059

Hi Gurus!

In my program I ahve a selection screen which allows us to enter data and then

on executing the program it inserst or updates or shows data already exists .

There are 3 field sin the selection screen which allows a numberic value

which can be put there and insert that into the table which it uploads.

These there fields have a range of between 0-10, 00-99, and 00-zz, so

any values in between the range showuld only get inserted bewteen these range .

But when I put anything beyond this range its till inserts it into the table

which is wrong. Should I specify the range for all these fields in my selection

or initialize thos e field with the numbers or teher is something els

ethat I need to do.

selection-screen  begin of block 3 with frame title text-003. " DLS.
parameters:
  pa_zlsd      type zsds_uwi-zlsd modif id g1,      " Location SubDivision.
  pa_zsec      type zsds_uwi-zsec modif id g1,      " Section.
  pa_ztwp      type zsds_uwi-ztwp modif id g1,      " Township.
  pa_zrang    type zsds_uwi-zrange modif id g1,     " Range.
  pa_zmeri     type zsds_uwi-zmeridian modif id g1. " Meridian.
selection-screen  end of block 3.

start-of-selection.

  if pa_dls = cl_abap_typedescr=>true.
    select single * from zwell_dls where
      bukrs     = pa_bukrs and
      land1     = pa_land1 and
      regio     = pa_regio and
      zss       = '1'      and
      zle       = pa_zle   and
      zlsd      = pa_zlsd  and
      zsec      = pa_zsec  and
      ztwp      = pa_ztwp  and
      zrange    = pa_zrang and
      zmeridian = pa_zmeri and
      zevent    = pa_zeven and
      ztype     = 'W'.

Thanks

Aarav

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
959

Validate the Range.

Use:

AT SELECTION-SCREEN .

IF FIELD1 NOT BETWEEN 0 AND 9.

Message 'Values not in range' type 'E' Display Like 'S'.

ENDIF.

IF FIELD2 NOT BETWEEN 00 AND 99.

Message 'Values not in range' type 'E' Display Like 'S'.

ENDIF.

IF FIELD2 NOT BETWEEN 00 AND 'ZZ'.

Message 'Values not in range' type 'E' Display Like 'S'.

ENDIF.

Control will only go to START-OF-SELECTION If the Range is validated.

Note : It will also work in AT SELECTION_SCREEN ON FIELD.

Hope this resolves your issue.

Regards,

Gurpreet

Hi Gurus!

In my program I ahve a selection screen which allows us to enter data and then

on executing the program it inserst or updates or shows data already exists .

There are 3 field sin the selection screen which allows a numberic value

which can be put there and insert that into the table which it uploads.

These there fields have a range of between 0-10, 00-99, and 00-zz, so

any values in between the range showuld only get inserted bewteen these range .

But when I put anything beyond this range its till inserts it into the table

which is wrong. Should I specify the range for all these fields in my selection

or initialize thos e field with the numbers or teher is something els

ethat I need to do.

selection-screen  begin of block 3 with frame title text-003. " DLS.
parameters:
  pa_zlsd      type zsds_uwi-zlsd modif id g1,      " Location SubDivision.
  pa_zsec      type zsds_uwi-zsec modif id g1,      " Section.
  pa_ztwp      type zsds_uwi-ztwp modif id g1,      " Township.
  pa_zrang    type zsds_uwi-zrange modif id g1,     " Range.
  pa_zmeri     type zsds_uwi-zmeridian modif id g1. " Meridian.
selection-screen  end of block 3.

start-of-selection.

  if pa_dls = cl_abap_typedescr=>true.
    select single * from zwell_dls where
      bukrs     = pa_bukrs and
      land1     = pa_land1 and
      regio     = pa_regio and
      zss       = '1'      and
      zle       = pa_zle   and
      zlsd      = pa_zlsd  and
      zsec      = pa_zsec  and
      ztwp      = pa_ztwp  and
      zrange    = pa_zrang and
      zmeridian = pa_zmeri and
      zevent    = pa_zeven and
      ztype     = 'W'.

Thanks

Aarav

6 REPLIES 6
Read only

Former Member
0 Likes
960

Validate the Range.

Use:

AT SELECTION-SCREEN .

IF FIELD1 NOT BETWEEN 0 AND 9.

Message 'Values not in range' type 'E' Display Like 'S'.

ENDIF.

IF FIELD2 NOT BETWEEN 00 AND 99.

Message 'Values not in range' type 'E' Display Like 'S'.

ENDIF.

IF FIELD2 NOT BETWEEN 00 AND 'ZZ'.

Message 'Values not in range' type 'E' Display Like 'S'.

ENDIF.

Control will only go to START-OF-SELECTION If the Range is validated.

Note : It will also work in AT SELECTION_SCREEN ON FIELD.

Hope this resolves your issue.

Regards,

Gurpreet

Read only

0 Likes
959

Thanks it works but one thing has stopped , there are two radiobuttons which controil a third selection screen , when first is selected a particluar selection screen comes and when second another comes into play , unfortunatley the second one is onmot popping out at all and gives me the error messhe for the second insted.

PARAMETERS:
  pa_bukrs TYPE bukrs DEFAULT '1000',
  pa_land1 TYPE kna1-land1 DEFAULT 'CA' OBLIGATORY,         " Land1.
  pa_regio TYPE kna1-regio DEFAULT 'AB' OBLIGATORY, " Region.
  pa_zle      TYPE zdt_zle DEFAULT '00' OBLIGATORY, " Location Exception Code.
  pa_zeven    TYPE zsds_uwi-zevent DEFAULT '00'.    " Event Sequence.
SELECTION-SCREEN  END OF BLOCK 1.

SELECTION-SCREEN  BEGIN OF BLOCK 2 WITH FRAME TITLE text-002. " Mode.
PARAMETERS:
  pa_dls TYPE c RADIOBUTTON GROUP g1
  DEFAULT 'X' USER-COMMAND shift,               " DLS
  pa_nts TYPE c RADIOBUTTON GROUP g1.           " NTS
SELECTION-SCREEN  END OF BLOCK 2.

SELECTION-SCREEN  BEGIN OF BLOCK 3 WITH FRAME TITLE text-003. " DLS.
PARAMETERS:
  pa_zlsd      TYPE zsds_uwi-zlsd MODIF ID g1,      " Location SubDivision.
  pa_zsec      TYPE zsds_uwi-zsec MODIF ID g1,      " Section.
  pa_ztwp      TYPE zsds_uwi-ztwp MODIF ID g1,      " Township.
  pa_zrang    TYPE zsds_uwi-zrange MODIF ID g1,     " Range.
  pa_zmeri     TYPE zsds_uwi-zmeridian MODIF ID g1. " Meridian.
SELECTION-SCREEN  END OF BLOCK 3.

SELECTION-SCREEN  BEGIN OF BLOCK 4 WITH FRAME TITLE text-004. " NTS.
PARAMETERS:
  pa_zqu       TYPE zsds_uwi-zqu   MODIF ID g2 ,   " Quarter Unit.
  pa_zunit     TYPE zsds_uwi-zunit MODIF ID g2 ,   " Unit.
  pa_zbloc    TYPE zsds_uwi-zblock MODIF ID g2,    " Block.
  pa_zshee    TYPE zsds_uwi-zsheet MODIF ID g2,    " Sheet.
  pa_zmusu    TYPE zsds_uwi-zmusub MODIF ID g2,    " Map Unit Subdivision.
  pa_zmaps     TYPE zsds_uwi-zmapsheet MODIF ID g2.
SELECTION-SCREEN  END OF BLOCK 4.

AT SELECTION-SCREEN OUTPUT.
*-Screen grouping for DLS/NTS
  IF pa_dls = 'X'.
    LOOP AT SCREEN.
      CHECK screen-group1 = 'G2'.
      screen-active = 0.
      MODIFY SCREEN.
    ENDLOOP.
  ELSE.
    LOOP AT SCREEN.
      CHECK screen-group2 = 'G1'.
      screen-active = 0.
      MODIFY SCREEN.
    ENDLOOP.
  ENDIF.

AT SELECTION-SCREEN.
* Check whether region entered is applicable for the survey system selected.
  IF pa_dls = 'X'.
    IF pa_regio NE 'AB' AND pa_regio NE 'MB'
    AND pa_regio NE 'SK' AND pa_regio NE 'BC'.
      MESSAGE e010(zsd).
    ENDIF.
    if pa_zlsd not between 00 and 16 .
      message e044(zsd) .

    elseif pa_zsec not between  00 and 36.
      message e045(zsd) .

    elseif pa_ztwp not between 000 and 126.
      message e046(zsd) .

    elseif pa_zrang  not between 00 and 34.
      message e047(zsd) .

    elseif pa_zmeri not between 00 and 06.
      message e048(zsd) .
    endif.
*endif.
*endif.

  ELSE.
    IF pa_regio NE 'BC'.
      MESSAGE e008(zsd).
    ENDIF.
     if pa_zqu not between 'A' and 'D'.
        message e049(zsd).

      elseif pa_zunit not between 0001 and 126.
        message e050(zsd).

      elseif pa_zbloc not between 'A' and 'L'.
        message e051(zsd).

      elseif pa_zshee not between 001 and 100.
        message e052(zsd).

      elseif pa_zmusu not between 'A' and 'P'.
        message e053(zsd).

      elseif pa_zmaps not between 01 and 16.
        message e054(zsd).
*endif.
*endif.
endif.
  ENDIF.

Thanks

Read only

0 Likes
959

Hi,

just a small change and the code will run absolutely fine

TABLES :
SSCRFIELDS.

AT SELECTION-SCREEN.
* Check whether region entered is applicable for the survey system selected.
if sscrfieds-ucomm = 'ONLI'.                 " This means that only when you press F8 then only the 
" validations should be done
  IF pa_dls = 'X'.
    IF pa_regio NE 'AB' AND pa_regio NE 'MB'
    AND pa_regio NE 'SK' AND pa_regio NE 'BC'.
      MESSAGE e010(zsd).
    ENDIF.
    if pa_zlsd not between 00 and 16 .
      message e044(zsd) .
 
    elseif pa_zsec not between  00 and 36.
      message e045(zsd) .
 
    elseif pa_ztwp not between 000 and 126.
      message e046(zsd) .
 
    elseif pa_zrang  not between 00 and 34.
      message e047(zsd) .
 
    elseif pa_zmeri not between 00 and 06.
      message e048(zsd) .
    endif.
*endif.
*endif.
 
  ELSE.
    IF pa_regio NE 'BC'.
      MESSAGE e008(zsd).
    ENDIF.
     if pa_zqu not between 'A' and 'D'.
        message e049(zsd).
 
      elseif pa_zunit not between 0001 and 126.
        message e050(zsd).
 
      elseif pa_zbloc not between 'A' and 'L'.
        message e051(zsd).
 
      elseif pa_zshee not between 001 and 100.
        message e052(zsd).
 
      elseif pa_zmusu not between 'A' and 'P'.
        message e053(zsd).
 
      elseif pa_zmaps not between 01 and 16.
        message e054(zsd).
*endif.
*endif.
endif.
endif.
  ENDIF.

Regards,

Siddarth

Read only

0 Likes
959

Hi Aarav,

Try this code for the issue you are facing in the selection screen,

U need to make these changes in your at selection screen event first.


AT SELECTION-SCREEN OUTPUT.
*-Screen grouping for DLS/NTS
  IF pa_dls = 'X'.
    LOOP AT SCREEN.
      IF screen-group1 = 'G1'.
       screen-active = 1.
      ELSEIF screen-group1 = 'G2'.
         screen-active = 0.
      ENDIF.
      MODIFY SCREEN.
    ENDLOOP.
  ELSE.
    LOOP AT SCREEN.
      IF screen-group1 = 'G1'.
       screen-active = 0.
      ELSEIF screen-group1 = 'G2'.
         screen-active = 1.
      ENDIF.
      MODIFY SCREEN.
    ENDLOOP.
  ENDIF.

The validations on the parameters can be done in the START-OF-SELECTION as shown below.

or You can also use the code given by Siddarth for validating parameters in AT-SELECTION EVENT.


START-OF-SELECTION.

* Check whether region entered is applicable for the survey system selected.
  IF pa_dls = 'X'.
    IF pa_regio NE 'AB' AND pa_regio NE 'MB'
    AND pa_regio NE 'SK' AND pa_regio NE 'BC'.
      MESSAGE e010(zsd).
    ENDIF.
    if pa_zlsd not between 00 and 16 .
      message e044(zsd) .

    elseif pa_zsec not between  00 and 36.
      message e045(zsd) .

    elseif pa_ztwp not between 000 and 126.
      message e046(zsd) .

    elseif pa_zrang  not between 00 and 34.
      message e047(zsd) .

    elseif pa_zmeri not between 00 and 06.
      message e048(zsd) .
    endif.
*endif.
*endif.

  ELSEif  pa_nts = 'X'.
    IF pa_regio NE 'BC'.
      MESSAGE e008(zsd).
    ENDIF.
     if pa_zqu not between 'A' and 'D'.
        message e049(zsd).

      elseif pa_zunit not between 0001 and 126.
        message e050(zsd).

      elseif pa_zbloc not between 'A' and 'L'.
        message e051(zsd).

      elseif pa_zshee not between 001 and 100.
        message e052(zsd).

      elseif pa_zmusu not between 'A' and 'P'.
        message e053(zsd).

      elseif pa_zmaps not between 01 and 16.
        message e054(zsd).
*endif.
*endif.
endif.
  ENDIF.

This code works fine. I have tested it.

Hope it helps.

Regards,

Jose

Edited by: Jose Anthony Reddy on Mar 12, 2009 11:17 PM

Read only

former_member313782
Active Participant
0 Likes
959

Hi Aarav,

The reply given above will also help you.

But, I suggest that you use 'AT SELECTION-SCREEN ON' event.

I see that you are making some changes to the selection screen using the MODIF-ID group.

You can put that code in the AT SELECTION-SCREEN event.

The validation on the fields for ranges should be done in AT SELECTION-SCREEN ON event.

Making use of the REPORT EVENTS will enhance the performance of your program.

The code goes like this,

AT SELECTION-SCREEN ON field1.

IF FIELD1 NOT BETWEEN 0 AND 9.

Message 'Values not in range' type 'E' Display Like 'S'.

ENDIF.

AT SELECTION-SCREEN ON field2.

IF FIELD2 NOT BETWEEN 00 AND 99.

Message 'Values not in range' type 'E' Display Like 'S'.

ENDIF.

AT SELECTION-SCREEN ON field3.

IF FIELD2 NOT BETWEEN 00 AND 99.

Message 'Values not in range' type 'E' Display Like 'S'.

ENDIF.

after all selection screen validations are done, use the START-OF -SELECTION.event.

Regards,

Jose

Read only

Former Member
0 Likes
959

Hi Aarav,

The answer given by Gurpreet will surely work for the situation you have mentioned but there are certain flaws in it...

Since the messages which has to appear are error messages

instead of messages type 'E' display like 'S'.

just write

messages <message> type 'E'.

and another one.

once you press F8 and the error message is issued the next time you validate and press enter logically it is not meant to proceed further in Enter, I think Gurpreet just forgot to put in one small thing to validate that...

in the declaration use

Tables :

SSCRFIELDS.

and then in AT SELECTION-SCREEN.

just before the message is issued for every if condition

use the statement

clear sscrfields-ucomm.

remember this should come just before every message type 'E'.

Regards,

Siddarth