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

Search dump using range table

ling_shi
Associate
Associate
0 Likes
976

Hi Guys,

When I use the following code, it creates dump. I wonder any body can help me how to solve it.

regards.

Ling

data: t_range type range of string with HEADER LINE,

s_range like line of t_range.

s_range-sign = 'I'.

s_range-option = 'CP'.

s_range-low = '*'.

append s_range to t_range.

types: BEGIN OF typ_stru,

ch type c,

in type i,

end of typ_stru.

data: lt_ids type table of typ_stru,

ls_ids type typ_stru.

do 3 times.

ls_ids-ch = sy-index.

ls_ids-in = sy-index.

append ls_ids to lt_ids.

enddo.

clear ls_ids.

loop at lt_ids into ls_ids.

if ls_ids-ch in t_range.

write:/ ls_ids-in.

endif.

endloop.

6 REPLIES 6
Read only

Former Member
0 Likes
790

Hi Ling,

My understanding is you cant compare a String type table range in a IF condition.

Try to change the data definition as shown below. Hope this works.

Original Code:

data: t_range type range of string with HEADER LINE

Suggested Code:

data: t_range type range of CHAR10 with HEADER LINE

Anyways i am still unclear of what exactally u r trying to do. Let me know if the above info helps.

Cheers

VJ

Read only

Former Member
0 Likes
790

Hi Ling,

Welcome to SDN Forums.

As you are comparing each and every row anyway, I don't see a reason why you will have to RANGES here.

Why can't you do this?

<b>

IF ls_ids-ch CP '*'.

write:/ ls_ids-in.

ENDIF.</b>

Regards,

Ravi

Note : Please mark all the helpful answers

Read only

Former Member
0 Likes
790

ABAP is very specific about how to build range tables. Try this:


TYPES: BEGIN OF typ_stru,
  ch TYPE c,
  in TYPE i,
END OF typ_stru.

DATA: lt_ids TYPE TABLE OF typ_stru,
ls_ids TYPE typ_stru.

RANGES: s_range FOR ls_ids-ch.

s_range-sign = 'I'.
s_range-option = 'CP'.
s_range-low = '*'.
APPEND s_range.

DO 3 TIMES.
  ls_ids-ch = sy-index.
  ls_ids-in = sy-index.
  APPEND ls_ids TO lt_ids.
ENDDO.
CLEAR ls_ids.
LOOP AT lt_ids INTO ls_ids.
  IF ls_ids-ch IN s_range.
    WRITE:/ ls_ids-in.
  ENDIF.
ENDLOOP.

Rob

Read only

Former Member
0 Likes
790

Where are you getting the error(which line)? What is the error message?

I don't think you are allowed to use string type ranges.

Read only

ling_shi
Associate
Associate
0 Likes
790

Hi all,

Actually the range table t_range will be used in dynamic search criteria in a danamic program, i.e. a variant with type char40 in t_range, a variant with type raw in t_range. So it has to be defined as range of string.

Best Regards.

Ling

Read only

vinod_gunaware2
Active Contributor
0 Likes
790

Instead of below code use read statement

if ls_ids-ch in t_range.

write:/ ls_ids-in.

endif.

<b>read t_range with key low = ls_ids-ch .

if sy-subrc = 0.

write:/ ls_ids-in.

endif.</b>

this will solve ur problem.

regards

vinod