Need to have comma separated format
Hi all
I have developed a code in which is a file is stored in application server. The text in the file is continous without any space. I need to have text in comma separated format.
Plz help. Its urgent.
Regrds
Mona
Hi,
Following report tis the sample report for your requirement.
*Reading and Writing a text file from and to the application server*
* sy-subrc = 0 Record read from file
* sy-subrc = 4 End of file reached
data: w_dataset1(27) value '/var/textfile.txt',
w_dataset2(27) value '/var/outfile.txt'.
data:begin of itab1 occurs 0, "Text file format
matnr(18), "MATERIAL NUMBER
bwkrs(4), "PLANT
end of itab1.
*Uploading of text file from Application server.
open dataset w_dataset1 for input in text mode.
do.
if sy-subrc <> 0.
exit.
endif.
read dataset w_dataset1 into itab1.
append itab1.
clear itab1.
enddo.
close dataset w_dataset1.
*Downloading of text file to Application server.
open dataset w_dataset2 for output in text mode.
loop at itable.
transfer itable to w_dataset2.
endloop.
close dataset w_dataset2.
Thanks,
Sankar M
Similar Messages
-
Comma separated format is required
Hi all
this is the code which i have written:
OPEN DATASET g_ufile FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
LOOP AT t_file WHERE werks = t_file1-werks.
MOVE : gc_kaganplntcode TO t_file-fieldname1,
gc_productcode TO t_file-fieldname2,
gc_qtyavailable TO t_file-fieldname3.
CONCATENATE t_file-fieldname1
t_file-fieldname2
t_file-fieldname3
INTO gv_itemdet1 separated by ','.
ENDLOOP.
transfer gv_itemdet1 to g_ufile.
loop at t_file into t_file1.
condense t_file1 no-gaps.
transfer t_file1 to g_ufile.
append t_file1.
clear t_file1.
clear gv_itemdet.
endloop.
in t_file1 data is coming in continous manner. i need to have comma separated data. ie each field shud be separated by ','.
can anybody tell me logic for it.
very urgent.
regrd
Mona
Edited by: Alvaro Tejada Galindo on Apr 14, 2008 1:03 PMTry it this way mona
Declare a fiel-symbol type any and an string to tranfer the contents.
loop at t_file into t_file1.
clear string.
condense t_file1 no-gaps.
do.
assign component sy-index of structure t_file1 to <fs>.
if sy-subrc ne 0.
exit.
endif.
concatenate string <fs> ',' into string.
enddo.
transfer string to g_ufile.
append t_file1.
clear t_file1.
clear gv_itemdet.
endloop. -
Need to Convert Comma separated data in a column into individual rows from
Hi,
I need to Convert Comma separated data in a column into individual rows from a table.
Eg: JOB1 SMITH,ALLEN,WARD,JONES
OUTPUT required ;-
JOB1 SMITH
JOB1 ALLEN
JOB1 WARD
JOB1 JONES
Got a solution using Oracle provided regexp_substr function, which comes handy for this scenario.
But I need to use a database independent solution
Thanks in advance for your valuable inputs.
GeorgeGo for ETL solution. There are couple of ways to implement.
If helps mark -
How to generate oracle report output in a comma separated format in reports
Pls any one can help in generation of oracle report in comma separated format in reports 10g.....
thanks,
prasad.
1,Chennai,Nokiasiemen,Convent junction,5535Use desformat=delimited.
http://download.oracle.com/docs/cd/E15523_01/bi.1111/b32122/orbr_howto007.htm#i1040102 -
Convert work area data into comma separator format ( CSV format )
the function moudule sap_convert_to_csv_format is not available in my system . it is a not released fm as of now. so i cant use it.
My requirement is to send the details to app server in a comma separated format.
For each work area , which i transfer to application server, i hv to separte each field by a comma separtaor.
TRANSFER wa to VA_FILENAME LENGTH 256 ENF OF LINE.
Suppose my work area has fields wa-f1 wa-f2 wa-f3, it should write in app server as value1, value2, value3 like wise....
Suggest me if there is any alternative function module to acheiver this like when we pass wa to fm, the fields should be comma separator,
Any other useful suggestions are welcome.
ThanksHi,
here is the piece of code to transfer data from internal table to applivcation server as a comma seperated file..
FORM comma_sep_file .
DATA: l_cost_center_str TYPE type_cost_center.
IF it_cost_center[] IS NOT INITIAL.
**Concatenate file path and file name
CONCATENATE p_cpath p_cfile INTO v_cost_cen_output.
OPEN DATASET v_cost_cen_output FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
If Network file could not be opened, give a message.
IF sy-subrc <> 0.
WRITE : / text-030 , v_cost_cen_output .
MESSAGE s000(zp) WITH text-015 .
CLEAR : v_cost_cen_output,
p_cpath .
ELSE.
LOOP AT it_cost_center INTO l_cost_center_str.
CONCATENATE l_cost_center_str-co_cen_code
l_cost_center_str-co_cen_name
l_cost_center_str-fld3
l_cost_center_str-fld4
l_cost_center_str-set_true INTO wa_csvdata
SEPARATED BY c_const_sep.
TRANSFER wa_csvdata TO v_cost_cen_output.
CLEAR wa_csvdata.
ENDLOOP.
ENDIF."IF sy-subrc <> 0.
CLOSE DATASET v_cost_cen_output.
ENDIF.
ENDFORM. "
i hope this will help you...
Thanks & Regards
Ashu Singh -
Combine data from a table and insert to another in comma separated format
In my SQL database table i have some data as shown below.
KNO Course Grade Institution
124 BTECH First IIT Calicut
128 BE First KKS Institute
124 CCNA Q NIIT Delhi
124 DDCN Q Appl Calicut
128 DIT A NIIT Delhi
128 VB Q IICM Delhi
i want this courses to be arranged as sample given under to a table named mainpers
KNO Course
124 BTECH[First], CCNA[Q],DDCN[Q]
128 BE[First], DIT[A], VB[Q]
I am a System Administrator at VadodaraYou can do this in SQL.
with cte as (
select distinct KNO
from Table1
select KNO
, Stuff(
(select ',' + Course + '[' + Grade + ']'
from Table1
where Table1.KNO = cte.KNO
for xml path ('')
), 1, 1, '') as Course
from cte
http://davidduffett.net/post/5334646215/get-a-comma-separated-list-of-values-in-sql-with-for
Russel Loski, MCT, MCSE Data Platform/Business Intelligence. Twitter: @sqlmovers; blog: www.sqlmovers.com -
Rows in comma (,) separated format
Hi all,
Let's consider that my EMP table has the following data:
EmpID DeptID
101 10
102 10
103 10
104 20
105 20
106 30
107 20
Now I need a query to get the result as:
DeptID Emps
10 101,102,103
20 104,105,107
30 106
Thanks in advance.
Edited by: Iniyavan on Sep 20, 2009 4:00 PMHi,
That's called String Aggregation . (Even if 101, 102, and 103 are numbers, '101,102,103' with the commas, is a string.)
[AskTom.oracle.com|http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:2196162600402] shows several different ways to do it.
For convenience, you can't beat the first solution on that page, a user-defined aggregate function clled STRAGG.
Once you have STRAGG installed (it can be copied verbatim from that page) it can be used over and over in queries like:
SELECT DeptID
, STRAGG (EmpID) AS Emps
FROM emp
GROUP BY DeptID;Unfortunately, STRAGG is not so good at ordered output.
If order is important, then use one of the other solutions, like SYS_CONNECT_BY_PATH, near the end of the page:
WITH got_r_num
SELECT DeptID
, EmpID
, ROW_NUMBER () OVER ( PARTITION BY DeptID
ORDER BY EmpID
) AS r_num
FROM emp
SELECT DeptID
, SUBSTR ( SYS_CONNECT_BY_PATH ( EmpID, ',')
, 2
) AS Emps
FROM got_r_num
WHERE CONNECT_BY_ISLEAF = 1
START WITH r_num = 1
CONNECT BY r_rnum = PRIOR r_num + 1
AND DeptID = PRIOR DeptID
;Sorry, I'm not at a database, so I can't test this.
Edited by: Frank Kulash on Sep 20, 2009 7:01 AM
Examples added -
I need to have COMMit WORK with in a FM, which is calling in UPDATE task
Hello
I am sending out the custom IDOC from SAP to partner application by writing a custom my_OB_IDOC_FM, well.
With in this my_OB_IDOC_FM, for some functionality, i am using a standard SAP FM and I need to use a COMMIT WORK immediately after this standard SAP FM call.
But, all my IDOC is calling in update task, so once am triggering IDOC (inturn my_OB_IDOC_FM is calling in UPDATE task) am getting dump because of that inside used COMIT WORK statement!
So, pls. let me know how can replace this COMMIT WORK or hoe can i fix my issue? can i do like CALL FUNCTION standard_SAP_FM in background task/seperate task? so that i can use COMMIT WORK?
Thank youI've dealt with something similar before.
You could make a new z-program and run in a background job... like this:
* create the job
CALL FUNCTION 'JOB_OPEN'
EXPORTING
JOBNAME = mv_JOBNAME
IMPORTING
JOBCOUNT = mv_JOBCOUNT
EXCEPTIONS
CANT_CREATE_JOB = 1
INVALID_JOB_DATA = 2
JOBNAME_MISSING = 3
OTHERS = 4.
* submit the program to the job
SUBMIT ZPROGRAM
WITH i_ebeln in mr_ebeln
WITH updall = 'X'
WITH wq_simul = ''
TO SAP-SPOOL
DESTINATION sv_output_device
IMMEDIATELY ''
KEEP IN SPOOL 'X'
WITHOUT SPOOL DYNPRO
USER sy-uname
VIA JOB mv_jobname NUMBER mv_jobcount
AND RETURN.
* submit the job
CALL FUNCTION 'JOB_CLOSE'
EXPORTING
JOBCOUNT = mv_JOBCOUNT
JOBNAME = mv_JOBNAME
STRTIMMED = 'X'
EXCEPTIONS
CANT_START_IMMEDIATE = 1
INVALID_STARTDATE = 2
JOBNAME_MISSING = 3
JOB_CLOSE_FAILED = 4
JOB_NOSTEPS = 5
JOB_NOTEX = 6
LOCK_FAILED = 7
OTHERS = 8. -
Need to have same report format in Xcelsius as there in WEBI report
Hi All,
I have 5 tables in my WEBI report placed horizontally. But when i try to bring these tables from webi to Xcelsius using Live office, those tables are appearing Vertically in excel. In there any work around for this. I need to display those tables horizontally in the excel as there in WEBI report.
Thanks,
Shweta.Hi Remi,
If export the CR report to excel, you can import this excel sheet in Dashboards using the symbol near Manage Connections option.
But this will be a static spreadsheet. If you want to use the live data then you will have to go with Live Office data connection. -
Get Comma separated result from SQL Query
Hey Everyone
I have a requirement where i need to get comma separated result of names because there is one to many relationship i.e for every protocol there are mutiple people associated to it , and i created PL/SQL function for that and everything was fine and when it is in production multiple number of cursors were opened because of the logic and leading to RAC fail over and for that we were manually clearing the cursors every weekend and i am looking to create a Materialized view for this logic but i was unable to code the logic using Connect by clause
Result is like and i want comma separated names for every protocol
P06065 TESTER13 TESTER13
P02095 PATRICIA CARMELITANO
P02095 ANNE MUIR
P02095 ROBERT HARLOW
P02095 JANICE ALBERT
P02095 Jacqueline van Dalen
P02095 GUENTER HENNIG DR.
P05209 Olga Xenaki
P05553 Birgit Limbach-Angele
P05553 Anja Schulz Dr.
P05553 CHRISTA HAGENBUCHER
here is the function which i wrote, i need to get the same logic through SQL Statement .. thanks for your help
cursor c_GSCR is
select T565804.FST_NAME||' '||T565804.LAST_NAME
from
S_PT_POS_HST_LS T544105 /* S_PT_POS_HST_LS_Protocol_Team */ ,
S_CONTACT T565804 /* S_CONTACT_Protocol_Team */,
S_CL_PTCL_LS T541903 /* S_CL_PTCL_LS_Protocol */
where ( T541903.ROW_ID = T544105.CL_PTCL_ID and
T544105.POSTN_ID = T565804.PR_HELD_POSTN_ID and
T544105.ROLE_CD = 'Lead Project Manager' AND
T541903.ROW_ID = v_PTCL_ID and
T541903.PAR_PTCL_ID is null and T544105.END_DT is null );
BEGIN
l_row_num := 0;
l_role := '';
l_role_list := '';
v_PTCL_ID := PTCL_ID;
OPEN C_GSCR;
if C_GSCR%isopen THEN
LOOP
FETCH C_GSCR INTO l_role;
exit when C_GSCR%notfound;
IF l_role_list IS NULL THEN
l_role_list:=l_role;
ELSE
l_role_list:=l_role_list||', '||l_role;
END IF;
END LOOP;
CLOSE C_GSCR;
end if;
~SrixHi,
Srix wrote:
Thanks for the Info .. My database in 10g R 2 i started using COLLECT Function
select T541903.PTCL_NUM ,
CAST(COLLECT(T565804.FST_NAME||' '||T565804.LAST_NAME) AS varchar2_ntt) , 7) AS LPM_NAME
from
S_PT_POS_HST_LS T544105 /* S_PT_POS_HST_LS_Protocol_Team */ ,
S_CONTACT T565804 /* S_CONTACT_Protocol_Team */,
S_CL_PTCL_LS T541903 /* S_CL_PTCL_LS_Protocol */
where T541903.ROW_ID = T544105.CL_PTCL_ID and
T544105.POSTN_ID = T565804.PR_HELD_POSTN_ID and
T544105.ROLE_CD = 'Lead Project Manager' AND
T541903.PAR_PTCL_ID is null and T544105.END_DT is null
GROUP BY T541903.PTCL_NUM
The result i like ...Do you mean "The result *is* like ..."?
Or do you mean "The result I [would] like [is] ..."?
The code above has unblanaced parentheses. If you are getting anything other than an error message, then I don't believe you are really running what you posted.
Whenever you have a problem, post a complete test script that people can use to recreate the problem and test their ideas.
Please do that. Post CREATE TABLE and INSERT statements to crate the sample data, the code you used to create the carachr2_ntt type and the function, and your best attempt at a query (formatted). Simplify as much as possible. For example, do you really need 3 tables to illustrate the problem? For purposes of asking a question on this forum, can't you pretend you have just one table, with 2 columns?
I suspect the problem has to do with the user-defined type and function, which you didn't post. I can't even see how you called the function in your query. Without the information I mentioned above, there's not much I can do to help you. -
Comma separated Excel file FCC?
Hi Experts,
I have an excel file like below (I have just mentioned the row n column to give an idea):
first name(A1), last name(B1), street (C1) city(D1), state(E1)
John (A2), Smith(B2), MacArthur(C2), Dallas(D2), TX(E2)
Mike(A3), Dale(B3), Main St(C3), Austin(D3), TX(E3)
Kevin(A4), Costner(B4), 2nd Steert(C4), Houston(D4), TX(E4)
Can I tranform this into xml out-of-the box using XI 3.0 file adapter file content conversion? If I have to use the module, is there as stadard module available or should have to build from scratch?
If I open the excel file in notepad, it opens as comma separated text file
first name,last name, street,city,state
John,Smith,MacArthur,Dallas,TX
Mike,Dale,Main St,Austin,TX
Kevin,Costner,2nd Steert,Houston,TX
How do I do FCC for the above CSV file? I mean I have one header with the field names and remaings rows as record sets.> I have an excel file like below (I have just mentioned the row n column to give an idea):
>
PI Standard Adapter will not support Execl files.,there is no standard module available, you have to develop adapter module to process EXCEL files.
>
> Can I tranform this into xml out-of-the box using XI 3.0 file adapter file content conversion? If I have to use the module, is there as stadard module available or should have to build from scratch?
> If I open the excel file in notepad, it opens as comma separated text file
>
If you have comma separated values in text file then you can use file content conversion to convert CSV file in to XML,standard adapter will support this.
> How do I do FCC for the above CSV file? I mean I have one header with the field names and remaings rows as record sets.
search in sdn , many blogs available on the same ,converting CSV to XML it is very easy.
Regards,
Raj -
Changing to comma separated values from a table
Hi Gurus
I have a column called ID and second column duplicatesID. So for each ID I can have more than one Duplicate ID.
I want to have comma separated for values of Dup IDs for each ID.
so
ID | DuplicateIDs
1 | 10501
1 | 2010
2 | 103
2 | 109856
2 | 1245
result wanted is
ID | DupsIDs
1 | 10501 , 2010
2 | 103,109856, 1245
regards,
ebroMy preferred way is this
SELECT ID,
STUFF((SELECT ',' + CAST( DuplicateIDs AS varchar(10)) FROM table WHERE ID = t.ID FOR XML PATH(''),TYPE).value('.','varchar(max)'),1,1,'') AS DupsIDs
FROM (SELECT DISTINCT ID FROM Table)t
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs -
File need to be read in different formats( Tab formatted, commas separated)
Hi All,
I am reading an input text file which can be in any of the format like tab formatted, commas separated or fixed format. How can i write a code to make it work for all these file format other than writing separately for the above three cases. Kindly suggest.
Thanks,
Neslin.As far as seperators are concerned you may read entire file to stirng table, then identify separator (i.e. if you find tab mark, you assume it is tab separated; if you find ";" mark you assume this is a column separator). Use SEARCH or FIND statement and then (after having the separator) loop at string table and split each entry at this separator. If none of the above was find (no separator or fixed one) split according to given fixed format.
-
Result may contain single string or comma separated need to split into rows
Hi, All... I've searched through the forums and found plenty on splitting comma separated into rows; though I'm struggling applying it to my situation. I have data that looks like the below where I need to split a value into multiple rows if it should be but the same field in the table may also contain a string that should not be separated (indicated by the "Array" field being 0 or 1)...
WITH t AS
(SELECT 1 as array, '"Banana", "Apple", "Pear"' as str FROM dual union all
SELECT 0, 'Fruit is delicious' FROM dual union all
SELECT 0, 'So are vegetables' FROM dual union all
SELECT 1, '"Bean", "Carrot", "Broccoli"' FROM dual union all
SELECT 1, '"Apple", "Banana"' FROM dual)I've looked through many of the connect_by posts on the forum and I haven't come across one that splits a field if it should be but doesn't if it should not be... may have missed it because there are plenty of these requests on the forum!
If you're feeling even more ambitious - the ultimate goal is to count the number of times a particular answer appears in an array - so notice the last portion of the data contains "Apple", "Banana"... the result would show:
RESULT
Banana 2
Apple 2
Pear 1
Bean 1
Carrot 1
Broccoli 1
Fruit is delicious
So are vegetablesI can always sort them later based on other fields in the table - but the result above would be my ultimate goal!
Any help is always appreciated. Thanks! 11gHi,
The examples you found should work for you. Just use a CASE expression to determine if str needs to be split or not, by looking at array.
Here's one way:
WITH got_part_cnt AS
SELECT array, str
, CASE
WHEN array = 0
THEN 1
-- ELSE 1 + REGEXP_COUNT (str, '", "') -- See note below
ELSE 1 + ( ( LENGTH (str)
- LENGTH (REPLACE (str, '", "'))
/ 4
END AS part_cnt
FROM t
, cntr AS
SELECT LEVEL AS n
FROM (
SELECT MAX (part_cnt) AS max_part_cnt
FROM got_part_cnt
CONNECT BY LEVEL <= max_part_cnt
, got_sub_str AS
SELECT CASE
WHEN p.array = 0
THEN p.str
ELSE REGEXP_SUBSTR ( p.str
, '[^"]+'
, 1
, (2 * c.n) - 1
END AS sub_str
FROM got_part_cnt p
JOIN cntr c ON c.n <= p.part_cnt
SELECT sub_str
, COUNT (*) AS cnt
FROM got_sub_str
GROUP BY sub_str
ORDER BY cnt DESC
, sub_str
{code}
The only database at hand right now is Oracle 10.2, which doesn't have REGEXP_COUNT. I had to use a complicated way of counting how many times '", "' occurs in str in order to test this in Oracle 10. Since you have Oracle 11, you can un-comment the line that uses REGEXP_COUNT in the first CASE expression, and remove the alternate ELSE clause (that is, the next 5 lines, up to END).
To make sure that this query is really paying attention to array, I added this row to the sample data:
{code}
SELECT 0, '"Bean", "Carrot", "Broccoli"' FROM dual union all
{code}
Even though str looks just like a delimited list, array=0 tells the query not to split it, so it produces these results:
{code}
SUB_STR CNT
Apple 2
Banana 2
"Bean", "Carrot", "Broccoli" 1
Bean 1
Broccoli 1
Carrot 1
Fruit is delicious 1
Pear 1
So are vegetables 1
{code} -
Comma separated Values have repeated values
Find the Comma separated Values have repeated values
say
Str:= '123,abc,4566,4897996,46546546,ouiouiou,lhjlhlh,123,pojpoj,465465,123,poipoio,lahslka,'
The above sting has 123 repeated 3 times i need to make a note of it and intimate to user
can a Oracle Function does this?
Thanks!This is one way of doing so, using Pure Oracle functions:
with dat as
select ',' || '123,abc,4566,4897996,46546546,ouiouiou,lhjlhlh,123,pojpoj,465465,123,poipoio,lahslka,' col
from dual
select col, length(translate(lower(replace(col, ',123,', '~')), '~abcdefghijklmnopqrstuvwxyz1234567890-=+_)(*&^%$#@!<>?":|}{,.', '~')) occurances
from dat;
COL OCCURANCES
,123,abc,4566,4897996,46546546,ouiouiou,lhjlhlh,123,pojpoj,465465,123,poipoio,lahslka, 3
Maybe you are looking for
-
Error when making a database call froman ejb
Hello, I am getting the following error when accessing the database from an ejb - java.rmi.ServerException: RemoteException occurred in server thread; nested exception is: java.rmi.RemoteException at com.sun.corba.ee.internal.iiop.ShutdownU
-
Gnome-open opens urls only in firefox [SOLVED]
Hi, I've been facing a problem since I switched from firefox to chromium, all the apps open urls in firefox. I've been investigating a little to find xdg-open uses gnome-open to open my urls. I've set up custom/chromium %s in Preffered Applications (
-
Dear All I got this information in SDN, please find the statement. Is it correct? Sales order is normally Cost Object. Below information he menctioned, If Sales Order is Cost Object. Can u explain. If sales order is cost object (or if sales order
-
Installing Itunes 7.0 after dowloading
Please bear with me as I am not that computer literate. I am currently trying to upgrade my current Itunes 6 to the newly offere Itunes 7.0. I go onto the Itunes 7.0 upgrade site and I download the upgrade. It takes me to a page that says thank you f
-
Tip: Flash Chart without values displayed
Hi people, I have no question but a Tip. Some weeks ago I was lokking for a possibility to get a Stacked Bar Flash Chart. At first I have choosen the 2D-Chart. But in this Chart the values are always be displayed and by using the XML-settings and the