Not able to get file from application server with read dataset
Hi,
Firstly i download a file from application server from read data set and then i sent this file as attachment. But problem is that i am able to send .jpg .bmp file but i am not able to send .pdf or .doc file so what can i do for that. ?
My code is like below...
DATA : PATH TYPE STRING.
DATA: E_FILE LIKE RLGRAP-FILENAME.
CONCATENATE '/tmp/' NAME_WITH_EXT INTO E_FILE SEPARATED BY SPACE.
CONDENSE E_FILE NO-GAPS.
IF EXTENSION = 'TXT'.
OPEN DATASET E_FILE FOR INPUT IN TEXT MODE ENCODING DEFAULT WITH WINDOWS LINEFEED . " MESSAGE MSG.
IF SY-SUBRC <> 0.
WRITE: SY-SUBRC, MSG, ' LIKE ', C_FNAME.
ELSE.
WHILE SY-SUBRC = 0.
READ DATASET E_FILE INTO WA_C.
IF SY-SUBRC <> 0.
EXIT.
ENDIF.
APPEND WA_C TO IT_C.
ENDWHILE.
CLOSE DATASET E_FILE.
ENDIF.
ELSE.
OPEN DATASET E_FILE FOR INPUT IN BINARY MODE. " ENCODING DEFAULT. " INPUT IN BINARY MODE . " TEXT MODE ENCODING NON-UNICODE.
IF SY-SUBRC = 0.
DO .
READ DATASET E_FILE INTO GS_PDF_TAB.
IF SY-SUBRC = 0.
APPEND GS_PDF_TAB TO GT_PDF_TAB.
ELSE.
EXIT.
ENDIF.
ENDDO.
CLOSE DATASET E_FILE.
ENDIF.
ENDIF.
Regards,
Gurprit Bhatia
delete this line DEFAULT WITH WINDOWS LINEFEED and check this..
Similar Messages
-
Reading File from Application Server using Read Dataset
Hi,
i am trying to read excel file from Application Server and has multiple records in that based on structure below. but when i execute its giving me error message.here is the code, can sumone suggest me on this please ??
FORM f_data_upload .
DATA:
l_filename TYPE string, "file name
l_wa_string TYPE string. "file record
l_filename = p_inp_as. "File path from Application Server
OPEN DATASET l_filename FOR INPUT IN TEXT MODE ENCODING DEFAULT.
DO.
IF sy-subrc <> 0.
EXIT.
ENDIF.
Read the data from the file in Application server.
READ DATASET l_filename INTO l_wa_string.
IF sy-subrc = 0.
SPLIT l_wa_string AT cl_abap_char_utilities=>horizontal_tab
INTO w_data-tcode
w_data-matnr
w_data-mtart
w_data-werks
w_data-vkorg
w_data-vtweg
w_data-lgort
w_data-meins
w_data-maktx
w_data-spart
w_data-kosch
w_data-mstae
w_data-brgew
w_data-ntgew
w_data-groes
w_data-matkl
w_data-prdha
w_data-mstde
w_data-mtpos_mara
w_data-gewei
w_data-spart
w_data-mstav
w_data-mstdv
w_data-dwerk
w_data-taxkm
w_data-versg
w_data-kondm
w_data-ktgrm
w_data-mtpos
w_data-mtvfp
w_data-tragr
w_data-ladgr
w_data-herkl
w_data-ekgrp
w_data-webaz
w_data-dismm
w_data-beskz
w_data-prctr
w_data-bklas
w_data-bwtty
w_data-vprsv
w_data-verpr
IN CHARACTER MODE.
APPEND w_data TO i_data.
CLEAR w_data.
ENDIF.
ENDDO.
CLOSE DATASET l_filename.
Error Message while executing
What happened?
At the conversion of a text from codepage '4110' to codepage '4102':
- a character was found that cannot be displayed in one of the two
codepages;
- or it was detected that this conversion is not supported
The running ABAP program 'ZHDI_LOMM_VEHI_MAT_MASS_CREATE' had to be terminated
as the conversion
would have produced incorrect data.
The number of characters that could not be displayed (and therefore not
be converted), is 449. If this number is 0, the second error case, as
mentioned above, has occurred.
Error analysis
An exception occurred that is explained in detail below.
The exception, which is assigned to class 'CX_SY_CONVERSION_CODEPAGE', was not
caught in
procedure "F_DATA_UPLOAD" "(FORM)", nor was it propagated by a RAISING clause.
Since the caller of the procedure could not have anticipated that the
exception would occur, the current program is terminated.
The reason for the exception is:
Characters are always displayed in only a certain codepage. Many
codepages only define a limited set of characters. If a text from a
codepage should be converted into another codepage, and if this text
contains characters that are not defined in one of the two codepages, a
conversion error occurs.
Moreover, a conversion error can occur if one of the needed codepages
'4110' or '4102' is not known to the system.
If the conversion error occurred at read or write of screen, the file
name was '/usr/sap/interfaces/conversion/pioneer/ddm/data/test_data1.xls'.
(further information about the file: "X 549
24064rw-rw----200812232135082008122307293120081223072931")
Please help me
Thank YouWoah ... perfect guru
but data looks like all junk characters ? its filling with special characters, hashes # and other characters but not with Excel data.. any idea ??
Temesh
Edited by: New2Sap Abap on Dec 24, 2008 6:42 AM -
How to get files from application server
Hi
I got a requirement like i have some n number of file in application server at specified path now i want to get that files from application server to presentation server.
Please help me out.
Thanks in advance.
Regards
KrishnaHI.
Use this Unix script. Give IP and other details as ur requirment.
Setup variables. #
Input Directory > #
Output Directory > #
Source System > #
Target System > #
Files FTPed > lxxxxx* #
set -x
DATE="`date +%y%m%d%H%M%S`"
FTP destination details.
ftp_host=""
ftp_user=" "
ftp_pass="a"
ftp_remote_dir=" "
File path and names
host_dir=""
ftp_local_file="lxxxx"
ftp_local_file_dir=" "
ftp_arch_dir=" "
ftp_output=" "
FTP
if -f $ftp_local_file_dir ; then
ftp -i -n -d -v $ftp_host<<EOINPUT >$ftp_output
user $ftp_user $ftp_pass
cd $ftp_remote_dir
lcd $host_dir
mget $ftp_local_file
bye
EOINPUT
mv $ftp_local_file_dir $ftp_arch_dir$ftp_remote_file_name
else
echo "ERROR: Local $ftp_local_file_dir does not exist.">>$ftp_output;
fi
exit;
Edited by: Jay on Feb 14, 2008 5:36 PM -
Upload xml file from aplication server using read dataset, parser error.
Hi,
I would like to upload xml file from app. server but parser failed. If I upload this xml file from workstation (using ws_upload) it is correct. For uploading xml file from app. server I use open dataset... read dataset. In loop section I remove '#' char. How do You upload xml file from app server? What Could be incorrect.
I try to open dataset in binary mode, text mode...
TYPES: BEGIN OF xml_line,
data(255) TYPE c,
END OF xml_line.
DATA: gt_xml_table TYPE TABLE OF xml_line,
gs_xml_structure TYPE xml_line,
gv_xml_table_size TYPE i.
OPEN DATASET s FOR INPUT IN BINARY MODE.
IF sy-subrc <> 0.
MESSAGE e001(zet) WITH '....'.
ENDIF.
DO.
READ DATASET s INTO gs_xml_structure.
IF sy-subrc <> 0.
EXIT.
ELSE.
len = STRLEN( gs_xml_structure ).
len = len - 1.
check len > 0.
WRITE gs_xml_structure(len) TO gs_xml_structure.
APPEND gs_xml_structure TO gt_xml_table.
ENDIF.
ENDDO.You Can do this too
parameters: p_file like rlgrap-filename.
data: subrc like sy-subrc.
create object me.
REFRESH t_data.
* Open XML File
CALL METHOD me->CREATE_WITH_FILE
EXPORTING
filename = p_file
RECEIVING
retcode = subrc.
* Saves Data in an itab from XML File.
CALL METHOD me->get_data
IMPORTING
retcode = subrc
CHANGING
dataobject = t_data[].
Regards,
Claudio. -
Logical path for getting a Flat file from application server
Hi All,
We have loaded some .csv files to application server, what is the logical path we have to mention in the infopackage scheduler screen? please guide me how to give the path for getting a flat file from application server.
Thanks,
Sairam.Hi Sairam,
I hope you know which location you have saved in the Application server.
Now if you go to the Infopackage and click on the "External Data" tab, there you will see Radio Buttons for
1) Client Workstation
2) Application Server
Choose the second radio button, then in the Field "Name of the File" you will be able to use the F4 help and browse AL11 transaction through this option. You can then choose the File.
Hope this helps
Regards,
Praveen. -
Not recognizing # while reading the file from application server
Hi
I am reading a file from application server. While reading into internal table with read statement the last field in each record is filling with hash symbol in the last digit. If I write any if condition with HASH symbol its not going inside the if condition, means its not recognizing as hash may be its internally treating as some other. I need to remove the hash from that field. How I can do that.
Thanks,
kishoreI faced exact situation. Yes, internally its treated as some other special character. What i did was, becuase hash symbol was always coming at the end...i created a dummy field in my internal table so that it will not interfere with my actual data. When i see the data in my internal table, the hash always falls in the last field (dummy) which i will ignore. I could not get solution to remove this hash so i adopted this approach and it worked!!
Hope it helps,
SKJ -
Sender File Adapter not able to get file via FTP from an external system
Hi,
I have a Sender File Adapter using FTP which polls a server every 10 seconds looking for a file ".xml". The adapter will connect and pick up the waiting file, but sometimes the adapter not able to get file via FTP from an external system. The file is on the server, but despite the polling, the adapter does not pick up it. There is no return error.
The connect mode is Permanently and the transfer mode is Binary.
Can you help me?
Thanks.
T.Hi Teresa,
does this case appears with a file size higher the others?
Personally, I do not recommend to have a polling under 1min.
10s could be too just, if the file is not small and/or if the file server is far (several kilometers) to where the Adapter Engine is, and/or this file server is beside a firewall. Do not forget also that, with previous points, you could have like a conflict, betwen the 1st polling and the 2nd polling, if in less 10s PI adapter has not enough time: to connect to the FTP server (several Km), find the file (perhaps among 100 other files in the directory), go back to the file to Adapter Engine server (several Km again), convert your file to XML message (with a complex Content Conversion), then check the XML structure, and when all that is done, return back to FTP server (several Km), to archive the source file... Well It's my understanding of a FTP exchange with FILE adapter...
If you really need a 10s polling, that's mean your have a pseudo real time interface. In that case, in my mind file should not be used! but we should use a Web service, JDBC JMS (any exchange without a physical object like a file). For me, it's a non-sens to have a file in that case.
regards.
mickael -
Download PDF file from Application Server in BSP
Hello,
We have a requirement on which we want to download a PDF file stored in Application server using BSP application. I have used function module ARCHIVFILE_SERVER_TO_CLIENT but this FM will help only if i want to download file from GUI it won't work in BSP application.
Further i have used class CL_BSP_UTILITY and download method to download file from application server but it is not working in desired manner.
I am attaching my code for your reference:
DATA: BUTTON_EVENT TYPE REF TO CL_HTMLB_EVENT_BUTTON ,
EVENT TYPE REF TO IF_HTMLB_DATA.
DATA: LS_HOURS LIKE LINE OF GT_HOURS.
DATA STR TYPE STRING.
DATA: OUTPUT TYPE STRING ,
L_XSTRING TYPE XSTRING ,
APP_TYPE TYPE STRING.
EVENT = CL_HTMLB_MANAGER=>GET_EVENT( REQUEST ).
DATA PHY_NAME_OUT TYPE SAPB-SAPPFAD.
IF EVENT IS NOT INITIAL AND EVENT->EVENT_NAME = HTMLB_EVENTS=>BUTTON .
BUTTON_EVENT ?= EVENT .
CASE EVENT->EVENT_SERVER_NAME.
WHEN 'test' .
IF GT_HOURS IS NOT INITIAL.
PHY_NAME_OUT = '/usr/sap/put/form16//01000200_2007.PDF'.
OPEN DATASET PHY_NAME_OUT FOR INPUT IN TEXT MODE ENCODING DEFAULT.
IF SY-SUBRC IS INITIAL.
DO.
READ DATASET PHY_NAME_OUT INTO STR.
IF SY-SUBRC IS INITIAL.
CONCATENATE
OUTPUT
str
cl_abap_char_utilities=>cr_lf
INTO output SEPARATED BY space. "cl_abap_char_utilities=>horizontal_tab
ELSE.
EXIT.
ENDIF.
ENDDO.
ENDIF.
*LOOP AT gt_hours INTO ls_hours.
*CONCATENATE
*OUTPUT
*ls_hours-hour
*cl_abap_char_utilities=>cr_lf
*INTO output SEPARATED BY space. "cl_abap_char_utilities=>horizontal_tab
*ENDLOOP.
APP_TYPE = 'APPLICATION/PDF;charset=utf-16le'.
CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
EXPORTING
TEXT = OUTPUT
MIMETYPE = 'APPLICATION/PDF;charset=utf-16le'
IMPORTING
BUFFER = L_XSTRING.
CONCATENATE CL_ABAP_CHAR_UTILITIES=>BYTE_ORDER_MARK_LITTLE
L_XSTRING
INTO L_XSTRING IN BYTE MODE.
CALL METHOD CL_BSP_UTILITY=>DOWNLOAD
EXPORTING
OBJECT_S = L_XSTRING
CONTENT_TYPE = APP_TYPE
CONTENT_DISPOSITION = 'attachment;filename=webforms.pdf'
RESPONSE = _M_RESPONSE
NAVIGATION = NAVIGATION.
ENDIF.
ENDCASE.
ENDIF.
From this code i am able to download PDF file but it is not opening in local machine.
If any other way to download file then please suggest.
waiting for ur reply.
Regards,
GaganHi,
you do the file reading wrong:
have a look at:
Local declarations.
data:
components type stringtab,
component type string,
path type text255,
file type text255,
line_length type i,
filecontent_binary type sdokcntbin,
rows type sytabix,
content type sdokcntbin,
exception type ref to cx_sy_file_access_error,
exception_tmf type ref to cx_sy_too_many_files ,
block_size type i value 1022,
length type i.
field-symbols:
<hex_container> type x.
constants:
c_dms_blk_size type i value 2550.
clear file_size.
try.
open dataset file_name for input in binary mode message message.
catch cx_sy_file_open into exception.
case exception->textid.
when '4182174D03030063000000000A1551B1'. raise access_error.
when '41825AD355C3005E000000000A1551B1'. raise open_error.
when '47E8B03AECE5BA07E10000000A114829'. raise already_open.
when others.
endcase.
catch cx_sy_file_authority into exception.
case exception->textid.
when '4182174D03030063000000000A1551B1'. raise access_error.
when 'A70BB8396F051547E10000000A11447B'. raise authority_error.
when others.
endcase.
catch cx_sy_too_many_files into exception_tmf.
case exception_tmf->textid.
when '8708B73915F6B645E10000000A11447B'. raise too_many_files.
when others.
endcase.
endtry.
do.
try.
read dataset file_name into filecontent_binary-line.
if sy-subrc <> 0.
add line_length to file_size.
append filecontent_binary to file_content_binary.
exit.
else.
add line_length to file_size.
append filecontent_binary to file_content_binary.
endif.
catch cx_sy_file_open_mode into exception.
case exception->textid.
when '9207B73915F6B645E10000000A11447B'. raise cx_sy_file_open_mode.
when '9807B73915F6B645E10000000A11447B'. raise read_only.
when '9E07B73915F6B645E10000000A11447B'. raise not_open.
when '409D273A2D824360E10000000A11447B'. raise incompatible_mode.
when others.
endcase.
endtry.
enddo.
try.
close dataset file_name.
catch cx_sy_file_close into exception.
case exception->textid.
when '4182174D03030063000000000A1551B1'. raise access_error.
when 'C10BB8396F051547E10000000A11447B'. raise close_error.
when others.
endcase.
catch cx_sy_file_access_error into exception.
case exception->textid.
when '4182174D03030063000000000A1551B1'. raise access_error.
when others.
endcase.
endtry.
Get file size.
split file_name at '/' into table components.
describe table components lines sy-tfill.
read table components into component index sy-tfill.
path = file_name.
replace component in path with ''.
file = component.
call function '/EUH/MMS_GET_FILE_SIZE'
exporting
dir_name = path
file_name = file
importing
file_size = file_size.
and function /euh/mms_get_file_size.
""Local Interface:
*" IMPORTING
*" VALUE(DIR_NAME) TYPE TEXT255
*" VALUE(FILE_NAME) TYPE TEXT255
*" EXPORTING
*" VALUE(FILE_SIZE) TYPE SDOK_FSIZE
*" EXCEPTIONS
*" NO_AUTHORITY
*" ACTIVITY_UNKNOWN
*" NOT_A_DIRECTORY
*" NO_MEDIA_IN_DRIVE
*" TOO_MANY_ERRORS
*" TOO_MANY_FILES
*" BRACKET_ERROR_IN_FILENAME
*" NO_SUCH_PARAMETER
types: begin of files,
line like ocs_file,
end of files.
data: file type files,
f_subrc like sy-subrc value 0,
errno(3) type c,
errmsg(40) type c,
pos type i,
len type i,
parameter(120) type c,
help1(120) type c,
help2(120) type c,
error_counter type i.
data:
dir_list like ocs_file occurs 0 with header line.
CASE sy-subrc.
WHEN 1. f_subrc = 64.
WHEN 2. f_subrc = 65.
WHEN 0.
search dir_name for 'SY-HOST'. "Is SY-HOST used in directory name?
if sy-subrc = 0.
pos = sy-fdpos + 7.
move dir_name(sy-fdpos) to help1.
move dir_name+pos to help2.
concatenate help1 sy-host help2 into dir_name.
endif.
do 12 times. " To avoid endless loop
if dir_name cs '$('. " Replace parameter by their value
pos = sy-fdpos + 2.
if dir_name cs ')'.
len = sy-fdpos - pos.
if len le 0.
f_subrc = 4. exit.
else.
parameter = dir_name+pos(len).
call 'C_SAPGPARAM' id 'NAME' field parameter
id 'VALUE' field parameter.
if sy-subrc = 0.
len = pos + len + 1.
pos = pos - 2.
if pos > 0.
move dir_name(pos) to help1.
else.
help1 = ''.
endif.
pos = strlen( dir_name ).
if pos > len.
move dir_name+len to help2.
else.
help2 = ''.
endif.
concatenate help1 parameter help2 into dir_name.
else.
f_subrc = 8. exit.
endif.
endif.
else.
exit.
endif.
else.
exit.
endif.
enddo.
shift dir_name right deleting trailing '/\ '.
shift dir_name left deleting leading space.
call 'C_DIR_READ_FINISH' " this is from RSWATCH0
id 'ERRNO' field errno
id 'ERRMSG' field errmsg.
call 'C_DIR_READ_START'
id 'DIR' field dir_name
id 'FILE' field file_name
id 'ERRNO' field errno
id 'ERRMSG' field errmsg.
case sy-subrc.
when 1.
case errno.
when 2 or 20. f_subrc = f_subrc + 66.
when ' '. f_subrc = f_subrc + 67.
endcase.
when 0.
clear error_counter.
do.
clear file.
clear dir_list.
call 'C_DIR_READ_NEXT'
id 'TYPE' field file-line-type
id 'NAME' field file-line-name
id 'LEN' field file-line-len
id 'OWNER' field file-line-owner
id 'MTIME' field file-line-mtime
id 'MODE' field file-line-acc_mode
id 'ERRNO' field errno
id 'ERRMSG' field errmsg. "sy-subrc = 3 is e.g. if return
if sy-subrc = 0 or sy-subrc = 3."data do not fit into variables
perform p6_to_date_time_tz(rstr0400) using
file-line-mtime
file-line-mod_time
file-line-mod_date.
file_size = file-line-len.
dir_list = file-line.
append dir_list.
elseif sy-subrc = 1. " nothing (more) found
exit.
else.
if error_counter > 50.
call 'C_DIR_READ_FINISH'
id 'ERRNO' field errno
id 'ERRMSG' field errmsg.
pos = f_subrc mod 2.
if pos = 0. f_subrc = f_subrc + 1. endif.
exit.
endif.
add 1 to error_counter.
endif.
if sy-index > 1000.
pos = f_subrc mod 4.
if pos = 0. f_subrc = f_subrc + 2. endif.
exit.
endif.
enddo.
call 'C_DIR_READ_FINISH'
id 'ERRNO' field errno
id 'ERRMSG' field errmsg.
if sy-opsys(3) = 'Win' and not ( file_name cs '*' ).
describe table dir_list lines len.
if len = 0.
help1 = file_name.
translate help1 to upper case.
translate help1 using
'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.
call 'C_DIR_READ_START'
id 'DIR' field dir_name
id 'FILE' field help1.
if sy-subrc = 0.
clear error_counter.
do.
clear file.
clear dir_list.
call 'C_DIR_READ_NEXT'
id 'TYPE' field file-line-type
id 'NAME' field file-line-name
id 'LEN' field file-line-len
id 'OWNER' field file-line-owner
id 'MTIME' field file-line-mtime
id 'MODE' field file-line-acc_mode
id 'ERRNO' field errno
id 'ERRMSG' field errmsg.
if sy-subrc = 0 or sy-subrc = 3.
help2 = file_name.
translate help2 to upper case.
help1 = file-line-name.
translate help1 to upper case.
if help1 = help2.
perform p6_to_date_time_tz(rstr0400) using
file-line-mtime
file-line-mod_time
file-line-mod_date.
dir_list = file-line.
append dir_list.
endif.
elseif sy-subrc = 1.
exit.
else.
if error_counter > 50.
call 'C_DIR_READ_FINISH'
id 'ERRNO' field errno
id 'ERRMSG' field errmsg.
pos = f_subrc mod 2.
if pos = 0. f_subrc = f_subrc + 1. endif.
exit.
endif.
add 1 to error_counter.
endif.
if sy-index > 1000.
pos = f_subrc mod 4.
if pos = 0. f_subrc = f_subrc + 2. endif.
exit.
endif.
enddo.
call 'C_DIR_READ_FINISH'
id 'ERRNO' field errno
id 'ERRMSG' field errmsg.
endif.
endif.
endif.
endcase.
ENDCASE.
CASE f_subrc.
WHEN 1 OR 3. RAISE too_many_errors.
WHEN 2. RAISE too_many_files.
WHEN 4 OR 5 OR 6 OR 7 OR 70 OR 71.
RAISE bracket_error_in_filename.
WHEN 8 OR 9 OR 10 OR 11 OR 74 OR 75.
RAISE no_such_parameter.
WHEN 64. RAISE no_authority.
WHEN 65. RAISE activity_unknown.
WHEN 66. RAISE not_a_directory.
WHEN 67. RAISE no_media_in_drive.
ENDCASE.
endfunction.
Now you will be able to get the filesize and the file in SDOK format sdokbin.
Okay.
You have to build an request and push the content to the user like:
call method server->response->set_header_field( name = 'Content-Type' value = value ).
describe field file_content_binary-line length line_length in byte mode.
bytes_rest = file-size.
loop at file_content_binaries assigning <file_content_binary>.
move <file_content_binary>-line to data.
if bytes_rest <= 0. "mismatch between line values and size
exit.
endif.
if bytes_rest >= line_length.
call method server->response->append_data( data = data
length = line_length ).
else.
call method server->response->append_data( data = data
length = bytes_rest ).
endif.
bytes_rest = bytes_rest - line_length.
endloop.
This will work.
You can set the header fields like you want. Have also a look at sicf node contentserver
and its handler: CL_HTTP_EXT_CSIF -
File from Application server into BW
Hi All,
I have a urgent requirement and I do not know much of ABAP
The requirement is
selecting existing file from application server Dynamically in BW server. This will be done by writing an ABAP code at the InfoPackage level in the External Data Tab but I am in need some ABAP code for the same
Also let me know which table stores AL11 files
I know USER_DIR stores directories but I required the table for the files within the directories.
Any help is appreciatedHi DPN,
If we have a condition like depending on System Date we have to get a file some thing like that then we can do that by using the ABAP Routine. But in your Scenario there are no specific conditions to select a file.
If we have some variable which stores the value which we give and gets the specified file... That Would be Great.
But in Routine we can not use Variables..(As Far As I Know)
So better Select manually every time...
Hope This Helps.
Regards,
rik. -
File from application server-- Email ?
Hi,
I need to pickup a file from application server and Email the same to the intended receipents through ABAP program
For that i had used the following code:
REPORT ZEMAIL_APP_SER_FAIL.
DATA :is_doc_chng TYPE sodocchgi1,
it_objtxt TYPE STANDARD TABLE OF solisti1,
is_objtxt TYPE solisti1,
it_objpack TYPE STANDARD TABLE OF sopcklsti1,
is_objpack TYPE sopcklsti1,
it_objbin TYPE STANDARD TABLE OF solisti1,
is_objbin TYPE solisti1,
it_reclist TYPE STANDARD TABLE OF somlreci1,
is_reclist TYPE somlreci1,
w_lines_tx TYPE i.
** Create Message Body
** Title and Description
*is_doc_chng-obj_name = 'MAIL'.
is_doc_chng-obj_descr = 'Auto genareted Mail from Application server'.
** main text
is_objtxt-line = 'This is an automatically generated mail. Please do not reply to it.'(028).
APPEND is_objtxt TO it_objtxt.
is_objtxt-line = space.
APPEND is_objtxt TO it_objtxt.
* write packing list (main)
DESCRIBE TABLE it_objtxt LINES w_lines_tx.
READ TABLE it_objtxt INTO is_objtxt INDEX w_lines_tx.
is_doc_chng-doc_size = ( w_lines_tx - 1 ) * 255 + STRLEN( is_objtxt ).
CLEAR is_objpack-transf_bin.
is_objpack-head_start = 1.
is_objpack-head_num = 0.
is_objpack-body_start = 1.
is_objpack-body_num = w_lines_tx.
is_objpack-doc_type = 'CVS'.
is_objpack-OBJ_NAME = 'GIND_EXP'.
is_objpack-Obj_langu = 'E'.
APPEND is_objpack TO it_objpack.
is_reclist-receiver = 'XXX'@'YYY'.COM'.
is_reclist-rec_type = 'A'.
Break-point.
*is_reclist-REC_ID = 'XXX@YYY'.COM'.
APPEND is_reclist TO it_reclist.
CLEAR is_reclist.
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = is_doc_chng
put_in_outbox = 'X'
commit_work = 'X'
TABLES
packing_list = it_objpack
contents_txt = it_objtxt
receivers = it_reclist
EXCEPTIONS
too_many_receivers = 1
document_not_sent = 2
document_type_not_exist = 3
operation_no_authorization = 4
parameter_error = 5
x_error = 6
enqueue_error = 7
OTHERS = 8.
IF sy-subrc NE 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
when i execute this program:
I get the following error msg:
Activation setting not yet maintained
May i know what is the problem?If you are sending an email, the receiver type should be U (internet mail address type). From your code it appears that you have input it as 'A'. I am not sure if the error message is related to this. Have you checked in transaction SOST, whether an email has been triggered from your program? At what point of execution is this error message triggered?
-
File from application server -Read and process and delete the file .
Hi All,
I writing a ZEE program which will read the file from application server(file will be in text delimat format) and moving the data to internal table and uploadind data base.The part which iam facing problem is -
> I hve read the file from application server like below ,
OPEN DATASET ld_file FOR INPUT IN TEXT MODE ENCODING DEFAULT.
IF sy-subrc NE 0.
EXIT.
ELSE.
DO.
CLEAR: wa_string, wa_uploadtxt.
READ DATASET ld_file INTO wa_string.
IF sy-subrc NE 0.
EXIT.
ELSE.
SPLIT wa_string AT con_tab INTO wa_uploadtxt-name1
wa_uploadtxt-name2
wa_uploadtxt-age.
Spliting part i having problem .i need to seperate each field which is seperate from tab delimite and pass it into respective fields of internal table .
Second if another file come to the appicaltion server , wether my first file will be there ? or should i need to delete the first file after redaing how should i proceed further ?.
Regards
SRIRAM...
THANKS In ADVANCEHI,
1.
OPEN DATASET ld_file FOR INPUT IN TEXT MODE ENCODING DEFAULT.
IF sy-subrc NE 0.
EXIT.
ELSE.
DO.
CLEAR: wa_string, wa_uploadtxt.
READ DATASET ld_file INTO wa_string.
IF sy-subrc NE 0.
EXIT.
ELSE.
SPLIT wa_string AT cl_abap_char_utilities=>horizontal_tab INTO wa_uploadtxt-name1
wa_uploadtxt-name2
wa_uploadtxt-age.
APPEND wa_uploadtxt TO itab.
ENDDO.
CLOSE DATASET ld_file.
ENDIF.
2. If the another file get's generated in the application server with same file name then the data in old file get's over written with the new data. You are not required to delete the file. -
Read Tab delimited File from Application server
Hi Experts,
I am facing problem while reading file from Application server.
File in Application server is stored as follows, The below file is a tab delimited file.
##K#U#N#N#R###T#I#T#L#E###N#A#M#E#1###N#A#M#E#2###N#A#M#E#3###N#A#M#E#4###S#O#R#T#1###S#O#R#T#2###N#A#M#E#_#C#O###S#T#R#_#S#U#P#P#L#1###S#T#R#_#S#U#P#P#L#2###S#T#R#E#E#T###H#O#U#S#E#_#N#U#M#1
i have downloaded this file from Application server using Transaction CG3Y. the Downloaded file is a tab delimited file and i could not see "#' in the file,
The code is as Below.
c_split TYPE abap_char1 VALUE cl_abap_char_utilities=>horizontal_tab.
here i am using IGNORING CONVERSION ERRORS in order to avoid Conversion Error Short Dump.
OPEN DATASET wa_filename-file FOR INPUT IN TEXT MODE ENCODING DEFAULT IGNORING CONVERSION ERRORS.
IF sy-subrc = 0.
WRITE : /,'...Processing file - ', wa_filename-file.
DO.
Read the contents of file
READ DATASET wa_filename-file INTO wa_file-data.
IF sy-subrc = 0.
SPLIT wa_file-data AT c_split INTO wa_adrc_2-kunnr
wa_adrc_2-title
wa_adrc_2-name1
wa_adrc_2-name2
wa_adrc_2-name3
wa_adrc_2-name4
wa_adrc_2-name_co
wa_adrc_2-city1
wa_adrc_2-city2
wa_adrc_2-regiogroup
wa_adrc_2-post_code1
wa_adrc_2-post_code2
wa_adrc_2-po_box
wa_adrc_2-po_box_loc
wa_adrc_2-transpzone
wa_adrc_2-street
wa_adrc_2-house_num1
wa_adrc_2-house_num2
wa_adrc_2-str_suppl1
wa_adrc_2-str_suppl2
wa_adrc_2-country
wa_adrc_2-langu
wa_adrc_2-region
wa_adrc_2-sort1
wa_adrc_2-sort2
wa_adrc_2-deflt_comm
wa_adrc_2-tel_number
wa_adrc_2-tel_extens
wa_adrc_2-fax_number
wa_adrc_2-fax_extens
wa_adrc_2-taxjurcode.
WA_FILE-DATA is having below values
##K#U#N#N#R###T#I#T#L#E###N#A#M#E#1###N#A#M#E#2###N#A#M#E#3###N#A#M#E#4###S#O#R#T#1###S#O#R#T#2###N#A#M#E#_#C#O###S#T#R#_#S#U#P#P#L#1###S#T#R#_#S#U#P#P#L#2###S#T#R#E#E#T###H#O#U#S#E#_#N#U#M#1
And this is split by tab delimited and moved to other variables as shown above.
Please guide me how to read the contents without "#' from the file.
I have tried all possible ways and unable to get solution.
Thanks,
ShrikanthHi ,
In ECC 6 if all the unicode patches are applied then UTF 16 will defintly work..
More over i would suggest you to ist replace # with some other * or , and then try to see in debugging if any further # appears..
and no # appears then try to split now.
if even now the # appears after replace statement then try to find out what exactly is it... wheather it is a horizantal tab etc....
and then again try to replace it and then split..
Please follow the process untill all the # are replaced...
This should work for you..
Let me know if you further face any issue...
Regards
Satish Boguda -
Problem in uploading file from Application Server
Hi everyone,
i got a problem in uplaoding a file from application server.i am having two folder (one folder name is current and another one is processed)in application server. In current folder i am having N no of files.I want to upload all the files names into one internal table and i want to process one by one file.After processing each file the file should be moved to processed folder and the files should not exist in current folder.All these process must be done everyday.Please rectify my problem asap.Ramesh,
Take authorization from basis guy.
Use the below code to get the list of files from require directory
*& Report ZDIRFILES *
REPORT ZDIRFILES .
PARAMETER: p_fdir type pfeflnamel DEFAULT '/usr/sap/tmp'.
data: begin of it_filedir occurs 10.
include structure salfldir.
data: end of it_filedir.
*START-OF-SELECTION
START-OF-SELECTION.
Get Current Directory Listing for OUT Dir
call function 'RZL_READ_DIR_LOCAL'
exporting
name = p_fdir
tables
file_tbl = it_filedir.
Now in internal table "it_filedir" will have all your files.
For moving and deleting
report zrich_0001.
Parameters: d1 type localfile default '/usr/sap/TST/SYS/fld1/Data1.txt',
d2 type localfile default '/usr/sap/TST/SYS/fld2/Data1.txt'.
data: begin of itab occurs 0,
rec(20) type c,
end of itab.
data: wa(20) type c.
start-of-selection.
open dataset d1 for input in text mode.
if sy-subrc = 0.
do.
read dataset d1 into wa.
if sy-subrc <> 0.
exit.
endif.
itab-rec = wa.
append itab.
enddo.
endif.
close dataset d1.
open dataset d2 for output in text mode.
loop at itab.
transfer itab to d2.
endloop.
close dataset d2.
delete dataset d1.
Check below FM if required
To move the file to archive directoryuse FMs 'PFL_COPY_OS_FILE'
To Delete 'EPS_DELETE_FILE'.
Don't forgot to reward if useful -
Problem in reading file from application server
while reading the file from application server i am succesful in reading from dataset but the program gets terminated giving a runtime error "CONVT_CODEPAGE".
the code written is as below :
open dataset d1 for input in text mode encoding default.
IF sy-subrc NE 0.
EXIT.
ENDIF.
do.
Read dataset d1 into btab.
if sy-subrc <> 0.
exit.
else.
condense btab NO-GAPS.
wtt_text-text1 = btab-wa+0(10).
wtt_text-text2 = btab-wa+10(1).
wtt_text-text3 = btab-wa+11(3).
append wtt_text.
clear wtt_text.
wt_counter = wt_counter + 1.
ENDIF.
enddo.
write : /10 ' number of records :'.
write : wt_counter.
kindly help me asap.
regards,
rachu.If I am not wrong you are working on a Unicode enabled system. That is why this error is coming.
Look at the link below, where the solution is provided.
http://help.sap.com/saphelp_nw2004s/helpdata/en/79/c554dcb3dc11d5993800508b6b8b11/content.htm
open dataset DSN in text mode for output encoding utf-8.
Regards,
Ravi
Note - Please close the thread by selecting PROBLEM SOLVED against the answer which helped your most, if the issue is resolved. -
How to transfer file from application server to presentation server in background?
Hi Experts,
How to transfer file from application server to presentation server in background?
Thanks in advance
NamitaThanks Raman and Challa,
We want to move file from application server to Shared folder, not on local machine. We checked FM which you guys have provided but those are not able to read file from application server.
We need this program to run in background so that we can use this in daily process chain.
Appreciate your inputs on this.
Thanks,
Namita
Maybe you are looking for
-
Creating Sales Order using inbound IDOC
hi, Using test tool WE19 if i create sales order in foregound no error occurs and order is created successfully but if i try to create in backgound it gives error "No batch input data for screen SAPMSSY0 0120". please suggest a way out .
-
Hi I want to do different operations in a single form. It is like saving data,clearing all and save&clear submit buttons. How to perform all these in a same jsp program (it includes database operations too). Thanks. Jency.
-
How to read magnetic stripe cards
hello everybody, I have asked about magnetic stripe cards regularly. can any one tell me whether the data reading can be done from simple array copy function or we need anything else. does the card listener works for the magnetic stripe in same way .
-
What version of Blackberry desktop manager is compatible with Mac OS 10.7 Lion
What version of Blackberry desktop manager is compatible with Mac OS 10.7 Lion?
-
How to make a collage of 7 photos?
How to make a collage of 7 photos, using 7 photos?