Application Development 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: 

BAPI_MATERIAL_SAVEDATA

Former Member
0 Kudos

Hi Experts,

Can somebody let me know whether BAPI_MATERIAL_SAVEDATA can be used to upload/change the data in 'Costing 1' view.

If it is possible, kindly let me know which paramaters to be set to change

MARC-LOSGR (Costing lot size) .

Thanks in advance.

Regards,

Srikanth.

1 ACCEPTED SOLUTION

former_member189629
Active Contributor
0 Kudos

Matt,

Check out this sample program using the same BAPI in my blog

http://allaboutsap.blogspot.com/2007/09/program-to-create-material-master-data.html

Populate the structures

BAPI_MARC1 LIKE BAPI_MARC, " Plant View

BAPI_MARCX LIKE BAPI_MARCX, " Checkbox Structure for BAPI_MARC

Reward if helpful,

Karthik

2 REPLIES 2

former_member189629
Active Contributor
0 Kudos

Matt,

Check out this sample program using the same BAPI in my blog

http://allaboutsap.blogspot.com/2007/09/program-to-create-material-master-data.html

Populate the structures

BAPI_MARC1 LIKE BAPI_MARC, " Plant View

BAPI_MARCX LIKE BAPI_MARCX, " Checkbox Structure for BAPI_MARC

Reward if helpful,

Karthik

Former Member
0 Kudos

u can create or change the material using this bapi function module

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

existing material master data. The data on a material can be transferred

for each call.

When creating material master data, you must transfer the material

number, the material type, and the industry sector to the method. You

must also enter a material description and its language.

When changing material master data, you need enter only the material

number.

In the header data, you must select at least one view for which data is

to be created. Depending on the view selected, you must maintain other

required parameters. If you do not enter values for all of the required

parameters, the method is ended with an error message.

The corresponding fields in the tables (such as CLIENTDATA) must first

be supplied with data by the calling program. An indicator must also be

set for each of these fields so that the data is written to the database

by the method. This requires the calling program to supply the

corresponding field with the indicator in a checkbox table (for example,

CLIENTDATAX). Checkbox tables exist for tables that do not contain any

language-dependent texts (MAKT, MLTX), International Article Numbers

(MEAN), or tax classifications (MLAN). Several data records for a

material can be created in these tables.

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, there must be a unique assignment of

the ISO code to the SAP code in the following activities in Customizing

for Global Parameters:

o Check Units of Measurement

o Define Countries

If you want to maintain long texts (basic data texts, internal comments,

purchase order texts, material memos, or sales texts) or

customer-defined fields for a material, some special conditions have to

be observed. They are described in the documentation for parameters

MATERIALLONGTEXT and EXTENSIONIN.

TABLES:BAPIMATHEAD,BAPI_MAKT,BAPI_MARA,BAPI_MARAX.

DATA:BEGIN OF ITAB OCCURS 0,

MATERIAL TYPE BAPIMATHEAD-MATERIAL,

IND_SECTOR(20),

MATL_TYPE TYPE BAPIMATHEAD-MATL_TYPE,

MATL_GROUP TYPE BAPI_MARA-MATL_GROUP,

LANGU TYPE BAPI_MAKT-LANGU,

MATL_DESC TYPE BAPI_MAKT-MATL_DESC,

END OF ITAB.

DATA:IT_RETURN LIKE BAPIRET2.

DATA:IT_BAPI LIKE BAPI_MAKT OCCURS 0 WITH HEADER LINE.

PARAMETERS:P_FILE TYPE IBIPPARMS-PATH OBLIGATORY.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.

PERFORM GET_F4HELP.

START-OF-SELECTION.

PERFORM UPLOAD_FILE_ITAB.

PERFORM CALL_BAPI.

&----


*& Form get_f4help

&----


  • text

FORM GET_F4HELP .

CALL FUNCTION 'F4_FILENAME'

EXPORTING

PROGRAM_NAME = SYST-CPROG

