Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Fieldcatalog cannot be generated

Former Member
0 Likes
2,330

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.

DATAv_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(4096TYPE 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

1 ACCEPTED SOLUTION
Read only

rosenberg_eitan
Active Contributor
0 Likes
2,284

Hi,

If you can try to use cl_salv_table .(No need for field catalog)

See http://wiki.scn.sap.com/wiki/display/Snippets/displaying+icons+in+alv+using+class+cl_salv_table or demo program that use this class .

- To use CL_GUI_ALV_GRID look at demo program in package SLIS.

- Use this search in google: site:help.sap.com  CL_GUI_ALV_GRID

- Get the book 

See chapter "Building Field Catalog Manually"

CLEAR ls_fcat .

ls_fcat-fieldname = 'CONNID' .

ls_fcat-ref_table = 'SFLIGHT' .

ls_fcat-ref_field = 'CONNID' .

APPEND ls_fcat to pt_fieldcat .

Regards.

12 REPLIES 12
Read only

Former Member
0 Likes
2,284

type wa_field_catalog_csv-fieldname = 'VkOrg'. in capitals and check


wa_field_catalog_csv-fieldname = 'VKORG


and laso fill wa_field_catalog_csv- tabname '. with internal table name

Read only

0 Likes
2,284

what do you mean with this?:

and also fill wa_field_catalog_csv- tabname '. with internal table name


Should I somehow declare it or just write in the fieldcatalog part?

Read only

former_member188724
Contributor
0 Likes
2,284

Hi Denis,

Looks like your fields are

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.

VKORG, MATNR & PREIS

You should use fieldname as 'MATNR', 'VKORG' & 'PREIS' and also reference as internal table.

you mention as 'VkOrg'  & 'Material' which is wrong.

Please Change and check.

Regards,

K.S.

Read only

venkateswaran_k
Active Contributor
0 Likes
2,284

Hi Denis

In your output table struecture - zst_preisupload

is the field names  -  'VkOrg'  & 'Material', 'preis'  are valid?  Kindly check it.

Secondly, the field names should be in Capital - in the field catalog section.

Example:  'preis'  - should be 'PREIS'    - same as other fields as well

Regards,

Venkat

Read only

Former Member
0 Likes
2,284

   CLEAR wa_field_catalog_csv.

   wa_field_catalog_csv-fieldname = 'VkOrg'.

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-fieldname = 'MATNR'.

   "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'.

   wa_field_catalog_csv-fieldname = 'PREIS'.

   "2wa_field_catalog_csv-edit = abap_true.

   APPEND wa_field_catalog_csv TO ta_field_catalog_csv.

Read only

0 Likes
2,284

it doesn't work unfortunatelly still get the error pop-up

Read only

VenkatRamesh_V
Active Contributor
0 Likes
2,284

Hi Denis,

Check the zst_preisupload Structure, Declare the same field name in capital letters,



Regards,

Venkat.




Read only

0 Likes
2,284

I use this structure:

And whateever I use here:

wa_field_catalog_csv-fieldname = Component or Data Type i keep getting the message:

"Field catalog not found"

Read only

0 Likes
2,284

Hi,

wa_field_catalog_csv-ref_table = 'ZST_PREISUPLOAD'.

wa_field_catalog_csv-ref_field = 'VKORG'.
    
    APPEND wa_field_catalog_csv TO ta_field_catalog_csv.

 

    CLEAR wa_field_catalog_csv.
   

wa_field_catalog_csv-ref_table = 'ZST_PREISUPLOAD'.
wa_field_catalog_csv-ref_field = 'MATNR'.
APPEND wa_field_catalog_csv TO ta_field_catalog_csv.

    CLEAR wa_field_catalog_csv.
wa_field_catalog_csv-ref_table = 'ZST_PREISUPLOAD'.
wa_field_catalog_csv-ref_field = 'PREIS'.
APPEND wa_field_catalog_csv TO ta_field_catalog_csv.

Try this and check whether it works.

Regards,

K.S.

Read only

VenkatRamesh_V
Active Contributor
0 Likes
2,284

Hi Denis,

Try,

    wa_field_catalog_csv-fieldname = 'VKORG'.
    wa_field_catalog_csv-seltext_m = 'Sales Organization'.    
    APPEND wa_field_catalog_csv TO ta_field_catalog_csv.

 

    CLEAR wa_field_catalog_csv.
   
    wa_field_catalog_csv-fieldname = 'MATNR'.
    wa_field_catalog_csv-seltext_m = 'Material'.
    APPEND wa_field_catalog_csv TO ta_field_catalog_csv.

 

    CLEAR wa_field_catalog_csv.

    wa_field_catalog_csv-fieldname = 'PREIS'.
    wa_field_catalog_csv-seltext_m = 'Proposed Amount'.
    APPEND wa_field_catalog_csv TO ta_field_catalog_csv.



Regards,

Venkat.

Read only

rosenberg_eitan
Active Contributor
0 Likes
2,285

Hi,

If you can try to use cl_salv_table .(No need for field catalog)

See http://wiki.scn.sap.com/wiki/display/Snippets/displaying+icons+in+alv+using+class+cl_salv_table or demo program that use this class .

- To use CL_GUI_ALV_GRID look at demo program in package SLIS.

- Use this search in google: site:help.sap.com  CL_GUI_ALV_GRID

- Get the book 

See chapter "Building Field Catalog Manually"

CLEAR ls_fcat .

ls_fcat-fieldname = 'CONNID' .

ls_fcat-ref_table = 'SFLIGHT' .

ls_fcat-ref_field = 'CONNID' .

APPEND ls_fcat to pt_fieldcat .

Regards.

Read only

Former Member
0 Likes
2,284

Hi Denis,

Also add  col_pos and ref_tabname in field catalog internal table.

wa_field_catalog_csv-col_pos = 1

wa_field_catalog_csv-fieldname = 'VKORG'.

wa_field_catalog_csv-ref_tabname = 'VBAK'.

"wa_field_catalog_csv-edit = abap_true.

APPEND wa_field_catalog_csv TO ta_field_catalog_csv.



Please Change and check.