2016 Mar 23 3:22 PM
In my sapscript form, there is a variable LTAP-NLENR which has value '000000000010000000712'.
All I want to do is remove the leading zeros so it becomes '10000000712'.
I have read so many discussions and they all say just use &variable(Z)&. So I tried that:
ST <AP-NLENR(Z)&
But the leading zeros were still there. Why?
So then I tried changing the print program (shown below) but this still didn't work.
/: DEFINE &LV_NLENR& = <AP-NLENR&
/: PERFORM GET_PALLETID IN PROGRAM ZWM_1043_DATA_INC
/: USING <AP-NLENR&
/: CHANGING &LV_NLENR&
/: ENDPERFORM
ST <AP-NLENR&
FORM get_palletid TABLES in_tab structure itcsy
out_tab structure itcsy.
DATA: lv_nlenr type ltap-nlenr.
CLEAR lv_nlenr.
REFRESH out_tab.
READ TABLE in_tab WITH KEY NAME = 'LTAP-NLENR'.
lv_nlenr = in_tab-value.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
EXPORTING
INPUT = lv_nlenr
IMPORTING
OUTPUT = lv_nlenr.
CLEAR out_tab.
out_tab-name = 'LTAP-NLENR'.
out_tab-value = lv_nlenr.
APPEND out_tab.
ENDFORM.
What am I doing wrong?
2016 Mar 23 4:13 PM
Hi,
where did you test your formular? same mandant? dont forget that changing the script has to be transported to other mandants. did you check that your new changes did take effect? are you sure, you changed the right programm-part?
sometimes its in loop and there are several statements printing the same variable. what value does the global variable has, when you call the script-call?
screenhot debugger
screenshot script (in target mandant)
(Z) should work. does CONVERSION_EXIT_ALPHA_OUTPUT drop the leading 0? should also work.
it was long ago since i worked with scripts. what type does your field has?
maybe add K -> &symbol(KZ)& for ignoring conversion exits.
LG
Stefan Seeburger
2016 Mar 23 3:36 PM
Hi.
(Z) option command is correct but NLENR field has got CONVERSION_EXIT_LENUM_INPUT/OUTPUT as conversion routine set.
I suggest you to use CONVERSION_EXIT_LENUM_OUTPUT routine conversion or
to use a local field l_nlenr(20) TYPE n OR c and assign your LFTAP-NLENR.
Hope to help
Bye
2016 Mar 23 3:48 PM
I changed the code but it still doesn't work:
FORM get_palletid TABLES in_tab STRUCTURE itcsy
out_tab STRUCTURE itcsy.
DATA: lv_nlenr(20) TYPE n.
CLEAR lv_nlenr.
REFRESH OUT_TAB.
READ TABLE in_tab WITH KEY NAME = 'LTAP-NLENR'.
lv_nlenr = in_tab-value.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
EXPORTING
INPUT = lv_nlenr
IMPORTING
OUTPUT = lv_nlenr.
CLEAR out_tab.
out_tab-NAME = 'LTAP-NLENR'.
out_tab-VALUE = lv_nlenr.
APPEND out_tab.
ENDFORM. " GET_PALLETID
What am I doing wrong?
2016 Mar 23 4:00 PM
Hi.
Conversion routine works for type declaration.
You should work on Internal tables and referenced fields that has no TYPE LTAP-NLENR.
Command (Z) is for leading zeros and there's an option to say how many zeros if you need.
Let us know.
Bye
2016 Mar 23 4:03 PM
Can you please give me a code example?
I have tried so many ways and none of them have worked.
Thank you in advance.
2016 Mar 23 4:13 PM
Hi,
where did you test your formular? same mandant? dont forget that changing the script has to be transported to other mandants. did you check that your new changes did take effect? are you sure, you changed the right programm-part?
sometimes its in loop and there are several statements printing the same variable. what value does the global variable has, when you call the script-call?
screenhot debugger
screenshot script (in target mandant)
(Z) should work. does CONVERSION_EXIT_ALPHA_OUTPUT drop the leading 0? should also work.
it was long ago since i worked with scripts. what type does your field has?
maybe add K -> &symbol(KZ)& for ignoring conversion exits.
LG
Stefan Seeburger
2016 Mar 29 2:51 PM