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

problem with loop statement

Former Member
0 Likes
1,640

Hi Experts,

My loop statement doesn't kindly suggest what am missing here.

Thanks, will appreciate your response.

TYPES: BEGIN OF lty_matnr,

matnr TYPE /sapapo/matnr,

END OF lty_matnr.

DATA: lt_matnr TYPE STANDARD TABLE OF lty_matnr WITH HEADER LINE,

ls_matnr TYPE lty_matnr.

Loop at lt_matnr[]. " THIS DOESN'T WORK"

ls_content_query-matnr_rng-high = lt_matnr-high.

ls_content_query-matnr_rng-low = lt_matnr-low.

ls_content_query-matnr_rng-sign = lt_matnr-sign.

ls_content_query-matnr_rng-option = lt_matnr-option.

append ls_content_query-matnr_rng.

Clear ls_content_query-matnr_rng.

Endloop.

15 REPLIES 15
Read only

former_member195698
Active Contributor
0 Likes
1,619

use Loop at lt_matnr.

Read only

0 Likes
1,619

if i use lt_matnr instead of lt_matnr[] it gives me an error.

Error: lt_matnr doesn;t have a component high

Read only

0 Likes
1,619

loop at table without the [] is the right way to do it.

Loop at lt_matnr[]. " THIS DOESN'T WORK"

ls_content_query-matnr_rng-high = lt_matnr-high. < your code is erroring here

ls_content_query-matnr_rng-low = lt_matnr-low.

ls_content_query-matnr_rng-sign = lt_matnr-sign.

ls_content_query-matnr_rng-option = lt_matnr-option.

You are already inside the loop. Does the table have a column named high?

Read only

0 Likes
1,619

it gives me an error at loop it_matnr[] . It says i need to use an assign ,transportation or into wa statement along with it

Read only

0 Likes
1,619

doh, made a mistake in my last post. I forgot to remove the []. The code should be:

Loop at lt_matnr.

ls_content_query-matnr_rng-high = lt_matnr-high. < your code is erroring here

ls_content_query-matnr_rng-low = lt_matnr-low.

ls_content_query-matnr_rng-sign = lt_matnr-sign.

ls_content_query-matnr_rng-option = lt_matnr-option.

append ls_content_query-matnr_rng.

Clear ls_content_query-matnr_rng.

Endloop.

Can you post the definition for the table lt_matnr?

Read only

0 Likes
1,619

Kevin is correct. You do not need the Brackets at yout LOOP it_matnr. You do get inside the loop and you error is at the next line of code. Check your struture for it_matnr, does it include a component named HIGH, as well as the other fields?

Read only

0 Likes
1,619

Hi,

*TYPES: BEGIN OF lty_matnr,

*matnr TYPE /sapapo/matnr,

*END OF lty_matnr.

DATA: lt_matnr TYPE range of matnr,

ls_matnr like line of lt_matnr.

Loop at lt_matnr into ls_matnr.

ls_content_query-matnr_rng-high = ls_matnr-high.

ls_content_query-matnr_rng-low = ls_matnr-low.

ls_content_query-matnr_rng-sign = ls_matnr-sign.

ls_content_query-matnr_rng-option = ls_matnr-option.

append lt_content_query-matnr_rng from ls_content_query. "Declare an internal table of structure ls_content-query.

Clear ls_content_query-matnr_rng.

Endloop.

Regards,

Subramanian

Edited by: Subramanian PL on Jun 27, 2008 3:50 PM

Read only

0 Likes
1,619

Only ranges have the high low option and sign

Read only

Former Member
0 Likes
1,619

Hi,

When you declare an object as select-options and ranges

then only HIGH and LOW values are possible.

Declare your object type of ranges.

Regards,

Rajitha.

Read only

kesavadas_thekkillath
Active Contributor
0 Likes
1,619

TYPES: BEGIN OF lty_matnr,

matnr TYPE /sapapo/matnr,

END OF lty_matnr.

DATA: lt_matnr TYPE STANDARD TABLE OF lty_matnr ,

ls_matnr TYPE lty_matnr.

Loop at lt_matnr[] into ls_matnr. " THIS DOESN'T WORK"

ls_content_query-matnr_rng-high = lt_matnr-high.

ls_content_query-matnr_rng-low = lt_matnr-low.

ls_content_query-matnr_rng-sign = lt_matnr-sign.

ls_content_query-matnr_rng-option = lt_matnr-option.

append ls_content_query-matnr_rng.

Clear ls_content_query-matnr_rng.

Endloop.

Read only

bpawanchand
Active Contributor
0 Likes
1,619

TYPES: BEGIN OF lty_matnr,

matnr TYPE /sapapo/matnr,

END OF lty_matnr.

DATA: lt_matnr TYPE STANDARD TABLE OF lty_matnr WITH HEADER LINE,

ls_matnr TYPE lty_matnr.

Loop at lt_matnr.

ls_content_query-matnr_rng-high = lt_matnr-high.

ls_content_query-matnr_rng-low = lt_matnr-low.

ls_content_query-matnr_rng-sign = lt_matnr-sign.

ls_content_query-matnr_rng-option = lt_matnr-option.

append ls_content_query-matnr_rng.

Clear ls_content_query-matnr_rng.

Read only

Former Member
0 Likes
1,619

Hi,

you are looping the body of your internal without any header, so the basic of internal table is that to read a internal table you always req a header line or work area so you have to specify a work area.

say

loop at itab. instead of loop at itab[].

with luck,

pritam.

Read only

Former Member
0 Likes
1,619

hi

u r Using

loop at i_iatab[] which signifies whole body of the table not the header line.

PLz use

loop at i_itab.

<statements>

endloop.

This will definately work.

Reward if helpful.

Sumit Agarwal

Read only

Former Member
0 Likes
1,619

HI ,

declare your structure as below

TYPES: BEGIN OF lty_matnr,

Sign type c,

option(2) type c,

low TYPE /sapapo/matnr,

high TYPE /sapapo/matnr,

END OF lty_matnr.

or declare

data : lt_matnr type range of matnr.

and check it will work.

Regards

Raj

Read only

Former Member
0 Likes
1,619

TYPES: BEGIN OF lty_matnr,

matnr TYPE /sapapo/matnr,

END OF lty_matnr.

DATA: lt_matnr TYPE STANDARD TABLE OF lty_matnr WITH HEADER LINE,

ls_matnr TYPE lty_matnr.

Loop at lt_matnr. " Just Remove the Square Braces it will work"

ls_content_query-matnr_rng-high = lt_matnr-high.

ls_content_query-matnr_rng-low = lt_matnr-low.

ls_content_query-matnr_rng-sign = lt_matnr-sign.

ls_content_query-matnr_rng-option = lt_matnr-option.

append ls_content_query-matnr_rng.

Clear ls_content_query-matnr_rng.

Endloop.