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

Unknown table type in function module

Former Member
0 Likes
1,635

Hello,

i try to create a function module, which has one internal table as a result table. The structure is unknown during design time, because the table has the structure like a range table, therefor the fieldtype of the 'low and high' values, depends on the declaration of the calling programm, and is not knowing in the function module during design time.

The function module load the results of a DDIC-Customizingtable and shell fill the sign, option, low and high field of the result table.

Is there anybody with an idea how to solve this.

Thanks in advance

Michael

1 ACCEPTED SOLUTION
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
1,168

Yes, don't enter any type when defining the tables parameter. It will allow you to do this.

Regards,

Rich Heilman

8 REPLIES 8
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
1,169

Yes, don't enter any type when defining the tables parameter. It will allow you to do this.

Regards,

Rich Heilman

Read only

0 Likes
1,168

Thanks,

but this don't work, because you can't fill the fields of the internal table without knowing his fieldname. If i define the table as 'any table', no assignment ist possible, because the table has no structure and therefor no field you can assign to.

Read only

0 Likes
1,168

For example..... here is a program which calls the function module. Notice that ITAB in the TABLES section is not defined.

Program Code.



report zrich_0002.


ranges: r_datum for sy-datum.


call function 'Z_TEST'
     tables
          itab = r_datum.


check sy-subrc  = 0.

Function Module Code.



function z_test.
*"----------------------------------------------------------------------
*"*"Local interface:
*"  TABLES
*"      ITAB
*"----------------------------------------------------------------------

* Fill with data
  itab = 'IBT2006010399991231'.
  append itab.


endfunction.

Regards,

Rich HEilman

Read only

0 Likes
1,168

Hi Michael,

Please try Table type "STANDARD TABLE". This will take the dynamic table structure.

May be this will work for you.

Lanka

Read only

0 Likes
1,168

Also, if you know that it will always be a range table, you can access the fields like this in the function module.



function z_test.
*"----------------------------------------------------------------------
*"*"Local interface:
*"  TABLES
*"      ITAB
*"----------------------------------------------------------------------

  field-symbols: <fs>.

  assign component 1 of structure itab to <fs>.
  <fs> = 'I'.

  assign component 2 of structure itab to <fs>.
  <fs> = 'BT'.

  assign component 3 of structure itab to <fs>.
  <fs> = '20060103'.

  assign component 4 of structure itab to <fs>.
  <fs> = '99991231'.

  append itab.


endfunction.


Regards,

Rich HEilman

Read only

0 Likes
1,168

Thank you very much.

I thought to complicated.

I tried abap class cl_abap_typedescr and field_symbols

Yes thats it !! very easy and working.

Michael

Read only

0 Likes
1,168

Cool. Glad that it worked out for ya.

Regards,

Rich Heilman

Read only

0 Likes
1,168

Cool. Glad that it worked out for ya.

Regards,

Rich Heilman