DYNPRO_NUMBER = SYST-DYNNR

  • FIELD_NAME = ' '

IMPORTING

FILE_NAME = P_FILE

.

ENDFORM. " get_f4help

&----


*& Form upload_file_itab

&----


  • text

FORM UPLOAD_FILE_ITAB .

DATA:V_FILE TYPE STRING.

MOVE P_FILE TO V_FILE.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

FILENAME = V_FILE

FILETYPE = 'ASC'

HAS_FIELD_SEPARATOR = 'X'

  • HEADER_LENGTH = 0

  • READ_BY_LINE = 'X'

  • DAT_MODE = ' '

  • CODEPAGE = ' '

  • IGNORE_CERR = ABAP_TRUE

  • REPLACEMENT = '#'

  • CHECK_BOM = ' '

  • VIRUS_SCAN_PROFILE = VIRUS_SCAN_PROFILE

  • NO_AUTH_CHECK = ' '

  • IMPORTING

  • FILELENGTH = FILELENGTH

  • HEADER = HEADER

TABLES

DATA_TAB = ITAB

  • EXCEPTIONS

  • FILE_OPEN_ERROR = 1

  • FILE_READ_ERROR = 2

  • NO_BATCH = 3

  • GUI_REFUSE_FILETRANSFER = 4

  • INVALID_TYPE = 5

  • NO_AUTHORITY = 6

  • UNKNOWN_ERROR = 7

  • BAD_DATA_FORMAT = 8

  • HEADER_NOT_ALLOWED = 9

  • SEPARATOR_NOT_ALLOWED = 10

  • HEADER_TOO_LONG = 11

  • UNKNOWN_DP_ERROR = 12

  • ACCESS_DENIED = 13

  • DP_OUT_OF_MEMORY = 14

  • DISK_FULL = 15

  • DP_TIMEOUT = 16

  • OTHERS = 17

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

ENDFORM. " upload_file_itab

&----


*& Form call_bapi

&----


  • text

FORM CALL_BAPI .

LOOP AT ITAB.

BAPIMATHEAD-MATERIAL = ITAB-MATERIAL.

BAPIMATHEAD-IND_SECTOR = ITAB-IND_SECTOR.

BAPIMATHEAD-MATL_TYPE = ITAB-MATL_TYPE.

BAPIMATHEAD-BASIC_VIEW = 'X'.

BAPI_MARA-MATL_GROUP = ITAB-MATL_GROUP.

BAPI_MARA-BASE_UOM = 'KGS'.

BAPI_MARAX-MATL_GROUP = 'X'.

BAPI_MARAX-BASE_UOM = 'X'.

IT_BAPI-LANGU = ITAB-LANGU.

IT_BAPI-LANGU_ISO = 'EN'.

IT_BAPI-MATL_DESC = ITAB-MATL_DESC.

APPEND IT_BAPI.

CLEAR IT_BAPI.

CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'

EXPORTING

HEADDATA = BAPIMATHEAD

CLIENTDATA = BAPI_MARA

CLIENTDATAX = BAPI_MARAX

IMPORTING

RETURN = IT_RETURN

TABLES

MATERIALDESCRIPTION = IT_BAPI

  • UNITSOFMEASURE = UNITSOFMEASURE

  • UNITSOFMEASUREX = UNITSOFMEASUREX

  • INTERNATIONALARTNOS = INTERNATIONALARTNOS

  • MATERIALLONGTEXT = MATERIALLONGTEXT

  • TAXCLASSIFICATIONS = TAXCLASSIFICATIONS

  • RETURNMESSAGES = RETURNMESSAGES

  • PRTDATA = PRTDATA

  • PRTDATAX = PRTDATAX

  • EXTENSIONIN = EXTENSIONIN

  • EXTENSIONINX = EXTENSIONINX

.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

  • EXPORTING

  • WAIT = WAIT

  • IMPORTING

  • RETURN = RETURN

.

WRITE:/ IT_RETURN-TYPE.

ENDLOOP.

ENDFORM. " call_bapi