Christian
Christian

Reputation: 536

How can i define a parameter of type integer (or similar) on the selection-screen with a fixed number of digits?

I need a single digit positive number on the Selection-Screen.

Things I have tried so far:

  1. This has no effect on visible length:

    parameters pnum TYPE i VISIBLE LENGTH 1.

  2. Using type p LENGTH 1 works:

    parameters pp TYPE p LENGTH 1 VISIBLE LENGTH 1.

    However the input field on the Selection-Screen has the sign digit present, and if two digits are entered it triggers error 00089: Entry too long (enter in the format ~V)

I could, of course, always use a char1 type but then i have to implement logic to validate that input is a number.

Is there a simple way to implement this that I'm not aware of?

Upvotes: 0

Views: 119

Answers (2)

AlexSchell
AlexSchell

Reputation: 1722

  1. One possibilty is to use char1 with a simple validation:
PARAMETERS: pnum TYPE char1.

AT SELECTION-SCREEN.
  IF pnum IS NOT INITIAL AND NOT pnum CO '0123456789'.
    MESSAGE 'Please enter a single digit number' TYPE 'E'.
  ENDIF.
  1. Another possibility is to create a domain with fixed values (e.g., 0-9) and assign it to the parameter. This approach restricts the user input at the source level enforcing numeric input with a single digit:

Create a domain: for example ZDIGIT/ Data Type: NUMC / Length: 1 / Fixed Value Range: 0 to 9. Use this domain in the type for your parameter:

PARAMETERS: pnum TYPE zdigit_type.
  1. Third possibility is to use of n type:
PARAMETERS pnum TYPE n LENGTH 1.
  1. It is also possible to define the parameter as P / I type and add the necessary validation in AT SELECTION-SCREEN.

Upvotes: 4

József Szikszai
József Szikszai

Reputation: 5071

Just use numeric type, only digits can be entered:

PARAMETERS pnum TYPE n LENGTH 1.

Upvotes: 3

Related Questions