Read UTF-8 input file correctly (#576)

This commit is contained in:
Gregor Wolf 2019-01-09 15:29:41 +01:00 committed by Ivan
parent 4ca4991167
commit 095f3d135b

View File

@ -4,9 +4,9 @@
*&---------------------------------------------------------------------* *&---------------------------------------------------------------------*
*& This report creates a monthly calendar in the specified date range. *& This report creates a monthly calendar in the specified date range.
*& Each month is put on a seperate worksheet. The pictures for each *& Each month is put on a seperate worksheet. The pictures for each
*& month can be specified in a tab delimited file called "Calendar.txt" *& month can be specified in a tab delimited UTF-8 encoded file called
*& which is saved in the Export Directory. By default this is the SAP *& "Calendar.txt" which is saved in the Export Directory.
*& Workdir. The file contains 3 fields: *& By default this is the SAP Workdir. The file contains 3 fields:
*& *&
*& Month (with leading 0) *& Month (with leading 0)
*& Image Filename *& Image Filename
@ -29,12 +29,12 @@ INCLUDE zdemo_calendar_classes.
DATA: lv_workdir TYPE string. DATA: lv_workdir TYPE string.
PARAMETERS: p_from TYPE dfrom DEFAULT '20130101', PARAMETERS: p_from TYPE dfrom DEFAULT '20190101',
p_to TYPE dto DEFAULT '20131231'. p_to TYPE dto DEFAULT '20191231'.
SELECTION-SCREEN BEGIN OF BLOCK orientation WITH FRAME TITLE orient. SELECTION-SCREEN BEGIN OF BLOCK orientation WITH FRAME TITLE orient.
PARAMETERS: p_portr TYPE flag RADIOBUTTON GROUP orie, PARAMETERS: p_portr TYPE flag RADIOBUTTON GROUP orie,
p_lands TYPE flag RADIOBUTTON GROUP orie DEFAULT 'X'. p_lands TYPE flag RADIOBUTTON GROUP orie DEFAULT 'X'.
SELECTION-SCREEN END OF BLOCK orientation. SELECTION-SCREEN END OF BLOCK orientation.
INITIALIZATION. INITIALIZATION.
@ -45,27 +45,27 @@ INITIALIZATION.
START-OF-SELECTION. START-OF-SELECTION.
DATA: lo_excel TYPE REF TO zcl_excel, DATA: lo_excel TYPE REF TO zcl_excel,
lo_worksheet TYPE REF TO zcl_excel_worksheet, lo_worksheet TYPE REF TO zcl_excel_worksheet,
lo_column TYPE REF TO zcl_excel_column, lo_column TYPE REF TO zcl_excel_column,
lo_row TYPE REF TO zcl_excel_row, lo_row TYPE REF TO zcl_excel_row,
lo_hyperlink TYPE REF TO zcl_excel_hyperlink, lo_hyperlink TYPE REF TO zcl_excel_hyperlink,
lo_drawing TYPE REF TO zcl_excel_drawing. lo_drawing TYPE REF TO zcl_excel_drawing.
DATA: lo_style_month TYPE REF TO zcl_excel_style, DATA: lo_style_month TYPE REF TO zcl_excel_style,
lv_style_month_guid TYPE zexcel_cell_style. lv_style_month_guid TYPE zexcel_cell_style.
DATA: lo_style_border TYPE REF TO zcl_excel_style, DATA: lo_style_border TYPE REF TO zcl_excel_style,
lo_border_dark TYPE REF TO zcl_excel_style_border, lo_border_dark TYPE REF TO zcl_excel_style_border,
lv_style_border_guid TYPE zexcel_cell_style. lv_style_border_guid TYPE zexcel_cell_style.
DATA: lo_style_center TYPE REF TO zcl_excel_style, DATA: lo_style_center TYPE REF TO zcl_excel_style,
lv_style_center_guid TYPE zexcel_cell_style. lv_style_center_guid TYPE zexcel_cell_style.
DATA: lv_full_path TYPE string, DATA: lv_full_path TYPE string,
image_descr_path TYPE string, image_descr_path TYPE string,
lv_file_separator TYPE c. lv_file_separator TYPE c.
DATA: lv_content TYPE xstring, DATA: lv_content TYPE xstring,
width TYPE i, width TYPE i,
lv_height TYPE i, lv_height TYPE i,
lv_from_row TYPE zexcel_cell_row. lv_from_row TYPE zexcel_cell_row.
DATA: month TYPE i, DATA: month TYPE i,
@ -86,11 +86,11 @@ START-OF-SELECTION.
FIELD-SYMBOLS: <month_name> LIKE LINE OF month_names. FIELD-SYMBOLS: <month_name> LIKE LINE OF month_names.
TYPES: BEGIN OF tt_datatab, TYPES: BEGIN OF tt_datatab,
month_nr TYPE fcmnr, month_nr TYPE fcmnr,
filename TYPE string, filename TYPE string,
descr TYPE string, descr TYPE string,
url TYPE string, url TYPE string,
END OF tt_datatab. END OF tt_datatab.
DATA: image_descriptions TYPE TABLE OF tt_datatab. DATA: image_descriptions TYPE TABLE OF tt_datatab.
FIELD-SYMBOLS: <img_descr> LIKE LINE OF image_descriptions. FIELD-SYMBOLS: <img_descr> LIKE LINE OF image_descriptions.
@ -98,10 +98,10 @@ START-OF-SELECTION.
CONSTANTS: lv_default_file_name TYPE string VALUE 'Calendar', "#EC NOTEXT CONSTANTS: lv_default_file_name TYPE string VALUE 'Calendar', "#EC NOTEXT
c_from_row_portrait TYPE zexcel_cell_row VALUE 28, c_from_row_portrait TYPE zexcel_cell_row VALUE 28,
c_from_row_landscape TYPE zexcel_cell_row VALUE 38, c_from_row_landscape TYPE zexcel_cell_row VALUE 38,
from_col TYPE zexcel_cell_column_alpha VALUE 'C', from_col TYPE zexcel_cell_column_alpha VALUE 'C',
c_height_portrait TYPE i VALUE 450, " Image Height in Portrait Mode c_height_portrait TYPE i VALUE 450, " Image Height in Portrait Mode
c_height_landscape TYPE i VALUE 670, " Image Height in Landscape Mode c_height_landscape TYPE i VALUE 670, " Image Height in Landscape Mode
c_factor TYPE f VALUE '1.5'. " Image Ratio, default 3:2 c_factor TYPE f VALUE '1.5'. " Image Ratio, default 3:2
IF p_path IS INITIAL. IF p_path IS INITIAL.
p_path = lv_workdir. p_path = lv_workdir.
@ -117,6 +117,7 @@ START-OF-SELECTION.
filetype = 'ASC' " File Type (ASCII, Binary) filetype = 'ASC' " File Type (ASCII, Binary)
has_field_separator = 'X' has_field_separator = 'X'
read_by_line = 'X' " File Written Line-By-Line to the Internal Table read_by_line = 'X' " File Written Line-By-Line to the Internal Table
codepage = '4110'
CHANGING CHANGING
data_tab = image_descriptions " Transfer table for file contents data_tab = image_descriptions " Transfer table for file contents
EXCEPTIONS EXCEPTIONS
@ -344,7 +345,7 @@ START-OF-SELECTION.
* last_day_of_month = date_to. * last_day_of_month = date_to.
date_to = date_from. date_to = date_from.
date_to+6(2) = '01'. " First of month date_to+6(2) = '01'. " First of month
add 31 to date_to. " Somewhere in following month ADD 31 TO date_to. " Somewhere in following month
date_to = date_to - date_to+6(2). " Last of month date_to = date_to - date_to+6(2). " Last of month
IF p_portr = abap_true. IF p_portr = abap_true.
zcl_helper=>add_calendar( zcl_helper=>add_calendar(