Skip to Content
0
Former Member
Apr 27, 2007 at 09:51 AM

HI

15 Views

While down loading data from internal table into excel sheet

leading zero's are missing Pl.. excute the following program

and give me the solution for that.

REPORT zy.

TYPES:BEGIN OF ty_kna1,

kunnr TYPE kunnr,

name1 TYPE name1,

land1 TYPE land1,

END OF ty_kna1,

BEGIN OF ty_text,

custno(30) TYPE c,

name(30) TYPE c,

country(30) TYPE c,

END OF ty_text.

DATA:st_kna1 TYPE ty_kna1,

t_kna1 TYPE STANDARD TABLE OF ty_kna1,

t_text TYPE STANDARD TABLE OF ty_text,

st_text TYPE ty_text.

DATA:w_fname1 TYPE string,

w_fname2 TYPE string.

select-options:s_kunnr for st_kna1-kunnr.

PARAMETERS:p_fname1 LIKE rlgrap-filename,

p_fname2 LIKE rlgrap-filename.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_fname1.

CALL FUNCTION 'F4_FILENAME'

EXPORTING

program_name = syst-cprog

dynpro_number = syst-dynnr

IMPORTING

file_name = p_fname1.

START-OF-SELECTION.

SELECT kunnr name1 land1 INTO TABLE t_kna1 FROM kna1

where kunnr in s_kunnr.

st_text-custno = 'Cust.No'.

st_text-name = 'Cust.Name'.

st_text-country = 'Cust.Country'.

APPEND st_text TO t_text.

CLEAR st_text.

w_fname1 = p_fname1.

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

  • BIN_FILESIZE =

filename = w_fname1

  • 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 = t_text

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

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

  • BIN_FILESIZE =

filename = w_fname1

  • FILETYPE = 'ASC'

APPEND = 'X'

write_field_separator = 'X'

  • HEADER = st_text

  • TRUNC_TRAILING_BLANKS = ' '

  • WRITE_LF = 'X'

  • COL_SELECT = ' '

  • COL_SELECT_MASK = ' '

  • IMPORTING

  • FILELENGTH =

TABLES

data_tab = t_kna1

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

After excuting this I am getting output like

Cust.No Cust.Name Cust.Country

1 al_dsuza US

2 al_dsuza DE

5 al_dsuza IN

7 al_dsuza US

10 General Motors US

21 Rahul IN

90 Distribution Plant GB

99 al_dsuza DE

Though customer filed is char type leading zero's are missing

pl.. give solution