09-18-2009 1:37 PM
Hi!
I have an itab with many lines and want to save this itab to a file as csv. That means, that the fields of the structure the table consists of should be separated by a comma, not the lines!
I found the solution in this forum, the function 'SAP_CONVERT_TO_CSV_FORMAT' should do this!
But on our system this function is missing!? Is there a class which can do this conversion?
Thanks
Manfred
Edited by: Manfred Fettinger on Sep 18, 2009 2:37 PM
09-18-2009 1:39 PM
09-18-2009 1:41 PM
09-18-2009 1:43 PM
09-18-2009 1:43 PM
what version of SAP you are using?
system->status : component version : SAP ECC 6.0 or SAP 4.6c etc
09-18-2009 1:54 PM
Hi!
Its SAP EHP 1 for SAP NetWeaver 7.0
Ok, it looks like i have it to implement my own. Thanks to max bianchi for the code example!
09-18-2009 1:44 PM
Hi
Which is your release?
Anyway this is a method I've developed for my reports:
CLASS LC_FILE DEFINITION.
......
CLASS-METHODS: INSERT_SEPARATOR_CHAR
IMPORTING
SEPARATOR TYPE STRING
RECORD_IN TYPE ANY
NO_GAPS TYPE C DEFAULT SPACE
EXPORTING
RECORD_OUT TYPE STRING.
..........
ENDCLASS.
.CLASS LC_FILE IMPLEMENTATION.
METHOD INSERT_SEPARATOR_CHAR.
FIELD-SYMBOLS: <FS_FIELD> TYPE ANY.
DATA: WA_STRING(10000) TYPE C,
WA_VALUE(1000) TYPE C.
DATA: LEN_SEPAR TYPE I,
LEN_FIELD TYPE I,
LEN_STRING TYPE I,
LEN_VALUE TYPE I.
DATA: TYPE_FIELD TYPE C.
LEN_SEPAR = STRLEN( SEPARATOR ).
DO.
ASSIGN COMPONENT SY-INDEX OF STRUCTURE RECORD_IN TO <FS_FIELD>.
IF SY-SUBRC <> 0. EXIT. ENDIF.
* DESCRIBE FIELD <FS_FIELD> LENGTH LEN_FIELD IN CHARACTER MODE
* TYPE TYPE_FIELD.
DESCRIBE FIELD <FS_FIELD> LENGTH LEN_FIELD IN BYTE MODE
TYPE TYPE_FIELD.
IF TYPE_FIELD = 'g'.
LEN_FIELD = STRLEN( <FS_FIELD> ).
ENDIF.
CLEAR WA_VALUE.
WRITE: <FS_FIELD> TO WA_VALUE(LEN_FIELD),
<FS_FIELD> TO WA_STRING+LEN_STRING(LEN_FIELD).
LEN_VALUE = STRLEN( WA_VALUE ).
IF NOT NO_GAPS IS INITIAL.
LEN_FIELD = LEN_VALUE.
ENDIF.
LEN_STRING = LEN_STRING + LEN_FIELD.
WRITE: SEPARATOR(LEN_SEPAR) TO WA_STRING+LEN_STRING.
LEN_STRING = LEN_STRING + LEN_SEPAR.
ENDDO.
LEN_STRING = STRLEN( WA_STRING ).
MOVE WA_STRING(LEN_STRING) TO RECORD_OUT.
ENDMETHOD. "INSERT_SEPARATOR_CHAR
............
ENDCLASS.
.
Some stataments are adjusted for rel ECC 6.00
Max