‎2008 Sep 23 9:29 AM
Hi,
I am working on a report which is previously developed ,this is basically code for the smartforms in which it is showing the upper limit and the lower limit which are present in the table QPMK having the fields toleranzun and toleranzob. i.e. if the lower limit is specified and the upper limit is specified i.e. 0.15 and the lower limit is not then it is picking up the default value 0 and showing the data as :-
carbon -> 0.15 - 0.00
But i want to show the data that if its lower limit or upper limit is not defined then it should display the only value which is defined .
for example,
if upper limit is defined as 0.15 and the lower limit is not told then it should display the data as :-
carbon -> 0.15
i had tried to modify the code but it is able to display it.
here's d cde:-
LOOP AT vv.
SELECT toleranzob FROM qpmk INTO vv-toleranzob WHERE mkmnr = vv-verwmerkm AND toleranzob GT 0.
MODIFY vv FROM vv INDEX sy-tabix TRANSPORTING toleranzob.
ENDSELECT.
ENDLOOP.
LOOP AT vv.
SELECT toleranzun FROM qpmk INTO vv-toleranzun WHERE mkmnr = vv-verwmerkm AND toleranzun GT 0.
MODIFY vv FROM vv INDEX sy-tabix TRANSPORTING toleranzun.
ENDSELECT.
ENDLOOP.
plzz provide guidelines for solving it.....
‎2008 Sep 23 9:44 AM
check the below condition....
if toleranzun > 0 and toleranzob > 0
write: toleranzun-value - toleranzob-value.
else toleranzun > 0 and toleranzob = 0
write: toleranzun-value.
else toleranzun = 0 and toleranzob > 0
write: toleranzob-value.
endif.
‎2008 Sep 23 12:08 PM
hi,
I had changed the logic a bit but still it is displaying the upper and lower limit values if is not defined.
Instead of 2 loops i am displaying the data in 1 loop.
but when i add the if else condition then it is not displaying the data .....
how should i specify the if else condition here?
****************************************************************************
*if toleranzun > 0 and toleranzob > 0
*MODIFY vv FROM vv INDEX sy-tabix TRANSPORTING toleranzob.
*MODIFY vv FROM vv INDEX sy-tabix TRANSPORTING toleranzun.
*else toleranzun > 0 and toleranzob = 0
*MODIFY vv FROM vv INDEX sy-tabix TRANSPORTING toleranzun.
*else toleranzun = 0 and toleranzob > 0
*MODIFY vv FROM vv INDEX sy-tabix TRANSPORTING toleranzob.
*endif.
*****************************************************************************
here 's d code which i am currently i am using :-
LOOP AT vv.
SELECT toleranzob FROM qpmk INTO vv-toleranzob WHERE mkmnr = vv-verwmerkm AND toleranzob GT 0.
MODIFY vv FROM vv INDEX sy-tabix TRANSPORTING toleranzob.
ENDSELECT.
SELECT toleranzun FROM qpmk INTO vv-toleranzun WHERE mkmnr = vv-verwmerkm AND toleranzun GT 0.
MODIFY vv FROM vv INDEX sy-tabix TRANSPORTING toleranzun.
ENDSELECT.
plzz provide me guidelines for solving this problem.
‎2008 Sep 23 12:21 PM
Hi Ricx,
If u r sure tht only 1 line will be fetched after select query thn use SELECT SINGLE... instead of SELECT...ENDSELECT. This will improve the performance also.
Chk this code:
LOOP AT vv.
SELECT SINGLE toleranzob FROM qpmk INTO vv-toleranzob WHERE mkmnr = vv-verwmerkm AND toleranzob GT 0.
SELECT SINGLE toleranzun FROM qpmk INTO vv-toleranzun WHERE mkmnr = vv-verwmerkm AND toleranzun GT 0.
if toleranzun > 0 and toleranzob > 0.
MODIFY vv FROM vv INDEX sy-tabix TRANSPORTING toleranzob toleranzun.
elseif toleranzun > 0 and toleranzob = 0
MODIFY vv FROM vv INDEX sy-tabix TRANSPORTING toleranzun.
elseif toleranzun = 0 and toleranzob > 0
MODIFY vv FROM vv INDEX sy-tabix TRANSPORTING toleranzob.
endif.
endloop.
Regards,
Saba
‎2008 Sep 23 12:24 PM
Hi Saba,
the problem is multiple lines are fetched in the select query thats why i had used it. what should i do for it?
‎2008 Sep 23 12:25 PM
Pls note:
TRANSPORTING variables in MODIFY stmnt will be vv-toleranzob and vv-toleranzun instead of toleranzob and toleranzun.
i.e.
if toleranzun > 0 and toleranzob > 0.
MODIFY vv FROM vv INDEX sy-tabix TRANSPORTING vv-toleranzob vv-toleranzun.
elseif toleranzun > 0 and toleranzob = 0
MODIFY vv FROM vv INDEX sy-tabix TRANSPORTING vv-toleranzun.
elseif toleranzun = 0 and toleranzob > 0
MODIFY vv FROM vv INDEX sy-tabix TRANSPORTING vv-toleranzob.
endif.
‎2008 Sep 23 12:27 PM
If multiple lines are fetched then it will be overwritten by the first or the last value in the variables vv-toleranzob and vv-toleranzun i think so because they are variables that can store one value at a time unlike internal tables.
‎2008 Sep 23 12:30 PM
Srry pl ignore my post as i thought vv-toleranzob and vv-toleranzun are variables. After gng thru the thread agn i realized they are internal table/wrk area.
‎2008 Sep 23 12:34 PM
hi,
i am using ur code and done some modification in it,but it is still displaying the same output,nothing is changed.
here's d code:-
LOOP AT vv.
SELECT SINGLE toleranzob FROM qpmk INTO vv-toleranzob WHERE mkmnr = vv-verwmerkm AND toleranzob GT 0.
SELECT SINGLE toleranzun FROM qpmk INTO vv-toleranzun WHERE mkmnr = vv-verwmerkm AND toleranzun GT 0.
if vv-toleranzun > 0 and vv-toleranzob > 0.
MODIFY vv FROM vv INDEX sy-tabix TRANSPORTING toleranzob toleranzun.
elseif vv-toleranzun > 0 and vv-toleranzob = 0.
MODIFY vv FROM vv INDEX sy-tabix TRANSPORTING toleranzun.
elseif vv-toleranzun = 0 and vv-toleranzob > 0.
MODIFY vv FROM vv INDEX sy-tabix TRANSPORTING toleranzob.
endif.
endloop.
it is still giving the same output..
even i had debugged it the statements are getting fetched.
Edited by: ricx .s on Sep 23, 2008 1:53 PM
‎2008 Sep 23 9:45 AM
Hi,
One Solution i think is to change the datatype of that particular field in Smartform to alphanumeric like NUMC, so that it wont display any thing if value is 0.
Hope it works...