SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

BAPI_MATERIAL_GETINTNUMBER



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> Interfaces | Интерфейсы -> BAPI
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1640

PostPosted: Sat Apr 26, 2008 3:08 pm    Post subject: BAPI_MATERIAL_GETINTNUMBER Reply with quote

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.

CALL FUNCTION 'BAPI_MATERIAL_GETINTNUMBER'
  EXPORTING
    material_type   = 'ZROH'
    industry_sector = 'M'
  TABLES
    material_number = imat.

READ TABLE imat INDEX 1.
IF sy-subrc = 0.
  headdata-material = imat-material.
ENDIF.

headdata-ind_sector = 'M'.
headdata-matl_type = 'ZROH'.
headdata-basic_view = 'X'.

clientdata-base_uom = 'EA'.
clientdatax-base_uom = 'X'.
clientdata-old_mat_no = 'Old Material'.
clientdatax-old_mat_no = 'X'.
clientdata-division = '00'.
clientdatax-division = 'X'.

descdata-langu = sy-langu.
descdata-matl_desc = 'This is the description'.
APPEND descdata.

CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'
  EXPORTING
    headdata = headdata
    clientdata = clientdata
    clientdatax = clientdatax
*plantdata =
*plantdatax =
*forecastparameters =
*forecastparametersx =
*planningdata =
*planningdatax =
*storagelocationdata =
*storagelocationdatax =
*valuationdata =
*valuationdatax =
*warehousenumberdata =
*warehousenumberdatax =
*salesdata =
*salesdatax =
*storagetypedata =
*storagetypedatax =
  IMPORTING
    return = return
  TABLES
    materialdescription = descdata
*unitsofmeasure =
*unitsofmeasurex =
*internationalartnos =
*materiallongtext =
*taxclassifications =
    returnmessages = returnm
*prtdata =
*prtdatax =
*extensionin =
*extensioninx =
.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> Interfaces | Интерфейсы -> BAPI All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
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.