2009 Oct 13 3:24 AM
Dear forumers,
In my program codes, I have a material number select-option (multiple values are possible) and I will need to make sure that its format is converted to the internal 18 characters number for processing.
For this reason, I am using the FM, CONVERSION_EXIT_MATN1_INPUT. However, I am still struggling to make sure that the output is 18 characters (I can't seem to get this done, especially because material number is a select-option). How may I achieve this properly?
Thanks in advance for all the help here.
As an example, even this (simpler example) does not work:-
DATA:
v_matnr1(9) TYPE c,
v_matnr2(18) TYPE c.
v_matnr1 = '123456789'.
CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
EXPORTING
input = v_matnr1
IMPORTING
output = v_matnr2
EXCEPTIONS
length_error = 1
OTHERS = 2.
" V_MATNR2 is still outputted as '123456789'
IF sy-subrc NE 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.What could have gone wrong here?
2009 Oct 13 3:57 AM
Dear forumers,
In my program codes, I have a material number select-option (multiple values are possible) and I will need to make sure that its format is converted to the internal 18 characters number for processing.
For this reason, I am using the FM, CONVERSION_EXIT_MATN1_INPUT. However, I am still struggling to make sure that the output is 18 characters (I can't seem to get this done, especially because material number is a select-option). How may I achieve this properly?
Thanks in advance for all the help here.
As an example, even this (simpler example) does not work:-
DATA:
v_matnr1(9) TYPE c,
v_matnr2(18) TYPE c.
v_matnr1 = '123456789'.
CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
EXPORTING
input = v_matnr1
IMPORTING
output = v_matnr2
EXCEPTIONS
length_error = 1
OTHERS = 2.
" V_MATNR2 is still outputted as '123456789'
IF sy-subrc NE 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.What could have gone wrong here?
2009 Oct 13 3:57 AM
2009 Oct 13 4:34 AM
Hi Soumyaprakash,
I tried that much earlier too and it works.
But the FM, CONVERSION_EXIT_MATN1_INPUT was already specified by the functional consultant in the Spec requirements.
I'll have to make sure that this requirement is fulfilled.
2009 Oct 13 4:36 AM
2009 Oct 13 4:38 AM
The other issue that may arise from using the FM, CONVERSION_EXIT_ALPHA_INPUT is that the user is allowed to enter data of the format MARA-MFRPN (40 characters) into the material number select-option on the report's selection screen.
I'll have to make sure that the data is converted properly, specifically for the 18 characters material number format.
2009 Oct 13 4:42 AM
for alpha_input the parameters is CLIKE ..right?
so use any number of chars you want.
you also can do the same after converting.
2009 Oct 13 4:55 AM
Hi Soumyaprakash,
Yup, that's right - it's CLIKE.
I'll try this out as well, but I'm just a lil hesitant because the spec clearly specified to use the other FM - CONVERSION_EXIT_MATN1_INPUT.
Thanks.
2009 Oct 13 4:09 AM
My dear friend,
<li>When you define material no as select-option like above by referring to standard table field, If a screen field refers to a domain with a conversion routine, this conversion routine is executed automatically each time an entry is made in this screen field or when values are displayed with this screen field.
<li>You can go to domain of matnr and check conversion routine is assigned. So automatically it converts the values entered into internal format .
<li>You can check that using like below by putting break point .
TABLES:marc.
SELECT-OPTIONS:s_matnr FOR marc-matnr.
<li>It does not show leading zeroes on the screen but you can see that in select-option table s_matnr.
Thanks
Venkat.OAT SELECTION-SCREEN.
LOOP AT s_matnr.
BREAK-POINT.
"Check s_matnr-low value.
ENDLOOP.
2009 Oct 13 4:48 AM
Hi Venkat,
Thanks for the explanations there. Appreciate it.
I have tried this out. But, I'm still not seeing the leading zeros populated for the material number.
Here's how I did it, with the data inputs as '123456' TO '123460' in the selection screen:-
TABLES:
mbew.
...
SELECT-OPTIONS:
s_matnr FOR mbew-matnr.
...
LOOP AT s_matnr.
break-point.
" Here, s_matnr-low = '123456' and s_matnr-high = '123460'
ENDLOOP.The other issue is, the user is also allowed to enter data format of MARA-MFRPN (40 char and its domain does not have a conversion routine) into S_MATNR at the selection screen. This is why I'll need to use the FM explicitly also, right?
Please help once again. Thanks.
2009 Oct 13 6:27 AM
Hi Tan, <li>You need to call CONVERSION_EXIT_MATN1_INPUT function module explicitly to convert the other values entered in MARA-MFRPN field. Thanks Venkat.O
2009 Oct 13 8:03 AM
Hi forumers,
Got this issue resolved and properly tested already.
Thanks for all the help. Appreciate the inputs given here.
2009 Oct 13 5:32 AM
This code works for me
TABLES:mara.
SELECT-OPTIONS:so_matnr FOR mara-matnr.
DATA:ra_matnr TYPE RANGE OF mara-matnr.
DATA:wa LIKE LINE OF ra_matnr.
START-OF-SELECTION.
LOOP AT so_matnr.
PERFORM fm_conversion_exit USING so_matnr-low
CHANGING wa-low.
PERFORM fm_conversion_exit USING so_matnr-high
CHANGING wa-high.
wa-option = so_matnr-option.
wa-sign = so_matnr-sign.
APPEND wa TO ra_matnr.
CLEAR wa.
ENDLOOP.
loop at ra_matnr into wa.
write:/ wa.
endloop.
FORM fm_conversion_exit USING p_so_matnr
CHANGING p_wa.
CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
EXPORTING
input = p_so_matnr
IMPORTING
output = p_wa.
ENDFORM.
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |