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: 

SAPCE AFTER CHARACTERS

Former Member
0 Kudos

Hi,

I am downloading a txt file for E payment but i am having one query...

when i download a txt file in header data i have one query

in header my last field is 20 character long but it has 4 character 'ABCD' (FOR EXAMPLE )

So now i want other 16 character should be space

I had done



DATA : SRC_CD(20).

  SHIFT  SRC_CD RIGHT DELETING TRAILING SPACE.
  TRANSLATE SRC_CD USING '* '.

  WA_HEADER-SRC_CD = SRC_CD.

  TRANSLATE WA_HEADER-SRC_CD USING '* '.

  APPEND WA_HEADER TO IT_HEADER.
  CLEAR WA_HEADER.

But when i open the txt file it does not put last 16 space

Pls help me on this.

Regards

Rajan

1 ACCEPTED SOLUTION

Former Member
0 Kudos

in gui_download function module use *WRITE_FIELD_SEPARATOR = ' X'. *

it will separates column by column.

11 REPLIES 11

Former Member
0 Kudos

>

>


>   SHIFT  SRC_CD RIGHT DELETING TRAILING SPACE.
>   TRANSLATE SRC_CD USING '* '.
> 

Hi avoid using deleting trailing space and try.

Regards

Karthik D

0 Kudos

Hi karthik

I have tried

and i hv removed all that

i thought if its length is 20 C then automatically it should take up

but its not taking

0 Kudos

HI Sourav ,

Thanxs

but i dont want 3456 at the end

my problem is i want space only after first 4 characters ...that means 16 space

but after downloading it is not happening

Pls help me on this

Thnxs & Regards

Rajan

0 Kudos

Hi rajan,

If you are sure to have space after the text i have a turnaround.

Try like this;

data lv_text(20) TYPE C VALUE 'ABCD'.

data : begin of itab OCCURS 0,
  lv_text(21),
  count,
  end of itab.

BREAK-POINT.
CONCATENATE lv_text '.' INTO itab-lv_text RESPECTING BLANKS.
itab-count = '1'.
APPEND itab.

CALL FUNCTION 'GUI_DOWNLOAD'
        EXPORTING
          filename                = 'c:\hello.txt'
          filetype                = 'DAT'
          write_lf                = 'X'
        TABLES
          data_tab                = itab.

Here i have increased the length of the variable to 21 and added a . (Dot) in 21st position. so download it as usual and after down load open it in notepad , Edit -> Replace, in that Find . (dot) and replace with '' (no space between quotes) and press Replace all.

If you need any clarification revert back.

Regards

Karthik D

0 Kudos

hi dude

are thats not possible

here for an example i m using gui_download actualy i m downloding and saving this flat file to application server tan i pacle to portal application server

so thats not the correcty way

if u hv any other way

do tell me

thanxs by the way

Regards

Rajan

0 Kudos

First imp thing is that you can not add spaces after the last character of string. These sapces will be deleted automatically. One thing you can do is add spaces before the actual string using 'shift right'. But in this case, your field will be right alligned.

Regards,

Aparna Gaikwad

0 Kudos

Hi

aparna

i know i can add space before but as i m downloading this flat file and using as an e payment with bank

so bank ppl are saying that they need space if the variable is 20 C and its coming 5 C ..

15 spaces shoulld be there

i hv to do it anyhow...

regards

Rajan

former_member212653
Active Contributor
0 Kudos

Check out this code:


*&---------------------------------------------------------------------*
*& Report  ZTEST_SOURAV23
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT  ztest_sourav23.


DATA: table TYPE STANDARD TABLE OF char100,
      line TYPE char100,
      blank_char TYPE string,
      length TYPE i,
      filename TYPE string,
      req_spaces type string.

PARAMETERS: p_fname TYPE localfile OBLIGATORY.

CALL METHOD cl_abap_char_utilities=>get_simple_spaces_for_cur_cp
  RECEIVING
    s_str = blank_char.

*Move first field
line = 'ABCD'.
length = STRLEN( line ).
length = 20 - length.
DO length TIMES.
  CONCATENATE blank_char+0(1) req_spaces INTO req_spaces.
ENDDO.
*Move second field
CONCATENATE line '343434' INTO line SEPARATED BY req_spaces.

APPEND line TO table.

filename = p_fname.

CALL FUNCTION 'GUI_DOWNLOAD'
  EXPORTING
*   BIN_FILESIZE                    =
    filename                        = filename
*   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                        = table
*   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.

Former Member
0 Kudos

in gui_download function module use *WRITE_FIELD_SEPARATOR = ' X'. *

it will separates column by column.

0 Kudos

are dudde

read the above answers then reply

Former Member
0 Kudos

its done

regards

rajan