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>
Similar Messages
-
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 -
FM to read XML files from Application server in ECC5.0
Hi All,
We need to pick up an XML file from Application server/FTP server. The requirement is to parse the XML file and process it to create material master. SAP provides standard function modules to read XML files.
Now we need to read the XML file contents of MM01 and upload into SAP Data Base through BAPI
I need to know about the Function modules to read XML files from Application Server and also about the FM's that will update the Date base tables with the data obtained form XML files.
Regards
PrathimaParsing XML data:
http://help.sap.com/saphelp_nw04/helpdata/en/86/8280ba12d511d5991b00508b6b8b11/frameset.htm
or alternatively check out ABAP online help for "CALL TRANSFORMATION".
For creating the material master look at BAPI_STANDARDMATERIAL_CREATE.
Thomas -
Function module to read xml files from application server
Hi experts,
I need to read xml files from application server to sap. Is the any siutable function moldule for that?Hi Cenosure,
Donno about FM which will upload data directly to SAP, I think you have to do some mapping for it so that it will suit the SAP format. Again it depends on your requirement..
Please elaborate more about your requirement.
Please have a look on below FM
TEXT_CONVERT_XML_TO_SAP
Also search on SCN there are many threads on the same topic available.
http://abapreports.blogspot.com/2008/09/upload-xml-file-from-application-server.html
This is the link which will give you the Code
http://www.geocities.com/rmtiwari/Resources/MySolutions/Dev/Codes/Report/Z_RMTIWARI_XML_TO_ABAP_46C.html
Use this XML file to Upload the same, this Program will work for your XML file also,
http://www.geocities.com/rmtiwari/Resources/MySolutions/Dev/Codes/Report/input_xml.xml
See the below thread also
Upload XML to internal table and vice versa in SAP 4.6C
Hope it will solve your problem..
Thanks & Regards
ilesh 24x7
ilesh Nandaniya -
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 -
Reading XML File from application server
Hi experts,
My aim is to read a XML file from application server and extract the relevant data from it and process further.
When I am trying to read a XML file from application server it is reading success fully but the problem is that its not reading the last root structure of XML file why is so happening can any body help me?
I am using the following code:
TYPES: BEGIN OF xml_line,
text(256) type x,
END OF xml_line.
DATA: e_file LIKE rlgrap-filename VALUE 'applcatin server path'
OPEN DATASET e_file FOR INPUT IN BINARY MODE.
IF sy-subrc EQ 0.
DO.
READ DATASET e_file INTO wa_item1-text.
IF sy-subrc EQ 0.
APPEND wa_item1 TO gt_item1 .
CLEAR wa_item1.
ELSE.
EXIT.
ENDIF.
ENDDO.
ENDIF.
CLOSE DATASET e_file.
after this i am passing this internal table to "cl_ixml" class to extract the data
but it returning the itab with required value except the last record.
The stream reading the file it self is i thought in complete thats why it is not converting the all values.
Please help me...
Thanks a ton in advance.Hi,
1 Copy Report BCCIIXMLT1
2 (you can change the way of filling internal table xml_table if necessary)
3 you don't need the part between
*-- render the DOM back into an output stream/internal table
and
*-- print the whole DOM tree as a list...
Comment it out or simply delete it
4 Rename form print_node to your liking e.g. process_node
5 In your new form you need three extra variables:
data: attribs type ref to IF_IXML_NAMED_NODE_MAP,
attrib_node type ref to IF_IXML_NODE,
attrib_value type string.
6 After the lines:
when if_ixml_node=>co_node_element.
string = pNode->get_name( ).
Insert:
attribs = pNode->get_attributes( ).
clear attrib_value.
case string.
when ''. "put your XML tag name here
attrib_node = attribs->get_named_item(name = '' ). "put your XML attribute name here
attrib_value = attrib_node->get_value( ).
You can also refer link,
/people/r.eijpe/blog/2005/11/21/xml-dom-processing-in-abap-part-ii--convert-an-xml-file-into-an-abap-table-using-sap-dom-approach
thanks & regards
shreemohan -
What are the non available features in iphone bought from saudi arabia ?
Hello ,
I am going to buy an iphone from saudi arabia since i am there but i heard it lack some features there such as facetime !
I am going to the iphone in netherlands , i live there , and i would like to know if i will still have the iphone without all the features working
Thank you.If it was purchased unlocked, and from an authorized Apple distributor. If it was bought from some random phone shop then there is no way of knowing.
-
Problem Reading Flat File from Application server
Hi All,
I want to upload a Flat File which is having a Line Length of 3000.
While uploading it to Application server , only upto 555 length it is getting uploaded .
i am using the code :
DATA: BEGIN OF TB_DATA OCCURS 0,
LINE(3000),
END OF TB_DATA.
*----Uploading the flat file from the Local drive using FM "UPLOAD".
OPEN DATASET TB_FILENAM-DATA FOR OUTPUT IN TEXT MODE." ENCODING DEFAULT.
IF SY-SUBRC NE 0.
WRITE:/ 'Unable to open file:', TB_FILENAM-DATA.
ELSE.
LOOP AT TB_DATA.
TRANSFER TB_DATA TO TB_FILENAM-DATA.
ENDLOOP.
ENDIF.
CLOSE DATASET TB_FILENAM-DATA.
What could be the problem?
Could it be due to any Configuration Problem?
Waiting for your replies.
Thanks and Regards.
SukiYour code looks OK, but you may have touble displaying the full width. Try:
WRITE: /001 TB_FILENAM-DATA+555.
(And don't forget to append your ITAB after each read.)
Rob -
What are the steps to remove SMS Provider traces from a server
Hi,
My client's environment is set up with a standalone primary site. They decided to install a second SMS Provider on a site system also running the Reprting Services Point to provide redundancy in the case the SMS Provider on the primary site
would go down.
They experienced a problem with the server running the second SMS Provider and it went down for about a day. The behavior for SCCM console users was to get an error message preventing them to connect to SCCM; they had to close the console and re-launch it
so it would randomly connect to the SMS provider on the primary site successfully. When a SMS provider is down, it seems the console won't redirect itself automatcally to another provider when trying to connect.
Since it was causing some frustration because console users had to launch it several times before they could connect, someone removed the second SMS Provider using the Site Maintenance wizard on the primary site. The thing is the wizard ran while the second
SMS Provider was down, it removed traces of this SMS Provider from the site configuration, but couldn't remove the actual SMS Provider files and registry entries since the server was down.
Now, only one SMS Provider is active on the primary site server, but we have orphaned SMS Provider files and registry keys on the site system server. Is there a way to remove them cleanly? The site system is still running the Reporting Services Point, so
we cannot remove everything related to SCCM.
Now we prefer to keep a single SMS Provider on the primary site server, since SCCM is not consider critical to the business anyway, and to avoid this issue in the future.
My guess would be to reinstall the SMS Provider from the Site Maintenance wizard and remove it after, but I just want to have feedback from people who might have deal with it in the past.
Tnx for help
PatrickHi,
Could you install the SMS Provider from the Site Maintenance wizard while SMS Provider files and registry entries are still there? Please have a look on the thread below, although it is for sccm 2007.
http://social.technet.microsoft.com/Forums/systemcenter/en-US/bb307748-7638-404d-a6a4-982827a051c8/how-do-i-remove-sql-provider-that-was-previously-installed-on-a-remote-sql-server?forum=configmgrsetup
Best Regards,
Joyce
We
are trying to better understand customer views on social support experience, so your participation in this
interview project would be greatly appreciated if you have time.
Thanks for helping make community forums a great place. -
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 -
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 -
Uploading and reading file from application server
Hi
My problem is when am uploading a file to application server it is getting stored in
usr/sap/transyp1/prod/in directory
after that i want to read that file from application server to update database
when using below code it is showing some other directory in f4 help
DATA: lv_hostname TYPE msxxlist-name.
DATA: lv_server TYPE bank_dte_jc_servername.
PARAMETERS: p_file TYPE rlgrap-filename.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
CALL FUNCTION 'BANK_API_SYS_GET_CURR_SERVER'
IMPORTING
e_server = lv_server.
lv_hostname = lv_server.
CALL FUNCTION 'F4_DXFILENAME_4_DYNP'
EXPORTING
dynpfield_filename = 'P_FILE'
dyname = sy-cprog
dynumb = '1000'
filetype = 'P'
location = 'A'
server = lv_hostname.
experts could you please help me out
Thanks & Regards
Nagesh.ParuchuriUser Transaction file. You will get all logical file path names.
used following fucntion module to read file name and use command open dataset to read the file.
CALL FUNCTION 'FILE_GET_NAME'
EXPORTING
CLIENT = SY-MANDT
LOGICAL_FILENAME = C_LOGICAL_FILENAME
OPERATING_SYSTEM = SY-OPSYS
PARAMETER_1 = P_IN_FILENAME
IMPORTING
FILE_NAME = P_OUT_FILENAME
EXCEPTIONS
FILE_NOT_FOUND = 1
OTHERS = 2.
OPEN DATASET P_OPEN_FILE ENCODING UTF-8 IN TEXT MODE FOR OUTPUT.
IF SY-SUBRC <> 0.
MESSAGE E000(38) WITH 'Error in Opening file: ' V_PHY_FILENAME.
ENDIF. -
Reading tab delimited file from application server
Hi All,
I do know that we need to use Open data set to read a file from application server, but my question is when you use read DATASET v_file into wa_final - this wa_final is an work area and also i have mentione an internal table. so do we need to Split the record at tab into the corresponding fields. Append the records into an internal table i_input.????
Please let me know on this....
thanks in advance....
Poonam....Hi,
first see the file contents in application server, how the contents whether the contents seperated by any symbol or not, if the contents seperated by any symbol then you have to split the data before appending to internal table.
check this code.
DATA: l_data_string TYPE string.
filename = p_file.
OPEN DATASET p_file FOR INPUT IN TEXT MODE ENCODING DEFAULT.
IF sy-subrc EQ 0.
DO.
READ DATASET filename INTO l_data_string.
IF sy-subrc NE 0.
EXIT.
ENDIF.
CLEAR k_input.
SPLIT l_data_string AT '#' INTO k_input-agreement k_input-suffix k_input-status
k_input-first_name k_input-last_name k_input-job_title k_input-tel k_input-fax k_input-email_address k_input-mob_number.
APPEND k_input TO i_input.
ENDDO.
ENDIF.
Regards,
Venu -
Error Loading the file from application server
Hi Team,
I'm trying to load the .CSV file from application server and I'm getting the error message.
In the data package
Update to PSA --Green
Transfer Rule -- Green
Update Rule - error ABORT was set in the customer routine 9998
Error 1 in the update
Please help me to provide the solution.
But when I try to load the other files there are no issues. thanks.
Regards,
SenthilRaj
check the below links, which can helps to solve your issues
Flat file data load
flat file Data loading issue
Mahesh -
Read Tilda separated file from Application Server
I have a requirement to read a tilda separated file from application server and write a tilda separeted output to application server. Please suggest how to to get data from tilda separated file to internal table ? and also How to create a tilda separated file from internal table to application server.
Hi again,
This some sample code for outputing data on application server with tilda separator.
OPEN DATASET p_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT. " MESSAGE msg.
IF sy-subrc <> 0.
message i812(LQ).
LEAVE LIST-PROCESSING.
ENDIF.
LOOP AT gs_input INTO wa_input.
CONCATENATE wa_input-wadat_ist
wa_input-sort2
wa_input-name1
wa_input-street
wa_input-region
wa_input-post_code1
wa_input-zzchep
wa_input-vbeln
wa_input-bstkd
wa_input-zfrom
wa_input-zland
wa_input-zccode
wa_input-zrcvd
wa_input-zfref
wa_input-znorc
wa_input-zsepr
wa_input-zvers
wa_input-zlout
wa_input-zinfo
wa_input-zinco
wa_input-zsqal
wa_input-zscod
wa_input-zrqal
wa_input-zeqal
wa_input-zecod
wa_input-zcust
wa_input-ztran INTO g_path SEPARATED BY '~'.
TRANSFER g_path TO p_file.
CLEAR : g_path, wa_input.
ENDLOOP.
CLOSE DATASET p_file.
Hope this will be helpful for you.
Regards,
Vijay
Maybe you are looking for
-
my macbook is loaded with microsoft word for macs and every time I try and open the program I get an error reading and it will not open. This is what it says: The application Microsof Word quit eunexpectedly. Powerpoint and the other applications st
-
Can No Longer Edit Song Meta Data In Latest iTunes 11.1???
I just discovered that since the update to version 11.1 I can no longer manually edit the meta data by using the Show info function, all options are greyed out. For instance I can no longer adjust the volume level on a song nor can I edit the fields
-
can someone help me ? My iMac remote control isn't working properly , well all buttons are working apart from the MENU button !! Can anyone shed any light on this ?
-
How to Display Item Property Description
Hi In Sales Quotation lines i want to display the name of the item property on selecting item . How this can be achieved. Thanks
-
Why is there no link to send a reset for security questions?
What the title says. I can't make any purchases.