Writing ABAP Functions

Source: Internet
Author: User

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.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.