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: 

How to convert select-options table into single field internal table

Former Member
0 Kudos

Hi,

My requirement is to convert select-options table into single internal table which has one field.

e.g. select-options: s_matnr for mara-matnr.

select-options table can have options 'BT',"EQ", "NE", "GE", "GT", "LE", "LT", "CP" etc. select-options table

have Sign:I ,Option:BT, Low: 1, High.10.The new internal table records should be 1,2,3,4,5,6,7,8,9,10.

Please suggest any function module available for this scenario in SAP.

Thanks,

Somi.

Edited by: somi reddy satti on Sep 15, 2009 3:18 PM

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Somi ,

Select option can be converted into an internal table of one field as below:

you need to have all the possible values of select option in any database table.Prefer Master table here.

Now , fetch all the records from master table based on the values in the select-option from screen.This you can keep it in internal table with single field.

This is usually done to avoid computations on the values that are not possible for a select option.

Hope it help you.

5 REPLIES 5

Former Member
0 Kudos

Hi,

If this Select-option is made on a Table field then Select Statement Can help you out here.

Data: Begin of i_mara occurs 0,

Matnr like mara-matnr,

end of i_mara.

Tables: MARA.

Select-options: S_MATNR for MARA-MATNR.

Select MATNR

into table i_mara

from MARA

where MATNR IN S_MATNR.

Now your i_mara will have all valid Material Numbers.

in other cases where the select-options field is not referring to any Database Table field..you need to do it programtically by doing a loop on Select-option internal Table and filling your single field table based on the value of the fields of the former table i.e SIGN,OPTION, LOW & HIGH

Former Member
0 Kudos

Hi Somi ,

Select option can be converted into an internal table of one field as below:

you need to have all the possible values of select option in any database table.Prefer Master table here.

Now , fetch all the records from master table based on the values in the select-option from screen.This you can keep it in internal table with single field.

This is usually done to avoid computations on the values that are not possible for a select option.

Hope it help you.

Former Member
0 Kudos

Not sure why were my reply was not a perfect help for you......I given the same answer and even with a Code also...and I also covered the second aspect also which says what to do when your select-option fields is not referring to any Table field.

If you can explain me the reason, it would help me to effectively help others in future.

0 Kudos

Can you please provide more details on how to convert the select option table into single field internal table if the select optionfield is not referring to any field in the data base. My senario is to convert a select option of month and year into 2 internal tables respectively.Kindly provide code if you can.

0 Kudos

Hi Sowmya,

Here is the answer if I understand well of your question.

Data: begin of gt_mon OCCURS 0,

mon(2) TYPE n,

end of gt_mon.

Data: begin of gt_year OCCURS 0,

year(4) TYPE n,

end of gt_year.

Select-options: s_period FOR ptdw_pws_db-kmonth NO-EXTENSION

DEFAULT sy-datum(6)

TO sy-datum(6).

For example according to above statement period is 201110 is 201201.

Period field does n't exists in SAP for selection. If your selection is on date based on period which is given on the selection-screen then you need to convert the period to date by concatenating ( or using FM to convert )01 at the end of each period . You need to declare one range table for date to select the data from table.

loop at s_period.

gr_date-sign = s_period-sign.

gr_date-option = s_period-option.

COncatenate s_period-low

'01'

into gr_date-high.

COncatenate s_period-high

'01'

into gr_date-low

append gr_date.

ENDloop.

Thanks,

Satheesh