关键代码:
FORM itabtoclip TABLES intab .
DATA: BEGIN OF itab_clip OCCURS 0 ,
line(10000) TYPE c ,
END OF itab_clip.
DATA: tmpchar TYPE string .
DATA: BEGIN OF headtab OCCURS 0 ,
length TYPE i ,
decimals TYPE i,
type_kind TYPE c,
name(30) TYPE c,
END OF headtab.
DATA n TYPE i .
DATA descr_ref TYPE REF TO cl_abap_structdescr.
FIELD-SYMBOLS: TYPE abap_compdescr ,
,
TYPE ANY .
DATA:str TYPE string ,
text1 TYPE c.
DATA: tab TYPE c VALUE cl_abap_char_utilities=>NEWLINE.
descr_ref ?= cl_abap_typedescr=>describe_by_data( intab ).
LOOP AT descr_ref->components ASSIGNING .
MOVE-CORRESPONDING TO headtab.
APPEND headtab.
ENDLOOP.
DESCRIBE TABLE headtab LINES n.
LOOP AT intab ASSIGNING .
DO n TIMES.
ASSIGN COMPONENT sy-index OF STRUCTURE TO .
str = .
READ TABLE headtab INDEX sy-index.
IF headtab-type_kind = 'I' OR headtab-type_kind = 'P'
OR headtab-type_kind = 'F'.
SEARCH str FOR '-'.
IF sy-subrc = 0 AND sy-fdpos <> 0.
SPLIT str AT '-' INTO str text1.
CONDENSE str.
CONCATENATE '-' str INTO str.
ELSE.
CONDENSE str.
ENDIF.
ELSE.
* SHIFT str LEFT DELETING LEADING '0' .
ENDIF.
CONCATENATE tmpchar str INTO tmpchar.
ENDDO.
CONCATENATE itab_clip-line tab tmpchar INTO itab_clip-line.
CLEAR tmpchar.
ENDLOOP.
SHIFT itab_clip-line.
CONCATENATE '"' itab_clip-line '"' INTO itab_clip-line.
APPEND itab_clip.
CALL FUNCTION 'CLPB_EXPORT'
TABLES
data_tab = itab_clip
EXCEPTIONS
clpb_error = 01.
ENDFORM.
阅读(3524) | 评论(0) | 转发(0) |