Inserting Record into CSV file from BizTalk Orchestration
Scenario:
1.Receive file from Source system via RecvPipeline
2.In Orchestration extracting some values like ENO,Ename,Salary etc.these values to be added in to CSV file from Expression Shape.How to append/add emp records in to CSV with out overriding the rows.
Ex:If we submitted 10 files then the CSV file should contain 10 rows in CSV.
Let me know how to create CSV file from Orchestration and how to add rows into that csv value
Regards BizTalkWorship
Simple.
Receive the message through a Receive Port/Location.
Create a flat-file schema representing the CSV file structure. Ensure each row is delimited by “{CR}{LF}”.
This flat-file schema should only contain the element which you want to see in the destination CSV file like ENO,Ename,Salary etc.
Have a map where the source schema should be the one which represents the received file and destination schema should be the one which is above created flat-file schema.
Map the source schema to the destination schema mapping the filed
ENO,Ename,Salary etc.
Have a custom send pipeline with flat-file assembler component it. Use this send pipeline in the send port.
In send port, configure the send filter like “BTS.ReceivePortName == YourReceivePortName”. Configure the send port’s “Outbound Maps” to the map which you have created in
above step
Key Point. In your send port, set the “Copy Mode” property to “Append” from default “Create New”
With your send port’s, “Copy Mode” property configured to “Append” this will append the value of the output to the existing file. Since in your flat-file schema, each record
is delimited by “{CR}{LF}” and since you’re overwriting the output file you will have one file with records appended. So if 10 files received, instead of 10 output files, you will have 1 CVS file with 10 rows.
If you want to construct the message in Orchestration as do, you do as opposed to map in send port at outbound map you can still do.
If this answers your question please mark it accordingly. If this post is helpful, please vote as helpful by clicking the upward arrow mark next to my reply.
Similar Messages
-
Error with date field when inserting records into sql server from webdynpro
Dear SDN's,
I am trying to insert the records into sql server through my webDynpro program.
I have created a date field in a dictionary with the datatype date.
In my webdynpro program to insert the date i am following the below format.
String dateString = "2006/12/10";
java.util.Date d=new java.util.Date(dateString);
java.sql.Date <b>date</b> = new java.sql.Date(d.getTime());
int i=stmt.executeUpdate("INSERT INTO TRAVEL_HEADER(TRQID,PROJECTID,<b>REQDT</b>,ADVCE,ETADV,PURTR) values(21, '555-1212', '" + <b>date</b> + "', 5000, '20060501','hi')");
when i try to execute it, it gives the following error.
<b>com.sap.sql.log.OpenSQLException: The SQL statement "INSERT INTO "TRAVEL_HEADER" ("TRQID","PROJECTID","REQDT","ADVCE","ETADV","PURTR") VALUES (21,'555-1212','2006-12-10',5000,'20060501','hi')" contains the semantics error[s]: - type check error: new value (element number 3 (CHAR)) is not assignable to column >>REQDT<< (DATE)</b>
Please correct me.
Your help will be appreciated.
Regards,
Sireesha.BHi,
int i=stmt.executeUpdate("INSERT INTO TRAVEL_HEADER(TRQID,PROJECTID,REQDT,ADVCE,ETADV,PURTR) values(21, '555-1212', 'date', 5000, '20060501','hi')");
try like this.
I Think in SQL the general format to take date as input like this.
INSERT INTO X VALUES ('10/30/56')
thaks,
Lohi. -
How to insert new record into oracle table from GridView in VS2005.
I need to insert records into Oracle10g table from VS2005 GridView using the Insert Method in Business Logic Class. The Update and Delete Methods are working fine. What's the best way out?
How is it "not possible"?
Either modify the Class for the new fields, or give the new fields default values (if applicable). If the type of an existing column has changed, then only the first option is available.
Where's the problem? -
Import data from oracle database table into csv file
Hi
I have to import data from a table into a csv file. Could anyone suggest the best method to do it? My application is JSP as frontend and have put business logic in servlet.
Thanks in advance.FastReader from wisdomforce will help you quickly export data into csv file. http://www.wisdomforce.com
fastreader can be called and executed as an external process ( Runtime.exec(..) ) to extract data from Oracle tables into flat file -
Saving result from query into CSV file
Hi folks,
in our application we're generating pages source using general packages (like htp, owa_util, ...). and in this part I'm a really beginner.
I want to modify source one of our page, I want to add functionality to enable save result from query (cursor) into CSV file, to enable user choose place where generated file will be created and also change file name.
I searched this forum and I found procedure, that could be useful:
procedure p_getcsv is
cursor cur is
select 'a1' col1, 'b1' col2, 'c1' col3 from dual
union select 'a2' col1, 'b2' col2, 'c2' col3 from dual
union select 'a3' col1, 'b3' col2, 'c3' col3 from dual;
begin
-- Set the MIME type
owa_util.mime_header( 'application/octet', FALSE );
-- Set the name of the file
htp.p('Content-Disposition: attachment; filename="test.csv"');
-- Close the HTTP Header
owa_util.http_header_close;
-- Loop through all rows in EMP
for x in cur
loop
-- Print out a portion of a row,
-- separated by commas and ended by a CR
htp.prn(x.col1||','|| x.col2||','||x.col3|| chr(13));
end loop;
end;What peace of code should I add to procedure that is generating web page to enable calling this procedure and whole saving process?
Can anybody help me with this?
Many thanks,
Tomas
Message was edited by:
TomeoHi Marc,
thanks for reply, problem is that I'm not using APEX application, I'm just generating web page code straight using oracle general packages.
But I found this solution (maybe some tunning will be good):
In page where I want to display Download i have
begin
htp.anchor2 (
curl => ... .p_getcsv'||'?term=2005&crn=123,
ctext => 'Download Class List'
HTP.br;
end;
...si I'm calling p_getcsv procedure:
procedure p_getcsv( term IN stvterm.stvterm_code%TYPE DEFAULT NULL,
crn IN sirasgn.sirasgn_crn%TYPE DEFAULT NULL) is
v_length NUMBER;
v_file_name VARCHAR2 (2000);
temp_blob blob;
line RAW(32767);
begin
DBMS_LOB.CREATETEMPORARY(temp_blob, TRUE);
FOR i IN 1..6 LOOP
line := UTL_RAW.CAST_TO_RAW(i||','||term||','||crn||',AAA,BBB,CCC'||chr(10));
DBMS_LOB.WRITEAPPEND(temp_blob, LENGTH(UTL_RAW.CAST_TO_VARCHAR2(line)), line);
END LOOP;
v_file_name := 'ClassList.csv';
v_length := DBMS_LOB.getlength (temp_blob);
-- set up HTTP header
-- use an NVL around the mime type and
-- if it is a null set it to application/octect
-- application/octect may launch a download window from windows
OWA_UTIL.mime_header (NVL ('csv', 'application/octet'), FALSE);
-- set the size so the browser knows how much to download
HTP.p ('Content-length: ' || v_length);
-- the filename will be used by the browser if the users does a save as
HTP.p ( 'Content-Disposition: attachment; filename="'
|| REPLACE (REPLACE (SUBSTR (v_file_name,
INSTR (v_file_name, '/') + 1
CHR (10),
NULL
CHR (13),
NULL
|| '"'
-- close the headers
OWA_UTIL.http_header_close;
-- download the BLOB
WPG_DOCLOAD.download_file (temp_blob);
-- release temporary blob
dbms_lob.freetemporary(temp_blob);
end;Regards,
Tomas -
Insert data into oracle table from XML file
I need to insert data into oracle table from XML file
If anybody handled this type of scenario, Please let me know how to insert data into oracle table from XML file
Thanks in advanceThe XML DB forum provides the best support for XML topics related to Oracle.
Here's the FAQ on that forum:
XML DB FAQ
where there are plenty of examples of shredding XML into Oracle tables and such like. ;) -
File To RFC Scenario- simply insert records into ztab
Hi
i have a requirment, where XI gets a flatfile and needs to map to RFC function module and then inserts records into ztable in SAP system. it doesn't require any response back.
proble here is:
i don't want to get RFC 'Response mesage' when i import RFC into XI IR. i require only 'Request message'.
please help me, how to create a RFC function module with out Response message, and it should contain only Request message.
i have created RFC in this way:
RFC doesn't vcontains neither import nor export parameters. and i have defined on table in TABLE tab which refers to a ztable created already.
Thanks in advance..
Regards,
RajeshThankx Michal,
I have written ZRFC this way:
insert ZMM_AUTO_GR from INPUT_TABLE .
if sy-subrc = 0.
commit work.
else.
rollback work.
im not using neither import nor export parameters..but using only tables parameters. but when imported in XI im getting same table structure in both request an response.
please suggest what changes required in above code to invoke my ZRFC in async way.
you will not get any response in XI- what chages required in my code to dnt get .reponse in XI.
appreciate your help.
Regards,
Rajesh. -
Reading a CSV file from server
Hi All,
I am reading a CSV file from server and my internal table has only one field with lenght 200. In the input CSV file there are more than one column and while splitting the file my internal table should have same number of rows as columns of the input record.
But when i do that the last field in the internal table is appened with #.
Can somebody tell me the solution for this.
U can see the my code below.
data: begin of itab_infile occurs 0,
input(3000),
end of itab_infile.
data: begin of itab_rec occurs 0,
record(200),
end of itab_rec.
data: c_comma(1) value ',',
open dataset f_name1 for input in text mode encoding default.
if sy-subrc <> 0.
write: /, 'FILE NOT FOUND'.
exit.
endif.
do
read dataset p_ipath into waf_infile.
split itab_infile-input at c_sep into table itab_rec.
enddo.
Thanks in advance.
SunilSunil,
You go not mention the platform on which the CSV file was created and the platform on which it is read.
A common problem with CSV files created on MS/Windows platforms and read on unix is the end-of-record (EOR) characters.
MS/Windows usings <CR><LF> as the EOR
Unix using either <CR> or <LF>
If on unix open the file using vi in a telnet session to confirm the EOR type.
The fix options.
1) Before opening the opening the file in your ABAP program run the unix command dos2unix.
2) Transfer the file from the MS/Windows platform to unix using FTP using ascii not bin. This does the dos2unix conversion on the fly.
3) Install SAMBA and share the load directory to the windows platforms. SAMBA also handles the dos2unix and unix2dos conversions on the fly.
Hope this helps
David Cooper -
Stored Proc to create .csv file from table
Hi all,
I have a table with 4 columns and 10 rows. Now I need a stored proc to create a .csv file from the table data. Here the scripts to create a table and insert the row's.
Create table emp(emp_id number(10), emp_name varchar2(20), department varchar2(20), salary number(10));
Insert into emp values ('1','AAAAA','SALES','10000');
Insert into emp values ('2','BBBBB','MARKETING','8000');
Insert into emp values ('3','CCCCC','SALES','12000');
Insert into emp values ('4','DDDDD','FINANCE','10000');
Insert into emp values ('5','EEEEE','SALES','11000');
Insert into emp values ('6','FFFFF','MANAGER','90000');
Insert into emp values ('7','GGGGG','SALES','12000');
Insert into emp values ('8','HHHHH','FINANCE','14000');
Insert into emp values ('9','IIIII','SALES','20000');
Insert into emp values ('10','JJJJJ','FINANCE','21000');
commit;
Now I need a stored proc to create a .csv file in my local location. Please let me know If you need any other details....Some pointers:
http://www.oracle-base.com/articles/9i/GeneratingCSVFiles.php
http://tkyte.blogspot.com/2009/10/httpasktomoraclecomtkyteflat.html
also, doing a search on this forum or http://asktom.oracle.com will give you many clues.
.csv file in my local location.What is your 'local location'?
A client machine? The database server machine?
What database version are you using?
(the result of: select * from v$version; ) -
CLR to get the SQL Server Data into .CSV File
Hi,
I transformed 10 columns 1000 rows from the source table to 1 column 1000 rows in the destination table by making the comma separated columns ( Just like ..
Insert into DestinationTable
SELECT col1+','+col2 ....
FROM SourceTable
Then I want to take this column into CSV file.
I dont have the rights to command shell.
I heard that we may use CLR procedure for this. Can someone throw light?using System;
using System.IOM
using System.Data;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using Microsoft.SqlServer.Server;
public class ExportFileClass {
[Microsoft.SqlServer.Server.SqlProcedure]
public static void export_file()
using (SqlConnection connection = new SqlConnection(
"context connection=true"))
connection.Open();
// Operation to open file goes here.
SqlCommand command = new SqlCommand("SELECT col FROM YourTable");
// Consume result set and write rows.
Build this from the command line:
sn -k keypair.snk
csc /target:library /keyfile:keypair.snk exportfile.cs
Then run in SQL Server (assuming that the files are in C:\temp on the SQL
Server machine:
[sql]
USE master
go
-- To be able to create an external-access assembly, we need to load
-- the key, the assembly is signed with. The key needs a password, but we
-- don't need to know the password.
DECLARE @sql nvarchar(MAX),
@password char(40)
SELECT @password = convert(char(36), newid()) + 'Ab4?'
SELECT @sql = 'CREATE ASYMMETRIC KEY slog_loopback FROM FILE = ' +
'''C:\temp\keypair.snk'' ' +
'ENCRYPTION BY PASSWORD = ''' + @password + ''''
PRINT @sql
EXEC(@sql)
-- And then a login to carry the permission.
CREATE LOGIN exportfile$asymkey FROM ASYMMETRIC KEY ExportFile
GRANT EXTERNAL ACCESS ASSEMBLY TO exportfile$asymkey
go
-- Now we can go back to our regular database and create the assembly.
USE youddatabase
go
CREATE ASSEMBLY ExportFile FROM 'C:\temp\exportfile.dll'
WITH PERMISSION_SET = EXTERNAL_ACCESS
go
CREATE PROCEDURE ExportFile AS
EXTERNAL NAME ExportFile.ExportFileClass.export_file
[sql]
It is likely that you will have to do ask your DBA to do things in the
master database.
Erland Sommarskog, SQL Server MVP, [email protected] -
Hello everyone,
I’ve been assigned one requirement wherein I would like to read around 50 CSV files from a specified folder.
In step 1 I would like to create schema for this files, meaning take the CSV file one by one and create SQL table for it, if it does not exist at destination.
In step 2 I would like to append the data of these 50 CSV files into respective table.
In step 3 I would like to purge data older than a given date.
Please note, the data in these CSV files would be very bulky, I would like to know the best way to insert bulky data into SQL table.
Also, in some of the CSV files, there will be 4 rows at the top of the file which have the header details/header rows.
According to my knowledge I would be asked to implement this on SSIS 2008 but I’m not 100% sure for it.
So, please feel free to provide multiple approaches if we can achieve these requirements elegantly in newer versions like SSIS 2012.
Any help would be much appreciated.
Thanks,
Ankit
Thanks, <b>Ankit Shah</b> <hr> Inkey Solutions, India. <hr> Microsoft Certified Business Management Solutions Professionals <hr> http://ankit.inkeysolutions.comHello Harry and Aamir,
Thank you for the responses.
@Aamir, thank you for sharing the link, yes I'm going to use Script task to read header columns of CSV files, preparing one SSIS variable which will be having SQL script to create the required table with if exists condition inside script task itself.
I will be having "Execute SQL task" following the script task. And this will create the actual table for a CSV.
Both these components will be inside a for each loop container and execute all 50 CSV files one by one.
Some points to be clarified,
1. In the bunch of these 50 CSV files there will be some exception for which we first need to purge the tables and then insert the data. Meaning for 2 files out of 50, we need to first clean the tables and then perform data insert, while for the rest 48
files, they should be appended on daily basis.
Can you please advise what is the best way to achieve this requirement? Where should we configure such exceptional cases for the package?
2. For some of the CSV files we would be having more than one file with the same name. Like out of 50 the 2nd file is divided into 10 different CSV files. so in total we're having 60 files wherein the 10 out of 60 have repeated file names. How can we manage
this criteria within the same loop, do we need to do one more for each looping inside the parent one, what is the best way to achieve this requirement?
3. There will be another package, which will be used to purge data for the SQL tables. Meaning unlike the above package, this package will not run on daily basis. At some point we would like these 50 tables to be purged with older than criteria, say remove
data older than 1st Jan 2015. what is the best way to achieve this requirement?
Please know, I'm very new in SSIS world and would like to develop these packages for client using best package development practices.
Any help would be greatly appreciated.
Thanks, <b>Ankit Shah</b> <hr> Inkey Solutions, India. <hr> Microsoft Certified Business Management Solutions Professionals <hr> http://ankit.inkeysolutions.com
1. In the bunch of these 50 CSV files there will be some exception for which we first need to purge the tables and then insert the data. Meaning for 2 files out of 50, we need to first clean the tables and then perform
data insert, while for the rest 48 files, they should be appended on daily basis.
Can you please advise what is the best way to achieve this requirement? Where should we configure such exceptional cases for the package?
How can you identify these files? Is it based on file name or are there some info in the file which indicates
that it required a purge? If yes you can pick this information during file name or file data parsing step and set a boolean variable. Then in control flow have a conditional precedence constraint which will check the boolean variable and if set it will execute
a execte sql task to do the purge (you can use TRUNCATE TABLE or DELETE FROM TableName statements)
2. For some of the CSV files we would be having more than one file with the same name. Like out of 50 the 2nd file is divided into 10 different CSV files. so in total we're having 60 files wherein the 10 out of 60 have
repeated file names. How can we manage this criteria within the same loop, do we need to do one more for each looping inside the parent one, what is the best way to achieve this requirement?
The best way to achieve this is to append a sequential value to filename (may be timestamp) and then process
them in sequence. This can be done prior to main loop so that you can use same loop to process these duplicate filenames also. The best thing would be to use file creation date attribute value so that it gets processed in the right sequence. You can use a
script task to get this for each file as below
http://microsoft-ssis.blogspot.com/2011/03/get-file-properties-with-ssis.html
3. There will be another package, which will be used to purge data for the SQL tables. Meaning unlike the above package, this package will not run on daily basis. At some point we would like these 50 tables to be purged
with older than criteria, say remove data older than 1st Jan 2015. what is the best way to achieve this requirement?
You can use a SQL script for this. Just call a sql procedure
with a single parameter called @Date and then write logic like below
CREATE PROC PurgeTableData
@CutOffDate datetime
AS
DELETE FROM Table1 WHERE DateField < @CutOffDate;
DELETE FROM Table2 WHERE DateField < @CutOffDate;
DELETE FROM Table3 WHERE DateField < @CutOffDate;
GO
@CutOffDate which denote date from which older data have to be purged
You can then schedule this SP in a sql agent job to get executed based on your required frequency
Please Mark This As Answer if it solved your issue
Please Vote This As Helpful if it helps to solve your issue
Visakh
My Wiki User Page
My MSDN Page
My Personal Blog
My Facebook Page -
To download data into csv file format
Hi All
I have to download data into csv file format. I use the FM
GUI_DOWNLOAD and gave the filename text.csv. But data is stored in excel
file in place of csv file.
Can anyone tell me what should i do to load the data into csv file or any other function module should used?
Regardssee this sample code
REPORT YSG_MATSTK_REPT LINE-SIZE 220
LINE-COUNT 50(5).
*& DATA DECLARATION *
TABLES: MARA, "GENERAL MASTER DATA
MARC, "PLANT DATA FOR MATERIAL
MARD, "STORAGE LOCATION DATA FOR MATERIAL
MVKE, "SALES DATA FOR MATERIAL
MAKT, "MATERIAL DESCRIPTION
EKKO, "PURCHASING DOCUMENT HEADER
EKPO, "PURCHASING DOCUMENT ITEM
VBAK, "SALES DOCUMENT HEADER DATA
VBAP. "SALES DOCUMENT ITEM DATA
TYPE-POOLS : SLIS.
DATA: VT_FIELDCAT1 TYPE SLIS_T_FIELDCAT_ALV,
V_FIELDCAT TYPE SLIS_FIELDCAT_ALV,
V_LAYOUT TYPE SLIS_LAYOUT_ALV,
BDCDATA LIKE BDCDATA OCCURS 0 WITH HEADER LINE,
BEGIN OF I_MARA OCCURS 0,
MATNR LIKE MARA-MATNR, "MATERIAL NUMBER
MBRSH LIKE MARA-MBRSH, "INDUSTRY SECTOR
MEINS LIKE MARA-MEINS, "BASE UNIT OF MEASURE
MATKL LIKE MARA-MATKL, "MATERIAL GROUP
END OF I_MARA,
BEGIN OF I_MARC OCCURS 0,
MATNR LIKE MARC-MATNR, "MATERIAL NUMBER
WERKS LIKE MARC-WERKS, "PLANT
LVORM LIKE MARC-LVORM, "FLAG MATERIAL FOR DELETION AT PLANT
"LEVEL
DISPO LIKE MARC-DISPO, "MRP CONTROLLER
END OF I_MARC,
BEGIN OF I_MAKT OCCURS 0,
MATNR LIKE MAKT-MATNR, "MATERIAL NUMBER
MAKTX LIKE MAKT-MAKTX, "MATERIAL DESCRIPTION
SPRAS LIKE MAKT-SPRAS, "LANGUAGE KEY
END OF I_MAKT,
BEGIN OF I_MVKE OCCURS 0,
MATNR LIKE MVKE-MATNR, "MATERIAL NUMBER
VKORG LIKE MVKE-VKORG, "SALES ORGANIZATION
VTWEG LIKE MVKE-VTWEG, "DISTRIBUTION CHANNEL
END OF I_MVKE,
BEGIN OF I_MARD OCCURS 0,
MATNR LIKE MARD-MATNR, "MATERIAL NUMBER
LGORT LIKE MARD-LGORT, "STORAGE LOCATION
LABST LIKE MARD-LABST, "VALUATED STOCK WITH UNRESTRICTED USE
END OF I_MARD,
BEGIN OF I_EKPO OCCURS 0,
EBELN LIKE EKPO-EBELN, "PURCHASING DOCUMENT NUMBER
EBELP LIKE EKPO-EBELP, "ITEM NUMBER OF PURCHASING DOCUMENT
MATNR LIKE EKPO-MATNR, "MATERIAL NUMBER
END OF I_EKPO,
BEGIN OF I_VBAP OCCURS 0,
VBELN LIKE VBAP-VBELN, "SALES DOCUMENT
POSNR LIKE VBAP-POSNR, "SALES DOCUMENT ITEM
MATNR LIKE VBAP-MATNR, "MATERIAL NUMBER
END OF I_VBAP,
BEGIN OF I_OUT OCCURS 0,
MATNR LIKE MARC-MATNR,
WERKS LIKE MARC-WERKS,
LVORM LIKE MARC-LVORM,
DISPO LIKE MARC-DISPO,
MBRSH LIKE MARA-MBRSH,
MEINS LIKE MARA-MEINS,
MATKL LIKE MARA-MATKL,
VKORG LIKE MVKE-VKORG,
VTWEG LIKE MVKE-VTWEG,
SPRAS LIKE MAKT-SPRAS,
MAKTX LIKE MAKT-MAKTX,
LGORT LIKE MARD-LGORT,
LABST LIKE MARD-LABST,
EBELN LIKE EKPO-EBELN,
EBELP LIKE EKPO-EBELP,
VBELN LIKE VBAP-VBELN,
POSNR LIKE VBAP-POSNR,
END OF I_OUT,
BEGIN OF I_HEADING OCCURS 0,
TEXT1(20),
TEXT2(20),
TEXT3(20),
TEXT4(20),
TEXT5(20),
TEXT6(20),
TEXT7(20),
TEXT8(20),
TEXT9(20),
TEXT10(20),
TEXT11(40),
TEXT12(20),
TEXT13(20),
TEXT14(20),
TEXT15(20),
TEXT16(20),
TEXT17(20),
END OF I_HEADING.
*& S E L E C T I O N - S C R E E N *
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-100.
SELECT-OPTIONS: S_MATNR FOR MARA-MATNR. "OBLIGATORY.
PARAMETERS: P_WERKS LIKE MARC-WERKS. "OBLIGATORY.
SELECT-OPTIONS: S_LGORT FOR MARD-LGORT,
S_DISPO FOR MARC-DISPO,
S_EBELN FOR EKPO-EBELN .
SELECTION-SCREEN END OF BLOCK B1.
SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME TITLE TEXT-101.
PARAMETERS : RB1 RADIOBUTTON GROUP G1,
RB2 RADIOBUTTON GROUP G1,
RB3 RADIOBUTTON GROUP G1.
SELECTION-SCREEN END OF BLOCK B2.
*& I N I T I A L I Z A T I O N *
*INITIALIZATION.
*& S T A R T - O F - S E L E C T I O N *
START-OF-SELECTION.
SELECT MATNR WERKS LVORM DISPO FROM MARC
INTO CORRESPONDING FIELDS OF TABLE I_MARC
WHERE MATNR IN S_MATNR
AND DISPO IN S_DISPO
AND WERKS = P_WERKS.
IF I_MARC[] IS INITIAL.
WRITE:/ 'NO MATCHING DATA AVAILABLE FROM MARC'.
EXIT.
ENDIF.
PERFORM PURCHASEDATA_VALIDATION.
PERFORM SALESDATA_VALIDATION.
SELECT MATNR LGORT LABST FROM MARD INTO TABLE I_MARD
FOR ALL ENTRIES IN I_MARC
WHERE MATNR = I_MARC-MATNR
AND WERKS EQ P_WERKS
AND LGORT IN S_LGORT.
IF I_MARD[] IS INITIAL.
WRITE:/ 'NO MATCHING DATA AVAILABLE FROM MARD'.
EXIT.
ENDIF.
SELECT MATNR VKORG VTWEG FROM MVKE INTO TABLE I_MVKE
FOR ALL ENTRIES IN I_MARC
WHERE MATNR = I_MARC-MATNR.
IF I_MVKE[] IS INITIAL.
WRITE:/ 'NO MATCHING DATA AVAILABLE FROM MVKE'.
EXIT.
ENDIF.
LOOP AT I_MARC.
MOVE-CORRESPONDING I_MARC TO I_OUT.
CLEAR MARC.
SELECT SINGLE MATNR MBRSH MEINS MATKL FROM MARA
INTO CORRESPONDING FIELDS OF MARA
WHERE MATNR = I_OUT-MATNR.
IF SY-SUBRC = 0.
MOVE: MARA-MBRSH TO I_OUT-MBRSH,
MARA-MEINS TO I_OUT-MEINS,
MARA-MATKL TO I_OUT-MATKL.
ELSE.
CONTINUE.
ENDIF.
SELECT SINGLE MATNR MAKTX SPRAS FROM MAKT
INTO CORRESPONDING FIELDS OF MAKT
WHERE MATNR = I_OUT-MATNR.
IF SY-SUBRC = 0.
MOVE: MAKT-MAKTX TO I_OUT-MAKTX,
MAKT-SPRAS TO I_OUT-SPRAS.
ELSE.
CONTINUE.
ENDIF.
LOOP AT I_EKPO WHERE MATNR = I_MARC-MATNR.
MOVE: I_EKPO-EBELN TO I_OUT-EBELN,
I_EKPO-EBELP TO I_OUT-EBELP.
ENDLOOP.
LOOP AT I_VBAP WHERE MATNR = I_MARC-MATNR.
MOVE: I_VBAP-VBELN TO I_OUT-VBELN,
I_VBAP-POSNR TO I_OUT-POSNR.
ENDLOOP.
LOOP AT I_MARD WHERE MATNR = I_MARC-MATNR.
MOVE: I_MARD-LABST TO I_OUT-LABST,
I_MARD-LGORT TO I_OUT-LGORT.
ENDLOOP.
LOOP AT I_MVKE WHERE MATNR = I_MARC-MATNR.
MOVE: I_MVKE-VKORG TO I_OUT-VKORG,
I_MVKE-VTWEG TO I_OUT-VTWEG.
ENDLOOP.
APPEND I_OUT.
CLEAR I_OUT.
ENDLOOP.
PERFORM OPTIONS.
FORM OPTIONS *
FORM OPTIONS.
IF RB2 = 'X'.
PERFORM FIELDCAT.
PERFORM OUTPUT.
ELSE.
IF RB1 = 'X'.
PERFORM HEADINGS.
PERFORM DLOAD.
ELSE.
IF RB3 = 'X'.
PERFORM HEADINGS.
PERFORM DLOAD.
PERFORM FIELDCAT.
PERFORM OUTPUT.
ENDIF.
ENDIF.
ENDIF.
ENDFORM. "OPTIONS
FORM HEADINGS *
FORM HEADINGS.
I_HEADING-TEXT1 = 'MATNR'.
I_HEADING-TEXT2 = 'WERKS'.
I_HEADING-TEXT3 = 'LVORM'.
I_HEADING-TEXT4 = 'DISPO'.
I_HEADING-TEXT5 = 'MBRSH'.
I_HEADING-TEXT6 = 'MEINS'.
I_HEADING-TEXT7 = 'MATKL'.
I_HEADING-TEXT8 = 'VKORG'.
I_HEADING-TEXT9 = 'VTWEG'.
I_HEADING-TEXT10 = 'SPRAS'.
I_HEADING-TEXT11 = 'MAKTX'.
I_HEADING-TEXT12 = 'LGORT'.
I_HEADING-TEXT13 = 'LABST'.
I_HEADING-TEXT14 = 'EBELN'.
I_HEADING-TEXT15 = 'EBELP'.
I_HEADING-TEXT16 = 'VBELN'.
I_HEADING-TEXT17 = 'POSNR'.
APPEND I_HEADING.
ENDFORM. "HEADINGS
FORM DLOAD *
FORM DLOAD.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
FILENAME = 'C:\MATSTK.csv'
FILETYPE = 'DAT'
WRITE_FIELD_SEPARATOR = 'X'
TABLES
DATA_TAB = I_HEADING
EXCEPTIONS
FILE_WRITE_ERROR = 1.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
FILENAME = 'C:\MATSTK.csv'
FILETYPE = 'DAT'
APPEND = 'X'
WRITE_FIELD_SEPARATOR = 'X'
TABLES
DATA_TAB = I_OUT.
ENDFORM. "DLOAD
FORM FIELDCAT *
FORM FIELDCAT.
V_FIELDCAT-COL_POS = '1'.
V_FIELDCAT-FIELDNAME = 'MATNR'.
V_FIELDCAT-TABNAME = 'I_OUT'.
V_FIELDCAT-HOTSPOT = 'X'.
V_FIELDCAT-REF_FIELDNAME = 'MATNR'.
V_FIELDCAT-REF_TABNAME = 'MARC'.
APPEND V_FIELDCAT TO VT_FIELDCAT1.
CLEAR V_FIELDCAT.
V_FIELDCAT-COL_POS = '2'.
V_FIELDCAT-FIELDNAME = 'WERKS'.
V_FIELDCAT-TABNAME = 'I_OUT'.
V_FIELDCAT-REF_FIELDNAME = 'WERKS'.
V_FIELDCAT-REF_TABNAME = 'MARC'.
APPEND V_FIELDCAT TO VT_FIELDCAT1.
CLEAR V_FIELDCAT.
V_FIELDCAT-COL_POS = '3'.
V_FIELDCAT-FIELDNAME = 'LVORM'.
V_FIELDCAT-TABNAME = 'I_OUT'.
V_FIELDCAT-REF_FIELDNAME = 'LVORM'.
V_FIELDCAT-REF_TABNAME = 'MARC'.
APPEND V_FIELDCAT TO VT_FIELDCAT1.
CLEAR V_FIELDCAT.
V_FIELDCAT-COL_POS = '4'.
V_FIELDCAT-FIELDNAME = 'DISPO'.
V_FIELDCAT-TABNAME = 'I_OUT'.
V_FIELDCAT-REF_FIELDNAME = 'DISPO'.
V_FIELDCAT-REF_TABNAME = 'MARC'.
APPEND V_FIELDCAT TO VT_FIELDCAT1.
CLEAR V_FIELDCAT.
V_FIELDCAT-COL_POS = '5'.
V_FIELDCAT-FIELDNAME = 'MBRSH'.
V_FIELDCAT-TABNAME = 'I_OUT'.
V_FIELDCAT-REF_FIELDNAME = 'MBRSH'.
V_FIELDCAT-REF_TABNAME = 'MARA'.
APPEND V_FIELDCAT TO VT_FIELDCAT1.
CLEAR V_FIELDCAT.
V_FIELDCAT-COL_POS = '6'.
V_FIELDCAT-FIELDNAME = 'MEINS'.
V_FIELDCAT-TABNAME = 'I_OUT'.
V_FIELDCAT-REF_FIELDNAME = 'MEINS'.
V_FIELDCAT-REF_TABNAME = 'MARA'.
APPEND V_FIELDCAT TO VT_FIELDCAT1.
CLEAR V_FIELDCAT.
V_FIELDCAT-COL_POS = '7'.
V_FIELDCAT-FIELDNAME = 'MATKL'.
V_FIELDCAT-TABNAME = 'I_OUT'.
V_FIELDCAT-REF_FIELDNAME = 'MATKL'.
V_FIELDCAT-REF_TABNAME = 'MARA'.
APPEND V_FIELDCAT TO VT_FIELDCAT1.
CLEAR V_FIELDCAT.
V_FIELDCAT-COL_POS = '8'.
V_FIELDCAT-FIELDNAME = 'VKORG'.
V_FIELDCAT-TABNAME = 'I_OUT'.
V_FIELDCAT-REF_FIELDNAME = 'VKORG'.
V_FIELDCAT-REF_TABNAME = 'MVKE'.
APPEND V_FIELDCAT TO VT_FIELDCAT1.
CLEAR V_FIELDCAT.
V_FIELDCAT-COL_POS = '9'.
V_FIELDCAT-FIELDNAME = 'VTWEG'.
V_FIELDCAT-TABNAME = 'I_OUT'.
V_FIELDCAT-REF_FIELDNAME = 'VTWEG'.
V_FIELDCAT-REF_TABNAME = 'MVKE'.
APPEND V_FIELDCAT TO VT_FIELDCAT1.
CLEAR V_FIELDCAT.
V_FIELDCAT-COL_POS = '10'.
V_FIELDCAT-FIELDNAME = 'SPRAS'.
V_FIELDCAT-TABNAME = 'I_OUT'.
V_FIELDCAT-REF_FIELDNAME = 'SPRAS'.
V_FIELDCAT-REF_TABNAME = 'MAKT'.
APPEND V_FIELDCAT TO VT_FIELDCAT1.
CLEAR V_FIELDCAT.
V_FIELDCAT-COL_POS = '11'.
V_FIELDCAT-FIELDNAME = 'MAKTX'.
V_FIELDCAT-TABNAME = 'I_OUT'.
V_FIELDCAT-REF_FIELDNAME = 'MAKTX'.
V_FIELDCAT-REF_TABNAME = 'MAKT'.
APPEND V_FIELDCAT TO VT_FIELDCAT1.
CLEAR V_FIELDCAT.
V_FIELDCAT-COL_POS = '12'.
V_FIELDCAT-FIELDNAME = 'LGORT'.
V_FIELDCAT-TABNAME = 'I_OUT'.
V_FIELDCAT-REF_FIELDNAME = 'LGORT'.
V_FIELDCAT-REF_TABNAME = 'MARD'.
V_FIELDCAT-SELTEXT_L = 'STRG LOCT'.
V_FIELDCAT-OUTPUTLEN = 10.
APPEND V_FIELDCAT TO VT_FIELDCAT1.
CLEAR V_FIELDCAT.
V_FIELDCAT-COL_POS = '13'.
V_FIELDCAT-FIELDNAME = 'LABST'.
V_FIELDCAT-TABNAME = 'I_OUT'.
V_FIELDCAT-SELTEXT_M = 'STOCK'.
V_FIELDCAT-OUTPUTLEN = 15.
V_FIELDCAT-REF_FIELDNAME = 'LABST'.
V_FIELDCAT-REF_TABNAME = 'MARD'.
V_FIELDCAT-DO_SUM = 'X'.
V_LAYOUT-TOTALS_TEXT = 'TOTAL STOCK:'.
V_FIELDCAT-HOTSPOT = 'X'.
APPEND V_FIELDCAT TO VT_FIELDCAT1.
CLEAR V_FIELDCAT.
V_FIELDCAT-COL_POS = '14'.
V_FIELDCAT-FIELDNAME = 'EBELN'.
V_FIELDCAT-TABNAME = 'I_OUT'.
V_FIELDCAT-HOTSPOT = 'X'.
V_FIELDCAT-REF_FIELDNAME = 'EBELN'.
V_FIELDCAT-REF_TABNAME = 'EKPO'.
APPEND V_FIELDCAT TO VT_FIELDCAT1.
CLEAR V_FIELDCAT.
V_FIELDCAT-COL_POS = '15'.
V_FIELDCAT-FIELDNAME = 'EBELP'.
V_FIELDCAT-TABNAME = 'I_OUT'.
V_FIELDCAT-REF_FIELDNAME = 'EBELP'.
V_FIELDCAT-REF_TABNAME = 'EKPO'.
APPEND V_FIELDCAT TO VT_FIELDCAT1.
CLEAR V_FIELDCAT.
V_FIELDCAT-COL_POS = '16'.
V_FIELDCAT-FIELDNAME = 'VBELN'.
V_FIELDCAT-TABNAME = 'I_OUT'.
V_FIELDCAT-HOTSPOT = 'X'.
V_FIELDCAT-REF_FIELDNAME = 'VBELN'.
V_FIELDCAT-REF_TABNAME = 'VBAP'.
APPEND V_FIELDCAT TO VT_FIELDCAT1.
CLEAR V_FIELDCAT.
V_FIELDCAT-COL_POS = '17'.
V_FIELDCAT-FIELDNAME = 'POSNR'.
V_FIELDCAT-TABNAME = 'I_OUT'.
V_FIELDCAT-REF_FIELDNAME = 'POSNR'.
V_FIELDCAT-REF_TABNAME = 'VBAP'.
APPEND V_FIELDCAT TO VT_FIELDCAT1.
CLEAR V_FIELDCAT.
ENDFORM. "FIELDCAT
FORM OUTPUT *
FORM OUTPUT.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
I_CALLBACK_TOP_OF_PAGE = 'TOP-OF-PAGE'
I_GRID_TITLE = 'CLICK ON MATERIAL/PURDOC/SALESDOC FOR DETAILS'
I_CALLBACK_USER_COMMAND = 'DISPLAYDETAILS'
IS_LAYOUT = V_LAYOUT
IT_FIELDCAT = VT_FIELDCAT1
TABLES
T_OUTTAB = I_OUT.
IF SY-SUBRC <> 0.
ENDIF.
ENDFORM. "OUTPUT
FORM TOP-OF-PAGE *
FORM TOP-OF-PAGE.
DATA: T_HEADER TYPE SLIS_T_LISTHEADER,
WA_HEADER TYPE SLIS_LISTHEADER.
WA_HEADER-TYP = 'H'.
WA_HEADER-INFO = 'REPORT FOR : '.
APPEND WA_HEADER TO T_HEADER.
CLEAR WA_HEADER.
WA_HEADER-TYP = 'S'.
WA_HEADER-INFO = 'MATERIAL DETAILS'.
APPEND WA_HEADER TO T_HEADER.
CLEAR WA_HEADER.
WA_HEADER-TYP = 'S'.
WA_HEADER-INFO = 'PURCHASE ORDER DETAILS'.
APPEND WA_HEADER TO T_HEADER.
CLEAR WA_HEADER.
WA_HEADER-TYP = 'S'.
WA_HEADER-INFO = 'SALES ORDER DETAILS'.
APPEND WA_HEADER TO T_HEADER.
CLEAR WA_HEADER.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
I_LOGO = 'GEAR'
IT_LIST_COMMENTARY = T_HEADER.
ENDFORM. "TOP-OF-PAGE
*& FORM DISPLAYDETAILS *
FORM DISPLAYDETAILS USING UCOMM LIKE SY-UCOMM
SELFIELD TYPE SLIS_SELFIELD.
IF SELFIELD-FIELDNAME = 'EBELN'.
IF UCOMM = '&IC1'.
READ TABLE I_OUT INDEX SELFIELD-TABINDEX.
PERFORM PORECDNG.
CLEAR BDCDATA[].
ENDIF.
ELSE.
IF SELFIELD-FIELDNAME = 'MATNR'.
IF UCOMM = '&IC1'.
READ TABLE I_OUT INDEX SELFIELD-TABINDEX.
PERFORM MMRECDNG.
CLEAR BDCDATA[].
ENDIF.
ELSE.
IF SELFIELD-FIELDNAME = 'VBELN'.
IF UCOMM = '&IC1'.
READ TABLE I_OUT INDEX SELFIELD-TABINDEX.
PERFORM SALESRECDNG.
CLEAR BDCDATA[].
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDFORM. "DISPLAYDETAILS
FORM PORECDNG *
FORM PORECDNG.
PERFORM BDC_DYNPRO USING 'SAPMM06E' '0105'.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'RM06E-BSTNR'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'/00'.
PERFORM BDC_FIELD USING 'RM06E-BSTNR'
I_OUT-EBELN.
PERFORM BDC_DYNPRO USING 'SAPMM06E' '0120'.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'RM06E-BSTPO(01)'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=AH'.
PERFORM BDC_FIELD USING 'RM06E-EBELP'
I_OUT-EBELP.
PERFORM BDC_FIELD USING 'RM06E-TCSELFLAG(01)'
'X'.
PERFORM BDC_TRANSACTION USING 'ME23'.
ENDFORM. "PORECDNG
FORM MMRECDNG *
FORM MMRECDNG.
PERFORM BDC_DYNPRO USING 'SAPLMGMM' '0060'.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'RMMG1-MATNR'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'/00'.
PERFORM BDC_FIELD USING 'RMMG1-MATNR'
I_OUT-MATNR.
PERFORM BDC_DYNPRO USING 'SAPLMGMM' '0070'.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'MSICHTAUSW-DYTXT(01)'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=ENTR'.
PERFORM BDC_FIELD USING 'MSICHTAUSW-KZSEL(01)'
'X'.
PERFORM BDC_TRANSACTION USING 'MM03'.
ENDFORM. "MMRECDNG
FORM SALESRECDNG *
FORM SALESRECDNG.
PERFORM BDC_DYNPRO USING 'SAPMV45A' '0102'.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'VBAK-VBELN'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'/00'.
PERFORM BDC_FIELD USING 'VBAK-VBELN'
I_OUT-VBELN.
PERFORM BDC_TRANSACTION USING 'VA03'.
ENDFORM. "SALESRECDNG
FORM BDC_TRANSACTION *
FORM BDC_TRANSACTION USING TCODE.
CALL TRANSACTION TCODE USING BDCDATA MODE 'E'.
ENDFORM. "BDC_TRANSACTION
FORM BDC_DYNPRO *
FORM BDC_DYNPRO USING PROGRAM DYNPRO.
CLEAR BDCDATA.
BDCDATA-PROGRAM = PROGRAM.
BDCDATA-DYNPRO = DYNPRO.
BDCDATA-DYNBEGIN = 'X'.
APPEND BDCDATA.
ENDFORM. "BDC_DYNPRO
INSERT FIELD *
FORM BDC_FIELD USING FNAM FVAL.
CLEAR BDCDATA.
BDCDATA-FNAM = FNAM.
BDCDATA-FVAL = FVAL.
APPEND BDCDATA.
ENDFORM. "BDC_FIELD
*& FORM PURCHASEDATA_VALIDATION *
FORM PURCHASEDATA_VALIDATION.
SELECT EBELN EBELP MATNR
FROM EKPO
INTO TABLE I_EKPO
FOR ALL ENTRIES IN I_MARC
WHERE MATNR = I_MARC-MATNR
AND EBELN IN S_EBELN
AND WERKS EQ P_WERKS.
IF I_EKPO[] IS INITIAL.
WRITE:/ 'NO MATCHING DATA AVAILABLE FROM TABLE EKPO'.
EXIT.
ENDIF.
DATA: T_EKPO LIKE I_EKPO OCCURS 0 WITH HEADER LINE.
T_EKPO[] = I_EKPO[].
REFRESH I_EKPO.
FREE I_EKPO.
LOOP AT T_EKPO.
SELECT SINGLE EBELN FROM EKKO INTO EKPO-EBELN
WHERE EBELN = T_EKPO-EBELN.
IF SY-SUBRC = 0.
MOVE-CORRESPONDING T_EKPO TO I_EKPO.
APPEND I_EKPO.
CLEAR I_EKPO.
ELSE.
CONTINUE.
ENDIF.
ENDLOOP.
SORT I_EKPO.
ENDFORM. "PURCHASEDATA_VALIDATION
*& FORM SALESDATA_VALIDATION *
FORM SALESDATA_VALIDATION.
SELECT VBELN POSNR MATNR
FROM VBAP
INTO CORRESPONDING FIELDS OF TABLE
I_VBAP FOR ALL ENTRIES IN I_MARC
WHERE MATNR = I_MARC-MATNR.
IF I_VBAP[] IS INITIAL.
WRITE:/ 'NO MATCHING DATA AVAILABLE FROM TABLE VBAP'.
EXIT.
ENDIF.
DATA: T_VBAP LIKE I_VBAP OCCURS 0 WITH HEADER LINE.
T_VBAP[] = I_VBAP[].
REFRESH I_VBAP.
FREE I_VBAP.
LOOP AT T_VBAP.
SELECT SINGLE VBELN FROM VBAK INTO VBAK-VBELN
WHERE VBELN = T_VBAP-VBELN.
IF SY-SUBRC = 0.
MOVE-CORRESPONDING T_VBAP TO I_VBAP.
APPEND I_VBAP.
CLEAR I_VBAP.
ELSE.
CONTINUE.
ENDIF.
ENDLOOP.
SORT I_VBAP.
ENDFORM. "SALESDATA_VALIDATION
regards,
srinivas
<b>*reward for useful answers*</b> -
Delete a .csv file from desktop system
Hi All,
My requirement is to read the .csv file from the desktop system having the shared folder and delete the file after read successfully.
Here I can read the .csv file from the location using the function RFC_REMOTE_FILE and updated the content into internal table.
But I cant delete the file from the presentation server ( Desktop system).
Can anyone tell me how to delete the .csv file from the desktop system on different location.
Note:
I followed this link to read file:
http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/9831750a-0801-0010-1d9e-f8c64efb2bd2&overridelayout=trueHi Rob,
Thanks. I solved this problem myself.
The solution to delete the file from remote system is
concatenate 'DEL' i_filename i_dirname into v_bkfile separated by space .
call function 'RFC_REMOTE_EXEC'
destination c_dest
exporting
command = v_bkfile
exceptions
system_failure = 1 MESSAGE v_ermsg
communication_failure = 2 MESSAGE v_ermsg. -
Error loading csv file from application server
Hi all,
While uploading a csv file from the application server to psa we are getting the following error,
Error 2 while splitting CSV data record
Message no. RSDS_ACCESS011
Diagnosis
Error 2 occurred while splitting the CSV data record 1
1 = Could not find a closing escape character
2 = Invalid escape character
3 = Conversion error
4 = Other error
System Response
The function was terminated.
Procedure
Check the values of the data separator and escape sign, and try again.
But i've checked the file and the escape sign, data seperator in it also. Everything is fine. The same file we are able to load successfully in quality system.
How to solve this error??
Thanks in advance.Hi BI consultant:
Could you please provide more details?
For example:
1.Is your P application server a UNIX flavor? (Solaris, AIX, UX, Linux)
If yes..
2. Are you able to see the contents of the file correctly with a "cat" or "vi" command? (at operating system level).
If no...
3. Did you upload the csv flat file to the server via FTP?
If yes...
4. Did you use the "binary" or the "ascii" parameter on the FTP command used to upload the file?
Probably you need to upload the CSV file again to your application server and make sure you can se the file contents ("cat" or "vi" command) before trying to execute the InfoPackage.
Regards,
Francisco Milán.
Edited by: Francisco Milan on Jun 3, 2010 11:13 AM -
Problem in converting table data into CSV file
Hi All,
In my Process i need to convert my error table data into csv file,my data is converted as csv file by using OdisqlUnload function,but the column headers are not converted,i use another procedure for converting column headers but iam getting below error ...
com.sunopsis.sql.SnpsMissingParametersException: Missing parameter string.find, string.find
SQL: import string import java.sql as sql import java.lang as lang import re sourceConnection = odiRef.getJDBCConnection("SRC") output_write=open('C:/Oracle/Middleware/Oracle_ODI2/oracledi/pro/PRO.txt','r+') myStmt = sourceConnection.createStatement() my_query = "select * FROM E$_LOCAL_F0911Z1" my_query=my_query.upper() if string.find(my_query, '*') > 0: myRs = myStmt.executeQuery(my_query) md=myRs.getMetaData() collect=[] i=1 while (i <= md.getColumnCount()): collect.append(md.getColumnName(i)) i += 1 header=','.join(map(string.strip, collect)) elif string.find(my_query,'||') > 0: header = my_query[7:string.find(my_query, 'FROM')].replace("||','||",',') else: header = my_query[7:string.find(my_query, 'FROM')] print header old=output_write.read() output_write.seek(0) output_write.write (header+'\n'+old) sourceConnection.close() output_write.close()
And i used below code for converting.......
import string
import java.sql as sql
import java.lang as lang
import re
sourceConnection = odiRef.getJDBCConnection("SRC")
output_write=open('C:/Oracle/Middleware/Oracle_ODI2/oracledi/pro/PRO.txt','r+')
myStmt = sourceConnection.createStatement()
my_query = "select FROM E$_COMPANY"*
*my_query=my_query.upper()*
*if string.find(my_query, '*') > 0:*
*myRs = myStmt.executeQuery(my_query)*
*md=myRs.getMetaData()*
*collect=[]*
*i=1*
*while (i <= md.getColumnCount()):*
*collect.append(md.getColumnName(i))*
*i += 1*
*header=','.join(map(string.strip, collect))*
*elif string.find(my_query,'||') > 0:*
*header = my_query[7:string.find(my_query, 'FROM')].replace("||','||",',')*
*else:*
*header = my_query[7:string.find(my_query, 'FROM')]*
*print header*
*old=output_write.read()*
*output_write.seek(0)*
*output_write.write (header+'\n'+old)*
*sourceConnection.close()*
*output_write.close()*
Any one can you help regarding this
Edited by: 30021986 on Oct 1, 2012 6:04 PMThis may not be an option for you but in pinch you may want to consider outputing your data to an MS Spreadsheet, then saving it as a CSV. It's somewhat of a cumbersome process, but it will get you by for now.
You will need to change your content type to application/vnd.ms-excel.
<% response.setContentType("application/vnd.ms-excel"); %>
Maybe you are looking for
-
Need help with adding form fields to PDF created in InDesign that includes links
I created a collateral piece in InDesignCC that includes hyperlinks and bookmarks - I then used LiveCycle to add an image field and text field to the front cover so our sales folks can customize it before use - the sales people with Reader can't save
-
JTable Moving Columns and keeping the index for re-display
I have a JTable with data. The data in the table is refreshed every two minutes. The user is allowed to move the columns around, but when the refresh happens, the columns go back to their original layout. I have a TableColumnModelListener attached to
-
I've created a pdf form using Adobe Live Cycle ES 8.2 and it has been working fine. Now I need to change the email address it gets sent to when the user clicks on the "Submit Form" button. How can I change this email address? Thank you in advance
-
Cannot uniquely identify member
Hi all, while Building the dimensions in essbase i am getting a warning "Can not uniquely identify member......" in dataload.err file. Has any body come across this kind of error. also i am building the dimensions from relational database using paren
-
Playback (Streaming) to bluetooth headphones constantly interrupts
Hi, I use a pair of Sennheiser Headphones (MM 450 Travel) connected via Bluetooth to my ipad (Ipad 1st Gen, Wi-Fi 64GB with iOS 4.3.3). I have absolutely no problem using them with content which is stored on my Ipad, like when I use the iPod applicat