Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

gui download

i'm posting this QA again becuse its very important to me and i tried all the answer and did not .

i download ztable into file.txt (gui_download)

my problem:

i want the field to download as is , if matnr is 10 and in data element 18 i need 1o and 8 space and after that i need ',' delimeter.

i made loop that make ',' at the end of matnr but it takes the space, i also add WRITE_FIELD_SEPARATOR = ','

but i get err and it not make this

HELP.

Tags:
replied

Notice, here I have modified your program to use MARA instead of ZCAL. Notice, that in the DO loop, I'm skipping over the first field MANDT. No need for the other loop to clear it out. Also, you can see that the MATNR fields is 18 characters(left zero filled). Are you see the same results?


report zdw_zcal_mstr_m_dwlo message-id bd..



data : begin of i_tab occurs 0.
      <b>  include structure mara.</b>
data: end of i_tab.

data: v_subrc(2),
v_recswritten(6).
data: iflat type table of string,
xflat type string.
field-symbols: <fs>.


parameters: p_file(80)
default 'C:test.txt'.

at selection-screen on value-request for p_file.
  call function 'WS_FILENAME_GET'
       exporting
            def_filename     = p_file
            mask             = ',*.txt.'
            mode             = 'O'
            title            = 'UDOWNLOAD File'(078)
       importing
            filename         = p_file
       exceptions
            inv_winsys       = 1
            no_batch         = 2
            selection_cancel = 3
            selection_error  = 4
            others           = 5.

  if sy-subrc <> 0.
    leave screen.
  endif.

start-of-selection.

  data: filename type string.

  filename = p_file.

<b>  select * from mara into table i_tab up to 100 rows.</b>

<b>*  loop at i_tab.
*    clear i_tab-mandt.
*    modify i_tab. " from w_tab.
*  endloop.</b>
  loop at i_tab.

    do.
<b>      check sy-index > 1.        " Skip over MANDT</b>
      assign component sy-index of structure i_tab to <fs>.
      if sy-subrc <> 0.
        exit.
      endif.
      if sy-index = 2.
        xflat = <fs>.
      else.
        concatenate xflat <fs> into xflat separated by ','.
      endif.
    enddo.
    append xflat to iflat.

  endloop.


* If text fields appear right justified or columns not lined up in
*output set
* TRUNC_TRAILING_BLANKS to X

  call function 'GUI_DOWNLOAD'
  exporting
* BIN_FILESIZE =
  filename = filename
  filetype = 'ASC'
* APPEND = ' '
  write_field_separator = 'X'
* HEADER = '00'
* TRUNC_TRAILING_BLANKS = ' '
* WRITE_LF = 'X'
* COL_SELECT = ' '
* COL_SELECT_MASK = ' '
* IMPORTING
* FILELENGTH =
  tables
  data_tab = iflat .

* SYST FIELDS ARE NOT SET BY THIS FUNCTION SO DISPLAY THE ERROR CODE *

  if sy-subrc <> 0.
    v_subrc = sy-subrc.
    message e899 with 'File Open Error' v_subrc.
  endif.


  describe table i_tab lines v_recswritten.

  message i899 with v_recswritten 'Records Written from zcal_mstr_m'.

Regards,

Rich Heilman

0 View this answer in context

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question