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

Creating an entry in MARC table using BAPI.

Former Member
0 Likes
1,334

Hello Experts,

I need to create an entry in MARC table using BAPI.

The program should create a new entry in MARC table using Material Number(MATNR) and Plant(WERKS).

Please suggest me how to proceed.

If i have to use BAPI_MATERIAL_SAVEDATA, then how to use this for updating MARC table alone?

I have searched SDN. But none suits my requirement.

If BAPI is not available, what else should i do?

Thanks and Best Regards,

Suresh

7 REPLIES 7
Read only

Former Member
0 Likes
1,122

Use the Import Structures ,,,,

PLANTDATA

PLANTDATAX

" VALUE(PLANTDATA*) LIKE BAPI_MARC STRUCTURE BAPI_MARC OPTIONAL >>>> data will be stored on MARC

" VALUE(PLANTDATAX*) LIKE BAPI_MARCX STRUCTURE BAPI_MARCX >>>> Mark the fields u want to change...

Regards,

Bhargava

Edited by: Bhargava TC on Jul 28, 2009 11:15 AM

Read only

0 Likes
1,122

Hi Bhargava,

I dont want to change anything in MARC.

Just i wanted to create an entry in MARC with MATNR and WERKS field value.

But it is not working.

Thanks and Best Regards,

Suresh

Read only

0 Likes
1,122

Hi all,

Please have a look at my code:

PARAMETERS: p_matnr TYPE matnr OBLIGATORY,

p_werks TYPE werks_d OBLIGATORY.

DATA: header LIKE bapimathead.

DATA: plant LIKE bapi_marc .

DATA: plantx LIKE bapi_marcx .

DATA: return LIKE bapiret2 .

AT SELECTION-SCREEN.

  • Validation

SELECT SINGLE matnr FROM marc

INTO p_matnr

WHERE matnr = p_matnr

AND werks = p_werks.

IF sy-subrc = 0.

MESSAGE 'Invalid material' TYPE 'E'.

ENDIF.

*

START-OF-SELECTION.

  • Header

header-material = p_matnr.

header-mrp_view = 'X'.

  • Plant

plant-plant = p_werks.

  • PlantX

plantx-plant = p_werks.

  • Call the BAPI

CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'

EXPORTING

headdata = header

plantdata = plant

plantdatax = plantx

IMPORTING

return = return.

  • Check the return type

IF return-type = 'E' OR return-type = 'A'.

WRITE: / 'ERROR in updating'.

ELSE.

COMMIT WORK.

WRITE: / 'Update Successful'.

ENDIF.

Thanks and Best Regards,

Suresh

Read only

0 Likes
1,122

Hello Experts,

Should i need to update some fields other than Material and Werks field mentioned in the code?

Thanks and Best Regards,

Suresh

Read only

0 Likes
1,122

Analyze the error messages in the return table (there are some "universal" required fields, but some may come from your Customizing)

You may also fill data in a structure like MARC (from another plant) or MARA and map it to BAPI_MARC via a FM like CFX_MAP2E_MARA_TO_BAPI_MARA and MOVE-CORRESPONDING or CFX_MAP2E_MARC_TO_BAPI_MARC.

Regards,

Raymond

Read only

0 Likes
1,122

Hi Raymond,

Could you please tell me the universal required fields?

I have tried my level best, but i found no improvements.

Thanks and Best Regards,

Suresh

Read only

0 Likes
1,122

Look via transaction OMSR and OMS9, it may depend on material type...

(you may also ask/search on forum )

You should ask your functional to give (write) you the rules by material type.

Regards,

Raymond