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 check in parameters

Former Member
0 Likes
618

Hi experts,

I have a selection screen with 2 parameters p_a and p_b.

Suppose I input any value in p_a and leave p_b blank,

ideally in the output I should get all the results in which p_a

condition is satisfied.

But what is happening is that the select query searches for the

entry where p_a is equal to the value entered, and also it searches

for p_b equal to blank.

Since there is no combination of this type, sy-subrc is always 4

What should I do to rectify this issue?

The select query I am writing is:

select emaildate

emailtime

from zabc

into table it_zabc

where a = p_a

and b = p_b.

This query looks wrong to me. What can be a correct one?

Thanks,

Ajay.

Hi experts,

I have a selection screen with 2 parameters p_a and p_b.

Suppose I input any value in p_a and leave p_b blank,

ideally in the output I should get all the results in which p_a

condition is satisfied.

But what is happening is that the select query searches for the

entry where p_a is equal to the value entered, and also it searches

for p_b equal to blank.

Since there is no combination of this type, sy-subrc is always 4

What should I do to rectify this issue?

The select query I am writing is:

select emaildate

emailtime

from zabc

into table it_zabc

where a = p_a

and b = p_b.

This query looks wrong to me. What can be a correct one?

Thanks,

Ajay.

4 REPLIES 4
Read only

Former Member
0 Likes
567

Use SELECT-OPTIONS instead of PARAMETERS

Read only

Former Member
0 Likes
567

Hello,

Using parameters, the select query will always look for the exact match while retreiving the records. If you want the desired output declare them as select-options instead of parameters.

Vikranth

Read only

Former Member
0 Likes
567

Hi

If you want to manage just one selection, u need to use the select-option instead of the parameter, so u have 2 chance:

A) Define p_a and p_b as select-option but having the format of parameter:

TABLES: BKPF.

SELECT-OPTIONS: SO_BUKRS FOR BKPF-BUKRS NO-EXTENSION  NO INTERVALS,
                SO_GJAHR FOR BKPF-GJAHR NO-EXTENSION  NO INTERVALS.

SELECT * FROM BKPF WHERE BUKRS IN SO_BUKRS
                     AND GJAHR IN SO_GJAHR.
ENDSELECT.

B) Transfer the parameters to a range:

TABLES: BKPF.

PARAMETERS: P_BUKRS LIKE BKPF-BUKRS,
            P_GJAHR LIKE BKPF-GJAHR.

RANGES: R_BUKRS FOR BKPF-BUKRS,
        R_GJAHR FOR BKPF-GJAHR.

IF NOT P_BUKRS IS INITIAL.
  R_BUKRS(3) = 'IEQ'.
  R_BUKRS-LOW = P_BUKRS.
  APPEND R_BUKRS.
ENDIF.

IF NOT P_GJAHR IS INITIAL.
  R_GJAHR(3) = 'IEQ'.
  R_GJAHR-LOW = P_GJAHR.
  APPEND R_GJAHR.
ENDIF.

SELECT * FROM BKPF WHERE BUKRS IN R_BUKRS
                     AND GJAHR IN R_GJAHR.
ENDSELECT.

Max

Read only

Former Member
0 Likes
567

Moderator message - Please do not ask or answer basic questions - thread locked

Rob