Skip to Content
0
Former Member
Sep 23, 2014 at 01:49 PM

Fieldcatalog cannot be generated

32 Views

Dear experts,

I'm trying to display some data from simple csv-file in ALV as following:

DATA: BEGIN OF st_csv_data,

vkorg TYPE vkorg,

matnr TYPE matnr,

preis(10) TYPE c,

END OF st_csv_data.

DATA: ta_files TYPE filetable.

DATA: v_sysubrc TYPE sysubrc.

DATA: v_user_action TYPE i.

DATA: v_filename TYPE string.

DATA: v_record TYPE string.

DATA: ta_csv LIKE STANDARD TABLE OF v_record.

DATA: ta_csv_data TYPE STANDARD TABLE OF zst_preisupload,

wa_csv_data LIKE LINE OF ta_csv_data.

"ALV-Grid Paknum

DATA: alv_grid_csv TYPE REF TO cl_gui_alv_grid,

ccontainer_csv TYPE REF TO cl_gui_custom_container,

ta_field_catalog_csv TYPE lvc_t_fcat,

wa_field_catalog_csv LIKE LINE OF ta_field_catalog_csv,

st_layout_csv TYPE lvc_s_layo.

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-t01.

PARAMETERS p_art TYPE rv13a-kschl.

PARAMETERS p_accseq TYPE v_t682i-kozgf.

PARAMETERS p_fname(4096) TYPE c.

SELECTION-SCREEN END OF BLOCK b1.

" Dateiselektor für Lokale Dateiauswahl

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_fname.

CALL METHOD cl_gui_frontend_services=>file_open_dialog

EXPORTING

multiselection = abap_false

file_filter = '*.csv'

default_extension = 'csv'

CHANGING

file_table = ta_files

rc = v_sysubrc

user_action = v_user_action.

"Keine Kopfzeile bei ta_files

READ TABLE ta_files INTO p_fname INDEX 1.

START-OF-SELECTION.

v_filename = p_fname.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

filename = v_filename

filetype = 'ASC'

TABLES

data_tab = ta_csv.

IF sy-subrc <> 0.

MESSAGE e000(z_preisupload).

ENDIF.

LOOP AT ta_csv INTO v_record.

"Ausblenden von Buchstaben sowie Sonderzeichen

REPLACE ALL OCCURRENCES OF REGEX '[^\d;,.]' IN v_record WITH ''.

IF sy-tabix = 1.

CONTINUE.

ENDIF.

SPLIT v_record AT ';'

INTO st_csv_data-vkorg

st_csv_data-matnr

st_csv_data-preis.

MOVE: st_csv_data-vkorg TO wa_csv_data-vkorg,

st_csv_data-matnr TO wa_csv_data-matnr,

st_csv_data-preis TO wa_csv_data-preis.

APPEND wa_csv_data TO ta_csv_data.

ENDLOOP.

CALL SCREEN 2000.

st_layout_csv-no_toolbar = 'X'.

st_layout_csv-no_headers = 'X'.

st_layout_csv-no_rowmark = 'X'.

st_layout_csv-zebra = 'X'.

st_layout_csv-sel_mode = 'D'.

st_layout_csv-cwidth_opt = 'X'.

CLEAR wa_field_catalog_csv.

wa_field_catalog_csv-fieldname = 'VkOrg'.

"wa_field_catalog_csv-edit = abap_true.

APPEND wa_field_catalog_csv TO ta_field_catalog_csv.

CLEAR wa_field_catalog_csv.

wa_field_catalog_csv-fieldname = 'Material'.

"wa_field_catalog_csv-edit = abap_true.

APPEND wa_field_catalog_csv TO ta_field_catalog_csv.

CLEAR wa_field_catalog_csv.

wa_field_catalog_csv-fieldname = 'Preis'.

"2wa_field_catalog_csv-edit = abap_true.

APPEND wa_field_catalog_csv TO ta_field_catalog_csv.

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

*& Module STATUS_2000 OUTPUT

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

* text

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

MODULE STATUS_2000 OUTPUT.

"Erstelle den Container für das spätere ALV

IF ccontainer_csv IS INITIAL.

CREATE OBJECT ccontainer_csv

EXPORTING

container_name = 'UPLOAD'.

"Erstelle das eigentliche ALV-Grid

CREATE OBJECT alv_grid_csv

EXPORTING

i_parent = ccontainer_csv.

ENDIF.

"Bereite das ALV auf die Darstellung vor

CALL METHOD alv_grid_csv->set_table_for_first_display

EXPORTING

is_layout = st_layout_csv

CHANGING

it_outtab = ta_csv_data

it_fieldcatalog = ta_field_catalog_csv.

ENDMODULE.


But I get the error PopUp "The fieldcatalog cannot be generated"


What do I do wrong?


Many thanks in advance


BR


Denis