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

Dynamic Structure Creation

Former Member
0 Likes
430

Hello Expert,

My requirement is like i have a selection screen where user can put any database table name and once he execute then all the records whatever stored in the table can download in a .TXT file.

I am trying this by using field symbol but i stuck in between , i can fetch the data and put into a WA but how can i pass those data to a internal table . For your reference here is my code.

types:ty_record type string.

data: my_table type REF TO data.

data: rt_date type REF TO data.

data: rt_date1 type REF TO data.

data: w_record type string.

data: t_file type TABLE OF ty_record.

FIELD-SYMBOLS: <WA> type ANY,

<WA2> type ANY TABLE,

<WA1> type any,

<WA3> type any

.

selection-screen begin of block b1.

PARAMETERS:

s_table(10).

SELECTION-SCREEN END OF BLOCK b1.

START-OF-SELECTION.

CREATE DATA my_table type (s_table) .

ASSIGN my_table->* to <WA>.

*

CREATE DATA rt_date type (s_table).

ASSIGN rt_date->* to <WA1>.

SELECT * from (s_table) into <WA>.

move <WA> to <WA1>.

ENDSELECT.

Thanks,

Satya

1 ACCEPTED SOLUTION
Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
401

Hello,

I think this is the way you should proceed:


DATA: s_table TYPE tabname VALUE 'T001'.

DATA: lt_tmp TYPE REF TO data.

FIELD-SYMBOLS: <lt_tmp> TYPE STANDARD TABLE.

CREATE DATA lt_tmp TYPE STANDARD TABLE OF (s_table).
ASSIGN lt_tmp->* TO <lt_tmp> .

SELECT * FROM (s_table) INTO TABLE <lt_tmp>.
IF sy-subrc = 0.
  CALL FUNCTION 'GUI_DOWNLOAD'
    EXPORTING
      filename                = 'C:\Documents and Settings\ssaha\Desktop\dyntab.txt'
    TABLES
      data_tab                = <lt_tmp>
    EXCEPTIONS
      file_write_error        = 1
      no_batch                = 2
      gui_refuse_filetransfer = 3
      invalid_type            = 4
      no_authority            = 5
      unknown_error           = 6
      header_not_allowed      = 7
      separator_not_allowed   = 8
      filesize_not_allowed    = 9
      header_too_long         = 10
      dp_error_create         = 11
      dp_error_send           = 12
      dp_error_write          = 13
      unknown_dp_error        = 14
      access_denied           = 15
      dp_out_of_memory        = 16
      disk_full               = 17
      dp_timeout              = 18
      file_not_found          = 19
      dataprovider_exception  = 20
      control_flush_error     = 21
      OTHERS                  = 22.
  IF sy-subrc NE 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.

ENDIF.

Now you have data in the dyn table <lt_tmp>.

BR,

Suhas

2 REPLIES 2
Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
402

Hello,

I think this is the way you should proceed:


DATA: s_table TYPE tabname VALUE 'T001'.

DATA: lt_tmp TYPE REF TO data.

FIELD-SYMBOLS: <lt_tmp> TYPE STANDARD TABLE.

CREATE DATA lt_tmp TYPE STANDARD TABLE OF (s_table).
ASSIGN lt_tmp->* TO <lt_tmp> .

SELECT * FROM (s_table) INTO TABLE <lt_tmp>.
IF sy-subrc = 0.
  CALL FUNCTION 'GUI_DOWNLOAD'
    EXPORTING
      filename                = 'C:\Documents and Settings\ssaha\Desktop\dyntab.txt'
    TABLES
      data_tab                = <lt_tmp>
    EXCEPTIONS
      file_write_error        = 1
      no_batch                = 2
      gui_refuse_filetransfer = 3
      invalid_type            = 4
      no_authority            = 5
      unknown_error           = 6
      header_not_allowed      = 7
      separator_not_allowed   = 8
      filesize_not_allowed    = 9
      header_too_long         = 10
      dp_error_create         = 11
      dp_error_send           = 12
      dp_error_write          = 13
      unknown_dp_error        = 14
      access_denied           = 15
      dp_out_of_memory        = 16
      disk_full               = 17
      dp_timeout              = 18
      file_not_found          = 19
      dataprovider_exception  = 20
      control_flush_error     = 21
      OTHERS                  = 22.
  IF sy-subrc NE 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.

ENDIF.

Now you have data in the dyn table <lt_tmp>.

BR,

Suhas

Read only

Former Member
0 Likes
401

Thanks Suhas..now i am getting the value.

Thanks,

Satya