Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Help on BAPI 'BAPI_MATERIAL_MAINTAINDATA_RT'

Former Member
0 Likes
15,188

How do i create Material Master data using the BAPI 'BAPI_MATERIAL_MAINTAINDATA_RT' ? Please help me with the mandatory fields that i need to fill in. My actual requirement is to update MARC table, which would require the table PLANTDATA in the BAPI to be filled. everytime im testing the BAPI i get thei error message 'Table MARC for article PAL TEST has no header segment'. Kindly help.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
7,371

Hi

here is the sample code.

data: wa_head like bapie1mathead,
      wa_return like bapireturn1.

types: begin of t_clientext.
       include structure bapie1maraextrt.
types: end of t_clientext.
data: wa_clientext type t_clientext,
      it_clientext type table of t_clientext.

types: begin of t_clientextx.
       include structure bapie1maraextrtx.
types: end of t_clientextx.
data: wa_clientextx type t_clientextx,
      it_clientextx type table of t_clientextx.


parameter: p_matnr like mara-matnr default '170'.

move: p_matnr to wa_head-material,
      'X' to wa_head-basic_view.

*&-- Custom field value
move: p_matnr to wa_clientext-material,
      'A' to wa_clientext-field1.
append wa_clientext to it_clientext.
clear wa_clientext.

*&-- Set check box to update the specific custom fields
move: p_matnr to wa_clientextx-material,
      'X' to wa_clientextx-field1.
append wa_clientextx to it_clientextx.
clear wa_clientextx.




call function 'BAPI_MATERIAL_MAINTAINDATA_RT'
  exporting
    headdata                   = wa_head
 importing
   return                     = wa_return
 tables
   clientext                  = it_clientext
   clientextx                 = it_clientextx

          .

if wa_return-type eq 'E'.
    write:/ 'Error in updating the Material'.
else.
  call function 'BAPI_TRANSACTION_COMMIT'.
    write:/ 'Updating the Material is Successful'.
endif.

Hope this will help.

Please reward suitable points.

Regards

-Atul

6 REPLIES 6
Read only

Former Member
0 Likes
7,372

Hi

here is the sample code.

data: wa_head like bapie1mathead,
      wa_return like bapireturn1.

types: begin of t_clientext.
       include structure bapie1maraextrt.
types: end of t_clientext.
data: wa_clientext type t_clientext,
      it_clientext type table of t_clientext.

types: begin of t_clientextx.
       include structure bapie1maraextrtx.
types: end of t_clientextx.
data: wa_clientextx type t_clientextx,
      it_clientextx type table of t_clientextx.


parameter: p_matnr like mara-matnr default '170'.

move: p_matnr to wa_head-material,
      'X' to wa_head-basic_view.

*&-- Custom field value
move: p_matnr to wa_clientext-material,
      'A' to wa_clientext-field1.
append wa_clientext to it_clientext.
clear wa_clientext.

*&-- Set check box to update the specific custom fields
move: p_matnr to wa_clientextx-material,
      'X' to wa_clientextx-field1.
append wa_clientextx to it_clientextx.
clear wa_clientextx.




call function 'BAPI_MATERIAL_MAINTAINDATA_RT'
  exporting
    headdata                   = wa_head
 importing
   return                     = wa_return
 tables
   clientext                  = it_clientext
   clientextx                 = it_clientextx

          .

if wa_return-type eq 'E'.
    write:/ 'Error in updating the Material'.
else.
  call function 'BAPI_TRANSACTION_COMMIT'.
    write:/ 'Updating the Material is Successful'.
endif.

Hope this will help.

Please reward suitable points.

Regards

-Atul

Read only

0 Likes
7,371

Hi Atul

Can u plz tell me how to create variants of generic articles using this fm??

Thanks

Read only

Former Member
0 Likes
7,371

Hi

Please read the BAPI function module documentation before making any coding as well.

Here is the documentation for your reference.

FUNCTION MODULE- BAPI_MATERIAL_MAINTAINDATA_RT
____________________________________________________
Short Text
Create and Change Material Master Data (Retail)

Functionality
You use this method to create new material master data or to change existing material master data.

Besides creating and changing material master data, you can also delete data for the following structures:

MATERIALDESCRIPTION
UNITSOFMEASURE
INTERNATIONALARTNOS
VENDOREAN
UNITOFMEASURETEXTS
LAYOUTMODULEASSGMT
MATERIALLONGTEXT
For the system to recognize that a data record is to be deleted, the field FUNCTION must contain the value 003 in the corresponding structure. This field is of no relevance when creating or changing data.

If the material specified in structure HEADDATA is a generic material, you can specify data on the generic material and also on the variants in the structures concerned (CLIENTDATA, and so on). Normally, this is of use only if you want to maintain special data on the variant differently from the data on the generic material. If no explicit data on the variants exists, it is created automatically on the basis of the data on the generic material.

If a variant is created, an entry must be defined in structure VARIANTSKEYS for this variant. This makes it possible to also create new variants for an existing generic material.

