Application Development 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: 

Min Between 2 Variable

Former Member
0 Kudos

Hi all

I have two variables, P_CPL and P_CPU.

I want to display variable which have minimum value.

How do I write the statement?

Thanks in advance.

az

1 ACCEPTED SOLUTION

Former Member
0 Kudos

If P_cpl GE P_cpu.

if sy-subrc eq 0.

write : P_Cpu.

else

write P_cpl.

endif.

regrads

Devanand

6 REPLIES 6

Former Member
0 Kudos

If P_cpl GE P_cpu.

if sy-subrc eq 0.

write : P_Cpu.

else

write P_cpl.

endif.

regrads

Devanand

0 Kudos

one thing where do u want to display

if u wamt to display in the selection screen.

at selection-screen output.

If p_cpu ge p_cpl.

if sy-subrc eq 0.

loop at screen.

screen-field = p_cpu.

screen-active = 0.

endloop.

else.

loop at screen.

screen-field = p_cpl.

screen-active = 0.

endloop.

endif.

regards

Devanand

nikhil_chitre
Active Participant
0 Kudos

HI,

Try this

If P_CPL > P_CPU.

then..your code....

If P_CPU > P_CPL.

then..your code....

Or you could also do

your Itab has values

sort itab by field1 aescending.

read table itab index 1.

v_min = itab-field1.

Regards,

Nikhil

Edited by: Nikhil A Chitre on Jun 26, 2008 11:47 AM

Former Member
0 Kudos

Hi,

We can use relational operators like GT , GE , > , >= to compare the variables.

DATA: L_MIN TYPE I.

IF P_CPL > P_CPU.

L_MIN =  P_CPU.

ELSE.

L_MIN = P_CPL

ENDIF.

WRITE: L_MIN.

This will surely help you.

Plz reward if useful.

Thanks,

Dhanashri.

former_member598013
Active Contributor
0 Kudos

Hi Alawiyah,

do this code.


if p_cpl > p_cpu.
  write: p_cpu.
else.
 write: p_cpl.
endif.

Former Member
0 Kudos

Hi all

Thanks for the useful answers.

Regards

az