04-14-2006 3:09 AM
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.
04-14-2006 3:33 AM
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
04-14-2006 3:51 AM
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
04-14-2006 3:56 AM
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
04-14-2006 4:55 AM
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.
04-14-2006 6:22 AM
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
04-14-2006 6:35 AM
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