09-10-2015 12:40 PM
Hi All,
I need to write a text file into application server values with spaces. I know this has been mentioned several times but I am unable to find a solution yet.
below is the coding;
DATA : lv_rec(1) TYPE c,
lv_source(4) TYPE c,
lv_seq_number(4) TYPE c,
lv_cutt(8) TYPE c,
lv_res(779) TYPE c.
DATA : lv_file_name TYPE string,
lv_space TYPE string,
lv_raw TYPE string.
lv_rec = 'M'.
lv_reserved = ' ' .
lv_source = 'TEST'.
lv_cutt = sy-datum.
lv_reserved = ' '.
lv_space = cl_abap_conv_in_ce=>uccp( '00a0' ).
OPEN DATASET lv_file_name FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
WRITE lv_space TO lv_reserved+778(1).
CONCATENATE lv_rec lv_source lv_cutt lv_res INTO lv_raw
TRANSFER: lv_raw TO lv_file_name.
CLOSE DATASET lv_file_name.
I dont see the file getting created as per the requirement . Variable LV_RES should have 779 SPACES.
Could anyone plz explain the satement "WRITE lv_space TO lv_reserved+100(1)".... specially what specially "+100(1)"
09-10-2015 1:54 PM
09-10-2015 12:50 PM
Hi,
Below statement will solve your issue.
OPEN DATASET lv_file_name FOR OUTPUT IN TEXT MODE ENCODING DEFAULT WITH WINDOWS LINEFEED.
BR
Gangadhar
09-10-2015 1:54 PM
09-10-2015 2:02 PM
Thanks for the reply..
is there a limitation of the charachters ? Cos If I use ;
WRITE lv_space TO lv_reserved+100(1).
then File is created with 100 spaces.
but If I use WRITE lv_space TO lv_reserved+778(1).
File has no SPACES...
09-10-2015 2:08 PM
Did you mean lv_res? Cause I could not find lv_reserved in your code. What is the data type you used for lv_reserved?
Also how do you know it is not working when WRITE lv_space TO lv_reserved+778(1)? Via AL11?
Note AL11 only shows up to 255 characters but in the OS level the file will be created with more than 255 characters.
R
09-10-2015 3:41 PM
Thanks for the reply.
Yes.it is Lv_res.
Data type: lv_res (779) type c.
Im using Tcode 'CG3Y' to check the file. (Download into Local PC)
Note : OS is OS400
09-10-2015 4:19 PM
There was a limitation of 1500 characters per line . Not sure if it still holds true.
Does not look like you have more than 1500 characters.
WITH SMART/NATIVE LINEFEED You can try to append CL_ABAP_CHAR_UTILITIES=>CR_LF at the end .
R
09-10-2015 8:13 PM
Hi Rudra,
Thank you for the reply..
I still can write a file with character length (including SPACE) around 200 - 256.
But how to write the text file with more than 700 ?
09-11-2015 1:24 PM
Hi,
Did you check downloading the file via CG3Y in Binary mode? Please check that once.
In order to check if the spaces are being written correctly I would put a dummy character(Put * or $ or something) at the end of the string and then download.
R
09-14-2015 11:38 AM
Not sure if your issue is fixed. Just came to my mind. One thing also you could try.
While concatenating, use addition RESPECTING BLANKS.
R