on 05-02-2016 11:55 AM
Hello All,
I want to import data from CSV file. I need to code in method IF_EX_MDG_FILECONVERTER~GET_DATA in BADI implementation.
Please guide me for the same.
I have code for Business Partner entity which includes Proxy Structure (generated) for BP like mdg_bp_bp_suitebulk_repl_req, MDG_BP_BPSUITERPLCT_REQ_MSG.
I do not know the Proxy Structure (generated) for MM entity.
Please let me know the way to Import data from CSV file through DIF.
Attaching code snippet.
surendra.badabagni3
Follow this document https://www.sap.com/documents/2015/07/5ebed256-5b7c-0010-82c7-eda71af511fa.html
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Riyajuddin,
The data import class available out of the box for MM supports IDOC import. You have to create BADI implementation to convert your CSV to IDOC format. The filter used in data import should be same the filter used in the BADI implementation.
Regards
Goutham
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I have written this code.
It gives error "Technical settings for business system are not defined,No Mapping Done"
Please let me know where I am going wrong.Also tell me if we have to do any configuration setting.
* Load a file as a string
* Split into lines and fields
* Convert into IDoc structures
* Contains one MARA and one MAKT (in logon language)
DATA: lo_conv TYPE REF TO cl_abap_conv_in_ce.
DATA: lv_file TYPE string.
DATA: lt_table_line TYPE STANDARD TABLE OF string.
DATA: lt_fields TYPE STANDARD TABLE OF string.
DATA: lt_content TYPE mdg_idoc_data_t.
DATA: ls_edidd TYPE edidd.
DATA: ls_maram TYPE e1maram.
* DATA: ls_zmaraext TYPE zmaraext.
DATA: ls_maktm TYPE e1maktm.
DATA: lv_docnum TYPE edi_docnum.
FIELD-SYMBOLS: <ls_table_line> TYPE string.
FIELD-SYMBOLS: <ls_content> TYPE mdg_idoc_data.
CLEAR: et_content, es_message. " But not EV_CONTENT!
* Get the file content
* Supporting UTF-8 Unicode encoding only
lo_conv = cl_abap_conv_in_ce=>create( encoding = 'UTF-8'
input = iv_file_content_frontend ).
TRY.
CALL METHOD lo_conv->read( IMPORTING data = lv_file ).
CATCH cx_sy_conversion_codepage
cx_sy_codepage_converter_init
cx_parameter_invalid_type
cx_parameter_invalid_range.
RETURN.
ENDTRY.
* Get the table lines from the input string
* SPLIT lv_file AT gc_delimeter_line INTO TABLE lt_table_line.
SPLIT lv_file AT 'XXX' INTO TABLE lt_table_line.
* Ignore first row containing only header information (column names)
DELETE lt_table_line INDEX 1.
* Get the field values
LOOP AT lt_table_line ASSIGNING <ls_table_line>.
SPLIT <ls_table_line> AT gc_delimeter_field INTO TABLE lt_fields.
CHECK NOT lt_fields IS INITIAL.
lv_docnum = lv_docnum + 1.
APPEND INITIAL LINE TO lt_content ASSIGNING <ls_content>.
" Move field information into IDoc segments
CLEAR: ls_maram, ls_maktm.
CALL METHOD fill_no_data_sign( EXPORTING iv_segment_name = gc_segment_mara CHANGING cs_segment = ls_maram ).
CALL METHOD fill_no_data_sign( EXPORTING iv_segment_name = gc_segment_makt CHANGING cs_segment = ls_maktm ).
READ TABLE lt_fields INDEX 2 INTO ls_maram-matnr.
READ TABLE lt_fields INDEX 3 INTO ls_maram-mtart.
READ TABLE lt_fields INDEX 4 INTO ls_maram-mbrsh.
READ TABLE lt_fields INDEX 5 INTO ls_maram-meins.
READ TABLE lt_fields INDEX 6 INTO ls_maram-matkl.
READ TABLE lt_fields INDEX 7 INTO ls_maram-gewei.
READ TABLE lt_fields INDEX 8 INTO ls_maram-labor.
READ TABLE lt_fields INDEX 9 INTO ls_maram-prdha.
READ TABLE lt_fields INDEX 10 INTO ls_maktm-maktx.
* READ TABLE lt_fields INDEX 11 INTO ls_zmaraext-compscope.
* READ TABLE lt_fields INDEX 12 INTO ls_zmaraext-glat.
" Fill ET_CONTENT
ls_edidd-docnum = lv_docnum.
ls_edidd-segnam = gc_segment_mara.
ls_edidd-sdata = ls_maram.
ls_edidd-dtint2 = strlen( ls_maram ).
APPEND ls_edidd TO <ls_content>-idoc_data.
* ls_edidd-docnum = lv_docnum.
* ls_edidd-segnam = gc_segment_zmaraext.
* ls_edidd-sdata = ls_zmaraext.
* ls_edidd-dtint2 = strlen( ls_zmaraext ).
* APPEND ls_edidd TO <ls_content>-idoc_data.
* ls_edidd-docnum = lv_docnum.
* ls_edidd-segnam = gc_segment_makt.
* ls_maktm-spras = 'Z'.
* ls_maktm-spras_iso = 'ZH'.
* ls_edidd-sdata = ls_maktm.
* ls_edidd-dtint2 = strlen( ls_maktm ).
* APPEND ls_edidd TO <ls_content>-idoc_data.
* READ TABLE lt_fields INDEX 10 INTO ls_maktm-maktx.
ls_edidd-docnum = lv_docnum.
ls_edidd-segnam = gc_segment_makt.
ls_maktm-spras = sy-langu.
* ls_maktm-spras = 'E'.
ls_maktm-spras_iso = 'EN'.
ls_edidd-sdata = ls_maktm.
ls_edidd-dtint2 = strlen( ls_maktm ).
APPEND ls_edidd TO <ls_content>-idoc_data.
<ls_content>-idoc_control-docnum = lv_docnum.
<ls_content>-idoc_control-idoctp = gc_matmas.
* <ls_content>-idoc_control-cimtyp = gc_matmasext.
<ls_content>-idoc_control-sndprn = gv_parnum. "MDG-M MATMAS loader needs partner information
<ls_content>-idoc_control-sndprt = gc_partyp. "MDG-M MATMAS loader needs partner information
ENDLOOP.
CLEAR: ev_content. " Clear at the end, as caller uses same variable for IV_CONTENT_FRONTEND and EV_CONTENT (passed by reference)...
et_content = lt_content.
User | Count |
---|---|
85 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.