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

Select-Options Processing

Former Member
0 Likes
1,329

Hi All,

I have a Select-Option: SF_KOSTL for CSKS-KOSTL.

I have a ZTable with two fields:

Username and KOSTL.

I need to determine if an entry Exists for Every SF_KOSTL (in the Select-option ) in the ZTable for username SY-UNAME.

IF there is one particular KOSTL, that doesn't have an entry in Ztable, I should ignore that from the SF_KOSTL Select-Options which is used in several other select statements.

How to overcome this.

Thanks in Advance...!

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,083

For every Cost Center in the Select-Options (It has to be a range), I need to check if entered Cost Center-SYUname pair exists in a ZAUTHtable. If it exists, I should continue with Processing. If the entry doesn't exist in the table, then i should Show them a Message saying :that cost center is ignored.

ZAUTHtable: only Contains Username and Cost Center Number. And more than one Cost Center exist for a username.

How would i check for every cost center.

Eg:

Select-Options: SF_KOSTL like CSKS-KOSTL.

How do i loop in SF_KOKSTL so that i go through each and every value that is Processed normally.

Sample Code Please.

6 REPLIES 6
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
1,083

That's pretty simple as it is the functionality of the select-option.

Select-Option: SF_KOSTL for CSKS-KOSTL.


select * into table itable 
         from ztable 
                where kostl in sf_kostl.



This select statement will only pull records where the KOSTL has exists in the select-option.

Regards,

Rich Heilman

Read only

Former Member
0 Likes
1,083

IF you have to check all the entries of the select option against Ztable then it might give you wrong output. Becase if you enter range of KOSTL then you can't check all values in the range against Ztable.

SO better create select option with restriction.

You can eliminate the range option from the select statement and allows only low values so that you can enter as many as values without range.

After that in the

AT SELECTION-SCREEN ON SF_KOSTL-LOW.

You can write code to chec against Ztable.

Regards

Aman

Read only

nablan_umar
Product and Topic Expert
Product and Topic Expert
0 Likes
1,083

Hi Raj,

You can combine the select statement so that only valid cost center and exist in ZTABLE will be selected.

select b~USERNAME

b~KOSTL

into corresponding fields of ZTABLE

from CSKS as a

inner join ZTABLE as b

on bKOSTL = aKOSTL

where a~kostl in SF_KOSTL

and b~USERNAME = SY-UNAME.

Read only

Former Member
0 Likes
1,084

For every Cost Center in the Select-Options (It has to be a range), I need to check if entered Cost Center-SYUname pair exists in a ZAUTHtable. If it exists, I should continue with Processing. If the entry doesn't exist in the table, then i should Show them a Message saying :that cost center is ignored.

ZAUTHtable: only Contains Username and Cost Center Number. And more than one Cost Center exist for a username.

How would i check for every cost center.

Eg:

Select-Options: SF_KOSTL like CSKS-KOSTL.

How do i loop in SF_KOKSTL so that i go through each and every value that is Processed normally.

Sample Code Please.

Read only

0 Likes
1,083

Oh ok. I see what you need to do now. Try something like this. Here you are getting all of the kostl in your range and looping at the internal table and checking against your ztable.



report zrich_0001 .

data: icsks type table of csks with header line.

select-options: s_kostl for icsks-kostl.

at selection-screen.

  clear icsks.  refresh icsks.
  select * into table icsks from csks
                where kostl in s_kostl.


  loop at icsks.

* Check against your table here
* select Single * from ztable
*            where uname = sy-uname
*              and kostl = icsks-kostl.
* if sy-subrc <> 0.
*   message w001(00) with 'Kostl will be ignored'.
* endif.

  endloop.

Regards,

Rich Heilman

Read only

0 Likes
1,083

Thanks For the Code.

Very Helpful.