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

transfering data in SELECT-OPTIONS into Internal Table

Former Member
0 Likes
6,388

Hello,

How can i get my range in select-option into an internal table ?

Thanks and Best Regards,

Shehryar Dahar

Hello,

How can i get my range in select-option into an internal table ?

Thanks and Best Regards,

Shehryar Dahar

10 REPLIES 10
Read only

venkat_o
Active Contributor
0 Likes
2,298

Hi, Select-Option means that is internal table with with the following structure DATA: BEGIN OF <select_op> OCCURS 0, SIGN(1), OPTION(2) LOW LIKE <f>, HIGH LIKE <f>, END OF <select_op>. example

SELECT-OPTIONS: s_matnr for mara-matnr.
define structure like this for s_matnr.
data: w_matnr like line of s_manr.
Internal table

data:begin of i_mara occurs 0 with header line,
           matnr type mara-matnr,
        end of i_matnr.
Use the loop like this for range if u have given.
data:l_times type i,
       l_count type i.
LOOP AT s_matnr into w_matnr.
  if w_matnr-option = 'BT' and w_matnr-sign = 'I'."Inclusive.
     l_times = w_matnr-high - w_matnr-low.
     l_count = 0.
      do l_times times.
         i_mara-matnr = w_matnr-low + l_count.
         l_count = l_count + 1.
      enddo.
  if w_matnr-option = 'BT' and w_matnr-sign = 'E'."Exclusive.
     l_times = w_matnr-high - w_matnr-low.
     l_count = 1.
      do l_times times.
         i_mara-matnr = w_matnr-low + l_count.
         l_count = l_count + 1.
      enddo.
  endif.
ENDLOOP.
I hope that it helps you . Regards, Venkat.O

Read only

Former Member
0 Likes
2,298

Hello Venkat,

Thanks for the reply, but the above logic will work for numbers only, my data(in the range) can either be alpha-numeric or numbers or both.

?

Best Regards,

Shehryar Dahar

Read only

venkat_o
Active Contributor
0 Likes
2,298

Shehryar dahar, If it is not number how do u give Range in Select-OPtion non-numbers. If you give multiple values, in the select-options. follow the this.

LOOP AT s_matnr INTO w_matnr.
  IF w_matnr-option = 'EQ' AND w_matnr-sign = 'I'.
    i_mara-matnr = w_matnr-low.
    APPEND i_mara.
    CLEAR  i_mara.
  ENDIF.
ENDLOOP.
Regards, Venkat.O

Read only

Former Member
0 Likes
2,298

Dear Venkat,

I am using the ekpo-bednr field (Requirement Tracking Number) which is actually a PO external number range from A0000 to AZZZZ (which is alpha numeric). I am using this field in the select-options.

Best Regards,

Shehryar Dahar

Read only

Former Member
0 Likes
2,298

Hi shehryar,

1. If i understand properly, then we

have to use a select query for the master table,

which contains all the field values.

2. suppose itab contains one field only,

in which u want all the values.

Select field

from dbtab

into itab

where field in seloption.

regards,

amit m.

Read only

Former Member
0 Likes
2,298

Hello,

Sorry for not explaining the scenario clearly, my bad !

We have two system. Old and New SAP systems. I want to get the details of all PO's in the old system and for that i am using BAPI_PO_GETDETAIL(thru RFC dest command), in the new system. I cannot carry out developments in the old system so i am bound on developing a customer BAPI to access all the PO's in the old system.

In the new system, i have created a report which input a PO or range of PO numbers in the select-options, which then uses the above BAPI to get the PO detail. This PO number can be inputted as '45XXXXXXXX' or as 'A0XXXX'. Now i want to transfer my range in select-options IN internal table so that i can loop on it and get detail of the PO's.

Or if anyone has a workaround on it, kindly advise.

Best Regards,

Shehryar Dahar

Read only

venkat_o
Active Contributor
0 Likes
2,298

Hi Shehryar dahar, PO number ranges are maintained in sometable. I dont remember. Just write select query like this. ex: select-options: s_ebeln for ekpo-ebeln. "Write one query to get PO number from number range table. Select <field> from <database table> into table i_pos where <field> in s_ebeln. Ask Functional guyz to PO number range table or where they maintain. Actuall Amit explained clearly. Regards, Venkat.O

Read only

uwe_schieferstein
Active Contributor
0 Likes
2,298

Hello

If you just want to "copy" the values from the select-option into a range variable then use the following approach:


DATA: gr_matnr      TYPE RANGE OF matnr,
           gs_rng         LIKE LINE OF gr_matnr.   " SIGN / OPTION / LOW / HIGH



SELECT-OPTIONS:
   o_matnr             FOR mara-matnr.



START-OF-SELECTION.

  gr_matnr = o_matnr[].  " NOTE: select-option = itab with header line

  LOOP AT gr_matnr INTO gs_rng.
  ...
  ENDLOOP.

Regards

Uwe

Read only

Former Member
0 Likes
2,298

Hi,

select-options and ranges are the internal tables having same structure.

You can transfer from select-options to ranges and viceversa.

select-options: s_matnr for mara-matnr.

ranges: r_matnr for mara-matnr.

*---to transfer data from select-options to ranges.

loop at s_matnr.

r_matnr-sign = s_matnr-sign.

r_matnr-option = s_matnr-option.

r_matnr-low = s_matnr-low.

r_matnr-high = s_matnr-high.

append r_matnr.

endloop.

Like this we can transfer data from ranges to select-options.

Reward.

Read only

Former Member
0 Likes
2,298

thanks