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,
Shrikanth
Hi ,
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
Similar Messages
-
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 -
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 -
Read an EXCEL file from application server
Hi all
I have to read an excel file from applicatin sever and update my custom tablels.
The problem is when the file is uploaded into the application server .
the fields it has are
name age gender
xyz 67 m.
when seeing the file using al11 tcode :
its showing the following:
###ࡱ##################>#######################################################################################################################
#################################################################O#b#j#I#n#f#o################################################################
How do i read this and put in my internal table
Pleaes help.
Thanks and Regards,Hi,
I am using ECC6.0.
I think the EXCEL file is stored in compressed format to save space.
Please let me know how to decompress etc.
I tried using the function moduel
text_convert_xls_to_sap.
How do I pass the parameter to I_filename.
Regards, -
Read a zip file from Application server.
Hi,
Is there a way to read a zip file from the applicatoin server to internal table in ABAP program? The operation system is running MS windows server. The zip file contains only 1 text file. I tried to use open dataset 'uncompress', and use read dataset, but read dataset gave me sy-subrc = 4. Any feedback is greatly appreciated.
Thanks.hi,
to convert xstring to text you can use this:
DATA unzipped_data TYPE xstring.
DATA text_data TYPE string.
DATA conv_x2c TYPE REF TO cl_abap_conv_in_ce.
conv_x2c = cl_abap_conv_in_ce=>create( ).
conv_x2c->convert( EXPORTING input = unzipped_data IMPORTING data = text_data ).
moreover, if you want to split your text at "end of line" (CR LF in microsoft windows) into lines:
DATA text_lines TYPE TABLE OF string.
SPLIT text_data AT cl_abap_char_utilities=>cr_lf INTO TABLE text_lines. -
Reading all the files from Application Server in a specific folder
Hi,
I want to read all the files present in a folder on Application Server ( AL11 ). My problem is that I do not know the name of the file but I know the folder path where files are present.
I need to go to this folder and pick up all the files present in this folder and then process these files in my program.
Can any one help me in this!
Regards,
LalitYou can use a call to
C_DIR_READ_START'
and
CALL 'C_DIR_READ_NEXT'
Regards,
John. -
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 -
Tab delimited file on app server. How to do that?
Hello,
When i transfer a tab delimited file from pre. server(windows) to app. server(windows) using CG3Z , the tab delimitation is not working.
for eg : the file with below layout
01.04.2007 31.03.2008 1 120
01.05.2007 31.07.2008 2 140
is getting changed like
01.04.2007#31.03.2008#1#120
01.05.2007#31.07.2008#2#140
All i need is a tab delimited file in app server also . Wats that i need to do for this ? Also how can i write a tab delimited file on app server through my program using open dataset.
Thanks for ur time.
Jeeva.Hi..
Check this code: you will find the solution:
Using the Static Attribute <b>CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB</b>
Example:
This is the Simple way you can download the ITAB with Tab delimiter:
DATA : V_REC(200).
OPEN DATASET P_FILE FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
LOOP AT ITAB INTO WA.
Concatenate WA-FIELD1 WA-FIELD2
INTO V_REC
SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
TRANSFER V_REC TO P_FILE.
ENDLOOP.
CLOSE DATASET P_FILE.
Note: if there are any Numeric fields ( Type I, P, F) In your ITAB then before CONCATENATE you have to Move them to Char fields ..
Reward if Helpful.
Example:
DATA: V_RECORD(200).
OPEN DATASET P_FILE FOR INPUT IN TEXT MODE ENCODING DEFAULT.
IF SY-SUBRC <> 0.
EXIT.
ENDIF.
DO.
READ DATASET P_FILE INTO V_RECORD.
IF SY-SUBRC NE 0.
EXIT.
ENDIF.
SPLIT V_Record at CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB
INTO WA-FIELD1 WA-FIELD2.
APPEND WA TO ITAB.
ENDDO.
<b>reward if Helpful.</b> -
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. -
Regarding Reading the file from Application Server
Hi,
I am trying to read data from Application Server but due to special characters it is getting dumped out.
US24,Q,Acero (Carbon),AA,0010,0001,01,Ver Mir para dimension#
US24,Q,Acero (Carbon),AA,0010,0002,01,Area rectificada sin da#os ra
US24,Q,Acero (Carbon),AA,0010,0003,01,Ver Mir para dimension#
US24,Q,Acero (Carbon),CD,0010,0001,01,ITPE Soken para verificacion
US24,Q,Acero (Carbon),CD,0010,0010,01,No se permite desprendimiento
US24,Q,Acero (Carbon),CD,0010,0002,01,"Vernier, cinta metrica"#
In the last line it is going into dump due to special character ".
Please suggest.
Thanks
Priyanka.Hi,
You can check the mode in which you are reading the file
from application server that is
Open Dataset in Binary or Text Mode.
Hope it helps
Regards
Mansi -
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. -
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. -
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 -
Error in Reading the file from Application Server
Hi,
This Error is regarding one of my interface, the issue is that , the interface reads data from file in bunch suppose 100 records at a time , then processes those records and once finished go for next 100 records .
Noe the error is that , the process takes place till 500 records correctly but when it went to fetch for next 100 i.e fom 501 to 600 it selects only 501 to 583 .
this records has been processed successfully but the job finished there only
but the file contains 788 records
When the same file has been run in other server it ran successfully without such error .
Can you please suggest how to resolve the issueHi,
Try to manually download the file from application server using standard transactions, and than check how many records are you able to download from app. server.
I guess there might be something wrong with the format of 583rd record, which makes sap assume that the file has come to an end.
Hope this will help you.
Regards,
Vinit...
Maybe you are looking for
-
I am trying to do a destructive recovery to a HP Compaq 6830s – XP Professional-
I am trying to do a destructive recovery to a HP Compaq 6830s – XP Professional- I backed up my entire system to an external hard drive. I made sure that I was set to start from cd drive. I put disk 1 in and started computer, click on any key to boot
-
How to configure service endpoints of custom webservice in SharePoint 2013?
Hi, I have created a custom webservice in SharePoint 2013. I placed it in a sub folder under the ISAPI folder. I followed the instructions of this article: http://msdn.microsoft.com/en-us/library/office/ff521581(v=office.14).aspx. The webservice work
-
What to do fcp x dosent open. it sticks on restoring window layout page
-
How can I get Soundbooth back to work on my new iMac?
A while ago I managed to download Photoshop CS on my new iMac computer, which worked fine, as well as Soundbooth. Then out of the blue, adobe asked me for my registration number in order to use Soundbooth. I only had one number, but it was no good (a
-
Unable to double click after using at line-selection
hi all... unable to double click after using at line-selection. But if i comment set pf-status, i can double click on the line but on first double click everytime i just get last record i.e. 200th and after second double click i'm not getting output.