Skip to Content

Smartforms - Form Interface - Syntax Error - REF TO

G'day guys,

I'm trying to add an object - CL_SALV_TABLE to the FORM Interface of my smartform and I get a Syntax error:

"You can only refer to object type CL_SALV_TABLE using "REF TO"."

I have added GRF_ALV_TAB TYPE REF TO CL_SALV_TABLE in the Form interface successfully.

This error is being output when I try and Test the Smartform, the syntax error is in the generated Function module.

Has anyone successfully added an object reference in their smartforms?

Am I doing something wrong?

Thanks,

Cheers,

Mick.

Edited by: Mick Pichaloff on Sep 8, 2009 1:51 PM

Add a comment
10|10000 characters needed characters exceeded

Related questions

3 Answers

  • Best Answer
    Posted on Sep 10, 2009 at 05:05 AM

    I solved this issue myself.

    SOLUTION:

    In the Form Interface of the smartform, add an import parameter without giving it a Type Assignment and Associated type, just a parameter name, e.g Parameter Name = GRF_SALV_TABLE.

    In the Global Definitions -> Initialization tab and add the following code, remember to include GRF_SALV_TABLE in the Input Parameters section in this tab:

    DATA: lrf_alv   TYPE REF TO cl_salv_table.
    DATA: lrf_cols  TYPE REF TO cl_salv_columns_table.
    
    FIELD-SYMBOLS:
       <fs_alv>    TYPE ANY.
    
    TRY .
        ASSIGN grf_salv_table TO <fs_alv>.
    
      CATCH cx_sy_assign_cast_illegal_cast
            cx_sy_assign_cast_unknown_type
            cx_sy_assign_out_of_range .
        MESSAGE 'Cannot assign ALV object'
           TYPE 'E'.
    ENDTRY.
    
    TRY .
        lrf_alv ?= <fs_alv>.
      CATCH cx_sy_move_cast_error
            cx_sy_dyn_call_illegal_method.
        MESSAGE 'Cannot cast to appropriate object reference'
           TYPE 'E'.
    ENDTRY.
    
    * execute "get_columns" method of the referenced class
    lrf_cols = lrf_alv->get_columns( ).
    

    hope this helps.

    Cheers,

    Mick.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 09, 2009 at 06:36 AM

    same table you need to pass in print program aslo, in FM

    CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'

    EXPORTING formname = lf_formname

    IMPORTING fm_name = lf_fm_name

    EXCEPTIONS no_form = 1

    no_function_module = 2

    OTHERS = 3.

    CALL FUNCTION lf_fm_name

    tables aslo....

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 09, 2009 at 08:05 AM

    Try passing REFERENCE instead of OBJECT while calling your FM for SMARTFORM

    you can get reference of any object by using GET REFERENCE

    Regards,

    Mohaiyuddin

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.