Skip to Content
1

'REUSE_ALV_GRID_DISPLAY_LVC' – No field catalog

Dec 29, 2016 at 09:09 PM

261

avatar image

(Please bear with me – absolute newbie regarding SAP)

Hi All,

I am trying to convert a program from REUSE_ALV_GRID_DISPLAY to REUSE_ALV_GRID_DISPLAY_LVC , but keep getting a "NO_FIELDCATALOG_AVAILABLE"
error.

My program's most relevant lines are as follow:

TYPES :
  BEGIN OF gty_s_alv,
  n1, n2, etc
END OF gty_s_alv.

DATA: gt_alv  TYPE TABLE OF gty_s_alv WITH HEADER LINE,   
DATA: mt_fieldcat TYPE lvc_t_fcat.

  PERFORM get_data. "load data into gt_alv
  PERFORM build_fieldcat.
  PERFORM list_display.

*----------------------------------------------------
FORM BUILD_FIELDCAT.
  CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
  EXPORTING
     i_structure_name  = 'GTY_S_ALV'
  CHANGING
     ct_fieldcat       = mt_fieldcat
  EXCEPTIONS
     inconsistent_interface  = 1
     program_error  = 2
     OTHERS  = 3.
ENDFORM.
*----------------------------------------------------
FORM list_display .
  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
  EXPORTING
     i_structure_name = 'GTY_S_ALV'
     i_grid_title     = 'Program_Title'(001)
     it_fieldcat_lvc  = mt_fieldcat
  TABLES
     t_outtab  = gt_alv
  EXCEPTIONS
     program_error  = 1
     OTHERS         = 2.


  IF sy-subrc <> 0.
  MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
  WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.
ENDFORM.  " list_display

I keep getting a "No field catalog" exception (dump). Any ideas?

Thanks in advance,

Luis Rodriguez

10 |10000 characters needed characters left characters exceeded

"I am trying to convert a program from REUSE_ALV_GRID_DISPLAY to REUSE_ALV_GRID_DISPLAY_LVC"

You should rather be trying to use the ALV OO-Model :)

1

Suhas,

I'm sure you are right. Nevertheless, this is an old system (with some quite old programs) and I thought that converting to the "LVC" version would imply less change in the code of existing programs.

Thanks for your comment, appreciate it.

Regards,

Luis

0
* Please Login or Register to Answer, Follow or Comment.

4 Answers

Best Answer
Fabian Lupa Dec 30, 2016 at 02:28 PM
1

The parameter i_structure_name takes the name of a dictionary table, view or structure as an actual parameter. Your structure gty_s_alv is defined globally in your program but not in the data dictionary.

You have the following options:

  • Define your gty_s_alv structure as a global structure in the data dictionary (SE11). If you do not want to change the field catalog you should be able to call REUSE_ALV_GRID_DISPLAY_LVC directly providing the parameter i_structure_name there and not supplying it_fieldcat_lvc.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
      EXPORTING
         i_structure_name = 'YOUR_GLOBAL_DDIC_STRUCTURE'
         i_grid_title     = 'Program_Title'(001)
      TABLES
         t_outtab         = gt_alv
      EXCEPTIONS
         program_error    = 1
         OTHERS           = 2.
  • Build your field catalog "by hand" and supply it to it_fieldcat_lvc.
  • Use a different function module or one of the class based alv approaches that can handle "local" type definitions.
Share
10 |10000 characters needed characters left characters exceeded
Sandra Rossi Dec 29, 2016 at 11:02 PM
0

You should use the debugger to make sure what happens. For instance, does LVC_FIELDCATALOG_MERGE return a field catalog?

Share
10 |10000 characters needed characters left characters exceeded
Luis Rodriguez Dec 30, 2016 at 01:48 PM
0

Sandra,

Thanks for your post. According to the debugger, mt_fieldcat is empty. That much I know. What I don't really get is WHY it is empty. I seem to be doing everything according to the examples I have seen on the web (I think :-) ) . The only thing I'm not sure about is the fact that my internal table (GT_ALV) has a header line. Could this be a factor?

