‎2007 Nov 14 5:53 AM
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
‎2007 Nov 14 5:59 AM
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
‎2007 Nov 14 5:59 AM
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
‎2007 Nov 14 6:15 AM
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.
‎2007 Nov 14 6:56 AM
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
‎2007 Nov 14 7:01 AM
Hi,
declare brgew and ntgew as character and then use initial and check..
Regards,
nagaraj
‎2007 Nov 14 8:14 AM
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
‎2007 Nov 16 4:16 PM
> 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.
‎2007 Nov 14 6:04 AM
Just use is initial no need to use 0 and initial in if statement.
‎2007 Nov 14 6:07 AM
Hi,
I think its datatype problem, just check it is initial or not. It will work
Regards,
Prashant
‎2007 Nov 14 6:18 AM
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.
‎2007 Nov 14 6:18 AM
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.
‎2007 Nov 14 7:12 AM
‎2007 Nov 14 7:17 AM
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.
‎2007 Nov 14 8:21 AM
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
‎2007 Nov 14 8:40 AM
Did you have uncheck the "Fixed point arithmetic" at program attributes