Application Development 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: 

Simple Select

Former Member
0 Kudos

Hi

I have a Z table entry with the following

Compnay code

IN*

I need a select statement to check whether the given company code in screen is valid or not with this table. Like if user entered IN01 then its valid. If GB01 then invalid.

select single * from ztable where bukrs cp p_bukrs.

CP is allowed in select command..How can I use select statement here?

Hope I am clear, do let me know if in detail!

Regds

1 ACCEPTED SOLUTION

suresh_datti
Active Contributor
0 Kudos

use LIKE 'IN%' in the WHERE clause.

~Suresh

4 REPLIES 4

suresh_datti
Active Contributor
0 Kudos

use LIKE 'IN%' in the WHERE clause.

~Suresh

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

I don't think you need to go to the database to check this, right? You can probably just use a range.

ranges: r_bukrs for t001-bukrs.

r_bukrs-sign = 'I'.
r_bukrs-option = 'CP'.
r_bukrs-low  = 'IN*'.
append r_bukrs.

If p_bukrs in r_bukrs.

Endif.

Regards,

Rich Heilman

Former Member
0 Kudos

Rather than using a parameter on the select screen, use a select-option. This will allow you to write:

SELECT SINGLE * FROM ztable
  WHERE bukrs IN s_bukrs.

Rob

Former Member
0 Kudos

Hi,

Try this..

TABLES: T001.

SELECT-OPTIONS: P_BUKRS FOR T001-BUKRS NO INTERVALS NO-EXTENSION.

AT SELECTION-SCREEN.

IF NOT P_BUKRS[] IS INITIAL.

SELECT SINGLE * FROM T001 WHERE BUKRS IN P_BUKRS.

IF SY-SUBRC <> 0.

MESSAGE E208(00) WITH 'NOT A VALID COMPANY CODE'.

ENDIF.

ENDIF.

Thanks,

Naren