‎2009 Jul 28 9:38 AM
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
‎2009 Jul 28 10:15 AM
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
‎2009 Jul 28 10:21 AM
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
‎2009 Jul 28 10:27 AM
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
‎2009 Jul 28 11:09 AM
Hello Experts,
Should i need to update some fields other than Material and Werks field mentioned in the code?
Thanks and Best Regards,
Suresh
‎2009 Jul 28 11:57 AM
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
‎2009 Jul 28 2:31 PM
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
‎2009 Jul 28 2:40 PM