Posted: Sat Apr 26, 2008 3:08 pm Post subject: BAPI_MATERIAL_GETINTNUMBER
BAPI_MATERIAL_GETINTNUMBER - Assign new internal numbers
Code:
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.
Author: Rich Heilman
In this example, were creating a HALB material using internal number assignment. Of course if your material type uses external number assignment, you can assign it directly.
Code:
REPORT zrich_0001.
DATA: headdata TYPE bapimathead.
DATA: clientdata TYPE bapi_mara.
DATA: clientdatax TYPE bapi_marax.
DATA: descdata TYPE TABLE OF bapi_makt WITH HEADER LINE.
DATA: return TYPE TABLE OF bapiret2 WITH HEADER LINE.
DATA: returnm TYPE TABLE OF bapi_matreturn2 WITH HEADER LINE.
DATA: imat TYPE TABLE OF bapimatinr WITH HEADER LINE.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG. SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG. Every effort is made to ensure content integrity. Use information on this site at your own risk.