05-22-2006 7:47 AM
hey can you people tell me how to add Zeros in front of quantity field or price field.
I used conversion_alpha_input FM before writing to file but its not writing with front zeros..
any alternatives.
Ambichan
05-22-2006 8:00 AM
Hi,
The easy solution is to convert the filed to a character filed and then apply a conversion exit function module (for eg. the FM attached to MATNR) and this could give a good output.
Hope it helps
Anirban
05-22-2006 9:10 AM
could you please be more specific..
please tell me which FM.
thanks.
Ambcihan
05-22-2006 9:17 AM
Have you tried using a NUMC variable?
It always has leading zeros.
Code would be:
data: amount(9) type c,
numc_amount(9) type n.
If char field only contains numeric data
if amount co '0123456789 '. "Added a space in here!"
numc_amount = amount.
endif.
If the numc amount is filled.
if not numc_amount is initial.
Do something with it! (for example: WRITE)
write: / 'Number is: ' numc_amount.
endif.
05-22-2006 10:40 AM
Hi
I was talking about <b>FM CONVERSION_EXIT_MATN1_INPUT</b>
Hope it helps
Anirban
05-22-2006 9:19 AM
05-22-2006 11:54 AM
hi,
a small logic to provide leading zeroes. i am not aware that is there any function module for this purpose.
*--To provide leading zeroes
DATA : V_CURR TYPE VBAK-NETWR,
LV_CHAR17(17) TYPE C VALUE '00000000000000000',
V_CHAR(17) TYPE C,
v_char2(17) type c.
V_CURR = '10.58'.
WRITE V_CURR TO V_CHAR.
CONDENSE V_CHAR NO-GAPS.
DATA : V_STRLEN TYPE I.
BREAK-POINT.
V_STRLEN = STRLEN( V_CHAR ).
if v_strlen < 17.
v_strlen = 17 - v_strlen.
CONCATENATE LV_CHAR17+0(V_strlen)
v_char
INto v_char.
endif.
NOW you can use V_CHAR field. (this will be prefixed with leading zeroes)
regards
srikanth
Message was edited by: Srikanth Kidambi
05-22-2006 12:36 PM
Hi,
Please have a look, logic is quite simple.
REPORT ZLEADQUANTZEROS .
DATA: L_MENGE(17).
DATA: L_DEC(13), L_FRACTION(3).
DATA: T_MSEG TYPE STANDARD TABLE OF MSEG WITH HEADER LINE.
SELECT * FROM MSEG
INTO TABLE T_MSEG
UP TO 100 ROWS.
LOOP AT T_MSEG.
L_MENGE = T_MSEG-MENGE.
SPLIT L_MENGE AT '.' INTO L_DEC L_FRACTION.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = L_DEC
IMPORTING
OUTPUT = L_DEC.
CONCATENATE L_DEC L_FRACTION INTO L_MENGE
SEPARATED BY '.' .
WRITE: / L_MENGE.
ENDLOOP.
05-22-2006 12:48 PM
Hi,
Do not required any programming to do this.
Just define them as NUMC data type- it will automatcally add initial zero's.
Regards,
Suresh