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

read table using range

kiran_k8
Active Contributor
0 Likes
22,401

Hi Folks,

I had declared a range for s_witht and wanna read the table tempx w.r.t to the belnr in printtab and range of values declared in s_witht.

loop at printtab.

READ TABLE TEMPX WITH KEY BELNR = PRINTTAB-BELNR

<b>WITHT IN S_WITHT</b>

MOVE TEMPX-WT_QBSHH TO PRINTTAB-EDUCS.

modify printtab.

endloop.

or

loop at printtab.

READ TABLE TEMPX WITH KEY BELNR = PRINTTAB-BELNR

if tempx-witht in s_witht

MOVE TEMPX-WT_QBSHH TO PRINTTAB-EDUCS.

endif.

modify printtab.

endloop.

But it is not reading the values in the range.Where am I going wrong.

Thanks,

K.Kiran.

6 REPLIES 6
Read only

former_member386202
Active Contributor
0 Likes
7,799

Hi,

While selecting data from database table into intarnal table check slect options in where condition.

then do like this

loop at printtab.

READ TABLE TEMPX WITH KEY BELNR = PRINTTAB-BELNR

if sy-subrc eq 0.

MOVE TEMPX-WT_QBSHH TO PRINTTAB-EDUCS.

endif.

modify printtab.

endloop.

Regards,

Prashant

Read only

Wil_Wilstroth
Active Participant
0 Likes
7,799

Hi Kiran,

Maybe you can try this:

IF tempx-witht <b>BETWEEN</b> s_witht-low <b>AND</b> s_witht-high.

          • Process

ENDIF.

I hope it helps you...

Thanks

William Wilstroth

William Wilstroth
Read only

JozsefSzikszai
Active Contributor
0 Likes
7,799

hi Kiran,

by READ TABLE you can only use EQ (or =). IN, NE, etc are not allowed.

ec

Read only

Former Member
0 Likes
7,799

Hi kiran,


"second condition looking OK.. try like this..

DATA : idx LIKE sy-tabix.

LOOP AT printtab.
idx =  sy-tabix.
READ TABLE tempx WITH KEY belnr = printtab-belnr.
IF sy-subrc EQ = 0.
  CHECK tempx-witht IN s_witht.
  MOVE tempx-wt_qbshh TO printtab-educs.
  MODIFY printtab INDEX idx.
ENDIF.
ENDLOOP.

Read only

Former Member
0 Likes
7,799

Hi,

'Read' statement fetches a single record that mathces the key field specification.

You cannot pass a range for 'Read' Statement.

Here is your code...

loop at printtab.

READ TABLE TEMPX WITH KEY BELNR = PRINTTAB-BELNR

if tempx-witht in s_witht

MOVE TEMPX-WT_QBSHH TO PRINTTAB-EDUCS.

endif.

modify printtab.

endloop.

You can modify it as follows.

Instead you can get the range of values into an internal table , say it_range. i.e. it_range will have the range of values of s_witht.

Specify the read statement inside the loop of it_range.

loop at printtab.

loop at it_range into wa_range.

READ TABLE TEMPX WITH KEY BELNR = PRINTTAB-BELNR

witht = wa_range-witht.

MOVE TEMPX-WT_QBSHH TO PRINTTAB-EDUCS.

modify printtab.

endloop.

endloop.

Hope this would solve your purpose...

Message was edited by:

P Sreenivasulu

Read only

jayanthi_jayaraman
Active Contributor
0 Likes
7,799

Hi,

loop at printtab.

READ TABLE TEMPX WITH KEY BELNR = PRINTTAB-BELNR.

if sy-subrc eq 0."Check the sy-subrc here

if tempx-witht in s_witht

MOVE TEMPX-WT_QBSHH TO PRINTTAB-EDUCS.

endif.

modify printtab.

endif.

endloop.

Another way is to try using loop.

loop at TEMPX where BELNR = PRINTTAB-BELNR

and WITHT IN S_WITHT.

...endloop.