cancel
Showing results for 
Search instead for 
Did you mean: 

Gui_Download

Former Member
0 Kudos

Problem with gui_download

I need to have a file like this input.

A800058000000500001

A800059205000000244

A800059205000000243

With the particularity of no existing spaces after last character in last line ( and cursor dont go to the other line )

But what i have is something like this:

A800058000000500001A800059205000000244A800059205000000243

I use this code:

-


OPEN DATASET file1 IN TEXT MODE ENCODING DEFAULT FOR OUTPUT.

IF sy-subrc = 0.

LOOP AT t_excel_interface.

TRANSFER t_excel_interface TO file1.

ENDLOOP.

ENDIF.

CLOSE DATASET file1.

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

  • BIN_FILESIZE =

filename = file1

filetype = 'BIN'

append = 'X'

  • write_field_separator = 'X'

  • HEADER = '00'

  • trunc_trailing_blanks = 'X'

  • 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'

  • IMPORTING

  • FILELENGTH =

TABLES

data_tab = t_excel_interface

  • 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

-


Regards Vitor Feio

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hello Vitor,

U can fill only the mandatory data in the GUI_DOWNLOAD.

use ascii ie ASC instead of BIN.

Please let me know the result..

Regards,

Tanveer.

Please mark helpful answers.

Former Member
0 Kudos

i already try that solution but the effect was not the expected.

The Objective of my doubt is not to pass the character from this e.g.

A800058000000500001A800059205000000244A800059205000000243

to this

A800058000000500001

A800059205000000244

A800059205000000243

__________________________________________________________

(I found that Specifying 'ASC' will ALWAYS add a CR & LF to the end of each line. That is the ASCII standard.)

What i want to happen is that the file must have this design and in the last line on the last character the cursor stop and dont go to next line (I found that Specifying 'ASC' will ALWAYS add a CR & LF to the end of each line. That is the ASCII standard).

Regards,

Vitor Feio

Answers (4)

Answers (4)

Former Member
0 Kudos

hi ,

GUI Download and GUIupload will upload and download the data in CSV (comma seerated) format,suppose your internal table have 3 columns then those 3 columns will come in one row seperated by comma,then other record will come in next row.

u can use filetype = 'ASC'



CALL FUNCTION 'GUI_DOWNLOAD'
  EXPORTING
*   BIN_FILESIZE                    =
    filename                        = p_file
    FILETYPE                        = 'ASC'
  tables
    data_tab                        = it_ts.

hope this will help in solving ur problem

thanks

tanmaya

Former Member
0 Kudos

Note the date of the original question.

Rob

former_member183924
Active Participant
0 Kudos

Hi Vitor,

I had the same problem like you and found a solution for it.

I didn't hope that your already waiting for a solution since 2006?!

It is also against SWIFT standard to add an CRLF charater at the end of a file...

Just add a new field to your structure (in example it is crlf) and fill it by looping the table with your data that should be exported into a file. You can also fill the CRLF charater (done by attribute cl_abap_char_utilities=>cr_lf to an existing field.

So here is my solution:


TABLES: makt

TYPES: BEGIN OF gs_records,
                matnr TYPE makt-matnr,
                maktx TYPE makt-maktx,
                crlf(2),
             END OF gs_records,
             tt_records TYPE TABLE OF gs_records.
DATA:  gt_records TYPE tt_records
          ,wa_recordsTYPE gs_records.

FIELD-SYMBOLS: <fs_records>.

DATA:  lv_makt_lines   TYPE sytabix
        ,lv_makt_sytabix TYPE sytabix.

SELECT matnr maktx
FROM makt
INTO CORRESPONDING FIELDS OF TABLE gt_records
WHERE matnr = *your favorite material number*


DESCRIBE TABLE gt_records LINES lv_makt_lines.

LOOP AT gt_records ASSIGNING <fs_records>.
  lv_makt_sytabix = sy-tabix.
  

  IF lv_makt_sytabix < lv_makt_lines.
     <fs_records>-crlf = cl_abap_char_utilities=>cr_lf.
  ENDIF.

ENDLOOP.



  CALL METHOD CL_GUI_FRONTEND_SERVICES=>GUI_DOWNLOAD
    EXPORTING
      FILENAME                  = FILENAME
      FILETYPE                  = 'ASC'    "BIN, DBF, WK1, DAT, OTHERS
      APPEND                    = 'X'
*      WRITE_FIELD_SEPARATOR     = SPACE
*      HEADER                    = '00'
      WRITE_LF                  = SPACE
*      TRUNC_TRAILING_BLANKS     = 'X' 
*      TRUNC_TRAILING_BLANKS_EOL = SPACE
*      COL_SELECT                = SPACE
*      COL_SELECT_MASK           = SPACE
*      DAT_MODE                  = SPACE
*      CONFIRM_OVERWRITE         = SPACE
*      NO_AUTH_CHECK             = SPACE
*      CODEPAGE                  = SPACE
*      IGNORE_CERR               = ABAP_TRUE
*      REPLACEMENT               = '#'
*      WRITE_BOM                 = SPACE
    CHANGING
      DATA_TAB                = gt_records[]
    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
      NOT_SUPPORTED_BY_GUI    = 22
      OTHERS                  = 23.

IF sy-subrc <> 0.
  MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

Link: SAP Note: 1015352

regards,

Steffen Fröhlich

Former Member
0 Kudos

Yes In the downloaded text file the cursor is moving till the records exists only.

and all the records are coming in seperate line.

Each row in the the table should end with crlf. ( crlf = cl_abap_char_utilities=>cr_lf . data crlf(2) )

(in my case itab2 has vauelike this)

loop at table.

CONCATENATE v_two 2nd_party_name v_lifnr w_2nd_party_name

v_st_date v_end_date v_temp_days v_amt_f

v_amt_v c_zero INTO i_tab2-rec

SEPARATED BY v_comma.

concatenate i_tab2-rec crlf INTO i_tab-rec.

APPEND i_tab2).

