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: 

error at download

Former Member
0 Kudos

hi all ,

i have data in my ztable (zcust) and i need to download it into a notepad. i hav started but it gives me runtime error when calling the FM i,e gui_download. so pls can u correct my code incase if i have gone wrong. below is my code:

PARAMETERS: p_file TYPE rlgrap-filename.

Data: Begin of i_string occurs 0,

line(1024) type c,

End of i_string.

types: begin of s_cust1,

zempno like zcust1-zempno,

zcustnumber like zcust1-zcustnumber,

zcustname like zcust1-zcustname,

zcustbd like zcust1-zcustbd,

zno_chil like zcust1-zno_chil,

END OF s_cust1.

data: i_cust1 TYPE STANDARD TABLE OF s_cust1 WITH HEADER LINE.

data: wa_cust1 like LINE OF i_cust1.

Data: filename type string,

delim(1) type c value '|',

g_lines type i.

select zempno

zcustnumber

zcustname

zcustbd

zno_chil

from zcust1

into CORRESPONDING FIELDS OF TABLE i_cust1.

if sy-subrc = 0.

message i009(zdd) with 'records fetched'.

endif.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.

CALL FUNCTION 'KD_GET_FILENAME_ON_F4'

CHANGING

file_name = p_file.

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

  • BIN_FILESIZE =

filename = 'c:\Documents and Settings\Desktop\down.txt'

FILETYPE = 'ASC'

  • APPEND = ' '

WRITE_FIELD_SEPARATOR = 'X'

tables

data_tab = i_cust1.

*

IF sy-subrc <> 0.

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

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

ENDIF.

thanks in advance

jacob

6 REPLIES 6

rainer_hbenthal
Active Contributor
0 Kudos

enclose your sourcecode with markup tags listed in the lower left corner. It makes sourcecode much more readable and i will not read any code nit in those tags.

Former Member
0 Kudos

Hi,

In FM,

in parameter FILENAME, give p_file, the variable in which you are getting the filename from 'KD_GET_FILENAME_ON_F4'.

Try with this. If any further issue, revert back.

Regards

Natasha Garg

0 Kudos

i hav given even the p_file in the file name but still it gives me that error.

i hav few doubts like

for the download do we need to put the data first in the note pad?

can u pls send me the sample prog pls

0 Kudos

Hi,

No its not necessary. You can download your data directly into the excel file if that is your requirement.

case sy-ucomm.

when 'DOWNLOAD'.

CALL FUNCTION 'GUI_DOWNLOAD'

filename = p_file

FILETYPE = 'ASC'

tables

data_tab = <internal_table name>.

IF sy-subrc <> 0.

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

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

ENDIF.

This code I have taken from a sample program only.

Pls revert back if this is your rquirement.

Regards

Natasha Garg

0 Kudos

it works fine but how can i display it in the notepad pls

Mohamed_Mukhtar
Active Contributor
0 Kudos

hi

PARAMETERS: p_file TYPE rlgrap-filename.
DATA: BEGIN OF i_string OCCURS 0,
line(1024) TYPE c,
END OF i_string.

TYPES: BEGIN OF s_cust1,
zempno LIKE zcust1-zempno,
zcustnumber LIKE zcust1-zcustnumber,
zcustname LIKE zcust1-zcustname,
zcustbd LIKE zcust1-zcustbd,
zno_chil LIKE zcust1-zno_chil,
END OF s_cust1.

DATA: i_cust1 TYPE STANDARD TABLE OF s_cust1 WITH HEADER LINE.
DATA: wa_cust1 LIKE LINE OF i_cust1.
data : w_path type string . "------> declare this variable
DATA: filename TYPE string,
delim(1) TYPE c VALUE '|',
g_lines TYPE i.

SELECT zempno
zcustnumber
zcustname
zcustbd
zno_chil
FROM zcust1
INTO CORRESPONDING FIELDS OF TABLE i_cust1.

IF sy-subrc = 0.
  MESSAGE i009(zdd) WITH 'records fetched'.
ENDIF.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
  CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
    CHANGING
      file_name = p_file.
      
      
w_path = p_file. "-------> include this in ur code
  CALL FUNCTION 'GUI_DOWNLOAD'
  EXPORTING

      * bin_filesize =

  filename = w_path "--------> pass this path as parameter
  filetype = 'ASC'

      * append = ' '

  write_field_separator = 'X'
  TABLES
  data_tab = i_cust1.
*

  IF sy-subrc 0.

     * message id sy-msgid type sy-msgty number sy-msgno
     * with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

  ENDIF.

Regards