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: 

How to get the space in the text file in the last after itab is downloaded

former_member190312
Active Participant
0 Kudos

Hi All,

I am trying to download one iternal table by using ws_download FM.

This iternal table have 3 fields (var1,var2 & var3 ). i want ,some 40 spaces will appear after var3 in the downloaded text file.

I tried all the way but the downloaded text file is not showing the spaces after the last field. any solution?

Thanks

pabi

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Pabitra,

please refer the below code to add spaces at the end.

data:  p_file TYPE string.
TYPES: BEGIN OF ty_data,
          V1 TYPE i,
          V2 TYPE c,
          V3 TYPE c,
          spc(40) TYPE c,
       END OF ty_data.

DATA: WA_DATA TYPE TY_DATA,
      IT_DATA TYPE STANDARD TABLE OF TY_DATA.
p_file = <file path>.

DO 5 times.
  CONCATENATE wa_data-spc cl_abap_char_utilities=>horizontal_tab INTO wa_data-spc.
ENDDO.

CONCATENATE wa_data-spc '.' INTO wa_data-spc.

wa_data-V1 = 1.
wa_data-V2 = 1.
wa_data-V3 = 1.
APPEND wa_data TO it_data.


wa_data-V1 = 2.
wa_data-V2 = 2.
wa_data-V3 = 2.
APPEND wa_data TO it_data.

wa_data-V1 = 3.
wa_data-V2 = 3.
wa_data-V3 = 3.
APPEND wa_data TO it_data.

wa_data-V1 = 4.
wa_data-V2 = 4.
wa_data-V3 = 4.
APPEND wa_data TO it_data.

wa_data-V1 = 5.
wa_data-V2 = 5.
wa_data-V3 = 5.
APPEND wa_data TO it_data.

wa_data-V1 = 6.
wa_data-V2 = 6.
wa_data-V3 = 6.
APPEND wa_data TO it_data.


wa_data-V1 = 7.
wa_data-V2 = 7.
wa_data-V3 = 7.
APPEND wa_data TO it_data.

CALL FUNCTION 'GUI_DOWNLOAD'
  EXPORTING
*   BIN_FILESIZE                    =
    filename                        = p_file
*   FILETYPE                        = 'ASC'
*   APPEND                          = ' '
*   WRITE_FIELD_SEPARATOR           = ' '
*   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       = 'X'
*   WK1_N_FORMAT                    = ' '
*   WK1_N_SIZE                      = ' '
*   WK1_T_FORMAT                    = ' '
*   WK1_T_SIZE                      = ' '
*   WRITE_LF_AFTER_LAST_LINE        = ABAP_TRUE
*   SHOW_TRANSFER_STATUS            = ABAP_TRUE
* IMPORTING
*   FILELENGTH                      =
  tables
    data_tab                        = it_data
*   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.

in the above code if you check i have added a "." at the end of spaces to notify the end of the line. i have used tabs five times to achieve the 40 spaces.

Please let me know if you require further details.

<more begging removed by moderator>

Regards,

Praveenkumar T.

Edited by: Thomas Zloch on Feb 14, 2012

2 REPLIES 2

Former Member
0 Kudos

you could either add another variable var4(40) type c to the table or u could manually concatenate 40 characters at the end of var3

Former Member
0 Kudos

Hi Pabitra,

please refer the below code to add spaces at the end.

data:  p_file TYPE string.
TYPES: BEGIN OF ty_data,
          V1 TYPE i,
          V2 TYPE c,
          V3 TYPE c,
          spc(40) TYPE c,
       END OF ty_data.

DATA: WA_DATA TYPE TY_DATA,
      IT_DATA TYPE STANDARD TABLE OF TY_DATA.
p_file = <file path>.

DO 5 times.
  CONCATENATE wa_data-spc cl_abap_char_utilities=>horizontal_tab INTO wa_data-spc.
ENDDO.

CONCATENATE wa_data-spc '.' INTO wa_data-spc.

wa_data-V1 = 1.
wa_data-V2 = 1.
wa_data-V3 = 1.
APPEND wa_data TO it_data.


wa_data-V1 = 2.
wa_data-V2 = 2.
wa_data-V3 = 2.
APPEND wa_data TO it_data.

wa_data-V1 = 3.
wa_data-V2 = 3.
wa_data-V3 = 3.
APPEND wa_data TO it_data.

wa_data-V1 = 4.
wa_data-V2 = 4.
wa_data-V3 = 4.
APPEND wa_data TO it_data.

wa_data-V1 = 5.
wa_data-V2 = 5.
wa_data-V3 = 5.
APPEND wa_data TO it_data.

wa_data-V1 = 6.
wa_data-V2 = 6.
wa_data-V3 = 6.
APPEND wa_data TO it_data.


wa_data-V1 = 7.
wa_data-V2 = 7.
wa_data-V3 = 7.
APPEND wa_data TO it_data.

CALL FUNCTION 'GUI_DOWNLOAD'
  EXPORTING
*   BIN_FILESIZE                    =
    filename                        = p_file
*   FILETYPE                        = 'ASC'
*   APPEND                          = ' '
*   WRITE_FIELD_SEPARATOR           = ' '
*   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       = 'X'
*   WK1_N_FORMAT                    = ' '
*   WK1_N_SIZE                      = ' '
*   WK1_T_FORMAT                    = ' '
*   WK1_T_SIZE                      = ' '
*   WRITE_LF_AFTER_LAST_LINE        = ABAP_TRUE
*   SHOW_TRANSFER_STATUS            = ABAP_TRUE
* IMPORTING
*   FILELENGTH                      =
  tables
    data_tab                        = it_data
*   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.

in the above code if you check i have added a "." at the end of spaces to notify the end of the line. i have used tabs five times to achieve the 40 spaces.

Please let me know if you require further details.

<more begging removed by moderator>

Regards,

Praveenkumar T.

Edited by: Thomas Zloch on Feb 14, 2012