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

Looping through an internal table column to compare values

bhat_vaidya2
Active Participant
0 Likes
1,183

hello,

I need assistance with my ABAP program to compare the range of values in a column and derived the required entry in my output data. I have used attached code to test the comparison.

My requirement is to loop through the amount in column J and compare the value with the amount coming from input table ( column D).

Case 1: the input amount in item 10 is 49 and my result should be line 6 where the amount is 40,100 since 49 is greater than 40

Case 2: the input amount in item 20 is 15. My result should be line 4 since value 15 is less than the next highest value which is 20,100

bap-lookup-code.txt

hello,

I need assistance with my ABAP program to compare the range of values in a column and derived the required entry in my output data. I have used attached code to test the comparison.

My requirement is to loop through the amount in column J and compare the value with the amount coming from input table ( column D).

Case 1: the input amount in item 10 is 49 and my result should be line 6 where the amount is 40,100 since 49 is greater than 40

Case 2: the input amount in item 20 is 15. My result should be line 4 since value 15 is less than the next highest value which is 20,100

bap-lookup-code.txt

1 REPLY 1
Read only

maheshpalavalli
Active Contributor
0 Likes
808

You can change the logic to below:


" amounts that are less than main table
if <result_fields>-amount >= wa_zlookup-amount. 
" Checking the best less amount record.
if <result_fields>-field2 < wa_zlookup-amount. " Highest values less than 
         <result_fields>-field1 = wa_zaxaptcnd-field1.
          <result_fields>-field2 = wa_zaxaptcnd-field2.
endif.

endif.