*&---------------------------------------------------------------------*
*& Include ZDB_DOWNLOAD_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: data2csv
*-----------------------------------------------------------------------
FORM data2csv USING
value(i_tabname)
CHANGING
ct_csv TYPE it_string.
DATA:
lt_dd03l TYPE STANDARD TABLE OF dd03l,
ls_dd02l TYPE dd02l,
l_fieldname TYPE fieldname,
l_position TYPE tabfdpos,
l_value TYPE string,
l_csv TYPE string,
l_len TYPE i,
l_length TYPE string,
ls_fs TYPE REF TO data.
FIELD-SYMBOLS:
TYPE dd03l,
TYPE ANY,
TYPE ANY.
REFRESH ct_csv.
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'.
LOOP AT lt_dd03l ASSIGNING .
IF -fieldname+0(1) = '.'.
CONTINUE.
ENDIF.
IF NOT l_csv IS INITIAL.
CONCATENATE l_csv ';' INTO l_csv.
ENDIF.
l_len = -intlen.
l_length = l_len.
CONDENSE l_length.
CONCATENATE l_csv '"' -fieldname
'(' -inttype l_length ')"'
INTO l_csv.
ENDLOOP.
APPEND l_csv TO ct_csv.
*content
CREATE DATA ls_fs TYPE (i_tabname).
ASSIGN ls_fs->* TO .
SELECT * FROM (i_tabname) INTO .
CLEAR l_csv.
LOOP AT lt_dd03l ASSIGNING .
CLEAR l_value.
IF -fieldname+0(1) = '.'.
CONTINUE.
ENDIF.
IF NOT -datatype = 'RAWSTRING'.
ASSIGN COMPONENT -fieldname OF STRUCTURE
TO .
l_value = .
ENDIF.
IF NOT l_csv IS INITIAL.
CONCATENATE l_csv ';' INTO l_csv.
ENDIF.
CONCATENATE l_csv '"' l_value '"' INTO l_csv.
ENDLOOP.
APPEND l_csv TO ct_csv.
IF sy-dbcnt = g_add_db_max_lines.
EXIT.
ENDIF.
ENDSELECT.
ENDFORM. "select_data2csv
*-----------------------------------------------------------------------
* form: data2xml
*-----------------------------------------------------------------------
FORM data2xml USING
value(i_tabname)
CHANGING
ct_xml TYPE it_string.
DATA:
lt_dd03l TYPE STANDARD TABLE OF dd03l,
ls_dd03t TYPE dd03t,
ls_dd02l TYPE dd02l,
ls_dd02t TYPE dd02t,
l_fieldname(30) TYPE c,
l_position TYPE tabfdpos,
l_value TYPE string,
l_xml TYPE string,
ls_fs TYPE REF TO data.
FIELD-SYMBOLS:
TYPE dd03l,
TYPE ANY,
TYPE ANY.
REFRESH ct_xml.
SELECT * FROM dd03l INTO TABLE lt_dd03l
WHERE tabname = i_tabname
AND as4local = 'A'
ORDER BY position.
APPEND '' TO ct_xml.
APPEND '' TO ct_xml.
APPEND '' TO ct_xml.
SELECT SINGLE * FROM dd02l INTO ls_dd02l
WHERE tabname = i_tabname
AND as4local = 'A'.
SELECT fieldname position FROM dd03l INTO (l_fieldname, l_position)
WHERE tabname = 'DD02L'
ORDER BY position.
ASSIGN COMPONENT l_fieldname OF STRUCTURE ls_dd02l
TO .
IF NOT IS INITIAL.
l_value = .
PERFORM encode_html CHANGING l_value.
TRANSLATE l_fieldname TO LOWER CASE.
CONCATENATE
'<' l_fieldname ' value="' l_value '"/>'
INTO l_xml.
APPEND l_xml TO ct_xml.
ENDIF.
ENDSELECT.
SELECT * FROM dd02t INTO ls_dd02t
WHERE tabname = i_tabname
AND as4local = 'A'.
CONCATENATE
''
ls_dd02t-ddtext
''
INTO l_xml.
APPEND l_xml TO ct_xml.
ENDSELECT.
APPEND '
' TO ct_xml.
LOOP AT lt_dd03l ASSIGNING .
IF -fieldname+0(1) = '.'.
CONTINUE.
ENDIF.
APPEND '' TO ct_xml.
SELECT fieldname position FROM dd03l INTO (l_fieldname, l_position)
WHERE tabname = 'DD03L'
AND fieldname <> 'TABNAME'
ORDER BY position.
ASSIGN COMPONENT l_fieldname OF STRUCTURE
TO .
l_value = .
IF NOT IS INITIAL.
PERFORM encode_html CHANGING l_value.
TRANSLATE l_fieldname TO LOWER CASE.
CONCATENATE
'<' l_fieldname '>' l_value '' l_fieldname '>'
INTO l_xml.
APPEND l_xml TO ct_xml.
ENDIF.
ENDSELECT.
SELECT * FROM dd03t INTO ls_dd03t
WHERE tabname = -tabname
AND fieldname = -fieldname
AND as4local = 'A'.
CONCATENATE
''
ls_dd03t-ddtext
''
INTO l_xml.
APPEND l_xml TO ct_xml.
ENDSELECT.
APPEND '' TO ct_xml.
ENDLOOP.
APPEND '' TO ct_xml.
*content
APPEND '' TO ct_xml.
CREATE DATA ls_fs TYPE (i_tabname).
ASSIGN ls_fs->* TO .
SELECT * FROM (i_tabname) INTO .
CLEAR l_xml.
APPEND '' TO ct_xml.
LOOP AT lt_dd03l ASSIGNING .
IF -fieldname+0(1) = '.'.
CONTINUE.
ENDIF.
CLEAR l_value.
IF NOT -datatype = 'RAWSTRING'.
ASSIGN COMPONENT -fieldname OF STRUCTURE
TO .
l_value = .
PERFORM encode_html CHANGING l_value.
ENDIF.
IF NOT IS INITIAL.
IF -fieldname(1) = '.'.
-fieldname(1) = '_'.
ENDIF.
CONCATENATE
''
l_value
' | ' INTO l_xml.
APPEND l_xml TO ct_xml.
ENDIF.
ENDLOOP.
APPEND '' TO ct_xml.
IF sy-dbcnt = g_add_db_max_lines.
EXIT.
ENDIF.
ENDSELECT.
APPEND '' TO ct_xml.
ENDFORM. "select_data2xml