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

Runtime error on Toolbar click in set_table_for_first_display

Former Member
0 Likes
505

<b>I am using OOP in my report.

The report will display an internal table which I build using selection criteria. The internal table is NOT an extract of ONE table but is composed of several tables.

I am getting a Runtime error after I click Print, Views ->Print Preview and Export-> Local file buttons. The error is "OBJECTS_NOT_CHARLIKE".</b>

<u> <b> First I define my Internal table this way:</b></u>

* Types declaration
TYPES: BEGIN OF it_ln,
        banfn  LIKE eban-banfn,
        bnfpo  LIKE eban-bnfpo,
        menge  LIKE eban-menge,
        preis  LIKE eban-preis,
        totval LIKE eban-menge,
        udate  LIKE cdhdr-udate,
        txz01  LIKE eban-txz01,
END OF it_ln.

* Data
DATA: BEGIN OF it_ln,
        banfn  LIKE eban-banfn,
        bnfpo  LIKE eban-bnfpo,
        menge  LIKE eban-menge,
        preis  LIKE eban-preis,
        totval LIKE eban-menge,
        udate  LIKE cdhdr-udate,
        txz01  LIKE eban-txz01,
END OF it_ln.

* Internal table declaration
DATA: it TYPE STANDARD TABLE OF it_ln.  " Int Table w/out header line

* Fieldcatalog declaration
      I_fld     TYPE lvc_t_fcat.

<u> <b> Then I build fieldcatalog:</b></u>

*----------------------------------------------------------------------*
*  Build Fieldcatalog.
*----------------------------------------------------------------------*
FORM fieldcat_init.
  gs_layout-zebra = 'X'.
  gs_layout-cwidth_opt = 'X'.

  wa_fld-fieldname   = 'BANFN'.
  wa_fld-ref_table   = 'IT'.
  wa_fld-coltext = 'Req Number'.
  APPEND WA_FLD TO I_FLD.

  wa_fld-fieldname   = 'BNFPO'.
  wa_fld-ref_table   = 'IT'.
  wa_fld-coltext = 'Item Number'.
  APPEND WA_FLD TO I_FLD.

  wa_fld-fieldname   = 'MENGE'.
  wa_fld-ref_table   = 'IT'.
  wa_fld-coltext     = 'Quantity'.
  APPEND WA_FLD TO I_FLD.

  wa_fld-fieldname   = 'PREIS'.
  wa_fld-ref_table   = 'IT'.
  wa_fld-coltext     = 'Price'.
  APPEND WA_FLD TO I_FLD.

  wa_fld-fieldname   = 'TOTVAL'.
  wa_fld-ref_table   = 'IT'.
  wa_fld-coltext     = 'Total Value'.
  APPEND WA_FLD TO I_FLD.

  wa_fld-fieldname   = 'UDATE'.
  wa_fld-ref_table   = 'IT'.
  wa_fld-coltext     = 'Date Approved'.
  APPEND WA_FLD TO I_FLD.

  wa_fld-fieldname   = 'TXZ01'.
  wa_fld-ref_table   = 'IT'.
  wa_fld-coltext     = 'Description'.
  APPEND WA_FLD TO I_FLD.

ENDFORM.                " fieldcat_init

<u> <b>After that I call set_table_for_first_display:</b></u>

  CALL  METHOD grid1->set_table_for_first_display
         EXPORTING i_structure_name = 'IT'
                   is_layout        = gs_layout
                   is_print         = gs_print
         CHANGING  it_outtab        = it[]
                   IT_FIELDCATALOG  = I_FLD[].

<b>If I change the call to use an existing table - then no error happens and all toolbar buttons work just fine:</b>

<u> <b> I build fieldcatalog:</b></u>

*----------------------------------------------------------------------*
* FORM fieldcat_init_flight.
*----------------------------------------------------------------------*

FORM fieldcat_init_flight.
  gs_layout-zebra = 'X'.
  gs_layout-cwidth_opt = 'X'.

  wa_fld-fieldname   = 'CARRID'.
  wa_fld-ref_table   = 'SFLIGHT'.
  wa_fld-coltext = 'Carrier'.
  APPEND WA_FLD TO I_FLD.

  wa_fld-fieldname   = 'CONNID'.
  wa_fld-ref_table   = 'SFLIGHT'.
  wa_fld-coltext = 'Connection'.
  APPEND WA_FLD TO I_FLD.

  wa_fld-fieldname   = 'FLDATE'.
  wa_fld-ref_table   = 'SFLIGHT'.
  wa_fld-coltext = 'Date'.
  APPEND WA_FLD TO I_FLD.

  wa_fld-fieldname   = 'PRICE'.
  wa_fld-ref_table   = 'SFLIGHT'.
  wa_fld-coltext = 'Price'.
  APPEND WA_FLD TO I_FLD.

