Skip to Content
avatar image
Former Member

Down load to excel file with specifying standard length gap (VERY URGENT )

Hi All,

I had developed a program to download to Excel file, but the thing is it is displaying all the data in a clumzy manner.

I want to display the output as for examp:

MATNR having 18 characters length, my data for MATNR is 10 characters only i have to leave the remaining 8 characters as space and then next field can display at 19th characters on wards.

Here is my sort of code:

<b>

DATA: LV_TAB TYPE X VALUE 9.

DATA: lv_vkorg(4) type c,

lv_dwerk(4) type c,

LV_VTWEG(2) TYPE c,

LV_MATNR(18) TYPE c ,

LV_MAKTX(40) TYPE c ,

LV_DSNAM(18) TYPE c ,

LV_KONDM(2) TYPE c ,

LV_VTEXT1(20) TYPE c ,

LV_PRODH(18) TYPE c,

LV_VTEXT(40) TYPE c ,

LV_VERSG(1) TYPE c,

LV_BEZEI20(20) TYPE c ,

LV_MATKL(9) TYPE c,

LV_WGBEZ(20) TYPE c,

LV_PRCTR(10) TYPE c.

LOOP AT GT_ALV1_DATA.

CONCATENATE

GT_ALV1_DATA-VKORG

lv_vkorg

GT_ALV1_DATA-DWERK(4)

lv_dwerk

GT_ALV1_DATA-VTWEG(2)

lv_vtweg

GT_ALV1_DATA-MATNR(18)

lv_matnr

GT_ALV1_DATA-MAKTX(40)

lv_maktx

GT_ALV1_DATA-DSNAM(18)

lv_dsnam

GT_ALV1_DATA-KONDM(2)

lv_kondm

GT_ALV1_DATA-VTEXT1(20)

lv_vtext1

GT_ALV1_DATA-PRODH(18)

lv_prodh

GT_ALV1_DATA-VTEXT(40)

lv_vtext

GT_ALV1_DATA-VERSG(1)

lv_versg

GT_ALV1_DATA-BEZEI20(20)

lv_bezei20

GT_ALV1_DATA-MATKL(9)

lv_matkl

GT_ALV1_DATA-WGBEZ(20)

lv_wgbez

GT_ALV1_DATA-PRCTR(10)

lv_prctr

INTO GT_OUTTAB-LINE.

APPEND GT_OUTTAB.

ENDLOOP.</b>

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • May 23, 2006 at 04:47 AM

    Hi,

    Use F.M <b> GUI_DOWNLOAD.</b>In that pass ur internal table and ur filename as default.xls.

    As said by sreenivas..

    use the field seperator = 'X'.

    Hope it helps...

    Chers,

    Simha.

    Message was edited by: Narasimha Rao Bandla

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hi

      Check the following code

      Data: begin of it occurs 0 , Ch1(1) , doc(10) , end of it .

      data: wa like it .

      data: it1 like it occurs 0 with header line .

      it-doc = '1' . append it . clear it .

      it-doc = '2' . append it . clear it .

      it-doc = '3' . append it . clear it .

      it-doc = '4' . append it . clear it .

      it-doc = '5' . append it . clear it .

      CALL FUNCTION 'GUI_DOWNLOAD'

      EXPORTING

      • BIN_FILESIZE =

      FILENAME = 'c:\abc.txt'

      • FILETYPE = 'ASC'

      • APPEND = ' '

      WRITE_FIELD_SEPARATOR = 'X'

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

      • WK1_N_FORMAT = ' '

      • WK1_N_SIZE = ' '

      • WK1_T_FORMAT = ' '

      • WK1_T_SIZE = ' '

      • IMPORTING

      • FILELENGTH =

      TABLES

      DATA_TAB = IT

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

      actually you have to set TRUNC_TRAILING_BLANKS_EOL = ' '

      regards

      Siddharth

  • avatar image
    Former Member
    May 23, 2006 at 05:29 AM

    Hi,

    Using concatenate will not be the right way to go if you want the output in fixed length format, instead use offset positions to specify fixed length.

    LOOP AT GT_ALV1_DATA.

    GT_OUTTAB-LINE+0(4) = GT_ALV1_DATA-VKORG.

    GT_OUTTAB-LINE+4(4) = GT_ALV1_DATA-DWERK.

    Similarly for matnr.

    CONDENSE GT_ALV1_DATA-MATNR.

    GT_OUTTAB-LINE+offset(18) = GT_ALV1_DATA-MATNR.

    APPEND GT_OUTTAB.

    ENDLOOP.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    May 23, 2006 at 07:03 AM

    Hi prabhakara,

    1. First of all use the FM GUI_DOWNLOAD.

    2.<b> DO NOT USE THIS PARAMETER</b> WRITE_FIELD_SEPARATOR = 'X'.

    3. If we use this parameters,

    then TAB will be there , in between the fields.

    4. If we do not use this parameter,

    SPACES (of the field defined length)

    <b> will be there in-betweeen the fields.</b>

    regards,

    amit m.

    Add comment
    10|10000 characters needed characters exceeded