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: 

Convert a report output in to txt file

Former Member
0 Kudos

Hi all,

I need to convert the report output into txt file .How can i do that?. can any one post some sample codes.

Regards,

Lisa.

10 REPLIES 10

Former Member
0 Kudos

Hi Lisa,

You always have the option to download the report from the output.

System>List>Save-->Local file

here use Unconverted.

Former Member
0 Kudos

Output screen-->

List>save>unconverted-->path/filename.txt

0 Kudos

Output screen-->

List>save>file>unconverted>path/filename.txt

Former Member
0 Kudos

Hi Lisa,

1. very simple

LIST_TO_TXT

This is one important FM.

2. sample code (just copy paste)

REPORT abc.

DATA : BEGIN OF itab OCCURS 0,

l(100) TYPE c,

END OF itab.

WRITE 😕 'am'.

CALL FUNCTION 'LIST_TO_TXT'

EXPORTING

LIST_INDEX = 0

TABLES

listtxt = itab

  • LISTOBJECT =

EXCEPTIONS

EMPTY_LIST = 1

LIST_INDEX_INVALID = 2

OTHERS = 3

.

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

  • BIN_FILESIZE =

filename = 'd:\abc.txt'

  • FILETYPE = 'ASC'

  • APPEND = ' '

  • WRITE_FIELD_SEPARATOR = ' '

  • HEADER = '00'

  • TRUNC_TRAILING_BLANKS = ' '

  • WRITE_LF = 'X'

  • COL_SELECT = ' '

  • COL_SELECT_MASK = ' '

  • DAT_MODE = ' '

  • CONFIRM_OVERWRITE = ' '

  • NO_AUTH_CHECK = ' '

  • CODEPAGE = ' '

  • IGNORE_CERR = ABAP_TRUE

  • REPLACEMENT = '#'

  • WRITE_BOM = ' '

  • TRUNC_TRAILING_BLANKS_EOL = 'X'

  • WK1_N_FORMAT = ' '

  • WK1_N_SIZE = ' '

  • WK1_T_FORMAT = ' '

  • WK1_T_SIZE = ' '

  • IMPORTING

  • FILELENGTH =

tables

data_tab = itab

  • FIELDNAMES =

  • 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 <> 0.

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

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

ENDIF.

break-point.

regards,

amit m.

Former Member
0 Kudos

Hi,

After report is executed use the following link

list->save->file

or

use pass your final internal table

to FM <b>GUI_DOWNLOAD in program.</b>

Regards

Amole

Former Member
0 Kudos

Hello,

From your output you can allways dowload the output to a text file trought System->List->Save->Local File (Unconverted) or if want to do it from the program itself you may have your list output on an internal table and call function do dowload it to local file.

Dunno if that was what you wanted ... hope i helped

Mário

0 Kudos

Hi all,

My questions was not clear before. I understood by seeing your replies.My requirement is download out put from the program directly.

Regards,

Lisa

0 Kudos

Hi again,

1. did u try my code

2. It does exactly how u want.

3. First the report is written thru WRITE statements.

4. Then the LIST Fm

Fetches the list into internal table.

5. The gui_download, downloads this internal table to text file !

regards,

amit m.

0 Kudos

You can use the FM LIST_TO_ASCI also.

0 Kudos

Directly from the same program, you can do something like this.




report zrich_0003 .

data: list like abaplist occurs 0 with header line.
data: begin of listout occurs 0,
      line(1024) type c,
      end of listout.

do 100 times.

  write:/ sy-index.

enddo.


call function 'SAVE_LIST'
* EXPORTING
*   LIST_INDEX               = '0'
  tables
    listobject               = list
 exceptions
   list_index_invalid       = 1
   others                   = 2
          .

call function 'LIST_TO_ASCI'
     tables
          listobject         = list
          listasci           = listout
     exceptions
          empty_list         = 1
          list_index_invalid = 2
          others             = 3.


call function 'GUI_DOWNLOAD'
     exporting
          filename = 'C:Test.txt'
     tables
          data_tab = listout.

Regards,

Rich Heilman