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: 

Regarding Ranges..

spandana_babu
Participant
0 Kudos

hi

Experts..

i am having customers in internal table , i want to move this customers in to ranges internal table to get the data from database. plz suggest hw can i move this

Reagards

Spanadana

1 ACCEPTED SOLUTION

kesavadas_thekkillath
Active Contributor
0 Kudos

its better to go for "for all entries"

for Ex: select * from kna1 into table itab for all entries in itab2

where kunnr = itab2-kunnr.

if u want it to move to ranges then.

ranges:ra_kunnr for kna1-kunnr.

ra_kunnr-option = 'EQ'.

ra_kunnr-sign = 'I'.

loop at itab2.

ra_kunnr-low = itab2-kunnr.

collect ra_kunnr.

endloop.

select * from kna1 into table itab

where kunnr in ra_kunnr.

6 REPLIES 6

kesavadas_thekkillath
Active Contributor
0 Kudos

its better to go for "for all entries"

for Ex: select * from kna1 into table itab for all entries in itab2

where kunnr = itab2-kunnr.

if u want it to move to ranges then.

ranges:ra_kunnr for kna1-kunnr.

ra_kunnr-option = 'EQ'.

ra_kunnr-sign = 'I'.

loop at itab2.

ra_kunnr-low = itab2-kunnr.

collect ra_kunnr.

endloop.

select * from kna1 into table itab

where kunnr in ra_kunnr.

Former Member
0 Kudos

loop at itab into wa_itab.

<range>-sign = c_i.

<range>-option = c_eq.

<range>-low = wa_itab-<customer>.

append <range>.

endloop.

Former Member
0 Kudos

Hello


RANGES: R_KUNNR FOR KNA1-KUNNR.
LOOP AT ITAB.
  R_KUNNR-SIGN = 'I'.
  R_KUNNR-OPTION = 'EQ'.
  R_KUNNR-LOW = ITAB-KUNNR.
  APPEND R_KUNNR.
ENDLOOP.

Former Member
0 Kudos

Hi,

You can do as below:


ranges : gr_cust for kna1-kunnr.

"Assuming u have all your customer number in itab and gs_tab is strcuture

Sort itab by kunnr descending.

read table itab index 1 into gs_tab..

gr_cust-option = 'BT'.
gr_cust-sign = 'I'.
gr_cust-high = itab-lifnr.

Sort itab by kunnr.
gr_cust-low. = itab-lifnr.

append gr_cust.

"Now you will hav the high and low values of the customer in the ranges and you can use 
gr_cust in your select statement.

Thanks,

Sriram Ponna.

SuhaSaha
Advisor
Advisor
0 Kudos

Hello Spandana,

Plz try this bit of code:


DATA:
  R_KUNNR  TYPE RANGE OF KUNNR,
  WA_KUNNR LIKE LINE OF R_KUNNR.

LOOP AT IT_KNA1 INTO WA_KNA1.
  WA_KUNNR-SIGN = 'I'.
  WA_KUNNR-OPTION = 'EQ'.
  WA_KUNNR-LOW = WA_KNA1-KUNNR.

  APPEND WA_KUNNR TO R_KUNNR.
  CLEAR WA_KUNNR.
ENDLOOP.

R_KUNNR is a RANGE table containing customer nos. You can use R_KUNNR for ur further selection.

Hope this helps.

BR,

Suhas

Former Member
0 Kudos

Hi,

Once you get the required data into your internal table, you can loop the internal table and pass those values into the ranges you have declared.

sample code:-

TYPES: BEGIN OF ty_kunnr,

kunnr TYPE kunnr,

END OF ty_kunnr.

DATA: it_kunnr TYPE TABLE OF ty_kunnr,

wa_kunnr TYPE ty_kunnr,

r_kunnr TYPE RANGE OF kna1-kunnr,

wa_r_kunnr LIKE LINE OF r_kunnr.

SELECT kunnr FROM kna1 INTO TABLE it_kunnr.

LOOP AT it_kunnr INTO wa_kunnr.

wa_r_kunnr-option = 'EQ'.

wa_r_kunnr-sign = 'I'.

wa_r_kunnr-low = wa_kunnr-kunnr.

append wa_r_kunnr to r_kunnr.

ENDLOOP.