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

TRANSFER ITABLE TO FILE

Former Member
0 Likes
862

hi.

I want transfer a internal table to a text file, how i can do it.

Thans.

Message was edited by:

ANDRES MOLDON

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
833

Hi,

Are you downloading to application server?

If you are then please use OPEN DATASET, TRANSFER and CLOSE DATASET statements.

Please check this link for sample code.

http://www.sapdevelopment.co.uk/file/file_downloadsap.htm

Regards,

Ferry Lianto

hi.

I want transfer a internal table to a text file, how i can do it.

Thans.

Message was edited by:

ANDRES MOLDON

6 REPLIES 6
Read only

Former Member
0 Likes
833

Check this sample report.


REPORT ZTESTAA.



TYPE-POOLS:TRUXS.
DATA: BEGIN OF ITAB OCCURS 0,
VBELN
LIKE VBAP-VBELN,
POSNR LIKE VBAP-POSNR,
END OF ITAB.
DATA:
ITAB1 TYPE TRUXS_T_TEXT_DATA.
SELECT VBELN POSNR UP TO
10 ROWS FROM VBAP INTO TABLE ITAB.

*******

CALL FUNCTION
'SAP_CONVERT_TO_CSV_FORMAT'
EXPORTING
I_FIELD_SEPERATOR = ';'
TABLES
I_TAB_SAP_DATA = ITAB
CHANGING
I_TAB_CONVERTED_DATA = ITAB1
EXCEPTIONS
CONVERSION_FAILED = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO WITH SY-MSGV1
SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

***
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
FILENAME = 'C:TEMPtest.txt'
TABLES
DATA_TAB = ITAB1
EXCEPTIONS
OTHERS = 1.

If useful reward.

Vasanth

Read only

Former Member
0 Likes
833

Hi,

Please check this link for sample codes to download internal table to either PC or application server.

http://www.sapdevelopment.co.uk/file/file_updown.htm

Regards,

Ferry Lianto

Read only

Former Member
0 Likes
833

hi Andreas,

Use GUI_DOWNLOAD fm

  DATA: ld_filename TYPE string,
        ld_path TYPE string,
        ld_fullpath TYPE string,
        ld_result TYPE i.

* Display save dialog window
  CALL METHOD cl_gui_frontend_services=>file_save_dialog
    EXPORTING
*      window_title      = ' '
      DEFAULT_EXTENSION = 'XLS'
      default_file_name = 'accountsdata'
      INITIAL_DIRECTORY = 'c:temp'
    CHANGING
      filename          = ld_filename
      path              = ld_path
      fullpath          = ld_fullpath
      user_action       = ld_result.

* Check user did not cancel request
  CHECK ld_result EQ '0'.

  CALL FUNCTION 'GUI_DOWNLOAD'
   EXPORTING
        filename         = ld_fullpath
        filetype         = 'ASC'
*       APPEND           = 'X'
        write_field_separator = 'X'
*       CONFIRM_OVERWRITE = 'X'
   TABLES
        data_tab         = it_datatab[]     "need to declare and populate
   EXCEPTIONS
        file_open_error  = 1
        file_write_error = 2
        OTHERS           = 3.

http://www.sapdevelopment.co.uk/file/file_updownpop.htm

Regards,

Santosh

Read only

Former Member
0 Likes
833

i can't use the function GUI_DOWNLOAD.

Some other.

Thanks.

Read only

0 Likes
833

hi Andreas,

Ferry is Right !!!!!!!!! Use OPEN , TRANSFER AND CLOSE dataset in that case

Regards,

Santosh

Read only

Former Member
0 Likes
834

Hi,

Are you downloading to application server?

If you are then please use OPEN DATASET, TRANSFER and CLOSE DATASET statements.

Please check this link for sample code.

http://www.sapdevelopment.co.uk/file/file_downloadsap.htm

Regards,

Ferry Lianto