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

maximum and minimum value..

Former Member
0 Likes
1,367

Hi,

I want to print/output maximum and minimun value as range from one internal table.

How to print.

Example: for entries 1,2,3,5,6,8,9.

output : 01-09.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
787

HI,

Use aggeriget function .

tables: ekko.

data: begin of itab occurs 0,

ebeln like ekko-ebeln,

matnr like ekpo-matnr,

netpr like ekpo-netpr,

end of itab.

data: v_cnt like sy-tabix.

select-options: s_ebeln for ekko-ebeln .

select ebeln from ekko into corresponding fields of table itab where ebeln in s_ebeln.

loop at itab.

select count(*) into v_cnt from ekpo where ebeln = itab-ebeln.

write:/1 itab-ebeln,15 v_cnt.

endloop.

Regards,

Nehru.s

5 REPLIES 5
Read only

Former Member
0 Likes
788

HI,

Use aggeriget function .

tables: ekko.

data: begin of itab occurs 0,

ebeln like ekko-ebeln,

matnr like ekpo-matnr,

netpr like ekpo-netpr,

end of itab.

data: v_cnt like sy-tabix.

select-options: s_ebeln for ekko-ebeln .

select ebeln from ekko into corresponding fields of table itab where ebeln in s_ebeln.

loop at itab.

select count(*) into v_cnt from ekpo where ebeln = itab-ebeln.

write:/1 itab-ebeln,15 v_cnt.

endloop.

Regards,

Nehru.s

Read only

Former Member
0 Likes
787

sort the values ...

say .. itab has entries

sort itab by field1.

read table itab index 1.

v_min = itab-field1.

sort itab by field1 descending.

read table itab index 1.

v_max = itab-field1.

Read only

Former Member
0 Likes
787

Hi,

Check this

Regards,

Satish

Read only

Former Member
0 Likes
787

Hi,

You can do as below:



sort itab by f1 descending.

Read table itab  index 1.

write : 'Maximum value is', itab-f1.

sort itab by f1 ascending.

Read table itab index 1.

write : 'Mnimum value is', itab-f1.

Thanks,

Sriram Ponna.

Read only

Former Member
0 Likes
787

Hi,

Check the below logic.

data: begin of itab occurs 0,

num type i,

end of itab.

data: v_min type i,

v_max type i.

do 9 times.

if sy-index = 4 or

sy-index = 7.

continue.

endif.

itab-num = sy-index.

append itab.

enddo.

if not itab[] is initial.

read table itab index 1.

v_min = itab-num.

v_max = itab-num.

loop at itab.

if itab-num lt v_min.

v_min = itab-num.

elseif itab-num gt v_max.

v_max = itab-num.

endif.

endloop.

endif.

write:/5 v_min, 25 v_max.