‎2008 Jan 24 4:49 PM
I have created a small report which helps in entering the external order number which is a combination of material number and serial number. My problem is that when I go through the transaction KO02 and enter the order number and click on the master data , heer I am supposed to enter the external order number .The problem is that this exit of mine is allowing me to save the external order number only when the serial number is numeric, when i enter the alpha numeric serial numbers it says invalid entry, can anyone help me.
Here is the exit what I have written.
data: l_matnr type matnr,
l_sernr type gernr.
check syst-dynnr = '0600'.
check i_actvt = '02'
"change
or i_actvt = '32'.
"save
if i_aufk-auart = 'CENT'.
if i_aufk-aufex is initial.
syst-msgid = 'Z001'.
syst-msgno = '999'.
syst-msgty = 'E'.
syst-msgv1 = 'Enter the External order Number'.
raise e_message.
endif.
l_matnr = i_aufk-aufex(5).
l_sernr = i_aufk-aufex+5(15).
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT
= l_matnr
IMPORTING
OUTPUT
= l_matnr.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT
= l_sernr
IMPORTING
OUTPUT
= l_sernr.
select count(*) from equi where
matnr = l_matnr and
sernr = l_sernr.
if sy-dbcnt = 0.
syst-msgid = 'Z001'.
syst-msgno = '999'.
syst-msgv1 = 'External order Number is Invalid'.
syst-msgty = 'E'.
raise e_message.
endif. __.____._
‎2008 Jan 24 4:56 PM
Change your code as follows, it should work.
DATA: l_matnr TYPE matnr,
l_sernr TYPE gernr.
CHECK syst-dynnr = '0600'.
CHECK i_actvt = '02' "change
OR i_actvt = '32'. "save
IF i_aufk-auart = 'CENT'.
IF i_aufk-aufex IS INITIAL.
syst-msgid = 'Z001'.
syst-msgno = '999'.
syst-msgty = 'E'.
syst-msgv1 = 'Enter the External order Number'.
RAISE e_message.
ENDIF.
l_matnr = i_aufk-aufex(5).
l_sernr = i_aufk-aufex+5(15).
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = l_matnr
IMPORTING
output = l_matnr.
CALL FUNCTION 'CONVERSION_EXIT_GERNR_INPUT'
EXPORTING
input = l_sernr
IMPORTING
output = l_sernr.
SELECT COUNT(*) FROM equi
WHERE matnr = l_matnr
AND sernr = l_sernr.
IF sy-dbcnt = 0.
syst-msgid = 'Z001'.
syst-msgno = '999'.
syst-msgv1 = 'External order Number is Invalid'.
syst-msgty = 'E'.
RAISE e_message.
ENDIF.
‎2008 Jan 24 4:56 PM
Change your code as follows, it should work.
DATA: l_matnr TYPE matnr,
l_sernr TYPE gernr.
CHECK syst-dynnr = '0600'.
CHECK i_actvt = '02' "change
OR i_actvt = '32'. "save
IF i_aufk-auart = 'CENT'.
IF i_aufk-aufex IS INITIAL.
syst-msgid = 'Z001'.
syst-msgno = '999'.
syst-msgty = 'E'.
syst-msgv1 = 'Enter the External order Number'.
RAISE e_message.
ENDIF.
l_matnr = i_aufk-aufex(5).
l_sernr = i_aufk-aufex+5(15).
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = l_matnr
IMPORTING
output = l_matnr.
CALL FUNCTION 'CONVERSION_EXIT_GERNR_INPUT'
EXPORTING
input = l_sernr
IMPORTING
output = l_sernr.
SELECT COUNT(*) FROM equi
WHERE matnr = l_matnr
AND sernr = l_sernr.
IF sy-dbcnt = 0.
syst-msgid = 'Z001'.
syst-msgno = '999'.
syst-msgv1 = 'External order Number is Invalid'.
syst-msgty = 'E'.
RAISE e_message.
ENDIF.
‎2008 Jan 24 6:16 PM
the error may not be in the code,
but may come from the inexistence of matnr+sernr in table EQUI.
Verify that.
Hope this helps,