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

use ranges

Former Member
0 Likes
744

i use it write ?

RANGES: r_course FOR hrp1001-sobid.

LOOP AT person_tab.

CLEAR r_course.

REFRESH r_course.

<b> r_course-high = hrp1001-sobid.

r_course-low = hrp1001-sobid.</b>

r_course-sign = 'I'.

r_course-option = 'BT'.

<b> APPEND r_course.</b>

ENDLOOP.

SELECT objid begda endda

FROM hrp1001

INTO (wa_itab-objid,wa_itab-begda,wa_itab-endda)

WHERE plvar ='01'

AND otype = 'D'

AND relat = '020'

AND rsign = 'B'

<b>AND objid IN r_course</b>

AND begda <= sy-datum

AND endda => sy-datum.

thankes for answer

6 REPLIES 6
Read only

Former Member
0 Likes
695

Hi

I'm trying to understand your code because it's very confused.

<u>This code is wrong,</u> you transfer the value from hrp1001, but where the select I checked the structure of PERSON_TAB and there isn't the field SOBID.

LOOP AT person_tab.
   CLEAR r_course.
   REFRESH r_course.               " Why're you refreshing the range
   r_course-high = hrp1001-sobid. " Where is the select
   r_course-low = hrp1001-sobid.
   r_course-sign = 'I'.
   r_course-option = 'BT'.
   APPEND r_course.
ENDLOOP.

I suppose you want write this:

 REFRESH r_course.
LOOP AT person_tab.
   CLEAR r_course.
   r_course-high = hrp1001-sobid. " but where are you getting SOBID
   r_course-low = hrp1001-sobid.
   r_course-sign = 'I'.
   r_course-option = 'BT'.
   APPEND r_course.
ENDLOOP.

Please to open several post for the same problem

Max

Read only

Former Member
0 Likes
695

Hi,

If you use the REFRESH statement, the internal table gets emptied out.

So you probably have just the last record you added.

Remove the REFRESH Statement and execute your query.

Regards

Meera

Read only

Former Member
0 Likes
695

In addition to not refreshing the table as the others have suggested, also consider that you are looping at person_tab, but assigning values from hrp1001-sobid. So the same values would be assigned each time anyway.

Since you are assigning the same value to both r_course-low and r_course-high, it would be better to test for equality on just r_course-low .

Rob

Read only

Former Member
0 Likes
695

Hi

i corrected the code which is below..

RANGES: r_course FOR hrp1001-sobid.

CLEAR r_course.

REFRESH r_course.

LOOP AT person_tab.

r_course-high = person_tab-sobid.

r_course-low = person_tab-sobid.

r_course-sign = 'I'.

r_course-option = 'BT'.

APPEND r_course.

ENDLOOP.

SELECT objid begda endda

FROM hrp1001

INTO (wa_itab-objid,wa_itab-begda,wa_itab-endda)

WHERE plvar ='01'

AND otype = 'D'

AND relat = '020'

AND rsign = 'B'

AND objid IN r_course

AND begda LE sy-datum

AND endda GE sy-datum.

Mark points if helpful.

Regs

Manas Ranjan Panda

Read only

anversha_s
Active Contributor
0 Likes
695

HI,

Please check this code. it will help u.

Define a range:

Ranges: r_field for <table>.

if not field1 is initial.
r_field-sign = 'I'.
r_field-option = 'EQ'.
r_field-option-low = field1.
append r_field.
endif.

if not field2 is initial.
r_field-sign = 'I'.
r_field-option = 'EQ'.
r_field-option-low = field2.
append r_field.
endif.

if field1 is initial and field2 is initial.
r_field-sign = 'I'.
r_field-option = 'EQ'.
append r_field.
endif.

select * from <table> where field1 in r_field.

Rgds

Anver

if hlped kindly mark points

Read only

Former Member
0 Likes
695

Hi sh,

1. I suppose u want to search / extract

for OBJID values,

which are contained in SOBID field.

2. Then do two changes :

a) RANGES: r_course FOR <b>hrp1001-OBJID</b>

(and not RANGES: r_course FOR hrp1001-sobid)

b) write hrp1001-sobid to r_course-high.

write hrp1001-sobid to r_course-low.

3. Also remove the

REFRESH r_course

(bcos it is clearing all times, in the looop)

regards,

amit m.