2009 Mar 19 5:48 AM
Hi,
I have module pool program, with create, change and display buttons.
Here I have a field PERNR type PERNR_D.
This field is not a mandatory field. so, I am creating a record without entering any value in this.
But when I go into display for this record, it is showing '0'.
How to remove single zero in display mode?
I tried with the following code but it is not working for me.
if zstruct-zpernr eq '00000000'.
write zstruct-zpernr to zstruct-zpernr no-zero.
endif.
Please advise me here
2009 Mar 19 5:51 AM
Hi:
It has NUMC - Character string with only digits so it shows 0 in the case of empty.
Just declare it by CHAR08 and move the value when it requires.
Regards
Shashi
2009 Mar 19 5:53 AM
but,
Here the field should accept only numbers or numerical values.
If i diclare this as char08, this may cause user to enter other than numbers..
is there any other suggestions?
2009 Mar 19 5:56 AM
PERNR_D is a data element of type NUMC, its default value is 0, but not the default value SPACE of CHAR. So you always get 0 in your table or internal table.
When you output the field to screen using WRITE or in a Table Control or ALV, you can omit 0 by using NO-ZERO or certain parameters.
2009 Mar 19 6:06 AM
hi chitra,
use this code to remove records with '0' PERNR.
DELETE itab WHERE pernr IS INITIAL.
regards,
Peter
2009 Mar 19 6:17 AM
Hi,
try this.
if zstruct-zpernr CO '0'.
write zstruct-zpernr to zstruct-zpernr no-zero.
endif.
Or if u want to use char08 ,then give validation.
if zstruct-zpernr CO '0123456789'.
write code.
else.
message 'Do not enter characters' type 'E' display like 'S'.
endif.
2009 Mar 19 6:50 AM
I tried all the ways except using char08.
as permy spec, I should not use this type.
So,
I tried to remove '0' by using the following code.but it is giving error as follows.
Please help me
Code:
if Zstruct-zpernr CO '0'.
if ( Zstruct-zpernr eq '00000000' ) or (Zstruct-zpernr is initial ).
write Zstruct-zpernr to Zstruct-zpernr no-zero.
endif.
error log:
Value is not numeric
Message no. E2135
Diagnosis
A value that is not numeric has been entered for a domain with a numeric data type. This is not allowed.
System Response
The system cannot accept the value.
Procedure
Correct your entry. You must enter a numeric value.