‎2008 Mar 26 12:31 PM
Hi Gurus,
The following code
DATA : lv_matnr LIKE mara-matnr.
DATA : itab2 LIKE itab1 OCCURS 0 WITH HEADER LINE .
DATA : itab3 LIKE itab1 OCCURS 0 WITH HEADER LINE .
DATA : index TYPE sy-index .
LOOP AT itab1 .
AT NEW matnr .
APPEND itab1 TO itab2 .
ENDAT .
ENDLOOP .
LOOP AT itab2 .
READ TABLE itab1 WITH KEY matnr = itab2-matnr .
IF sy-subrc = 0 .
index = sy-tabix .
index = index + 1 .
APPEND itab1 TO itab3 .
LOOP AT itab1 FROM index .
IF itab1-matnr <> itab2-matnr .
EXIT .
ENDIF .
CLEAR : itab1-posnr ,
itab1-matnr ,
itab1-arktx ,
itab1-kwmeng .
APPEND itab1 TO itab3 .
ENDLOOP .
ENDIF .
ENDLOOP .
REFRESH : itab1 .
itab1[] = itab3[] .
LOOP AT itab1.
PERFORM write_form USING 'ITEM_HEADER' 'SET' 'TOP' 'MAIN'.
SHIFT itab1-posnr LEFT DELETING LEADING '0'.
PERFORM write_form USING 'ITEM_LINE' 'SET' 'BODY' 'MAIN'.
ENDLOOP. -
>>>>>> generates output like below
_________________________________________________
Sr | MatNum | MatDesc | Quantity | Charecteristics |
no |
-
1 | 00000012 | CCslab | 50 | Moisture |
|0.000| over size
|0.000| under size
|0.000| phos percnt
|0.000| chrome
|0.000| Ferrous
___________________________________________________
It is clearing all values of posnr, matnr, arktx, in output after performing AT NEW but not able to clear value of quantity field kwmeng. Kwmeng is type of floating point field. as per i know when we clear any floating point value it is set to its initial value... thats why it is showing 0.000 in output as it is reset to initial..
my question is if it is like that then how i should i avoid appearing 0.000 in output of this.
what statement i should use to clear 0.000.
and what should be my approach.????
‎2008 Mar 26 12:36 PM
while writing the output check if the field kwmeng is initial
and write as ...
loop at itab1.
if itab1-kwmeng is initial.
write : ' '. <-- write blank if kwmeng is initial ...
endif.
endloop.
‎2008 Mar 26 12:36 PM
while writing the output check if the field kwmeng is initial
and write as ...
loop at itab1.
if itab1-kwmeng is initial.
write : ' '. <-- write blank if kwmeng is initial ...
endif.
endloop.
‎2008 Mar 26 12:36 PM
Hi,
If you use are using NON-ALV reports just move it to a variable of character data type and give the addition NO-ZERO with the WRITE Command. If you use alv add the field NO_ZERO with the fieldcat.
Regards,
Sankar.
‎2008 Mar 26 12:37 PM
hi ,
the system is doing right.
coz quantity is a number(packed decimal) field, thats why it will show initial values as 0.000.
if you do not want the initial value,
then pass the space to that quantity variable
by using SPACE command.
Ex:
Quantity Fld = SPACE.
Reawrd points if useful
Chandra
‎2008 Mar 26 12:39 PM
data:zch(1).
if itab1-kwmeng is inital.
zch = ' '.
endif.
then use zch in write statement.
‎2008 Mar 26 1:17 PM
hi gurus
as you said i used
if itab1-kwmeng is initial.
itab1-kwmeng = ' '.
endif.
after CLEAR : itab1-posnr,
itab1-matnr,
itab1-arktx,
itab1-kwmeng.
but it is showing same output and kwmeng showing 0.000
when i am using if itab1-kwmeng is initial.
itab1-kwmeng = ' 2.000 '. " or any other digit
endif.
it is showing that digit to the out put.but when i am using itab1-kwmeng = SPACE. or itab1-kwmeng = ' ' it is showing 0.000 again
is there any other way to remove 0.000
‎2008 Mar 26 1:27 PM
declare itab1-kwmeng as a character type ...
if itab1-kwmeng is initial.
itab1-kwmeng = ' '.
endif.