2014 Apr 18 5:58 AM
Hi,
I New To SAP I'm Trying To Create Material With BAPI_MATERIAL_SAVEDATA . When I Execute The Code I am Getting Message That ' Bytes Transfered' But When I Checking The MARA Table I Cannot Find The Enteries..
*************************************************************CODE*********************************************************************************
TABLES: bapimathead,
bapi_mara,
bapi_marax,
bapiret2.
TYPES: BEGIN OF lsmw_material_master,
matnr TYPE mara-matnr,
mtart TYPE mara-mtart,
mbrsh TYPE mara-mbrsh,
maktx TYPE makt-maktx,
meins TYPE mara-meins,
END OF lsmw_material_master.
DATA: it_master TYPE TABLE OF lsmw_material_master,
wa_master TYPE lsmw_material_master,
it_materialdesc TYPE TABLE OF bapi_makt WITH HEADER LINE,
it_return LIKE bapiret2.
SELECTION-SCREEN: BEGIN OF BLOCK a1 WITH FRAME TITLE text-001.
PARAMETERS: p_file TYPE rlgrap-filename OBLIGATORY.
SELECTION-SCREEN: END OF BLOCK a1.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
DATA: it_tab TYPE filetable,
iv_subrc LIKE sy-subrc.
CALL METHOD cl_gui_frontend_services=>file_open_dialog
EXPORTING
window_title = 'Select Source File'
CHANGING
file_table = it_tab
rc = iv_subrc
.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
LOOP AT it_tab INTO p_file.
ENDLOOP.
CALL FUNCTION 'UPLOAD'
EXPORTING
filename = p_file
filetype = 'DAT'
TABLES
data_tab = it_master
.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
LOOP AT it_master INTO wa_master.
bapimathead-material = wa_master-matnr.
bapimathead-ind_sector = wa_master-mtart.
bapimathead-matl_type = wa_master-mbrsh.
bapimathead-basic_view = 'X'.
bapi_mara-base_uom = wa_master-meins.
bapi_marax-base_uom = 'X'.
it_materialdesc-matl_desc = wa_master-maktx.
APPEND it_materialdesc.
CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'
EXPORTING
headdata = bapimathead
clientdata = bapi_mara
CLIENTDATAX = bapi_marax
IMPORTING
return = it_return
TABLES
materialdescription = it_materialdesc
.
ENDLOOP.
IF sy-subrc = 0.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
* EXPORTING
* WAIT =
* IMPORTING
* RETURN =
.
* ELSE.
WRITE:/ 'Error'.
* CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'
* IMPORTING
* RETURN =
.
ENDIF.
*************************************************************FILE >>>>>check.text.********************************************************************************
| Cooinfl_Fan | E | FERT | FANS | PC |
| Bathing_Fan | E | FERT | FANS | PC |
2014 Apr 18 6:07 AM
The message you are getting is from Function module "UPLOAD", please check if it_master contains data.Also, check it_return after " BAPI_MATERIAL_SAVEDATA" and see if it contains any errors.
Call commit within loop and endloop.
Regards
Then you need to check unit of measure. Check table "MARM" for unit of measure and use appropriate one. You might need conversion exit FM "CONVERSION_EXIT_CUNIT_INPUT" to first convert unit of measure "PC" to internal format and then pass this to BAPI.
Regards
2014 Apr 18 6:07 AM
The message you are getting is from Function module "UPLOAD", please check if it_master contains data.Also, check it_return after " BAPI_MATERIAL_SAVEDATA" and see if it contains any errors.
Call commit within loop and endloop.
Regards
2014 Apr 18 6:21 AM
Thanks, When I'm Trying To Print it_master , It Giving Error 'Internal Unit PC, Language EN Is Not Maintained.. However,Is Language Is Must?
2014 Apr 18 6:36 AM
Then you need to check unit of measure. Check table "MARM" for unit of measure and use appropriate one. You might need conversion exit FM "CONVERSION_EXIT_CUNIT_INPUT" to first convert unit of measure "PC" to internal format and then pass this to BAPI.
Regards
2014 Apr 18 7:42 AM
Ok, After Applying FM "CONVERSION_EXIT_CUNIT_INPUT" . it_master Displaying The Data. But it-return
Returning Error 'E'
2014 Apr 18 8:08 AM
2014 Apr 18 8:28 AM
2014 Apr 18 8:31 AM
Please share the message text, not just the type. List all the messages you are getting in it_return.
Regards
2014 Apr 18 8:50 AM
Message Type:E
Message Id: MG
Message no: 171.
Message: You have Not fully maintained the Descriptoin.
2014 Apr 18 8:53 AM
Please pass following values:
it_materialdesc-matl_desc = wa_master-maktx.
it_materialdesc-langu = 'E'.
it_materialdesc-langu_iso = 'EN'.
APPEND it_materialdesc.
Regards
2014 Apr 18 9:02 AM
Thanks It Working. But Can you Please Explain The Last Step, Why We Pass "lang" And ''lang-iso" Field.
2014 Apr 18 9:08 AM
Because texts are language dependent in SAP. Almost all text tables in SAP have language field as key field.
Regards
2014 Apr 18 9:12 AM
Ok, But Then Why If We Create Material Through MM01 ,Then It will Not Ask for Language field?
2014 Apr 18 9:24 AM
Because then system uses log on language of user to save text.
Regards
2014 Apr 18 9:29 AM
| User | Count |
|---|---|
| 6 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |