cancel
Showing results for 
Search instead for 
Did you mean: 

How add '0' dynamically? Help.

Former Member
0 Kudos

I set input box for the user to input the customer number, such as '1171'.

1171 is stored in <i>seh_custom</i> ,which is like <i>kna1-kunnr</i>.


  SELECT  SINGLE kunnr  name1 adrnr FROM kna1
            INTO CORRESPONDING FIELDS OF wa_custom
            WHERE kna1~kunnr = seh_custom .
  IF sy-subrc <> 0.
    ... "Error
  ENDIF.

But the codes don't work, as in database the <i>kunnr</i> is stored in '0000001171'.

Any suggestion ? Thanks very much!

Accepted Solutions (1)

Accepted Solutions (1)

hymavathi_oruganti
Active Contributor
0 Kudos

u need to use conversion routines,

generally SAP uses conversion routines internally to convert from user format to sap format and vice versa.

but some times if it does not use /work, we need to use explicitly conversion routines which convert data from user given format (ex:1) to sap format (ex: for kunnr as it is of char 10 internally stored as 0000000001).

there are many conversion exits.

u can use the following fn module for ur purpose.

generally their format will be

CONVERSION_EXIT_XXXXX_INPUT,

CONVERSION_EXIT_XXXXX_OUTPUT.

XXXXX-> IT IS OF 5 LETTERS .

AND THERE ARE MANY FN MODULES , U CAN CHECK IN SE37.

ex:

REPORT ZTESTH messAGE-ID ZV.

parameter : p_kunnr type kunnr.

data v_kunnr(10).

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

INPUT = p_kunnr

IMPORTING

OUTPUT = v_kunnr

.

write: p_kunnr, v_kunnr.

Message was edited by: Hymavathi Oruganti

Simha_
Employee
Employee
0 Kudos

Hi Use This one..

data: temp(10).

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

input = seh_custom

IMPORTING

output = temp.

Hope this is helpful..

Regards,

SImha.

Answers (3)

Answers (3)

Former Member
0 Kudos

HI

GOOD

WRONG

SELECT SINGLE kunnr name1 adrnr FROM kna1

INTO CORRESPONDING FIELDS OF wa_custom

WHERE kna1~kunnr = seh_custom .

RIGHT

SELECT SINGLE kunnr name1 adrnr FROM kna1

INTO CORRESPONDING FIELDS OF wa_custom

WHERE kna1-kunnr = seh_custom .

THANKS

MRUTYUN

Former Member
0 Kudos

Hi james,

1. I set input box for the user to input the customer number, such as '1171'

How is the input box / parameters defined ?

2. it should be LIKE KNA1-kunnr.

3. Then automatic conversion will happen.

(ie. padding of zeroes when using in variables)

regards,

amit m.

Former Member
0 Kudos

you can use CONVERSION_EXIT_ALPHA_INPUT, Pass SEH_CUSTOM to both INPUT and OUTPUT and then u will get the zero's automatically apppended.