Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Using FM, CONVERSION_EXIT_MATN1_INPUT on a select-option

former_member367551
Participant
0 Likes
5,494

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?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
3,797

why not try

conversion_exit_alpha_input !!!

why not try

conversion_exit_alpha_input !!!

11 REPLIES 11
Read only

Former Member
0 Likes
3,798

why not try

conversion_exit_alpha_input !!!

Read only

0 Likes
3,797

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.

Read only

0 Likes
3,797

both will any ways work similar this case.

Read only

0 Likes
3,797

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.

Read only

0 Likes
3,797

for alpha_input the parameters is CLIKE ..right?

so use any number of chars you want.

you also can do the same after converting.

Read only

0 Likes
3,797

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.

Read only

venkat_o
Active Contributor
0 Likes
3,797

My dear friend,

TABLES:marc.
SELECT-OPTIONS:s_matnr FOR marc-matnr.
<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 .
AT SELECTION-SCREEN.
  LOOP AT s_matnr.
    BREAK-POINT.
    "Check s_matnr-low value.
  ENDLOOP.
<li>It does not show leading zeroes on the screen but you can see that in select-option table s_matnr. Thanks Venkat.O

Read only

0 Likes
3,797

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.

Read only

venkat_o
Active Contributor
0 Likes
3,797

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

Read only

0 Likes
3,797

Hi forumers,

Got this issue resolved and properly tested already.

Thanks for all the help. Appreciate the inputs given here.

Read only

kesavadas_thekkillath
Active Contributor
0 Likes
3,797

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.