‎2008 Jun 20 4:06 PM
Following is a structure that I'm using to write data to a file on the app server. The last 331 bytes are spaces. When the file is written to the app server the last 331 bytes are truncated even though I specifically tell the statement the length is 630 bytes. How can I keep SAP/ABAP from truncating my record?
begin of st_header,
rectyp,
company(35),
acct_num(11),
rptbegda(8),
rptendda(8),
createda(8),
datatyp(3),
database(5),
reserved1(200),
servtyp(20),
reserved2(331),
end of st_header,
TRANSFER it_header TO lv_filename LENGTH 630.
‎2008 Jun 20 4:08 PM
Does this happen only if the last 330 characters are spaces?
or does this happen even if you have some data in it?
REgards,
Ravi
‎2008 Jun 20 4:08 PM
Does this happen only if the last 330 characters are spaces?
or does this happen even if you have some data in it?
REgards,
Ravi
‎2008 Jun 20 4:10 PM
It's filler so it always has spaces in it. I have downloaded to a local file and it's truncated.
‎2008 Jun 20 4:15 PM
Hi Steve,
here is an excerpt from the sap documentation:
"The Influence of Storage Type
The transfer depends on the storage type used when the file is opened using the statement OPEN DATASET. If the specified storage type requires conversion, it is carried out before the write process.
If the file was opened as a text file or a legacy text file, the trailing blank characters are deleted for all data objects, except for those of data type string. A platform-specific line end mark is then added to the remaining content of the data object or to the result of the conversion, and the final result is written byte-by-byte to the file. "
Regards,
ravi
‎2008 Jun 20 4:08 PM
hi Steve,
I guess you are unable to view that data which is actually being written to the application sever as we have limitation in viewing the numer of characters ... Download the file to a local file to view entire content ..
regards,
Santosh
‎2008 Jun 20 4:13 PM
If you check the program of Transaction AL11 (RSWATCH0) you will notice that, LINE-SIZE = 512.
So you can see a line upto 512 character.
that may be reason why u cant see the whole line.
You can download the data to exel and check the legth.
‎2008 Jun 20 4:17 PM
Hi,
If you are using in ECC6.0 please check the open dataset statement too.
The syntax for unicode and non-unicode is different.
please provide full code , so I can help in better way.
Bye
‎2008 Jun 20 4:20 PM
The problem was how I was looking at the file. I downloaded with transaction CG3Y and opened it and it's not truncated. If you download it from AL11 then it's truncated.
Thanks for your help!
‎2008 Jun 20 4:22 PM
AL11 doesn't show the full record. Infact transaction CG3Y also truncates values.
try this program to download the file from app server to presentation server and check it out:
*&---------------------------------------------------------------------*
*& Report ZCG_FILE_TRANSFER
*&
*&---------------------------------------------------------------------*
*& Transfers file between presentation and application server
*&
*&---------------------------------------------------------------------*
report zcg_file_transfer no standard page heading.
types: begin of t_data,
record(5000) type c,
end of t_data.
data: i_data type standard table of t_data
initial size 0 with header line.
data: v_subrc like sy-subrc,
v_fname like rlgrap-filename, "Source File name
v_tfile like rlgrap-filename. "Target file name
constants: c_m1(2) type c value 'M1', "Modif Id M1
c_m2(2) type c value 'M2', "Modif Id M2
c_check(1) type c value 'X'. "X:Checked
* Data Source
selection-screen begin of block b_source with frame title text-b01.
parameters: p_fname like rlgrap-filename modif id m1,
"Data file name
p_f_pc like rlgrap-filename modif id m2,
"PC file name
p_pc radiobutton group src
user-command ucomm,
"Prsntation srvr
p_server radiobutton group src default 'X'.
"Applicatn srvr
selection-screen end of block b_source.
selection-screen skip.
* Target file
selection-screen begin of block b_target with frame title text-t01.
parameters: p_tfname like rlgrap-filename modif id e1,
"Data file name
p_t_pc like rlgrap-filename modif id e2,
"PC file name
p_pc_t radiobutton group err default 'X'
user-command ucomm,
"Prsntation srvr
p_srv_t radiobutton group err. "Applicatn srvr
selection-screen end of block b_target.
*-------------------------------------------------------------------*
* At selection-screen output Event *
*-------------------------------------------------------------------*
at selection-screen output.
* Set the source file parameter dynamically
perform sub_set_file_param.
* Set the target file parameter dynamically
perform sub_target_file.
*-------------------------------------------------------------------*
*-------------------------------------------------------------------*
* At selection-screen on F4 help for PC file *
*-------------------------------------------------------------------*
at selection-screen on value-request for p_f_pc.
* Provide a F4 help for source file
perform sub_pcfile_f4 using p_f_pc.
*-------------------------------------------------------------------*
*-------------------------------------------------------------------*
* At selection-screen on F4 help for Server file *
*-------------------------------------------------------------------*
at selection-screen on value-request for p_fname.
* Provide a F4 help for source file
perform sub_serverfile_f4 using p_fname.
*-------------------------------------------------------------------*
* At selection-screen on F4 help for target file *
*-------------------------------------------------------------------*
at selection-screen on value-request for p_t_pc.
* Provide a F4 help for source file
perform sub_pcfile_f4 using p_t_pc.
*-------------------------------------------------------------------*
* At selection-screen on F4 help for Server target file *
*-------------------------------------------------------------------*
at selection-screen on value-request for p_tfname.
* Provide a F4 help for source file
perform sub_serverfile_f4 using p_tfname.
*-------------------------------------------------------------------*
*-------------------------------------------------------------------*
* Start of selection *
*-------------------------------------------------------------------*
** Start of Selection
start-of-selection.
* Set the global variable for filename
perform sub_set_filename.
* Imports the data from the specified source file
perform importdata tables i_data
using p_pc v_fname
changing v_subrc.
* Error whilst loading source data, terminate immediately
if v_subrc <> 0.
format color 6.
write: /5 'Error', v_subrc no-gap, ': Unable to open source file '
no-gap, v_fname.
format reset.
exit.
endif.
* Set the global variable for filename
perform sub_set_target_filename.
* Export the data to the Target file
perform exportdata tables i_data
using p_pc_t v_tfile
changing v_subrc.
* Error whilst opening target file , terminate immediately
if v_subrc <> 0.
format color 6.
write: /5 'Error', v_subrc no-gap, ': downloading to target file '
no-gap, p_fname.
format reset.
exit.
else.
format color 5.
write: /5 'Success:Transfered data to target file' no-gap, p_tfname.
format reset.
endif.
*&---------------------------------------------------------------------*
*& Form sub_set_filename
*&---------------------------------------------------------------------*
* This perform sets the global variable for filename
*----------------------------------------------------------------------*
* No Parameters
*----------------------------------------------------------------------*
form sub_set_filename .
* If PC file option is chosen set PC file name
if p_pc = c_check.
v_fname = p_f_pc.
* If server file option is chosen set server file
elseif p_server = c_check.
v_fname = p_fname.
endif.
endform. " sub_set_filename
*&---------------------------------------------------------------------*
*& Form sub_set_target_filename
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form sub_set_target_filename .
* If PC file option is chosen set PC file name
if p_pc_t = c_check.
v_tfile = p_t_pc.
* If server file option is chosen set server file
elseif p_srv_t = c_check.
v_tfile = p_tfname.
endif.
endform. " sub_set_target_filename
*&---------------------------------------------------------------------*
*& Form importdata
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->L_DATA
* -->L_PC text
* -->L_FNAME text
* <--L_SUBRC text
*----------------------------------------------------------------------*
form importdata tables l_data structure i_data
using l_pc
l_fname
changing l_subrc.
data: l_filename type string.
if l_pc = 'X'.
l_filename = l_fname.
call function 'GUI_UPLOAD'
exporting
filename = l_filename
filetype = 'ASC'
* HAS_FIELD_SEPARATOR = ' '
* HEADER_LENGTH = 0
* READ_BY_LINE = 'X'
* DAT_MODE = ' '
* CODEPAGE = ' '
* IGNORE_CERR = ABAP_TRUE
* REPLACEMENT = '#'
* CHECK_BOM = ' '
* VIRUS_SCAN_PROFILE =
* IMPORTING
* FILELENGTH =
* HEADER =
tables
data_tab = l_data
exceptions
file_open_error = 1
file_read_error = 2
no_batch = 3
gui_refuse_filetransfer = 4
invalid_type = 5
no_authority = 6
unknown_error = 7
bad_data_format = 8
header_not_allowed = 9
separator_not_allowed = 10
header_too_long = 11
unknown_dp_error = 12
access_denied = 13
dp_out_of_memory = 14
disk_full = 15
dp_timeout = 16
others = 17
.
if sy-subrc <> 0.
l_subrc = sy-subrc.
endif.
else.
open dataset l_fname for input in text mode encoding default.
if sy-subrc <> 0.
l_subrc = sy-subrc.
exit.
endif.
do.
read dataset l_fname into l_data.
append i_data.
clear l_data.
if sy-subrc ne 0.
exit.
endif.
enddo.
close dataset l_fname.
endif.
endform. " importdata
*&---------------------------------------------------------------------*
*& Form exportdata
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->L_DATA text
* -->L_PC text
* -->L_TFNAME text
* <--L_SUBRC text
*----------------------------------------------------------------------*
form exportdata tables l_data structure i_data
using l_pc
l_tfname
changing l_subrc.
data: l_filename type string,
l_mode type char10.
if l_pc is initial.
open dataset l_tfname for output in text mode encoding default.
if sy-subrc <> 0.
l_subrc = sy-subrc.
exit.
endif.
loop at l_data.
transfer l_data to l_tfname.
endloop.
close dataset l_tfname.
else.
l_filename = l_tfname.
l_mode = 'ASC'.
call function 'GUI_DOWNLOAD'
exporting
* BIN_FILESIZE =
filename = l_filename
filetype = l_mode
* 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 = ' '
* IMPORTING
* FILELENGTH =
tables
data_tab = l_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.
l_subrc = sy-subrc.
exit.
endif.
endif.
endform. " exportdata
*&---------------------------------------------------------------------*
*& Form sub_set_file_param
*&---------------------------------------------------------------------*
* Set the File parameter depending on the radio-button choice
*----------------------------------------------------------------------*
* No parameter
*----------------------------------------------------------------------*
form sub_set_file_param.
* Modify screen
loop at screen.
* If PC file chosen then set p_f_pc otherwise p_fname
if screen-group1 = c_m1.
if p_pc = c_check.
screen-active = 0.
endif.
elseif screen-group1 = c_m2.
if p_server = c_check.
screen-active = 0.
endif.
endif.
modify screen.
endloop.
endform. "sub_set_file_param
*&---------------------------------------------------------------------*
*& Form sub_target_file
*&---------------------------------------------------------------------*
* Sets the target file parameters depending on the choice
*----------------------------------------------------------------------*
* No parameters
*----------------------------------------------------------------------*
form sub_target_file .
* Modify screen
loop at screen.
* If PC file chosen then set p_f_pc otherwise p_fname
if screen-group1 = 'E1'.
if p_pc_t = c_check.
screen-active = 0.
endif.
elseif screen-group1 = 'E2'.
if p_srv_t = c_check.
screen-active = 0.
endif.
endif.
modify screen.
endloop.
endform. " sub_target_file
*&---------------------------------------------------------------------*
*& Form sub_pcfile_f4
*&---------------------------------------------------------------------*
* Provide a F4 help for PC file parameter
*----------------------------------------------------------------------*
* No parameter
*----------------------------------------------------------------------*
form sub_pcfile_f4 using l_file.
* This function module provides the F4 help for PC file
call function 'KD_GET_FILENAME_ON_F4'
changing
file_name = l_file
exceptions
mask_too_long = 1
others = 2.
* If the help funtion has an error, display a message.
if sy-subrc ne 0.
* Message 'Unable to find filepath'.
message i000(z_zzz_ca_messages) with 'Unable to find filepath'(082).
endif.
endform. "sub_pcfile_f4
*&--------------------------------------------------------------------*
*& Form sub_serverfile_f4
*&--------------------------------------------------------------------*
* Provides F4 help for the sever file
*---------------------------------------------------------------------*
* <-> L_FILE File name
*---------------------------------------------------------------------*
form sub_serverfile_f4 using l_file.
call function '/SAPDMC/LSM_F4_SERVER_FILE'
exporting
directory = './' " c_path
filemask = space
importing
serverfile = l_file
exceptions
canceled_by_user = 1
others = 2.
if sy-subrc <> 0.
* Message 'Unable to find filepath'.
message i000(z_zzz_ca_messages) with 'Unable to find filepath'(082).
endif.
endform. "sub_serverfile_f4
‎2008 Jun 20 4:26 PM
CG3Y did pull the file down correctly. Perhaps if the record length had been longer it wouldn't have. My QA person failed my program because she thought the record length was wrong but she was pulling down from AL11 (saving the list).