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: 

Structure of Dynamic Table in Function Module

former_member212005
Active Contributor
0 Kudos

Hi,

I'm trying to find a way to get as OUTPUT a dynamic Table from a Function Module.

I declared a table called T_DATA without a type.

And this table should have a dynamic table back.

The problem that I get the data back but, I only found a data without any field-elements.

The data is there but there's no structure, no table.

Is there any way that I can send the Data in a proper structure?

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi

Probably this'll help you:

[url]https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/f50dcd4e-0501-0010-3596-b686a7b51492

Cheers

Ravish

3 REPLIES 3

Former Member
0 Kudos

Hi

Try using the following code

type-pools:slis.

data:it_fcat type lvc_t_fcat,

wa_fcat type lvc_s_fcat,

itab type ref to data.

data:it_fcat1 type slis_t_fieldcat_alv,

wa_fcat1 like line of it_fcat1.

data:cl_tab type ref to cl_alv_table_create,

wa_ref type ref to data.

field-symbols:<itab> type table,

<wa> type any,

<comp>.

create object cl_tab.

refresh:it_fcat.

wa_fcat-fieldname = 'NAME'.

wa_fcat-inttype = 'C'.

wa_fcat-intlen = '10'.

wa_fcat1-fieldname = 'NAME'.

wa_fcat1-inttype = 'C'.

wa_fcat1-intlen = '10'.

append wa_fcat to it_fcat.

append wa_fcat1 to it_fcat1.

wa_fcat-fieldname = 'NAME2'.

wa_fcat-datatype = 'CHAR10'.

wa_fcat1-fieldname = 'NAME2'.

wa_fcat1-datatype = 'CHAR10'.

append wa_fcat to it_fcat.

append wa_fcat1 to it_fcat1.

cl_alv_table_create=>create_dynamic_table(

exporting

  • I_STYLE_TABLE = I_STYLE_TABLE

it_fieldcatalog = it_fcat

  • I_LENGTH_IN_BYTE = I_LENGTH_IN_BYTE

importing

ep_table = itab

  • E_STYLE_FNAME = E_STYLE_FNAME

  • EXCEPTIONS

  • GENERATE_SUBPOOL_DIR_FULL = 1

).

if sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

endif.

assign itab->* to <itab>.

create data wa_ref like line of <itab>.

assign wa_ref->* to <wa>.

do.

assign component 'NAME' of structure <wa> to <comp>.

<comp> = 'AA'.

unassign <comp>.

assign component 'NAME2' of structure <wa> to <comp>.

<comp> = 'AB'.

insert <wa> into table <itab>.

exit.

enddo.

call function 'REUSE_ALV_GRID_DISPLAY'

exporting

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER = ' '

  • I_BUFFER_ACTIVE = ' '

i_callback_program = sy-repid

  • I_CALLBACK_PF_STATUS_SET = ' '

  • I_CALLBACK_USER_COMMAND = ' '

  • I_CALLBACK_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_END_OF_LIST = ' '

  • I_STRUCTURE_NAME = I_STRUCTURE_NAME

  • I_BACKGROUND_ID = ' '

  • I_GRID_TITLE = I_GRID_TITLE

  • I_GRID_SETTINGS = I_GRID_SETTINGS

  • IS_LAYOUT = IS_LAYOUT

it_fieldcat = it_fcat1

  • IT_EXCLUDING = IT_EXCLUDING

  • IT_SPECIAL_GROUPS = IT_SPECIAL_GROUPS

  • IT_SORT = IT_SORT

  • IT_FILTER = IT_FILTER

  • IS_SEL_HIDE = IS_SEL_HIDE

  • I_DEFAULT = 'X'

  • I_SAVE = ' '

  • IS_VARIANT = IS_VARIANT

  • IT_EVENTS = IT_EVENTS

  • IT_EVENT_EXIT = IT_EVENT_EXIT

  • IS_PRINT = IS_PRINT

  • IS_REPREP_ID = IS_REPREP_ID

  • I_SCREEN_START_COLUMN = 0

  • I_SCREEN_START_LINE = 0

  • I_SCREEN_END_COLUMN = 0

  • I_SCREEN_END_LINE = 0

  • I_HTML_HEIGHT_TOP = 0

  • I_HTML_HEIGHT_END = 0

  • IT_ALV_GRAPHICS = IT_ALV_GRAPHICS

  • IT_HYPERLINK = IT_HYPERLINK

  • IT_ADD_FIELDCAT = IT_ADD_FIELDCAT

  • IT_EXCEPT_QINFO = IT_EXCEPT_QINFO

  • IR_SALV_FULLSCREEN_ADAPTER = IR_SALV_FULLSCREEN_ADAPTER

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER = E_EXIT_CAUSED_BY_CALLER

  • ES_EXIT_CAUSED_BY_USER = ES_EXIT_CAUSED_BY_USER

tables

t_outtab = <itab>

  • EXCEPTIONS

  • PROGRAM_ERROR = 1

.

Regards

Former Member
0 Kudos

Hi

Probably this'll help you:

[url]https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/f50dcd4e-0501-0010-3596-b686a7b51492

Cheers

Ravish

0 Kudos

Thanks Ravish, This is what I was looking for...