*----------------------------------------------------------------------*
* [汎用ADOOONテーブル データアップロードGUI_UPLOAD]V1.0
* GUI_UPLOAD
* 逆参照 dref->*
* File Type (ASC or BIN)
*----------------------------------------------------------------------*
REPORT ZERO_CHOTEST_GUI_UPLOAD.
*----------------------------------------------------------------------*
* 選択画面定義
*----------------------------------------------------------------------*
SELECTION-SCREEN COMMENT 1(26) comm1.
SELECTION-SCREEN SKIP 3.
PARAMETERS: P_FPATH TYPE STRING DEFAULT 'c:\abc.txt' OBLIGATORY,"
P_TABNAM TYPE TABNAME DEFAULT 'ZTBL001' OBLIGATORY."テーブル名
PARAMETERS: P_SPRTR TYPE C DEFAULT '1'. "タブ区切り[tabs]
SELECTION-SCREEN COMMENT 40(26) comm2.
*&---------------------------------------------------------------------*
*& AT SELECTION SCREEN OUTPUT.
*&---------------------------------------------------------------------*
AT SELECTION-SCREEN OUTPUT.
comm1 ='汎用ADOOONテーブル データアップロード'.
comm2 ='区切り 1:タブ 2:カンマ'.
*&---------------------------------------------------------------------*
*& START-OF-SELECTION
*&---------------------------------------------------------------------*
START-OF-SELECTION.
PERFORM MAIN_PROC.
*&---------------------------------------------------------------------*
*& Form MAIN_PROC
*&---------------------------------------------------------------------*
* メイン処理
*----------------------------------------------------------------------*
FORM MAIN_PROC.
DATA: LTD_DATA TYPE REF TO DATA,
LW_TABNAME TYPE TABNAME.
FIELD-SYMBOLS: <DATA> TYPE STANDARD TABLE.
* テーブル名のチェック
LW_TABNAME = P_TABNAM.
CONDENSE LW_TABNAME. "CONDENSE:先頭と末尾の空白が完全に除去さ れます。
IF LW_TABNAME+0(1) <> 'Z'.
* エラーメッセージ
MESSAGE '指定出来るテーブルはADDONのみです' TYPE 'S' DISPLAY LIKE 'E'.
LEAVE LIST-PROCESSING.
ENDIF.
* 命令 CREATE DATA にオプション tabkind OF を指定する と、内部テーブルが生成されます。
* このオプションは、命令 DATA による内部テー ブルの宣言と同じ意味があ ります。DATA: TBL_DATA TYPE TABLE OF TBL1.
* TBLは事前に知らない場合には、CREATE DATA...TYPE TABLE OFを使う
CREATE DATA LTD_DATA TYPE TABLE OF (P_TABNAM).
* 逆参照 dref->*
ASSIGN LTD_DATA->* TO <DATA>. "(逆参照演算子 ->* )
IF P_SPRTR = 1.
* ファイルアップロード
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = P_FPATH
* FILETYPE = 'ASC'
* FILETYPE = 'DAT'
HAS_FIELD_SEPARATOR = 'X' "'X' means columns
separated by tabs in case of ASCII upload
* HEADER_LENGTH = 0
* CODEPAGE = ' '
* IMPORTING
* FILELENGTH =
* HEADER =
TABLES
DATA_TAB = <DATA>
EXCEPTIONS
FILE_OPEN_ERROR = 1
FILE_READ_ERROR = 2
NO_BATCH = 3
GUI_REFUSE_FILETRANSFER = 4
INVALID_TYPE = 5
NO_AUTHORITY = 6
UNKNOWN_ERROR = 7
BAD_DATA_FORMAT = 8
HEADER_NOT_ALLOWED = 9
SEPARATOR_NOT_ALLOWED = 10
HEADER_TOO_LONG = 11
UNKNOWN_DP_ERROR = 12
ACCESS_DENIED = 13
DP_OUT_OF_MEMORY = 14
DISK_FULL = 15
DP_TIMEOUT = 16
OTHERS = 17.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ELSE.
* タブ区切り以外の場合は項目の分割が必要なため別処理
PERFORM GET_DATA2 TABLES <DATA>.
ENDIF.
* 対象のテーブルにデータをインサート
INSERT (P_TABNAM) FROM TABLE <DATA> ACCEPTING DUPLICATE KEYS.
IF SY-SUBRC = 0.
COMMIT WORK.
MESSAGE '処理成功' TYPE 'S'.
ELSE.
ROLLBACK WORK.
MESSAGE 'エラーが発生しました' TYPE 'E'.
ENDIF.
ENDFORM. " MAIN_PROC
*&---------------------------------------------------------------------*
*& Form GET_DATA2
*&---------------------------------------------------------------------*
* ファイルからのデータ取得(タブ区切り以外)
*----------------------------------------------------------------------*
* -->内部テーブル
*----------------------------------------------------------------------*
FORM GET_DATA2 TABLES ITD_DATA TYPE STANDARD TABLE.
DATA: LTD_FDAT TYPE STANDARD TABLE OF STRING,
LST_FDAT TYPE STRING,
LST_DATA TYPE REF TO DATA,
LW_SEPARAT TYPE C,
LW_TEMP TYPE STRING,
LW_I TYPE I.
FIELD-SYMBOLS: <LINE> TYPE ANY,
<ITEM> TYPE ANY.
CREATE DATA LST_DATA TYPE (P_TABNAM)."構造の宣言
ASSIGN LST_DATA->* TO <LINE>. "構造の逆参照
* ファイルアップロード
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = P_FPATH
TABLES
DATA_TAB = LTD_FDAT
EXCEPTIONS
FILE_OPEN_ERROR = 1
FILE_READ_ERROR = 2
NO_BATCH = 3
GUI_REFUSE_FILETRANSFER = 4
INVALID_TYPE = 5
NO_AUTHORITY = 6
UNKNOWN_ERROR = 7
BAD_DATA_FORMAT = 8
HEADER_NOT_ALLOWED = 9
SEPARATOR_NOT_ALLOWED = 10
HEADER_TOO_LONG = 11
UNKNOWN_DP_ERROR = 12
ACCESS_DENIED = 13
DP_OUT_OF_MEMORY = 14
DISK_FULL = 15
DP_TIMEOUT = 16
OTHERS = 17.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
* セパレータ[separate][,]の判断
CASE P_SPRTR.
WHEN '2'."カンマ
LW_SEPARAT = ','."カンマ
ENDCASE.
LOOP AT LTD_FDAT INTO LST_FDAT.
CLEAR LW_I.
DO.
LW_I = LW_I + 1.
***** For a structured data object struc, you can use the statement
***** ASSIGN COMPONENT comp OF STRUCTURE struc TO <fs>.
***** to assign one of its components comp to the field symbol <fs>.
***** You can specify the component compeither as a literal or a variable.
ASSIGN COMPONENT LW_I OF STRUCTURE <LINE> TO <ITEM>. "<ITEM>⇒<LINE>
IF SY-SUBRC <> 0.
EXIT.
ENDIF.
SPLIT LST_FDAT AT LW_SEPARAT INTO LW_TEMP LST_FDAT.
* 括り文字の考慮
IF LW_TEMP+0(1) = '"' OR LW_TEMP+0(1) = ''''.
SHIFT LW_TEMP RIGHT CIRCULAR.
SHIFT LW_TEMP BY 2 PLACES LEFT.
ENDIF.
<ITEM> = LW_TEMP.
ENDDO.
APPEND <LINE> TO ITD_DATA.
ENDLOOP.
ENDFORM. " GET_DATA2
***FUNCTION GUI_DOWNLOAD FILETYPE
***____________________________________________________
***File Type (ASC or BIN)
***Description
***During download, the data can be transferred in different formats,
depending on the value of the
*** FILETYPE parameter.
***Value range
***'ASC' :
***ASCII format. The table is transferred as text. Conversion exits
are performed. The output format
***additionally depends on the parameters CODEPAGE,
TRUNC_TRAILING_BLANKS, and TRUNC_TRAILING_BLANKS_EOL.
***'IBM' :
***ASCII format with IBM codepage conversion (DOS). This format
corresponds to the 'ASC' format when
***using target codepage 1103. This codepage is frequently used for
data exchange via floppy disk.
***'DAT' :
***Column-by-column transfer. With this format, the data is
transferred as text as with ASC. However,
*** no conversion exits are performed and the columns are separated by
tab characters. This format
*** generates files than can be uploaded again using gui_upload or ws_upload.
***'DBF' :
***Data is downloaded in dBase format. Since in this format the data
types of the individual columns
*** are stored as well, you can often avoid import problems, for
example, into Microsoft Excel,
*** especially when interpreting numeric values.
***'WK1' :
***Data is downloaded in Lotus 1-2-3 format.
***'BIN' :
***Binary format. Data is transferred binarily. There is no formatting
and no codepage conversion.
***The data is interpreted row by row; it is not formatted by columns.
Specify the data length in
*** parameter BIN_FILESIZE. The table should consist of a column
of type X, because especially
*** in Unicode systems, the conversion of structured into binary
data causes errors.
***Default
***'ASC'
5 comments:
uggs outlet, michael kors outlet online, vans pas cher, converse pas cher, mulberry uk, ray ban uk, michael kors outlet, michael kors outlet online, nike free uk, sac vanessa bruno, coach outlet store online, replica handbags, michael kors, hollister pas cher, nike roshe run uk, polo lacoste, ray ban pas cher, michael kors outlet online, north face uk, oakley pas cher, nike air max, burberry outlet, true religion outlet, michael kors, north face, nike tn, lululemon canada, nike air max uk, nike air max uk, coach outlet, timberland pas cher, uggs outlet, michael kors outlet online, burberry handbags, hogan outlet, true religion outlet, true religion outlet, true religion jeans, ralph lauren uk, new balance, sac hermes, nike air force, michael kors outlet, guess pas cher, kate spade, nike blazer pas cher, hollister uk, abercrombie and fitch uk, michael kors outlet
moncler, links of london, juicy couture outlet, louis vuitton, montre pas cher, karen millen uk, ugg uk, moncler, supra shoes, canada goose, ugg,ugg australia,ugg italia, canada goose outlet, ugg pas cher, louis vuitton, canada goose, thomas sabo, moncler, canada goose outlet, pandora charms, coach outlet, canada goose uk, ugg, replica watches, pandora jewelry, hollister, canada goose outlet, swarovski crystal, canada goose jackets, moncler, pandora uk, moncler uk, moncler outlet, canada goose, juicy couture outlet, ugg,uggs,uggs canada, louis vuitton, doudoune moncler, marc jacobs, pandora jewelry, wedding dresses, louis vuitton, louis vuitton, swarovski, toms shoes, moncler outlet
moncler jackets
yeezy
longchamp bags
jordan retro
balenciaga
ultra boost
nike foamposite
nike sneakers
kd 12
adidas zx flux
find more cheap designer bags replica home check that have a peek at this site have a peek at this website
r8v11h9p73 i5y25b4x50 e5u61z3i17 t5c20u7h53 m4w33x3q46 o9x49j1v45
Post a Comment