Thanks again,

Luis

Share
10 |10000 characters needed characters left characters exceeded
Luis Rodriguez Dec 30, 2016 at 03:14 PM
0

Fabian,

Thanks for your answer.

Let's say I would prefer not to create a new structure with SE11. In that case, you state that I "...should be able to call REUSE_ALV_GRID_DISPLAY_LVC directly providing the parameter i_structure_name there and not supplying it_fieldcat_lvc." Could you please enlighten me about how to do this?

Thanks again,

Luis

Show 5 Share
10 |10000 characters needed characters left characters exceeded

If you do not want to create a DDIC structure the function modules you use (REUSE_ALV_GRID_DISPLAY(_LVC) and LVC_FIELDCATALOG_MERGE) cannot build the field catalog for you (as far as I am aware).

There is a really old function module which can generate a field catalog from your internal table by scanning the source code. I would strongly recommend not using it though (it causes your application to dump if there are more than 80 characters in a line of code...). And also I doubt it will use the LVC format.

The easiest solution nowadays is to use the SALV classes, either for your whole ALV or, if you are not comfortable with that API, just for getting your field catalog.

For the "I only want the field catalog" solution this would be an approach:

DATA: gt_alv TYPE TABLE OF gty_s_alv WITH HEADER LINE.
DATA: mt_fieldcat TYPE lvc_t_fcat.

cl_salv_table=>factory(
  IMPORTING
    r_salv_table   = DATA(go_alv)
  CHANGING
    t_table        = gt_alv[]
).
mt_fieldcat = cl_salv_controller_metadata=>get_lvc_fieldcatalog(
                  r_columns      = go_alv->get_columns( )
                  r_aggregations = go_alv->get_aggregations( )
              ).
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
  EXPORTING
    i_grid_title     = 'Program_Title'(001)
    it_fieldcat_lvc  = mt_fieldcat
  TABLES
    t_outtab         = gt_alv
  EXCEPTIONS
    program_error    = 1
    OTHERS           = 2.

And the OO one by the way would literally be just this:

cl_salv_table=>factory(
  IMPORTING
    r_salv_table   = DATA(go_alv)
  CHANGING
    t_table        = gt_alv[]
).
go_alv->display( ).
1

Fabian,

Thanks. I think that (the "I only want the field catalog" code ) would be best way to do it. As I commented elsewhere in this thread, I'm just trying to change (update?) some old programs and, in the process, learn some new things myself.

Thanks again,

Luis

0

Fabian,

Just two quick questions, if I may:

1) When you wrote go_alv, I suppose that is a typo (you meant GT_alv, right)?

2) I keep getting an error indicating that "DATA" is unknown. Could it be a release issue (as I wrote in a prior post, this is an OLD system).

Thanks again and last, but no least, let me wish you (and yours) a very Happy New Year.

Regards,

Luis

0

Oh the DATA(go_alv) is not a typo but a 7.40 inline declaration. Without it it should look like this:

DATA: go_alv TYPE REF TO cl_salv_table.
cl_salv_table=>factory(
  IMPORTING
    r_salv_table   = go_alv
  CHANGING
    t_table        = gt_alv[]
).
1

Thanks.

I will be signing off for the weekend in about an hour (and I suppose you will be doing that soon, if not already have) but, as a last point (not really important, I'll dig a little more in this code and continue next year :-) ) I'm getting the following error:

"The field "GET_COLUMNS(" is unknown, but there is a field with the similar name "R_COLUMNS" . . . ."

in this statement:


mt_fieldcat = cl_salv_controller_metadata=>get_lvc_fieldcatalog(
r_columns = go_alv->GET_COLUMNS( )
R_AGGREGATIONS = GO_ALV->GET_AGGREGATIONS( )
).

I can see the method GET_COLUMNS in cl_salv_table, so I don't really know why it appears.

Again, don't worry too much. Thanks for all your help and go celebrate with family and friends...

Best Regards,

Luis

0