*&---------------------------------------------------------------------*
*& Include ZDB_UPLOAD_CONVERT_DATA *
*& *
*&---------------------------------------------------------------------*
*& *
*& This file is part of ZDB. *
*& *
*& ZDB_DOWNLOAD is free software: you can redistribute it and/or *
*& modify it under the terms of the GNU General Public License as *
*& published by the Free Software Foundation, either version 3 of the *
*& License, or any later version. *
*& *
*& ZDB_DOWNLOAD is distributed in the hope that it will be useful, *
*& but WITHOUT ANY WARRANTY; without even the implied warranty of *
*& MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
*& GNU General Public License for more details. *
*& *
*& You should have received a copy of the GNU General Public License *
*& along with ZDOWNLOAD. If not, see . *
*& *
*&---------------------------------------------------------------------*
*& *
*& Author: Ruediger von Creytz ruediger.creytz@globalbit.net *
*& Copyright: globalBIT, LLC http://www.globalbit.net *
*& *
*&---------------------------------------------------------------------*
*-----------------------------------------------------------------------
* form: csv2data
*-----------------------------------------------------------------------
FORM csv2data USING
value(i_tabname) TYPE tabname
it_csv TYPE it_string.
DATA:
lt_dd03l TYPE STANDARD TABLE OF dd03l,
ls_dd02l TYPE dd02l,
l_fieldname TYPE fieldname,
l_position TYPE tabfdpos,
lt_value TYPE it_string,
l_value TYPE string,
l_csv TYPE string,
l_len TYPE i,
l_cnt TYPE i,
l_length TYPE string,
l_quot TYPE flag,
ls_fs TYPE REF TO data.
FIELD-SYMBOLS:
TYPE string,
TYPE dd03l,
TYPE ANY,
TYPE ANY,
TYPE ANY.
SELECT * FROM dd03l INTO TABLE lt_dd03l
WHERE tabname = i_tabname
AND as4local = 'A'
ORDER BY position.
SELECT SINGLE * FROM dd02l INTO ls_dd02l
WHERE tabname = i_tabname
AND as4local = 'A'.
*content
CREATE DATA ls_fs TYPE (i_tabname).
ASSIGN ls_fs->* TO .
LOOP AT it_csv ASSIGNING .
IF sy-tabix = 1.
CONTINUE.
ENDIF.
CLEAR l_cnt.
SPLIT AT ';' INTO TABLE lt_value.
LOOP AT lt_value ASSIGNING .
IF l_quot = abap_true.
CONCATENATE l_value ';' INTO l_value.
ELSE.
l_value = .
IF l_value <> space AND l_value+0(1) = '"'.
l_quot = abap_true.
l_value = l_value+1.
ENDIF.
ENDIF.
IF l_quot = abap_true.
l_len = strlen( l_value ).
IF l_len > 0.
SUBTRACT 1 FROM l_len.
IF l_value+l_len(1) = '"'.
l_value = l_value+0(l_len).
l_quot = abap_false.
ENDIF.
ENDIF.
ENDIF.
IF l_quot = abap_false.
ADD 1 TO l_cnt.
READ TABLE lt_dd03l ASSIGNING INDEX l_cnt.
IF sy-subrc <> 0.
* message 'Cannot import data'.
EXIT.
ENDIF.
IF -fieldname <> 'MANDT'.
ASSIGN COMPONENT -fieldname OF STRUCTURE
TO .
= l_value.
ENDIF.
ENDIF.
ENDLOOP.
MODIFY (i_tabname) FROM .
CLEAR .
ENDLOOP.
ENDFORM. "select_csv2data