Skip to Content
author's profile photo Former Member
Former Member

SAPCE AFTER CHARACTERS

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

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Sep 22, 2008 at 12:34 PM

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

    it will separates column by column.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 22, 2008 at 09:45 AM

    >

    >

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

    Hi avoid using deleting trailing space and try.

    Regards

    Karthik D

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      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

  • Posted on Sep 22, 2008 at 10:22 AM

    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.
    
    

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 22, 2008 at 07:02 AM

    its done

    regards

    rajan

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.