OPEN DATASET - new line
Hi Friends,
I am facing a problem with OPEN DATASET to transfer data from XSTRING field to the text file.
Then problem is like this I have a internal table type XSTRING. Which will have
hi suresh,
check this,
data:
begin of STRUC2,
F1 type c,
F2(20) type c,
end of STRUC2.
Put data into text format
move-corresponding STRUC to STRUC2.
Write data to file
open dataset DSN in text mode for output encoding utf-8.
transfer STRUC2 to DSN.
close dataset DSN.
Read data from file
clear STRUC.
open dataset DSN in text mode for input encoding utf-8.
read dataset DSN into STRUC2.
close dataset DSN.
move-corresponding STRUC2 to STRUC.
write: / STRUC-F1, STRUC-F2.
The textual storage in UTF-8 format ensures that the created files are platform-independent.
Case 2: Old non-Unicode format must be retained
Write data to file
open dataset DSN in legacy text mode for output.
transfer STRUC to DSN.
close dataset DSN.
read from file
clear STRUC.
open dataset DSN in legacy text mode for input.
read dataset DSN into STRUC.
close dataset DSN.
write: / STRUC-F1, STRUC-F2.
Similar Messages
-
Hi,
I'm transferring data through an ABAP program to a file in background. The data is transferred ok, but the whole data gets inserted in the file as a single line.
I'm using the commands: OPEN DATASET file FOR OUTPUT IN TEXT MODE and all its variants ENCODING, LINEFEED, etc and also try ending my row data with CL_ABAP_CHAR_UTILITIES constants for end of lines (it is takes as Text and gets concatenated in the row).
Is there any way in which the data in the file writes in the new lines instead of one line?
Thanks & regardsHey Sebastien,
While transferring data, You should do it in a loop and endloop. And then close the dataset. Also I always recommend you to take a Field in the ITAB with some Flag or some Name like Tabnam so that you can always play with the data as you want.
Example : if you are transferring QMEL table data make sure your structure will be like mentioned below.
TYPES : BEGIN OF ty_qmel,
qmnum TYPE qmel-qmnum, "NOTIFICATION NUMBER
qmart TYPE qmel-qmart, "NOTIFICATION TYPE
tabname TYPE char10, "TABLE NAME FOR IDENTIFICATION-----> This makes you to identify which table data it is.
END OF ty_qmel,
Then While reading the data transfered from one system A(Data transferred from) to another system B(reading the Transfered data). It will be easy if you do like this.
OPEN DATASET file FOR INPUT IN TEXT MODE ENCODING DEFAULT MESSAGE gv_mes IGNORING CONVERSION ERRORS.
DO.
READ DATASET file INTO gv_string.
If sy-subrc = 0.
IF gv_string CS 'QMEL'. -
> Note you can always Identity which table data it is
CALL METHOD cl_abap_container_utilities=>read_container_c
EXPORTING
im_container = gv_string
IMPORTING
ex_value = wa_qmel
EXCEPTIONS
illegal_parameter_type = 1
OTHERS = 2.
APPEND wa_qmel TO it_qmel.
Endif.
Else.
Exit
Endif.
ENDDO.
CLOSE DATASET file.
Hope this helps,
Regards,
Bhargav. -
New-line Character for a file opened in BINARY mode for O/P
Can anybody please tell me how to put a new-line charcter for each record in a file opened in Binary mode for O/p. I cant use text mode for other reasons in my scenario.
DATA: l_outdata TYPE xstring.
OPEN DATASET file FOR OUTPUT IN BINARY MODE.
Application logic to populate l_outdata
TRANSFER l_outdata TO file.
Any help, or attempt towards it will be duely rewarded,
Thanks in advance,
Sujit.hi sujit,
1. how to put a new-line charcter for each record
but how will you decide, at which POSITION,
to put the new line character, if u have opened the file in binary mode.
2. However, if u know the exact positions(s),
u can use CL_ABAP_CHAR_UTILITIES=>CR_LF
to insert the new line character,
regards,
amit m. -
How do I add a new line to an already open but exhausted PO?
Hello,
I am looking for way(s) I can add a new line to an already open PO, (whose funds are exhausted) to accomodate unplanned expenses related to the same project/vendor. Is adding a new line to the original purshase requisition the right way to go?
Thank you
Fatima
Edited by: Fatima Imraan on Jul 4, 2008 8:05 PMHi Fatima,
For unplanned expenses we actually do not need additional line item.
In case the invoice from vendor shows other expenses then in MIRO there is a TAB for Unplanned Expenses and we can put such expenses there. These expenses should be with in the tolerances limits set. Now if the expenses cross the limit, depending on the settings you have made, the invoice is posted but blocked for payment. Then some one in the approval list should approve the same and the payment can be made.
This whole process also gets recorded as PO history and hence is very well documented as well
Normally once a PO is signed it is binding on both parties. So as a Business Process we should not try to add a line item when the PO is exsausted.
In such case i think it would be a good idea to either create a new PO.
Some times companies aslo use OPEN PO if it is a year round activity.
Hope my explanation is useful. assign points if yes.
Thanks
Anand -
When I open a new tab I almost always I know the URL of where I want to go. Therefore I do not want my cursor to be placed in the box of a search engine upon opening the new tab. I want it to be on the address line.
A new tab opens by default as a blank tab (about:blank).
If that isn't the case then an extension has changed that behavior.
*https://support.mozilla.com/kb/Troubleshooting+extensions+and+themes -
How do I open a new tab from address line?
How do I open a new tab from address line?
You Will have to hold down the Alt key and press Enter to make the link open in a new tab without using an extension.
By default links always open in the same tab.
You can search the Add-ons website for an extension if you want to change this default behavior. -
DW BUG - empty new lines on file open
I can't find a patch or an option for this bug. Everytime I
open a formated php script(with no empty spaces between code lines)
it gets a new formatting with 2-3-5 empty new lines betwen my code
lines, this causes that my scripts will become larger in size just
because it has almost 70% empty new lines added by DW CS3, 9
etc..What is your local OS? What is your host OS? What is your
setting for Line
break type in PREFERENCES | Code Format?
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.projectseven.com/go
- DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs,
Tutorials & Resources
==================
"blackshark10" <[email protected]> wrote in
message
news:fsi8pm$3ek$[email protected]..
>I can't find a patch or an option for this bug. Everytime
I open a formated
>php
> script(with no empty spaces between code lines) it gets
a new formatting
> with
> 2-3-5 empty new lines betwen my code lines, this causes
that my scripts
> will
> become larger in size just because it has almost 70%
empty new lines added
> by
> DW CS3, 9 etc..
> -
Open dataset - Lines getting truncated-Question cancelled
Question cancelled
Message was edited by:
Arjun PuthuruthyWalter - I ultimately removed the line feed statement Removed the other additions too.
open dataset dset for output in legacy text mode message msg_tab.
'#' is gone. Waiting to hear back from the legacy system team.
Aparna - You are right.. We have been noticing the same issue for other programs as well. But users are used to checking in notepad (very difficult convincing them).. Was there any problem @ the Unix end in your project? I am yet to check with the legacy system team if it's fine at their end..
Hope all goes well
Else I will re-visit this thread.
Thanks to all.
Regards,
DS
Edited by: D S on Jun 12, 2008 4:02 PM -
Vertical lines displayed whenerver I open a new query
Hey guys, whenever I open a new query I see 3 vertical lines on the screen, from top to button. Did a full reinstall, and they are still there.
Any ideas how to get rid of them?
Thank you!do you have any add on( i think may be SSMSBoost add-in (www.ssmsboost.com)) installed in SSMS
try disable in add on, if not possible or you have un-installed the add on or some other reason you cant get rid of guides , try below
go to regedit
HKEY_CURRENT_USER\Software\Microsoft\Microsoft SQL Server\100\Tool\shell\Text editor
delete "Guides" that should get rid of the vertical lines
refer
http://stackoverflow.com/questions/13939447/column-guides-in-editor-for-sql-server-management-studio-2012
http://www.ssmsboost.com/social/yaf_postst1190_v-2-12-Beta.aspx#post4613
Thanks
Saravana Kumar C -
When I have several tabs open and I open a new URL the new URL replaces the last tab on my bar. I would just like for the new URL to open in a new tab.
Did you have the Google Toolbar installed?
* http://www.google.com/support/toolbar/bin/answer.py?answer=115561 Web-browsing tools : Google new tab page and most visited websites
Other extension that have a similar feature:
*Speed Dial: https://addons.mozilla.org/firefox/addon/4810
*Fast Dial: https://addons.mozilla.org/firefox/addon/5721 -
How to identify a blank new line in an open txt file
hi all
i'm reading a file, and i have to identify all the blank new lines.
does anybody can help me?
thanks to all !!
follows a sample of the code i'm writing:
fHandler := UTL_FILE.FOPEN(FileAttuale.Oracle_Input,FileAttuale.Nome_File, 'r');
-- Lettura file
BEGIN
WHILE 1 < 2 LOOP
Line_Number := Line_Number + 1;
-- Leggo riga per riga finche non viene lanciata la eccezione NO_DATA_FOUND
UTL_FILE.GET_LINE(fHandler, buf);
if (buf is a blank new line) then
end if;
END LOOP;
END;
documentation says:
http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/u_file.htm
Because the line terminator character is not read into the buffer, reading blank lines returns empty strings.
but if i try
IF (BUF ='') THEN
do something
END IF;
IF (BUF is null) THEN
do something
END IF;
don't do nothing!!
thanks all
Edited by: Massimo T. on 4-mag-2011 12.0513 is ^K also known as Vertical Tab No Massimo, it's ^M, that is Carriage Return : you have to consider Dec column, since ASCII function returns the decimal representation in the database character set of the first character of char.
-
Writing in a in file and going to a new line.
Hello.
There's something in a program i am currently writing.
I'm trying to write in 2 files with a format like this :
line1.....
line2.....
In the first file, everything is ok but in the second file, with exactly the same instructions, instead og getting my file like i need it, i've something like that :
line1...... line2....
Here is the code i'm using to write in the file :
DATA : t_ent_estim like STANDARD TABLE OF ZVOIENT WITH HEADER LINE.
LOOP AT t_ent_estim.
TRANSFER t_ent_estim TO p_fici.
ENDLOOP.
PERFORM close_file(zvoiform) USING p_fici w_result.
The only difference is that in one case i use an internal table and in the other i use a structure i created myself :
DATA : BEGIN OF tbl_csv_trans OCCURS 0,
s_csvdata(400),
END OF tbl_csv_trans.
Anybody can explain to me why with the internal table, the instruction transfer does not write in a new line each occurence of my table ?
Thanks for the help.Hi Helder,
I have also used a structure, and it works fine for me.
Check whether you have opened the file in text mode.
data : BEGIN OF i_final_file OCCURS 0,
record(300) TYPE c,
END OF i_final_file,
Open the file for output **********************
OPEN DATASET wa_c_filename FOR OUTPUT IN TEXT MODE.
IF sy-subrc NE 0.
MESSAGE a999 WITH 'The file could not be created'.
ENDIF.
Write line items to file ************************
LOOP AT i_final_file.
TRANSFER i_final_file TO wa_c_filename.
ENDLOOP.
Close the file ******************************
CLOSE DATASET wa_c_filename.
Regards,
Susmitha
Reward points if helpful -
New Line using Transfer Statement
I need to write data to a text file in a particular format. I am not passing records of an internal table to the text file. I need to pass fields of a single row in a tabular format. For this, I need to use the new line character...I want fields of a single row to be displayed one below the other.
Any idea on how we could do this?Hi vidya,
1. For application server,
we have to use open dataset, transfer, close dataset,
(and take care of the spacing between the fields)
2. For presentation server,
we have to use the fm GUI_DOWNLOAD
and do not pass the parameter
WRITE_FIELD_SEPARATOR = 'X'
(when we do not pass this parameter,
the data is written in FIXED-LENGTH
including spaces)
(So when we view the data in notepad,
the fields will be very much aligned,
one below the other)
regards,
amit m. -
OPEN DATASET create .txt file in application server
Hi,
I'm trying to create a .txt into application server. Code as follows:-
OPEN DATASET gv_filestatus FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
IF sy-subrc <> 0.
WRITE: 'File cannot be opened.'.
ENDIF.
LOOP AT gt_pdfstatus INTO gw_pdfstatus.
TRANSFER gw_pdfstatus TO gv_filestatus.
ENDLOOP.
CLEAR gw_pdfstatus.
CLOSE DATASET gv_filestatus.
But I got the error "GW_PDFSTATUS" cannot be a table, a reference, a string, or contain any of these objects. GW_PDFSTATUS is a work area with 5 fields of different type. I know that I can transfer table type of TLINE but I'm not sure how to convert my internal table gt_pdfstatus as TLINE.
Please advise. Thanks.When transfering data to a file, you should convert the data to type char and then transfer it to the file.
So, you would need to declare a structure with 5 fields of type c with the corresponding length of the original structure.
Then move the corresponding fields of work are gw_pdfstatus to the character type structure. And then transfer the new structure to the file (gv_filestatus in your case).
"for example if all the fields in the gw_pdfstatus are of lenght 10, then declare a structure as follows
data : begin of file_wa,
f1(10) type c,
f2(10) type c,
f3(10) type c,
f4(10) type c,
f5(10) type c,
end of file_wa.
OPEN DATASET gv_filestatus FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
IF sy-subrc 0.
WRITE: 'File cannot be opened.'.
ENDIF.
LOOP AT gt_pdfstatus INTO gw_pdfstatus.
move-corresponding gw_pdfstatus to file_wa. " Add this
TRANSFER file_wa TO gv_filestatus. " Change this line
ENDLOOP.
CLEAR gw_pdfstatus.
CLOSE DATASET gv_filestatus.
Hope this helps.
KR,
Advait -
Problem in file format OPEN DATASET
Hi all,
i am upgrading the systemm 4.7 to ECC6.0
In one of the programs OPEN dataset statement is being used to download the file to unix server, but when i run the same program in ECC6.0 version an try to opn in notepad the same file it is coming in single line (i.e end of line delimiter is being ignored.)
Hence I tried using WITH WINDOWS LINEFEED addition
it is displayed correctlyin notepad but when i see thru
transaction AL11 character'#' is displayed after every end of line also when i take a printout now one extra new line is added
the delimiter which i have used here is
C type c value CL_ABAP_CHAR_UTILITIES=>CR_LF
Can anyone suggest a better method to solve the problem?DATA L_MSG1 TYPE STRING.
CONSTANTS: C_TAB1 TYPE C VALUE CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
*-- Open Dataset
OPEN DATASET p_aosvr FOR INPUT IN TEXT MODE ENCODING DEFAULT.
IF sy-subrc EQ 0.
DO.
*-- Read Dataset and Populate Input file data to Internal Table
READ DATASET unix_filename INTO L_MSG1.
IF sy-subrc EQ 0.
SPLIT L_MSG1 AT C_TAB1 INTO it_final-field1
it_final-field2
it_final-field3
it_final-field4
it_final-filed5.
APPEND it_final.
CLEAR it_final.
ELSE.
EXIT.
ENDIF.
ENDDO.
ELSE.
MESSAGE e000 WITH 'Error while uploading data'(013).
ENDIF.
*-- Close Dataset
CLOSE DATASET p_aosvr.
Maybe you are looking for
-
Comparison error while trying to round like Excel
I have two different but related issues. First: my LabVIEW application is not passing my client's validation because the results in LabVIEW are not exactly the same as the ones my client get when using MS Excel. The problem is with rounding: LabVIEW
-
I want to upgrade the hard drive in my MacBook Pro
I bought one of the first MacBook Pros that only came with a 100gb drive. I want to buy at least a 250gb drive for it. The problem is that I would like to maintain what I already have on the existing drive. I am getting Leopard on Monday so I'm not s
-
I can't see "the firefox button" - where is it???
In the starting-up info website, there is an orange firefox button in the top left space of the browser, but on my browser there is none - from this button you can do a lot of the cool things on firefox, but why don't I have it? Is there a way I can
-
Website is not working in OSX Lion
Link doesn't work when I hit "View Kirtan" on following web link http://sgpc.net/kirtanarc.asp step to reach to this link is 1. go to this page http://sgpc.net/kirtanarc.asp 2. choose any prior/ early date 3. hit View Kirtan 4. then you will reach to
-
Hi guys, I need to create an action. A simple one. The idea: One path is selected, a user runs the action, it makes a copy of that path, moves the copy, select both the path and its copy and makes a blend. I tried to record that action, but Illustrat