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

Min Between 2 Variable

Former Member
0 Likes
1,659

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
Read only

Former Member
0 Likes
1,293

If P_cpl GE P_cpu.

if sy-subrc eq 0.

write : P_Cpu.

else

write P_cpl.

endif.

regrads

Devanand

6 REPLIES 6
Read only

Former Member
0 Likes
1,294

If P_cpl GE P_cpu.

if sy-subrc eq 0.

write : P_Cpu.

else

write P_cpl.

endif.

regrads

Devanand

Read only

0 Likes
1,293

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

Read only

nikhil_chitre
Active Participant
0 Likes
1,293

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

Read only

Former Member
0 Likes
1,293

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.

Read only

Former Member
0 Likes
1,293

Hi Alawiyah,

do this code.


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

Read only

Former Member
0 Likes
1,293

Hi all

Thanks for the useful answers.

Regards

az