Diese Seite (Version-1) wurde zuletzt am 28-März-2017 14:37 von UnbekannterAutor geändert.

Du bist nicht autorisiert, diese Seite umzubenennen.

Du bist nicht autorisiert, diese Seite zu löschen.

Versionsgeschichte der Seite

Version Zuletzt geändert Größe Autor Änderungen Kommentar

Links

Eingehende Links Ausgehende Links

Versionsunterschiede

Unterschiede zwischen Version und .

Zeile 1: 86 Zeilen hinzugefügt.
[{ALLOW view All}]
[{ALLOW edit Authenticated}]
{{{
FORM WRITES_ITAB USING P_ITAB P_STRUC.
DATA: FIELDDATA TYPE STRING,
DTYPE TYPE C,
DREF TYPE REF TO CL_ABAP_TYPEDESCR,
LS_COMP TYPE ABAP_COMPONENTDESCR,
LS_STRUCT TYPE REF TO CL_ABAP_STRUCTDESCR,
LT_COMP TYPE STANDARD TABLE OF ABAP_COMPONENTDESCR,
ITAB_FILE TYPE STANDARD TABLE OF STRING,
LINE TYPE STRING,
WA_ITAB TYPE REF TO DATA.
FIELD-SYMBOLS: <STRUCTURE> TYPE ANY,
<ITAB> TYPE ANY TABLE,
<WA_ITAB> TYPE ANY,
<FS_COMP> TYPE ANY.
ASSIGN P_ITAB TO <ITAB>.
ASSIGN P_STRUC TO <STRUCTURE>.
" Define Workarea for <itab>
CREATE DATA WA_ITAB LIKE <STRUCTURE>.
" Make content of Itab Workarea accessible
ASSIGN WA_ITAB->* TO <WA_ITAB>.
"prepare tab separated lines for text file
REFRESH ITAB_FILE.
" add heading
LS_STRUCT ?= CL_ABAP_TYPEDESCR=>DESCRIBE_BY_DATA( <STRUCTURE> ).
LT_COMP = LS_STRUCT->GET_COMPONENTS( ).
CLEAR LINE.
LOOP AT LT_COMP INTO LS_COMP.
IF SY-TABIX > 1.
CONCATENATE LINE CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB INTO LINE.
ENDIF.
CONCATENATE LINE LS_COMP-NAME INTO LINE.
ENDLOOP.
APPEND LINE TO ITAB_FILE.
" add data
LOOP AT <ITAB> INTO <WA_ITAB>.
CLEAR LINE.
DO.
" get field
ASSIGN COMPONENT SY-INDEX OF STRUCTURE <WA_ITAB> TO <FS_COMP>.
IF SY-SUBRC NE 0.
EXIT.
ENDIF.
" add tabulator as delimiter
IF SY-INDEX > 1.
CONCATENATE LINE CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB INTO LINE.
ENDIF.
" add field data
FIELDDATA = <FS_COMP>.
" change date, time and float format
DESCRIBE FIELD <FS_COMP> TYPE DTYPE.
CASE DTYPE.
WHEN 'D'.
" DD.MM.YYYY
CONCATENATE FIELDDATA+6(2) '.' FIELDDATA+4(2) '.' FIELDDATA+0(4) INTO FIELDDATA RESPECTING BLANKS.
WHEN 'T'.
CONCATENATE FIELDDATA+0(2) ':' FIELDDATA+2(2) ':' FIELDDATA+4(2) INTO FIELDDATA RESPECTING BLANKS.
WHEN 'F' OR 'P'.
REPLACE FIRST OCCURRENCE OF SUBSTRING '.' IN FIELDDATA WITH ',' IN CHARACTER MODE.
ENDCASE.
CONCATENATE LINE FIELDDATA INTO LINE RESPECTING BLANKS.
ENDDO.
APPEND LINE TO ITAB_FILE.
ENDLOOP.
" write all data
LOOP AT ITAB_FILE INTO LINE.
WRITE: / LINE.
ENDLOOP.
ENDFORM.
}}}