CL_ABAP_CHAR_UTILITIES類

sapkitty發表於2007-07-06

本程式演示瞭如何利用類CL_ABAP_CHAR_UTILITIES在字串中加入tab字元,回車換行符,換頁符。

[@more@]

*&---------------------------------------------------------------------*

*& Report ZCHAR_UTILITIES

*&---------------------------------------------------------------------*

*& 文字列処理用のユーティリティクラスCL_ABAP_CHAR_UTILITIESの使用

*&---------------------------------------------------------------------*

REPORT ZCHAR_UTILITIES.

* 出力テーブル

DATA: BEGIN OF GH_FILE,

LINE(4096) TYPE C,

END OF GH_FILE.

DATA: GT_FILE LIKE TABLE OF GH_FILE.

* "キャリッジリターン(CR)と改行(LF)"文字

DATA: GW_CRLF(2) TYPE C.

* "改ページ"文字

DATA: GW_NEWPAGE TYPE C.

* "水平タブストップ" 文字

DATA: GW_HTAB TYPE C.

*----------------------------------------------------------------------*

* START-OF-SELECTION

*----------------------------------------------------------------------*

START-OF-SELECTION.

*

GW_CRLF = CL_ABAP_CHAR_UTILITIES=>CR_LF.

GW_NEWPAGE = CL_ABAP_CHAR_UTILITIES=>FORM_FEED.

GW_HTAB = CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.

* 出力テーブルの作成

GH_FILE-LINE = 'NAME:'.

CONCATENATE GH_FILE-LINE GW_HTAB 'ZHOUGH' INTO GH_FILE-LINE.

APPEND GH_FILE TO GT_FILE.

CONCATENATE GW_CRLF 'Detailed info:' INTO GH_FILE-LINE.

APPEND GH_FILE TO GT_FILE.

CONCATENATE GW_NEWPAGE 'New page' INTO GH_FILE-LINE.

APPEND GH_fILE TO GT_FILE.

* 出力テーブルのダウンロード

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

FILENAME = 'C:TEST.DOC'

TABLES

DATA_TAB = GT_FILE

EXCEPTIONS

FILE_WRITE_ERROR = 1

NO_BATCH = 2

OTHERS = 3.

IF SY-SUBRC <> 0.

WRITE SY-SUBRC.

ENDIF.

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/8214011/viewspace-924533/,如需轉載,請註明出處,否則將追究法律責任。

相關文章