endloop

CALL METHOD CL_GUI_FRONTEND_SERVICES=>GUI_DOWNLOAD

EXPORTING

filename = w_local

filetype = 'ASC'

WRITE_FIELD_SEPARATOR = SPACE

WRITE_LF = SPACE

TRUNC_TRAILING_BLANKS = 'X'

COL_SELECT = SPACE

IGNORE_CERR = 'X'

CHANGING

data_tab = i_tab2[]

EXCEPTIONS

file_write_error = 1.

Edited by: ranjith gupta on Mar 19, 2010 11:54 AM

Edited by: ranjith gupta on Mar 19, 2010 11:55 AM

Edited by: ranjith gupta on Mar 19, 2010 11:56 AM

Former Member
0 Kudos

Hai Vitor

check this code

&----


*& Report ZTEST_SDN1 *

*& *

&----


*& *

*& *

&----


REPORT ZTEST_SDN1 .

tables : mara.

data : begin of it_mara occurs 0,

matnr like mara-matnr,

mbrsh like mara-mbrsh,

mtart like mara-mtart,

meins like mara-meins,

end of it_mara.

parameters : P_mtart like mara-mtart default 'ROH'.

start-of-selection.

perform select_data.

perform download_data.

&----


*& Form select_data

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM select_data .

select

matnr

mbrsh

mtart

meins

from mara into table it_mara

where mtart = P_mtart.

if sy-subrc = 0.

sort it_mara by matnr.

endif.

ENDFORM. " select_data

&----


*& Form download_data

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM download_data .

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

FILENAME = 'c:\down_mara.txt'

FILETYPE = 'ASC'

APPEND = 'X'

TABLES

DATA_TAB = it_mara.

ENDFORM. " download_data

Thanks & Regards

Sreenivasulu P

Former Member
0 Kudos

Well i tried this code but the results are still the same . This code is to print a file that came from a idoc and is expected to divide in lines acording the material and is caracteristics (this output cames from sdata). I divide the fields by material and i need that this output came with the descrition and when the last character in the last line appear i want that the cursor stop there.

I dont know if it´s possible to do what i want. The cursor continue going to the other line and i dont want that happen.

It's the Gui_Download the best solution or exists other solution????

*----


Code----

-


**&----

-


**& Form ficheiro

**&----

-


FORM ficheiro.

DATA: l_init LIKE t_excel_interface,

l_file LIKE rlgrap-filename,

l_cmd(254),

tl_res(255) OCCURS 0 WITH HEADER LINE.

MOVE-CORRESPONDING t_excel_interface TO l_init.

  • T_EXCEL_INTERFACE-MANDT = 'Mandante'.

  • T_EXCEL_INTERFACE-DOCNUM = 'Docnum'.

  • T_EXCEL_INTERFACE-SEGNUM = 'Segnum'.

  • T_EXCEL_INTERFACE-SEGNAM = 'Segnam'.

  • T_EXCEL_INTERFACE-SDATA = 'Sdata'.

*

  • APPEND T_EXCEL_INTERFACE.

CLEAR t_excel_interface[].

LOOP AT t_interface_pos_por_ean.

  • MOVE-CORRESPONDING t_interface_pos_por_ean TO t_excel_interface.

MOVE t_interface_pos_por_ean TO t_excel_interface.

APPEND t_excel_interface.

ENDLOOP.

DESCRIBE TABLE t_excel_interface LINES w_lines.

IF w_lines GT 50000.

CONCATENATE w_return '' sy-repid '_' sy-uname '.TXT' INTO p_file1.

ELSE.

CONCATENATE w_return '' 'EAN1' "sy-uname '_' sy-datum

'' current_loja ' .15' INTO p_file1.

*w_return '' 'Materiais_' sy-uname '_' sy-datum '.xls' into p_file1.

ENDIF.

IF w_lines GE 1 AND sy-batch IS INITIAL.

CONDENSE p_file1 NO-GAPS.

MOVE p_file1 TO file1.

DATA: msg TYPE string.

OPEN DATASET file1 IN TEXT MODE ENCODING default FOR OUTPUT message msg.

IF sy-subrc = 0.

LOOP AT t_excel_interface.

TRANSFER t_excel_interface TO file1.

ENDLOOP.

ENDIF.

CLOSE DATASET file1.

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

  • BIN_FILESIZE =

filename = file1

filetype = 'ASC'

append = 'X'

  • write_field_separator = 'X'

  • HEADER = '00'

trunc_trailing_blanks = 'X'

  • 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'

  • IMPORTING

  • FILELENGTH =

TABLES

data_tab = t_excel_interface

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

*----

-


thanks too all

best regards

Vitor Feio

Former Member
0 Kudos

Use ASC instead of BIN as your file type in the FM paramters.

Regards,

nagaraju Chidurupalli.

Former Member
0 Kudos

hi Vitor,

Change Filetype as '<b>ASC</b>' instead of 'BIN'.

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

  • BIN_FILESIZE =

filename = file1

<b>filetype = 'ASC'</b>

append = 'X'

Regards,

Santosh

Note: Please Mark the Helpful answers