cancel
Showing results for 
Search instead for 
Did you mean: 

Endroutine lookup with interval logic

Former Member
0 Kudos

Hello experts

I wrote an endroutine which lookups a field from a standard DSO: ZWWSIC.

For the WHERE condition it checks if ZPR_FROM and ZPR_TO are equal to the result field.

This works fine.

But unfortunately ZPR_FROM and ZPR_TO sometimes is an intervall consisting of more than 2 values.

How can I implement an intervall logic comparison in the code below.

LOOP AT RESULT_PACKAGE ASSIGNING <RESULT_FIELDS>.
LOOP AT ITAB INTO WA
WHERE /BIC/ZPR_FROM = <RESULT_FIELDS>-/BIC/ZWWPRD
OR /BIC/ZWWPR_TO = <RESULT_FIELDS>-/BIC/ZWWPRD.

<RESULT_FIELDS>
-/BIC/ZWWSIC = WA-/BIC/ZWWSIC.
<RESULT_FIELDS>
-/BIC/ZZBRARW1 = <RESULT_FIELDS>-/BIC/ZZBRARW1.
<RESULT_FIELDS>
-/BIC/ZZBRARW = <RESULT_FIELDS>-/BIC/ZZBRARW.
<RESULT_FIELDS>
-/BIC/ZZBRA1 = <RESULT_FIELDS>-/BIC/ZZBRA1.
<RESULT_FIELDS>
-/BIC/ZZBRA = <RESULT_FIELDS>-/BIC/ZZBRA.
<RESULT_FIELDS>
-/BIC/ZWWPRD = <RESULT_FIELDS>-/BIC/ZWWPRD.
<RESULT_FIELDS>
-RECORD = ICOUNT.

ICOUNT
= ICOUNT + 1.
APPEND <RESULT_FIELDS> TO ITAB_TARGET.
ENDLOOP.
ENDLOOP.

Accepted Solutions (1)

Accepted Solutions (1)

former_member418141
Active Participant
0 Kudos

Hi Thomas

I would try it like this:

LOOP AT RESULT_PACKAGE ASSIGNING <RESULT_FIELDS>.
LOOP AT ITAB INTO WA.


IF /BIC/ZPR_FROM <= <RESULT_FIELDS>-/BIC/ZWWPRD
AND /BIC/ZWWPR_TO >= <RESULT_FIELDS>-/BIC/ZWWPRD.

<RESULT_FIELDS>
-/BIC/ZWWSIC = WA-/BIC/ZWWSIC.
<RESULT_FIELDS>
-/BIC/ZZBRARW1 = <RESULT_FIELDS>-/BIC/ZZBRARW1.
<RESULT_FIELDS>
-/BIC/ZZBRARW = <RESULT_FIELDS>-/BIC/ZZBRARW.
<RESULT_FIELDS>
-/BIC/ZZBRA1 = <RESULT_FIELDS>-/BIC/ZZBRA1.
<RESULT_FIELDS>
-/BIC/ZZBRA = <RESULT_FIELDS>-/BIC/ZZBRA.
<RESULT_FIELDS>
-/BIC/ZWWPRD = <RESULT_FIELDS>-/BIC/ZWWPRD.
<RESULT_FIELDS>
-RECORD = ICOUNT.

ICOUNT
= ICOUNT + 1.
APPEND <RESULT_FIELDS> TO ITAB_TARGET.

ENDIF

.
ENDLOOP.
ENDLOOP.

Former Member
0 Kudos

Thanks Tom

ZPR_FROM and ZPR_TO are CHAR fields.

Now I am getting the syntax error that ZPR_FROM and ZPR_TO are not known.

Any ideas?

Thanks

former_member418141
Active Participant
0 Kudos

Hi Thomas

Yap, I think it must be:

IF wa-/BIC/ZPR_FROM <= <RESULT_FIELDS>-/BIC/ZWWPRD
AND wa-/BIC/ZWWPR_TO >= <RESULT_FIELDS>-/BIC/ZWWPRD.


regards Tom

anshu_lilhori
Active Contributor
0 Kudos

Change the two lines like this :


IF wa-/BIC/ZPR_FROM LE <RESULT_FIELDS>-/BIC/ZWWPRD
AND  wa-/BIC/ZWWPR_TO GE <RESULT_FIELDS>-/BIC/ZWWPRD.

Now it should not give syntax error.

Regards,

AL

Answers (2)

Answers (2)

sakthi_ss
Active Participant
0 Kudos

Hi Thomas,

Whether the interval is between from and to or you mean to say there interval in from and to separately.

If interval is between from and to then you could use the code given by Tom Thielen but one issue is that it will decrease the loading performance since wa will hold all the data.

Also if you don't want the same date to be repeated, sort and delete the adjacent duplicate with comparison.

Regards,

Sakthi.

Former Member
0 Kudos

HI Sakhti

This DSO only holds less than 50 records, I think there is no need to sort.

Also the target DSO only holds 500 records.

Thanks

anshu_lilhori
Active Contributor
0 Kudos

can you please explain the record set with example like what value you are fetching and what value you have in source.

Regards,

AL