Application Development 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: 

How to pass field symbol of type table to subroutine

Former Member
0 Kudos

Hello Experts,

Got stuck when passing field symbol of type table to subroutines.

Here is my code..

FIELD-SYMBOLS: <dyn_table> TYPE STANDARD TABLE.

perform fill_table using <dyn_table>.

form fill_table using f_dyn_table.

field-symbols : <fs_dyn_tab>.

DATA tabDREF TYPE REF TO DATA.

CREATE DATA tabdref TYPE table OF (f_dyn_table).

ASSIGN tabDREF->* TO <fs_dyn_tab>.

endform. " fill_table

When I try to execute this code I am getting a dump which says

'The current statement(CREATE DATA tabdref ..... ) requires a character-type data object.'

Many Thanks

1 ACCEPTED SOLUTION

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

I don't see where you are assign to the field symbol <dyn_table>.

Regards,

Rich Heilman

5 REPLIES 5

Former Member
0 Kudos

Please find the solution here,

Regards

Kathirvel

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

I don't see where you are assign to the field symbol <dyn_table>.

Regards,

Rich Heilman

0 Kudos

Hello Rich,

I am creating dynamic Internal table .

  • Create dynamic internal table and assign to FS

CALL METHOD cl_alv_table_create=>create_dynamic_table

EXPORTING

it_fieldcatalog = it_fldcat

IMPORTING

ep_table = new_table.

ASSIGN new_table->* TO <dyn_table>.

  • Create dynamic work area and assign to FS

CREATE DATA new_line LIKE LINE OF <dyn_table>.

ASSIGN new_line->* TO <dyn_wa>.

Many Thanks

0 Kudos

Yes, but I think that you may need to assign the field symbol, before using it in the PERFORM statement.

FIELD-SYMBOLS: <dyn_table> TYPE STANDARD TABLE.

**  ASSIGN HERE

perform fill_table using <dyn_table>.

Regards,

Rich Heilman

raja_thangamani
Active Contributor
0 Kudos

Hi,

Refer this code..

***** Creating Internal Table at Run time*******

DATA: LINETYPE  TYPE REF TO CL_ABAP_STRUCTDESCR,
      TABLETYPE TYPE REF TO CL_ABAP_TABLEDESCR,
      KEY       TYPE ABAP_KEYDESCR_TAB.

FIELD-SYMBOLS: <TABLE> TYPE ANY TABLE.

DATA: DREF TYPE REF TO DATA.

* Get Structure of Some Database Table for example

LINETYPE ?=   CL_ABAP_TYPEDESCR=>DESCRIBE_BY_NAME( 'SPFLI' ).

* Specify Key fields if needed

APPEND 'CARRID' TO KEY.
APPEND 'CONNID' TO KEY.

* Generate Internal table Type Object

TABLETYPE = CL_ABAP_TABLEDESCR=>CREATE(
    P_LINE_TYPE  = LINETYPE
    P_TABLE_KIND = CL_ABAP_TABLEDESCR=>TABLEKIND_SORTED
    P_UNIQUE     = ABAP_TRUE
    P_KEY        = KEY ).

* Create a data object of a specific type using a type object

CREATE DATA DREF TYPE HANDLE TABLETYPE.

ASSIGN DREF->* TO <TABLE>.

perform fill_table using <table>.


form fill_table using f_dyn_table type table.
endform

Raja T