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

Problem in IF condition.

Former Member
0 Likes
1,751

hi all,

i have one condition as follows.

if ( ( g_wrk_ymdmat11-brgew = 0 ) or ( g_wrk_ymdmat11-brgew is initial ) ) AND

( ( g_wrk_ymdmat11-ntgew = 0 ) or ( g_wrk_ymdmat11-ntgew is initial ) ).

g_wrk_ymdmat11-brgew = 1.

g_wrk_ymdmat11-ntgew = 1.

endif.

here if i give g_wrk_ymdmat11-brgew value less than 0, then it is taking as 0 and assignning 1 to the variable g_wrk_ymdmat11-brgew .

It has to check only with 0 or initial.

if i give 0.005 it should not satisfy the condition (IF).

plz help me.

regards

sreeni

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,700

Hi,

Just use the IS INITIAL.

if g_wrk_ymdmat11-brgew is initial AND

g_wrk_ymdmat11-ntgew is initial.

g_wrk_ymdmat11-brgew = 1.

g_wrk_ymdmat11-ntgew = 1.

endif.

Thanks

Naren

14 REPLIES 14
Read only

Former Member
0 Likes
1,701

Hi,

Just use the IS INITIAL.

if g_wrk_ymdmat11-brgew is initial AND

g_wrk_ymdmat11-ntgew is initial.

g_wrk_ymdmat11-brgew = 1.

g_wrk_ymdmat11-ntgew = 1.

endif.

Thanks

Naren

Read only

0 Likes
1,700

Hi Narendran,

I think the solution you provided is just 50% right. The above mentioned issue will not be corrected just by mentioning initial. What in case the value of g_wrk_ymdmat11-brgew is equal to 0 ???. as 0 can not be the initial. so it fails with the condition. Please let me know your suggesstion on this.

Read only

0 Likes
1,700

hi,

I am sry.

when i give values for the specified variable only between (0 and 0.5) (not 0 and not 0.5) then the system is considering as 0 and satisfying the IF condition.

here it should not satisfy the IF condition for this values.

Plz help me.

regards

sreeni

Read only

0 Likes
1,700

Hi,

declare brgew and ntgew as character and then use initial and check..

Regards,

nagaraj

Read only

0 Likes
1,700

Hi,

These two feilds from mara table, so we are using as it is in IDOC also.

i gave u part of code only.

it should not satisfy if the value is 0.005, but it is satisfyilng IF condition.

For this wht to do.

plz help me.

points will be rewarded.

regards

sreeni

Read only

0 Likes
1,700

> declare brgew and ntgew as character and then use

> initial and check..

No, don't. It's extremely confusing to name a field after a standard one and give it a different type. The only time you should ever need to need to put a QUAN or CURR into a type C is just before outputting it to a file, and you should have done any maths on it well before it got to that stage.

Read only

Former Member
0 Likes
1,700

Just use is initial no need to use 0 and initial in if statement.

Read only

former_member386202
Active Contributor
0 Likes
1,700

Hi,

I think its datatype problem, just check it is initial or not. It will work

Regards,

Prashant

Read only

Former Member
0 Likes
1,700

Hi,

Make sure the data type for g_wrk_ymdmat11-brgew and g_wrk_ymdmat11-ntgew can contain 0.005. If the data type is integer, 0.005 will be regarded as 0 or initial.

Read only

Former Member
0 Likes
1,700

The above mentioned issue will not be corrected just by mentioning initial condition. What in case the value of g_wrk_ymdmat11-brgew is equal to 0 ???. as 0 can not be the initial. so it fails with the condition. I think there may be problem of brgew datatype.Please let me know your suggesstion on this.

Read only

kesavadas_thekkillath
Active Contributor
0 Likes
1,700

ntgew, brgew - > what is the data type of these fields ??

Read only

Former Member
0 Likes
1,700

If g_wrk_ymdmat11-brgew has datatype of Quantity field with decimal places.

Condition

If g_wrk_ymdmat11-brgew = 0 is false when u give 0.0005 to g_wrk_ymdmat11-brgew.

If g_wrk_ymdmat11-brgew is initial is also false when u give 0.0005 to g_wrk_ymdmat11-brgew.

Read only

kesavadas_thekkillath
Active Contributor
0 Likes
1,700

The data type of these 2 fields are QUAN.

For instance solution declare two variables of type p.

ex:

data:wk_brgew type p decimals 3,

wk_ntgew type p decimals 3.

wk_brgew = g_wrk_ymdmat11-brgew.

wk_ntgew = g_wrk_ymdmat11-ntgew.

try putting the if conditions like

1)if not ( g_wrk_ymdmat11-brgew > 0 and g_wrk_ymdmat11-ntgew > 0 ).

2)if ( g_wrk_ymdmat11-brgew = 0 and g_wrk_ymdmat11-ntgew = 0 ).

write u r code here.

endif.

if this didnt work try replacing 0 with initial.

reward if helpful

Read only

Former Member
0 Likes
1,700

Did you have uncheck the "Fixed point arithmetic" at program attributes