If a structure contains fields for units of measurement (such as structure CLIENTDATA, field BASE_UOM), language indicators (such as structure MATERIALDESCRIPTION, field LANGU), or country indicators (such as structure TAXCLASSIFICATIONS, field DEPCOUNTRY), there is always a field of the same name with the ending _ISO. This makes it possible to transfer either the internally used SAP code or a standardized ISO code for the units of measurement, language indicators, or country indicators. ISO codes are converted to an SAP code internally for further processing. The ISO code is used only if the SAP code is not transferred. If you use ISO codes, you must ensure that the SAP code can be uniquely determined from the ISO code in Customizing for units of measurement, language indicators, and country indicators.

The data transferred is updated synchronously; that is, not using an update task. This is necessary because this method is also used in distribution by Application Link Enabling (ALE), where asynchronous updating cannot be supported in inbound processing because the processing status of the assigned IDocs cannot otherwise be set reliably.

If a serious database error occurs during synchronous updating of the application data, a rollback for all database changes made so far is triggered in the method. If the method is called in a commit unit together with other methods, the database changes of the previously executed method calls are also rolled back as a result. The rollback is necessary to prevent database inconsistencies due to only part of the application data being updated correctly.

Any information or error messages that are issued while the data is being processed are recorded in the application log. If you want to view these messages, a commit must be performed after this method is called so that the data in the application log is written to the database. Even if the structure RETURN returns an E-type (error) message in field TYPE, a commit must be performed so that the application log is written. In the event of an error, the method itself ensures that the data is reset correctly. The commit is also necessary to trigger the updating of the classification data because the update module for the classification data is registered by means of PERFORM ON COMMIT and is started only by a COMMIT WORK.


Notes
To create or change data, you require the necessary authorizations for maintaining the corresponding material master data.

Further information
As of Release 4.5A, this method can also be used to distribute deletion flags correctly. Deletion flags are only set in retail for client-specific material data (parameter CLIENTDATA) and plant-specific material data (parameter PLANTDATA). If deletion flags (field DEL_FLAG) are transferred for one of these two parameters, a corresponding workflow is generated during updating. Depending on the value of the deletion indicator, this workflow triggers the discontinuation of the material for the client or for a specific plant, or the cancelling of an existing deletion flag.

For more information, see the SAP library documentation LO SAP Retail -> Articles: Article Discontinuation.

Parameters
HEADDATA
RETURN
VARIANTSKEYS
CHARACTERISTICVALUE
CHARACTERISTICVALUEX
CLIENTDATA
CLIENTDATAX
CLIENTEXT
CLIENTEXTX
ADDNLCLIENTDATA
ADDNLCLIENTDATAX
MATERIALDESCRIPTION
PLANTDATA
PLANTDATAX
PLANTEXT
PLANTEXTX
FORECASTPARAMETERS
FORECASTPARAMETERSX
FORECASTVALUES
TOTALCONSUMPTION
UNPLNDCONSUMPTION
PLANNINGDATA
PLANNINGDATAX
STORAGELOCATIONDATA
STORAGELOCATIONDATAX
STORAGELOCATIONEXT
STORAGELOCATIONEXTX
UNITSOFMEASURE
UNITSOFMEASUREX
UNITOFMEASURETEXTS
INTERNATIONALARTNOS
VENDOREAN
LAYOUTMODULEASSGMT
LAYOUTMODULEASSGMTX
TAXCLASSIFICATIONS
VALUATIONDATA
VALUATIONDATAX
VALUATIONEXT
VALUATIONEXTX
WAREHOUSENUMBERDATA
WAREHOUSENUMBERDATAX
WAREHOUSENUMBEREXT
WAREHOUSENUMBEREXTX
STORAGETYPEDATA
STORAGETYPEDATAX
STORAGETYPEEXT
STORAGETYPEEXTX
SALESDATA
SALESDATAX
SALESEXT
SALESEXTX
POSDATA
POSDATAX
POSEXT
POSEXTX
MATERIALLONGTEXT
PLANTKEYS
STORAGELOCATIONKEYS
DISTRCHAINKEYS
WAREHOUSENOKEYS
STORAGETYPEKEYS
VALUATIONTYPEKEYS

Exceptions
Function Group
1001

Hope this will help.

Please reward suitable points.

Regards

- Atul

Read only

Former Member
0 Likes
7,371

Thanks for the sample code Atul.Actually i need to create a new entry in MARC table. My requirement is to create a new material master data. and d sample code would actually help me update MARC table. it would be greatful if u could help me with creation of an entry in MARC.

Read only

Former Member
0 Likes
7,371

what u are passing to PLANT data, u have to pass MRP data , Profit Center data .

Regards

Prabhu

Read only

Former Member
0 Likes
7,371

I need to pass MRP Type, Planned delivery, Reference material, Reference plant, Multiplier, rounding profile, source of supply, PS Article Status, ABC indicator and Stock planner. These are d things i need to pass to PLANTDATA. so that a new enbtry would be created in MARC table.