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 displaying the data

Former Member
0 Likes
1,732

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 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.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,623

Dear Ricx ,

The data type of the fields might be packed with decimals 2 , when ever the value is initial , it will display the initial value only , for example for char type : ' ' , numeric : 0 etc , best way to approch this is when ever ur lower value is initial move that value into a charcter type value and display that , which obviously give u space.

Hope this Helps.

Regards,

Ramesh.

12 REPLIES 12
Read only

Former Member
0 Likes
1,623

Hi,

Try this.

Instead of checking for greater than 0, check whether the lower limit is initial or equal to space.

Sharin.

Read only

0 Likes
1,623

hi sharin,

I had checked in the tcode that it is not compulsory that the upper limit or lower limit is must required.It is picking up the by default 0,and i am trying that if there is no value of upper limit or lower limit is not defined it should not display by default 0,it shows only the value whic is defined in it.

Till now i am not able to do it with the code ii had defined, plzz provide me guidelines for solving this problem.

Edited by: ricx .s on Sep 24, 2008 6:09 AM

Read only

Former Member
0 Likes
1,623

Hi Rick,

Is this problem in display is for Report or Smartforms? you have mentioned both


I am working on a report which is previously developed ,
this is basically code for the smartforms

Actually the problem is not with this piece of code (even though this is poorly constructed logic)

If it is a ALV report then you need to set a flag in the Fieldcatalog

slis_fieldcat_alv-no_zero = 'X'.

Cheers,

Kothand

Read only

Former Member
0 Likes
1,624

Dear Ricx ,

The data type of the fields might be packed with decimals 2 , when ever the value is initial , it will display the initial value only , for example for char type : ' ' , numeric : 0 etc , best way to approch this is when ever ur lower value is initial move that value into a charcter type value and display that , which obviously give u space.

Hope this Helps.

Regards,

Ramesh.

Read only

0 Likes
1,623

hi,

It is basically a ABAP Program and it is passing the values to the SMARTFORMS and yes the values of the following is:-

toleranzob TYPE p DECIMALS 2,

toleranzun TYPE p DECIMALS 2,

u want to say that i should convert it into the char type ?

Read only

0 Likes
1,623

Hi,

Well. If it is report and passing value to smartforms then Ramesh is right. You need to declare these values as type 'C'. ( If there is no value calculation involved with this, then no problem in declaring it as 'C'. )

Also in smartform make these variables as Character type

Cheers,

Kothand

Read only

0 Likes
1,623

hi kothand,

I am doing the code for it as:-

DATA : BEGIN OF vv OCCURS 0,

verwmerkm LIKE plmk-verwmerkm ,

toleranzob TYPE p DECIMALS 2,

toleranzun TYPE p DECIMALS 2,

tot1 type string, "tot1 for the toleranzob

tot2 type string, "tot2 for the toleranzun

kurztext LIKE qpmt-kurztext,

END OF vv.

LOOP AT vv.

SELECT SINGLE toleranzob FROM qpmk INTO vv-toleranzob WHERE mkmnr = vv-verwmerkm.

SELECT SINGLE toleranzun FROM qpmk INTO vv-toleranzun WHERE mkmnr = vv-verwmerkm . "AND toleranzun GT 0.

vv-tot1 = vv-toleranzun.

vv-tot2 = vv-toleranzob.

if vv-tot1 > 0 and vv-tot2 > 0.

MODIFY vv FROM vv INDEX sy-tabix TRANSPORTING tot1 tot2.

elseif vv-tot1 > 0 and vv-tot2 = 0.

MODIFY vv FROM vv INDEX sy-tabix TRANSPORTING tot1.

elseif vv-tot1 = 0 and vv-tot2 > 0.

MODIFY vv FROM vv INDEX sy-tabix TRANSPORTING tot2.

endif.

endloop.

but i have to convert declare the variables in the smartform (tot1,tot2) so dat it can show the data .... tell me if anything i am doing wrong ?

Read only

0 Likes
1,623

Hi Rick,

Yes. You need to convert the variables that are displayed in the smartform also to String to avoid zero.

Also the code you have written can be tuned as follows


LOOP AT vv.

SELECT SINGLE toleranzob toleranzun FROM qpmk INTO ( vv-toleranzob, vv-toleranzun ) WHERE mkmnr = vv-verwmerkm. 

vv-tot1 = vv-toleranzun.
vv-tot2 = vv-toleranzob.

if vv-toleranzun > 0 and vv-toleranzob > 0.  "Dont compare string type with numbers
MODIFY vv FROM vv INDEX sy-tabix TRANSPORTING tot1 tot2.

elseif vv-toleranzun > 0 and vv-toleranzob = 0.
MODIFY vv FROM vv INDEX sy-tabix TRANSPORTING tot1.

elseif vv-toleranzun = 0 and vv-toleranzob > 0.
MODIFY vv FROM vv INDEX sy-tabix TRANSPORTING tot2.

endif.

clear w.
endloop.

Cheers,

Kothand

Read only

0 Likes
1,623

hi,

actually i pasted the wrong code ,this is the code which i am using right now,yes will declare the variables in the smartform also.

but if i will not compare them how it will show the desired result,is it possible?

here's d code :-

LOOP AT vv.

SELECT SINGLE toleranzob toleranzun FROM qpmk INTO ( vv-toleranzob, vv-toleranzun ) WHERE mkmnr = vv-verwmerkm.

vv-tot1 = vv-toleranzun.

vv-tot2 = vv-toleranzob.

if vv-tot1 > 0 and vv-tot2 > 0.

MODIFY vv FROM vv INDEX sy-tabix TRANSPORTING tot1 tot2.

elseif vv-tot1 > 0 and vv-tot2 = 0.

MODIFY vv FROM vv INDEX sy-tabix TRANSPORTING tot1.

elseif vv-tot1 = 0 and vv-tot2 > 0.

MODIFY vv FROM vv INDEX sy-tabix TRANSPORTING tot2.

endif.

clear w.

endloop.

Read only

0 Likes
1,623

Hello Rick,

I meant dont compare string with numbers and use packed decimals.


if vv-tot1 > 0 and vv-tot2 > 0. "Wrong

The following is correct format


if vv-toleranzob > 0 and vv-toleranzun > 0. "Correct

Cheers,

Kothand

Read only

0 Likes
1,623

oh ok ok ,i mistaken. anyways thanks for your guidance and i am looking for that smartforms now and change the values in it .

Read only

Former Member
0 Likes
1,623

Hi Ricx,

Do it as follows u will get the required result:

Data: v_toleranzob type string,

v_val type string.

if vv-toleranzob = '0'.

v_toleranzob = space.

else.

v_val = vv-toleranzob .

concatenate '-' v_val into v_toleranzob.

endif.

write:/ 'Carbon ->', vv-toleranzob, v_toleranzob.

try this code in ur program. Here if the value of vv-toleranzob is 0 and vv-toleranzun = '0.15'then output will come as

Carbon->0.15

otherwise if vv-toleranzob is not 0 , its some value say 0.17 output will come as:

Carbon->0.15 - 0.17

Regds.

Shweta.