09-22-2008 10:37 AM
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
09-22-2008 1:34 PM
in gui_download function module use *WRITE_FIELD_SEPARATOR = ' X'. *
it will separates column by column.
09-22-2008 10:45 AM
>
>
> SHIFT SRC_CD RIGHT DELETING TRAILING SPACE. > TRANSLATE SRC_CD USING '* '. >
Hi avoid using deleting trailing space and try.
Regards
Karthik D
09-22-2008 10:51 AM
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
09-22-2008 11:36 AM
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
09-22-2008 12:16 PM
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
09-22-2008 1:19 PM
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
09-22-2008 1:24 PM
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
09-22-2008 1:29 PM
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
09-22-2008 11: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.
09-22-2008 1:34 PM
in gui_download function module use *WRITE_FIELD_SEPARATOR = ' X'. *
it will separates column by column.
09-22-2008 2:05 PM
12-22-2008 7:02 AM