04-22-2008 10:33 AM
Hi all,
I am having trouble removing the leading zeros on a char field (MATNR) in an ALV grid.
When I select the option no-zero in the field catalog, it doesn't work as MATNR is a char field.
If i process the line item manually, using
SHIFT lt_data LEFT DELETING LEADING '0'.
It appears to work when I check the table contents in the debugger. However, the ALV grid output shows all MATNR fields converted this way as blank. Why is this happening, and what can I do to avoid it?
Cheers
04-22-2008 10:37 AM
04-22-2008 10:44 AM
I tried this; it has the same effect as SHIFT LEFT -
When I look in the table, the field looks ok, however when I run the program, the ALV grid displays these values as blank.
I've even tried setting up a temporary variable like this:
-
DATA: l_temp(18) TYPE c.
lv_temp = l_data-matnr
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
EXPORTING
INPUT = lv_temp
IMPORTING
OUTPUT = lv_temp.
l_output-matnr = lv_temp.
APPEND l_output.
-
But when my ALV grid displays the table l_output, the matnr column is blank, even though there are correctly formatted values in this field. Any other suggestions?
04-22-2008 10:38 AM
04-22-2008 10:45 AM
Hi,
Use the below code.
data: v_matnr(18) type c value '000000001234'.
data: v_len type i, v_num type i.
v_len = strlen( v_matnr ).
do v_len times.
if v_matnr+v_num(1) <> '0'.
v_matnr = v_matnr+v_num.
exit.
endif.
v_num = v_num + 1.
enddo.
write:/ v_matnr.
04-22-2008 10:55 AM
04-22-2008 11:03 AM
Please read my original post Raj; that was the first thing I tried.
04-22-2008 11:14 AM
Hi,
Use this statement only but in loop.
like this
loop at lt_data into wa_data.
move wa_data-matnr to c_field.
SHIFT c_field LEFT DELETING LEADING '0'.
clear: c_field.
endloop.
regards,
Sudha
Edited by: sudha yadav on Apr 22, 2008 12:17 PM
04-22-2008 11:34 AM
Hi,
Yes, I tried this, it didn't work either. Every time I am getting an empty MATNR column.
04-22-2008 11:46 AM
04-22-2008 12:10 PM
Thanks for your offer, unfortunately I can't send my code. However, I have discovered that if I modify the table field to contain a zero trimmed number, it won't display, but if I modify it to contain letters and numbers, or a number starting with zero, it will appear.
Eg:
00142525 Will display
0023ABC Will display
142525 Will not display
Is there an option in the fieldcatalog that I have missed or something? MATNR is declared as standard (char 18)
04-22-2008 12:16 PM
Hi Dakha,
Try with
wA_fcat-datatype = 'CHAR'
wa_fcat-LZERO = ' '.
LZERO - Leading Zero
04-22-2008 12:21 PM
Thanks for your suggestion. I have tried this and it doesn't work unfortunately. Very confusing!
04-22-2008 12:33 PM
Hi Dakha Dakha,
Check this one. while building final internal table , change material no even though it is Char field. It works.
Regards,
Venkat.O
DATA:l_matnr TYPE mard-matnr VALUE '00000845'.
WRITE l_matnr to l_matnr no-ZERO.
WRITE l_matnr.
04-22-2008 12:48 PM
Venkat O is correct.
Because you are using the Data Element MATNR, the domain provides for a conversion routine MATN1 and reguardless of what you do it will still process this routine when displaying it.
Create your display value as a CHAR and you should be able to resolve your issue.
04-22-2008 12:55 PM
Hi,
you are right do this way.
FIND '-' IN wa_data-matnr.
IF sy-subrc IS NOT INITIAL.
SHIFT wa_data-matnr LEFT DELETING LEADING '0'.
ENDIF.
regards,
Sudha