<u> <b> Then I call set_table_for_first_display:</b></u>

   CALL METHOD GRID1->SET_TABLE_FOR_FIRST_DISPLAY
         EXPORTING I_STRUCTURE_NAME = 'SFLIGHT'
                   IS_PRINT         = GS_PRINT
                   IS_LAYOUT        = GS_LAYOUT
         CHANGING  IT_OUTTAB        = GT_SFLIGHT
                   IT_FIELDCATALOG  = I_FLD[].

<b>Please help!

Thank you in advance</b>

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
448

hi

good

i would suggest you to debug the program and check whether there is any variable which should not be declare as character.

thanks

mrutyun^

3 REPLIES 3
Read only

uwe_schieferstein
Active Contributor
0 Likes
448

Hello Tatyana

Most likely the <i>Print-Preview</i> fails due to missing technical information in the fieldcatalog. Instead of building the fieldcatalog manually I would prefer to use the <b>function module</b> in the following way:

  REFRESH: gt_fcat.
  CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
    EXPORTING
      i_structure_name             = 'CDHDR'
*     I_CLIENT_NEVER_DISPLAY       = 'X'
    CHANGING
      ct_fieldcat                  = gt_fcat
    EXCEPTIONS
      inconsistent_interface       = 1
      program_error                = 2
      OTHERS                       = 3.
  IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.

  DELETE gt_fcat WHERE ( fieldname ne 'UDATE' ).


  REFRESH: gt_fcat.
  CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
    EXPORTING
      i_structure_name             = 'EBAN'
*     I_CLIENT_NEVER_DISPLAY       = 'X'
    CHANGING
      ct_fieldcat                  = gt_fcat
    EXCEPTIONS
      inconsistent_interface       = 1
      program_error                = 2
      OTHERS                       = 3.
  IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.  

  DELETE gt_fcat WHERE ( ref_table = 'EBAN' )
                          AND      ( fieldname ne 'BANFN'    AND
                                        fieldname ne 'BNFPO'    AND
                                        ... ).

" Finally, rearrange the fields if necessary
  READ TABLE gt_fcat INTO ls_fcat
            WITH KEY fieldname = 'UDATE'.
  IF ( syst-subrc = 0 ).
    DELETE gt_fcat INDEX syst-tabix.

   INSERT ls_fcat INTO gt_fcat INDEX 6.
  ENDIF.

" Renumbering of the columns
  LOOP AT gt_fcat INTO ls_fcat.
    ls_fcat-col_pos = syst-tabix.
    MODIFY gt_fcat FROM ls_fcat INDEX syst-tabix.
  ENDLOOP.

Regards

Uwe

Read only

Former Member
0 Likes
449

hi

good

i would suggest you to debug the program and check whether there is any variable which should not be declare as character.

thanks

mrutyun^

Read only

Former Member
0 Likes
448

Uwe and Mrutyunjaya, thank you very much!

You helped me both.

Here is what I came up with.

<b>#1.</b>

Prior to calling method 'SET_TABLE_FOR_FIRST_DISPLAY' the table catalog has to be built if the table is not defined in the data dictionary.

Obviously my internal table is NOT in the data dictionary.

My internal table IT is made of structure IT_LN.

The structure IT_LN contains fields MENGE, PREIS and TOTVAL which are not CHAR, NUMC or DATE.

After "try and see" I noticed that after I remove those fields from the table - then clicking Print, Print Preview and Local file buttons doesn't cause the program to blow up and everything is just fine.

So Print, Print Preview and Local file don't like NOT character fields when the catalog is NOT a default (meaning that you build the catalog yourself).

<b>#2.</b>

Function 'FIELDCATALOG_MERGE' is worth to use when the grid column headers comes from the data dictionary fields. Correct me if I am wrong here.

<b>Note:</b>

Is there a documentation on CHARLIKE restriction? How to find names of the functions performing Print, Print Preview and Local file so I could to look up?

Thank you,

Tatyana.