Read excel file in application server to internal table
Hi,
I have an excel file located in some folder in my application server. I don't have excel installed in the server. Now I want to read the excel file data into an internal table. I tried to use READ DATASET, but it returned junk characters.
I have searched SDN extensively for this, but without any succesful answer.
Regards,
Arun.
Hi Arun,
Please check the code below for your reference.
TABLES:eket.
TYPE-POOLS truxs.
DATA it_truxs(4056) TYPE c OCCURS 0.
DATA:v_dt(2),filename TYPE string,
i_temp TYPE truxs_t_text_data.
DATA:BEGIN OF it_eket OCCURS 0,
ebeln LIKE eket-ebeln,
ebelp LIKE eket-ebelp,
etenr LIKE eket-etenr,
eindt LIKE eket-eindt,
END OF it_eket.
PARAMETERS: p_path TYPE rlgrap-filename.
SELECTION-SCREEN : PUSHBUTTON /2(10) pb_but1 USER-COMMAND get.
PARAMETERS:p_no TYPE i.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_path.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
program_name = sy-cprog
dynpro_number = sy-dynnr
IMPORTING
file_name = p_path.
START-OF-SELECTION.
REFRESH :it_eket,i_temp,it_truxs.
filename = p_path.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = filename
filetype = 'ASC'
* has_field_separator = 'X'
TABLES
data_tab = i_temp.
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
i_field_seperator = 'X'
i_tab_raw_data = i_temp
i_filename = p_path
TABLES
i_tab_converted_data = it_eket
EXCEPTIONS
conversion_failed = 1
OTHERS = 2.
SORT it_eket BY ebeln.
DELETE ADJACENT DUPLICATES FROM it_eket COMPARING ebeln.
Similar Messages
-
Error while reading excel file from application server into internal table.
Hi experts,
My requirement is to read an excel file from application server into internal table.
Hence I have created an excel file fm_test_excel.xls in desktop and uploaded to app server using CG3Z tcode (as BIN file type).
Now in my program I have used :
OPEN DATASET v_filename FOR INPUT IN text mode encoding default.
DO.
READ DATASET v_filename INTO wa_tab.
The statement OPEN DATASET works fine but I get a dump (conversion code page error) at READ DATASET statement.
Error details:
A character set conversion is not possible.
At the conversion of a text from codepage '4110' to codepage '4103':
- 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 'Y_READ_FILE' 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 445. If this number is 0, the second error case, as
mentioned above, has occurred.
An exception occurred that is explained in detail below.
The exception, which is assigned to class 'CX_SY_CONVERSION_CODEPAGE', was not
caught and
therefore caused a runtime error.
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 '4103' is not known to the system.
If the conversion error occurred at read or write of screen, the file
name was '/usr/sap/read_files/fm_test_excel.xls'. (further information about
the file: "X 549 16896rw-rw----201105170908082011051707480320110517074803")
Also let me know whether this is the proper way of reading excel file from app server, if not please suggest an alternative .
Regards,
KarthikHi,
Try to use OPEN DATASET v_filename FOR INPUT IN BINARY mode encoding default. instead of OPEN DATASET v_filename FOR INPUT IN text mode encoding default.
As I think you are uploading the file in BIN format to Application server and trying to open text file.
Regards,
Umang Mehta -
Read Excel File on Application Server to Internal Table
Hi Everybody!
Can anyone tell me how I can Read in an Excel File from the Application Server?
I'm familiar with the OPEN DATASET Statement and I already use it to read in text files.
Important is, that it works in the Batch / can be used as a background job
I already tried using
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
which did not work.
Can anybody please help me`?
I created the file I try to read out from the Application Server Folder with the Standard upload
in ABAP Web Dynpro and Wrote it to the Server with the following code. Does anyone know
if maybe already the writing is to the application server is wrong?
try.
convt = cl_abap_conv_in_ce=>create(
input = lv_filedata
encoding = 'UTF-8'
replacement = '?'
ignore_cerr = abap_true ).
convt->read( importing data = s_cont ).
catch cx_sy_conversion_codepage.
wd_comp_controller->show_error( exporting
text = 'There occurred an error during conversioning the code page.' type = 'E' ).
endtry.
open dataset XLSFILEPATH for output in binary mode.
transfer s_cont TO XLSFILEPATH.
close dataset XLSFILEPATH.
Best Regards and Thanks,
SteffenHi Suhan,
I tried the following, but the output in the table doesn't look good at all
Can you please help?
OUTPUT:
??#u0871#?################>###??##############################=#######????########???????????????????????????????????????????????????????????????????????????????????????????????????????
####################################################################################### ###!###"#######$###%###&###'###(###)###*###+###,###-###.###/###0###1###2###3###4###5###6###7#
#?######Z##A#r#i#a#l###3########,#####0#\# #"#? "#;#\#-###,#####0#\# #"#? "###=########,#####0#\# #"#? "#;#[#R#e#d#]#\#-###,#####0#\# #"#? "###?########,#####0#.#0#0#\# #"#? "#;#\#-
###?? ##?########? ?#######?? ##?########? ?#######?? ##?#P######? ?#######?? ##?#P######? ?#######?? ##?# ######? ?#######?? #################A#?#?j}#(#}############################
##########?########}#?#}#############*##################_#? _#-########????#,#####0########????#? _#-#;########????#"#?#?#\########????#_#-#@#_
#######????########}#(#}#############+##################_#? _#-}#(#}#############,##################_#? _#-}#(#}#############-##################_#? _#-}#(#}#############.###########
##########?########}#<#}#############6#############?}#?#_#? _#-########??#?#,#####0}#<#}#############7#############?e#?#_#? _#-########????#,#####0}#?#}#############8###############
#######????########}#?#}#############9#############????#_#? _#-########????#,#####0########????#? _#-#;########????#"#?#?#\########????#_#-#@#_
#######????########}#(#}#############:##################_#? _#-}#-#}#############;##################_#? _#-#####}#P#}#############<##################_#? _#-#############,#####0#####
##Check Cell?#z#?##############?
#C#h#e#c#k# #C#e#l#l##########?##????########????#####?##????#######?##????#######?##????#######?##????##?###+?#??# #?##############?##C#o#m#m#a#####?###,?#??#(#?##############?##C#
#5####Input?#p#?##############?##I#n#p#u#t##########?##?u0319?#####?##??v?#####?#####?#######?#####?#######?#####?#######?#####?##?###6####Linked Cell?#F#?##############?##L#i#n#k#e#d#
?##N#o#t#e##########?##????#####?##????#######?##????#######?##????#######?##????##?###9####Output?#r#?##############?##O#u#t#p#u#t##########?##????#####?##????#####?##????#######?#
#;####Title?#1#?##############?##T#i#t#l#e##############I}?%####?#
#<####Total?#H#?##############?##T#o#t#a#l################?########O???##########O???##?###=####Warning Text?#:#?##############?##W#a#r#n#i#n#g# #T#e#x#t##########?##?##??#X#?######
##Commission###Health Incentive ###Housing Norm###Hypo Tax###Hypo Tax- Special Wages###Paid Time Off(##Vision Insurance- Withheld from Employee###Working Spouse/DP surcharge)##TX St
###########?#?#?######### #########c###?3###N##?h##?t##nu############d#################????MbP?_#####*#####+#####?#####?###########%#####?#?###?#########?#####?#####&###ffffff??'###
#I#######}########+######}#######$
######}#######m###############c###################?###################?###################?###################?###################?###################?###################?##########
CODING:
types: begin of st_excel_parse,
clientno type string,
fileid type string,
paymtreportingid type string,
name type string,
employee_id type string,
home_country type string,
host_country type string,
actstartdt type string,
actenddt type string,
assignment_status type string,
paymttypenm type string,
paymtcategorynm type string,
paymtdt type string,
transeffdt type string,
amount type string,
currency_code type string,
end of st_excel_parse.
data: ls_excel_parse type st_excel_parse,
lt_excel_parse type table of st_excel_parse.
data l_wa_raw_data type string.
open dataset gv_str_filename for input in text mode encoding default.
if sy-subrc = 0.
do.
read dataset gv_str_filename into l_wa_raw_data.
if sy-subrc = 0.
"Split the file record using <TAB> and store inside the work area
split l_wa_raw_data at cl_abap_char_utilities=>horizontal_tab into :
ls_excel_parse-clientno
ls_excel_parse-fileid
ls_excel_parse-paymtreportingid
ls_excel_parse-name
ls_excel_parse-employee_id
ls_excel_parse-home_country
ls_excel_parse-host_country
ls_excel_parse-actstartdt
ls_excel_parse-actenddt
ls_excel_parse-assignment_status
ls_excel_parse-paymttypenm
ls_excel_parse-paymtcategorynm
ls_excel_parse-paymtdt
ls_excel_parse-transeffdt
ls_excel_parse-amount
ls_excel_parse-currency_code .
append ls_excel_parse to lt_excel_parse.
endif.
enddo.
endif. -
Open data set for reading excel file on application server in back ground
open data set for reading excel file on application server in back ground
hi Vijay,
I am afraid you won't be able to read from Excel file on Appl. Server.
ec -
Upload XML file from Application Server to Internal Table
Hi Experts,
i have xml file in application server and i want to convert to internal table .
i have tried this link http://wiki.sdn.sap.com/wiki/display/ABAP/UploadXMLfiletointernal+table.
Here the file is loaded from local(presentation Server) ..
i want to know how to select file from application layer ..and schedule in background..
i also tried FM '/SAPDMC/LSM_F4_SERVER_FILE' but this need front end selection of file from application server..
i need to select a xml file from application server and convert into internal table in background.. help me on this..Have a look on
Re: How to convert XML data to different ABAP internal table
Thanks
Ravin -
Read the file on application server and Z table as Link in ALV report.
Hi ,
I need some suggession on following requirement.
I need to develop an ALV report where, I have to display 6 column. Four rows are kind of data which i am getting from some tables. But other two column are link to Excel files. So following are the two cases
Case 1: One of these column has a link, and when you select this link , an Excel file gets open and this Excel file is stored in Application server.
Case 2: The other column, will have a link and after selecting the link, an Excel file gets open but this time the Excel file is coming from a Z table( Stored as File name..file type and File content).
Please give some light on these two cases.
Regards
PGHi PG,
If I understood you have to handle some different links.
Well,
you can try to do this:
1- when you fill the fieldcat structure you have to add --> fieldcat-hotspot = 'X', for each column you want to handle like hotspot.
2- manage the method hotspot_click of class cl_event_receiver where you can handle your different excel files.
Let me know,
bye
Alessandro -
How to transfer excel files(on ftp server) into internal table?
hello,everyone
pls tell me how to transfer excel files those on a ftp server into internal table?
ps.i know the function 'ftp_server_to_r3',it can help to transfer flat file.Hi,
I believe you want to get the data from the FTP Server to R3.
I am also sending the code. Have a look and it would help you.
First get the Password and user name and the FTP Server Path where file is stored and FTP Server Host name
FUNCTION zfi_ftp_get.
*"*"Local Interface:
*" IMPORTING
*" VALUE(I_FILENAME) TYPE C
*" TABLES
*" T_BLOB STRUCTURE ZFI_TLM_LENGTH OPTIONAL " is a table type with a field called line of length 992
*" RETURN STRUCTURE BAPIRET2 OPTIONAL
DATA : i_password(30) TYPE c,
i_user(30) TYPE c,
i_host(30) TYPE c,
i_rfc_destination TYPE rfcdes-rfcdest,
i_length TYPE i,
i_folder_path(100) TYPE c.
DATA: lv_blob_length TYPE i.
DATA: lv_length TYPE i, "Password length
lv_key TYPE i VALUE 26101957,
lv_password(30) TYPE c,
lv_ftp_handle TYPE i,
lv_cmd(80) TYPE c.
DATA: BEGIN OF result OCCURS 0,
line(100) TYPE c,
END OF result.
TYPES: BEGIN OF ty_dummy,
line(392) TYPE c,
END OF ty_dummy.
DATA: lt_dummy TYPE TABLE OF ty_dummy,
ls_dummy LIKE LINE OF lt_dummy.
i_password = 'vnhdh'.
i_user = 'sdkgd'.
i_host = 'sbnksbg'.
i_rfc_destination = 'SAPFTP'.
i_length = '992'.
i_folder_path = '/hioj/hohjk/hh'.
lv_length = STRLEN( i_password ).
CALL FUNCTION 'HTTP_SCRAMBLE'
EXPORTING
SOURCE = i_password
sourcelen = lv_length
key = lv_key
IMPORTING
destination = lv_password.
CALL FUNCTION 'FTP_CONNECT'
EXPORTING
user = i_user
password = lv_password
host = i_host
rfc_destination = i_rfc_destination
IMPORTING
handle = lv_ftp_handle
EXCEPTIONS
not_connected = 1
OTHERS = 2.
IF sy-subrc = 1.
return-type = 'E' .
return-message = 'FTP Connection not Successful'.
APPEND return.
ELSEIF sy-subrc = 2.
return-type = 'E' .
return-message = 'FTP Connection not Successful'.
APPEND return.
ELSEIF sy-subrc EQ 0.
return-type = 'S' .
return-message = 'FTP Connection Successful'.
APPEND return.
CONCATENATE 'cd' i_folder_path INTO lv_cmd SEPARATED BY space.
CALL FUNCTION 'FTP_COMMAND'
EXPORTING
handle = lv_ftp_handle
command = lv_cmd
TABLES
data = result
EXCEPTIONS
command_error = 1
tcpip_error = 2.
IF sy-subrc = 1.
return-type = 'E' .
return-message = 'Command Error Occured during open of FTP Folder'.
APPEND return.
ELSEIF sy-subrc = 2.
return-type = 'E' .
return-message = 'TCIP Error Occured during open of FTP Folder'.
APPEND return.
ELSE.
REFRESH t_blob.
lv_blob_length = 992.
TRANSLATE i_filename TO LOWER CASE.
CALL FUNCTION 'FTP_SERVER_TO_R3'
EXPORTING
handle = lv_ftp_handle
fname = i_filename
IMPORTING
blob_length = lv_blob_length
TABLES
blob = lt_dummy.
t_blob[] = lt_dummy[].
ENDIF.
ENDIF.
ENDFUNCTION.
Regards
Sajid
Edited by: shaik sajid on Nov 16, 2010 7:25 AM -
Issue with uploading XML file from application server into internal table
i Need to fetch the XML file from the application server and place into internal table and i am getting error message while using the functional module SMUM_XML_PARSE and the error message is "line 1 col 1-unexpected symbol; expected '<', '</', entity reference, character data, CDATA section, processing instruction or comment" and could you please let me know how to resolve this issue?
TYPES: BEGIN OF T_XML,
raw(2000) TYPE C,
END OF T_XML.
DATA:GW_XML_TAB TYPE T_XML.
DATA: GI_XML_TAB TYPE TABLE OF T_XML INITIAL SIZE 0.
DATA:GI_STR TYPE STRING.
data: GV_XML_STRING TYPE XSTRING.
DATA: GI_XML_DATA TYPE TABLE OF SMUM_XMLTB INITIAL SIZE 0.
data:GI_RETURN TYPE STANDARD TABLE OF BAPIRET2.
OPEN DATASET LV_FILE1 FOR INPUT IN TEXT MODE ENCODING DEFAULT.
IF SY-SUBRC NE 0.
MESSAGE 'File does not exist' TYPE 'E'.
ELSE.
DO.
* Transfer the contents from the file to the work area of the internal table
READ DATASET LV_FILE1 INTO GW_XML_TAB.
IF SY-SUBRC EQ 0.
CONDENSE GW_XML_TAB.
* Append the contents of the work area to the internal table
APPEND GW_XML_TAB TO GI_XML_TAB.
ELSE.
EXIT.
ENDIF.
ENDDO.
ENDIF.
* Close the file after reading the data
CLOSE DATASET LV_FILE1.
IF NOT GI_XML_TAB IS INITIAL.
CONCATENATE LINES OF GI_XML_TAB INTO GI_STR SEPARATED BY SPACE.
ENDIF.
* The function module is used to convert string to xstring
CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
EXPORTING
TEXT = GI_STR
IMPORTING
BUFFER = GV_XML_STRING
EXCEPTIONS
FAILED = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
MESSAGE 'Error in the XML file' TYPE 'E'.
ENDIF.
ENDIF.
IF GV_SUBRC = 0.
* Convert XML to internal table
CALL FUNCTION 'SMUM_XML_PARSE'
EXPORTING
XML_INPUT = GV_XML_STRING
TABLES
XML_TABLE = GI_XML_DATA
RETURN = GI_RETURN.
ENDIF.
READ TABLE GI_RETURN TRANSPORTING NO FIELDS WITH KEY TYPE = 'E'.
IF SY-SUBRC EQ 0.
MESSAGE 'Error converting the input XML file' TYPE 'E'.
ELSE.
DELETE GI_XML_DATA WHERE TYPE <> 'V'.
REFRESH GI_RETURN.
ENDIF.Could you please tel me why the first 8 lines were removed, till <Soap:Body and also added the line <?xml version="1.0" encoding="UTF-8"?> in the beggining .
Becuase there will be lot of XML files will be coming from the Vendor daily and that should be uploaded in the application server and should update in the SAP tables based on the data in the XML file.
what information i need to give to vendor that do not add the first 8 lines in the XML file and add the line in the beggining <?xml version="1.0" encoding="UTF-8"?> ??????
Is there any other way we can do with out removing the lines? -
Download file from application server to internal table in background
hi all,
i want to download a file from appliaction server into my internal table but in background.
i had tryed CG3Z and CG3Y t-code but screen that is coming is asking for the parameters, and i want that screen should not appear and file should be saved in the predefined path by me.
if there any way to do so,
Points will be rewarded as per the Aswers.
thaks in advance.Hi Sudeep,
Use this code to get file data from application server.
REPORT ZE0232_BDC_APPLSERVER.
DATA: FILE_PATH TYPE STRING.
FILE_PATH = 'c:\bdc_mat.prn'.
DATA: BEGIN OF ITAB OCCURS 0,
END OF ITAB.
OPEN DATASET FILE_PATH FOR INPUT IN TEXT MODE ENCODING DEFAULT.
IF SY-SUBRC = 0.
DO.
READ DATASET FILE_PATH INTO ITAB.
IF ITAB-RESNO NE SPACE.
APPEND ITAB.
ELSE.
EXIT.
ENDIF.
ENDDO.
ENDIF.
CLOSE DATASET FILE_PATH.
LOOP AT ITAB.
WRITE:/ ITAB.
ENDLOOP.
FILE PATH IS application server path.
IF USEFULL REWARD -
How to read .xls file from FTP server t oInternal table
Hi
am using the FTP_SERVER_TO_R3 to read xls file from FTP server to internal table
but the data i get in LT_TEXT is special characters.
CALL FUNCTION 'FTP_SERVER_TO_R3'
EXPORTING
handle = hdl
fname = f_name "ProdDataFromCRM.xls.
* CHARACTER_MODE = 'X'
* IMPORTING
* BLOB_LENGTH =
TABLES
BLOB = lt_text
* TEXT = lt_text
EXCEPTIONS
TCPIP_ERROR = 1
COMMAND_ERROR = 2
DATA_ERROR = 3
OTHERS = 4
can any one help me out to get the exact data..
Really appreciate your quick response..
Thank YouHi, if you really retrieve an excel file, you can not see the data in ABAP. You may see them in Excel. For this you may use
CALL METHOD document->open_document_from_table
of the interface i_oi_document_proxy for OLE objects. You can access the data with reference to the interface i_oi_spreadsheet.
Please check [Desktop Office Integration (BC-CI)|http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCCIOFFI/BCCIOFFI.pdf] for details.
But, who knows, perhaps you want "And Now For Something Completely Different".
Regards
Clemens -
Reading XML file from application server and put into internal table-4.6C
Dear All,
Is there any way of reading XML file from application server to SAP? I am using 4.6C. Function module SCMS_STRING_TO_XSTRING function module is not available. Please suggest.
Thanks and regards,
AtanuHi Atanu!
Simply use the XSLT transformation 'ID'.
FIELD-SYMBOLS <ls_result> TYPE ANY.
CREATE DATA lref_data TYPE (your_structure).
ASSIGN lref_data->* TO <ls_result>.
CALL TRANSFORMATION id
SOURCE XML xmlstr
RESULT result = <ls_result>.
"xmlstr" contains your XML file. Just read it into it via standard I/O operations. "<ls_result>" will contain your DDIC formatted content.
Best regards
Torsten -
Downloading internal table in excel file on application server
Hi,
I am trying to download ITAB into excel file on my application server . I am using FM 'SAP_CONVERT_TO_XLS_FORMAT' for that .
When I run the report I can see file getting generated on APP server but no ITAB data is saved in that excel.
After debugging I found that error code 'SAVE_DOCUMENT_FAILED' is retuned in above FM.
Could any one please suggest how to go about this?
Regards,
GaneshHi ganesh,
Please have a look into the below link
[Link1|How to Upload Excel file to Application Server]
[Link2|Error in Downloading the Text file on Application Server]
Hope this will be Helpful
Thanks
Kalyan -
Create Excel file in application server but the field value is incorrect
Hi Experts,
i am facing a problem when create excel file in application server using OPEN DATASET command.
the internal table have 4 field and one of those field contains 19 digit number --> ICCID.
the code running well, successfully create EXCELfile in application server but the problem is SAP only copy exactly first 15 digit numeric only and the rest became zero 0
Example :
the field value in internal table is 8962118800000447654 but when i opened in the excel file the value became 8962118800000440000.
and if i add alphabet like a8962118800000447654 then it is correct.
is there is anything wrong with my code?
here is my code
CONSTANTS: c_tab TYPE abap_char1 VALUE cl_abap_char_utilities=>horizontal_tab. "Tab Char
Data : begin of lt_zdsdmmdt00005 occurs 0,
SERNR (18) type c,
MSISDNl(20) type c,
BOX1 (20) type c,
ICCID(30) type c,
end of lt_zdsdmmdt00005.
data : ld_temp(100) type c.
i_file = '/usr/sap/DM/test_excel.xls'.
open dataset i_file for output in legacy text mode.
loop at lt_zdsdmmdt00005.
move lt_zdsdmmdt00005-ICCID to ld_iccid .
concatenate lt_zdsdmmdt00005-sernr lt_zdsdmmdt00005-MSISDN lt_zdsdmmdt00005-BOX1 ld_iccid
into ld_temp separated by c_tab.
transfer ld_temp to i_file.
endloop.
close dataset i_file.
Best Regard,
Akbar.Hi Naveen,
thanks for your reply,
i already tried and the result still the same. any idea?
Best Regard,
Akbar. -
Uploading Excel File in application server
Hi,
I am uploading data from internal table to excel file in application server.I am using Open dataset to put in appln server.(background job).But the problem is it is not sitting in different colums,all data goes to single column.I want every field in separate columns.Please suggest to proceed.Hi,
save the internal table as a desktop file and then use CG3Z transaction to put the data from desktop to application server.
then to read the application file use the logic given below:
DATA: wa_file_data TYPE text4096,
lv_app_server_file TYPE string.
lv_app_server_file = pa_afile.
To read file from Application server
OPEN DATASET lv_app_server_file FOR INPUT IN TEXT MODE ENCODING DEFAULT.
DO.
READ DATASET lv_app_server_file INTO wa_file_data.
IF sy-subrc = 0.
APPEND wa_file_data TO gi_file_data.
ELSE.
EXIT.
ENDIF.
ENDDO.
CLOSE DATASET lv_app_server_file.
DATA: lv_file_separator TYPE c.
lv_file_separator = cl_abap_char_utilities=>horizontal_tab.
To upload file in other formats(CSV, Tab delimited etc)
CALL FUNCTION 'TEXT_CONVERT_TEX_TO_SAP'
EXPORTING
i_field_seperator = lv_file_separator
i_tab_raw_data = gi_file_data
TABLES
i_tab_converted_data = gi_zhralcon_file
EXCEPTIONS
conversion_failed = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
Hope it helps.
Regards,
Rajesh Kumar -
What are the commands available to read a file from application server and
What are the commands available to read a file from application server and store the file into an internal table?
Hi,
To read a file from an Application Server to an Object there is a command in ABAP called <b>READ DATASET</b>. After that file is transported to that object you have to do a loop and put that data in an Internal Table.
This statement exports data from the file specified in dset into the data object dobj. For dobj, variables with elementary data types and flat structures can be specified. In Unicode programs, dobj must be character-type if the file was opened as a text file.
For dset, a character-type data object is expected - that is, an object that contains the platform-specific name of the file. The content is read from the file starting from the current file pointer. After the data transfer, the file pointer is positioned after the section that was read. Using the MAXIMUM LENGTH addition, the number of characters or bytes to be read from the file can be limited. Using ACTUAL LENGTH, the number of characters or bytes actually used can be determined.
In a Unicode program, the file must be opened with an arbitrary access type; otherwise, an exception that cannot be handled will be triggered.
If the file has not yet been opened in anon-Unicode program, it will be implicitly opened as a binary file for read access using the statement
OPEN DATASET dset FOR INPUT IN BINARY MODE.
. If a non-existing file is accessed, an exception that can be handled can be triggered.
Influence of Access Type
Files can be read independently of the access type. Whether data can be read or not depends solely on the position of the file pointer. If the latter is at the end of the file or after the file, no data can be read and sy-subrc will be set to 4.
Influence of the Storage Type
The import function will take place irrespective of the storage type in which the file was opened with the statement OPEN DATASET.
If the file was opened as a text file or as a legacy text file, the data is normally read from the current position of the file pointer to the next end-of-line marking, and the file pointer is positioned after the end-of-line marking. If the data object dobj is too short for the number of read characters, the superfluous characters and bytes are cut off. If it is longer, it will be filled with blanks to the right.
If the file was opened as a binary file or as a legacy-binary file, as much data is read that fits into the data object dobj. If the data object dobj is longer than the number of exported characters, it is filled with hexadecimal 0 on the right.
If the specified storage type makes conversion necessary, this is executed before the assignment to the data object dobj. Afterwards, the read data is placed, byte by byte, into the data object.
System Fields
sy-subrc Meaning
0 Data was read without reaching end of file.
4 Data was read and the end of the file was reached or there was an attempt to read after the end of the file.
Thanks,
Samantak.
<b>Rewards points for useful answers.</b>
Maybe you are looking for
-
Issue while cancelling Commercial invoice
Hi All, I have a requirement from the business to check the excise invoice. if the Excise Invoice Doc (Created using J1IIN) is present and if so should not allow the cancellation of the Commercial Invoice . I think we need to use user exit for the sa
-
Is it possible to change the message of the automated validations?
Hi, In APEX 4.0, depending of the type of item you create and the settings you put, certain validations are automatically made like a check on the date when using a Date Picker. My question is, is it possible to change this message? Because what happ
-
How to install Windows XP in Satellite Pro L300-1A9?
Hi!, first of all, sorry if I'm asking something really obvious, but I'm quite new with this issues...also sorry for my English, I'm not native. I have a Toshiba Satellite Pro L300 1A9 with Windows Vista preinstalled but the thing is I prefer Windows
-
Reinstalling CC apps on a reformatted MacBook Air '13 SSD
I have a subscription to CC for my MacBook Air 2013. It has worked perfectly until this morning when I was forced to have a technician at the local Apple Store reformat my solid state drive. After the hard drive was wiped and reformatted, I have at
-
Pre - Get mail setting does not display " as they arrive" as an option
I have 3 email accounts set up on my Pre. 1 of the 3 accounts does not have the get mail option of "as they arrive". Why is that? Post relates to: Pre p100eww (Sprint)