Programming Methods with Parameters (BOR) 
Import parameters of the method are read in the program of the object type from the container CONTAINER using the macros SWC_GET_ELEMENT (for single-line elements) and SWC_GET_TABLE (for multiline elements), and passed on to the function module or the processing parameters ("SET/GET parameters") of a transaction.
Within method implementation in the program of the object type, export parameters are put into the container CONTAINER. The macro instructions SWC_SET_ELEMENT or SWC_SET_TABLE are used to do this for single-line export parameters or a multiline export parameters respectively.
Implementing the method GetInternalNumber (assign new internal numbers).
The method operates on an object of the object type BUS1001 (material). This object type has the key field Material (material number). The method has the following parameters:
Parameter |
Description |
Type |
|---|---|---|
MaterialType |
Material type |
Import |
IndustrySector |
Industry sector |
Import |
RequiredNumbers |
Amount of material numbers required |
Import |
Return |
Return Parameters |
Export |
MaterialNumber |
Assigned material numbers |
Import/Export |
You implement the method by calling the API function BAPI_MATERIAL_GETINTNUMBER.
Syntax
BEGIN_METHOD GETINTERNALNUMBER CHANGING CONTAINER.
DATA:
MATERIALTYPE LIKE BAPIMATDOA-MATL_TYPE,
INDUSTRYSECTOR LIKE BAPIMATDOA-IND_SECTOR,
REQUIREDNUMBERS LIKE BAPIMATALL-REQ_NUMBERS,
RETURN LIKE BAPIRETURN1,
MATERIALNUMBER LIKE BAPIMATINR OCCURS 0.
SWC_GET_ELEMENT CONTAINER 'MaterialType' MATERIALTYPE.
SWC_GET_ELEMENT CONTAINER 'IndustrySector' INDUSTRYSECTOR.
IF SY-SUBRC <> 0.
MOVE SPACE TO INDUSTRYSECTOR.
ENDIF. SWC_GET_ELEMENT CONTAINER 'RequiredNumbers' REQUIREDNUMBERS.
IF SY-SUBRC <> 0.
MOVE 1 TO REQUIREDNUMBERS.
ENDIF.
CALL FUNCTION 'BAPI_MATERIAL_GETINTNUMBER'
EXPORTING
REQUIRED_NUMBERS = REQUIREDNUMBERS
INDUSTRY_SECTOR = INDUSTRYSECTOR
MATERIAL_TYPE = MATERIALTYPE
IMPORTING
RETURN = RETURN
TABLES
MATERIAL_NUMBER = MATERIALNUMBER
EXCEPTIONS
OTHERS = 01.
CASE SY-SUBRC.
WHEN 0. " OK
WHEN OTHERS. " to be implemented
ENDCASE.
SWC_SET_ELEMENT CONTAINER 'Return' RETURN.
SWC_SET_TABLE CONTAINER 'MaterialNumber' MATERIALNUMBER.
END_METHOD.