The mm module has written a lot of reports and found that many places need to obtain the specification model of the billet or aluminum foil finished product according to the material number and batch. The code is repeated in many places, the code segment length is not intuitive in general, so I decided to write a function z_get_spec_from_batch.
1. Create a z_mm_group and an array. The development class is zmm;
2. Create the z_get_spec_from_batch function. The Code is as follows:
Function z_get_spec_from_batch.
*"----------------------------------------------------------------------
* "*" Local interface:
* "Importing
* "Reference (p_matnr) type matnr
* "Reference (p_charg) type charg_d
* "Exporting
* "Reference (p_spec) Type C
*"----------------------------------------------------------------------
Data:
S_val_num type table of bapi1003_alloc_values_num,
Val_num like bapi1003_alloc_values_num,
S_val_char type table of bapi1003_alloc_values_char.
Call function 'z _ fig001_get_char_from_batch'
Exporting
P_matnr = p_matnr
P_charg = p_charg
Tables
P_val_num = s_val_num
P_val_char = s_val_char
Exceptions
No_form = 1
No_function_module = 2
Others = 3.
If sy-subrc <> 0.
P_spec = ''.
Else.
Data: m (16) type C,
N (16) type C.
Loop at s_val_num into val_num.
If VAL_NUM-CHARACT EQ 'p0015'. "Width
Call function 'qss0 _ fltp_to_char_conversion'
Exporting
I _number_of_digits = '2'
I _fltp_value = VAL_NUM-VALUE_FROM
Importing
E_char_field = m.
Elseif VAL_NUM-CHARACT EQ 'p0016'. "Thickness
Call function 'qss0 _ fltp_to_char_conversion'
Exporting
I _number_of_digits = '2'
I _fltp_value = VAL_NUM-VALUE_FROM
Importing
E_char_field = n.
Endif.
Endloop.
Condense M.
Condense n.
Concatenate n' *'m into p_spec.
Endif.
Endfunction.