Extracting the date from a flat file name in OWB
Hi,
I have a particular scenario, where I need to retrieve the date value from the name of the flat file and load it into a table, as a field in the target table. Is it possible to do this directly in owb. Your help would be appreciated.
regards,
varsha
-- Product : Oracle Warehouse Builder
-- Generator Version : 10.1.2.3.63
-- Created Date : Mon May 15 20:07:54 IST 2006
-- Modified Date : Mon May 15 20:07:54 IST 2006
-- Created By : owbbeta4
-- Modified By : owbbeta4
-- Generated Object Type : EXTERNAL TABLE
-- Generated Object Name : CUSTEXTERNALTABLE
-- Comments :
-- Copyright © 2000, 2006, Oracle. All rights reserved.
WHENEVER SQLERROR EXIT FAILURE;
CREATE TABLE "CUSTEXTERNALTABLE"
"C1" VARCHAR2(255),
"C2" VARCHAR2(255),
"C3" DATE,
"C4" VARCHAR2(255),
"C5" VARCHAR2(255),
"C6" INTEGER
ORGANIZATION EXTERNAL (
TYPE ORACLE_LOADER
DEFAULT DIRECTORY NCDEX_STG_LOCATION_TO_HOURLY
ACCESS PARAMETERS (
RECORDS DELIMITED BY NEWLINE
CHARACTERSET WE8MSWIN1252
STRING SIZES ARE IN BYTES
NOBADFILE
NODISCARDFILE
NOLOGFILE
FIELDS
TERMINATED BY ','
NOTRIM
"C1" ,
"C2" ,
"C3" CHAR DATE_FORMAT DATE MASK "DD/MM/YYYY",
"C4" ,
"C5" ,
"C6"
LOCATION (
'bp20042005.csv'
REJECT LIMIT UNLIMITED
NOPARALLEL
;
Similar Messages
-
Problem in the BDC program to upload the data from a flat file.
Hi,
I am required to write a BDC program to upload the data from a flat file. The conditions are as mentioned below:-
1) Selection Screen will be prompted to user and user needs to provide:- File Path on presentation server (with F4 help for this obligatory parameter) and File Separator e.g. @,#,$,%,... etc(fields in the file will be separated by using this special character) or fields may be separated by tab(tab delimited).
2) Finally after the data is uploaded, following messages need to be displayed:-
a) Total Number of records successfully uploaded.
b) Session Name
c) Number of Sessions created.
Problem is when each record is fetched from flat file, the record needs to be split into individual fields separated by delimiter or in case tab separated, then proceeding in usual manner.
It would be great if you provide me either the logic, pseudocode, or sample code for this BDC program.
Thanks,Here is an example program, if you require the delimitor to be a TAB, then enter TAB on the selection screen, if you require the delimitor to be a comma, slash, pipe, whatever, then simply enter that value. This example is simply the uploading of the file, not the BDC, I assume that you know what to do once you have the data into the internal table.
REPORT zrich_0001.
TYPES: BEGIN OF ttab,
rec TYPE string,
END OF ttab.
TYPES: BEGIN OF tdat,
fld1(10) TYPE c,
fld2(10) TYPE c,
fld3(10) TYPE c,
fld4(10) TYPE c,
END OF tdat.
DATA: itab TYPE TABLE OF ttab.
data: xtab like line of itab.
DATA: idat TYPE TABLE OF tdat.
data: xdat like line of idat.
DATA: file_str TYPE string.
DATA: delimitor TYPE string.
PARAMETERS: p_file TYPE localfile.
PARAMETERS: p_del(5) TYPE c.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
DATA: ifiletab TYPE filetable.
DATA: xfiletab LIKE LINE OF ifiletab.
DATA: rc TYPE i.
CALL METHOD cl_gui_frontend_services=>file_open_dialog
CHANGING
file_table = ifiletab
rc = rc.
READ TABLE ifiletab INTO xfiletab INDEX 1.
IF sy-subrc = 0.
p_file = xfiletab-filename.
ENDIF.
START-OF-SELECTION.
TRANSLATE p_del TO UPPER CASE.
CASE p_del.
WHEN 'TAB'.
delimitor = cl_abap_char_utilities=>horizontal_tab.
WHEN others.
delimitor = p_del.
ENDCASE.
file_str = p_file.
CALL METHOD cl_gui_frontend_services=>gui_upload
EXPORTING
filename = file_str
CHANGING
data_tab = itab.
LOOP AT itab into xtab.
CLEAR xdat.
SPLIT xtab-rec AT delimitor INTO xdat-fld1
xdat-fld2
xdat-fld3
xdat-fld4.
APPEND xdat to idat.
ENDLOOP.
LOOP AT idat into xdat.
WRITE:/ xdat-fld1, xdat-fld2, xdat-fld3, xdat-fld4.
ENDLOOP.
Regards,
Rich Heilman -
Uploading the data from a flat file into ztable
Hi,
I have a requirement where I have to upload the data from 2 flat files into 2 z tables(ZRB_HDR,ZRB_ITM).From the 1st flat file only data for few fields have to be uploaded into ztable(ZRB_HRD) .Fromthe 2nd flat file data for all the fields have to me uploaded into ztable(ZRB_ITM). How can I do this?
Regards,
Hemahi,
declare two internal table with structur of your tables.
your flat files should be .txt files.
now make use of GUI_UPLOAD function module to upload your flatfile into internal tables.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = 'c:\file1.txt'
has_field_separator = 'X'
TABLES
data_tab = itab1
EXCEPTIONS
OTHERS = 1.
use this function twice for two tables.
then loop them individually and make use of insert command. -
Updating Table using the data from a flat file
Hi,
I have a table called emp;
Name,
empno,
accountno,
amount.
This table is filled with values of name and empno.
The columns accountno and amount are empty.
I have a flat file created in some folder.
Contents of the flat file can be like this:
mani | 23 | 123 | 1000
spr | 22 | 342 | 2133
asjf | 54 | 432 | 2345
I need to access the file in the specified location, read all the records one after the other in the flat file and update the table "emp" with the values in the flat file.
Row after row all the records in the file should be updated to the table.
I found out some way to do this - its sqlloader - But it loads the data from a file to the table - i dont need that - i need to update the table.
Let me know how this can be solved ?????????
Thanks in advance.......Just to clarify Andrew's point, you can use external tables as the source table for an UPDATE statement. You cannot use them as a target for an UPDATE statement (i.e. you can't update the text file from an Oracle table).
Justin
Distributed Database Consulting, Inc.
http://www.ddbcinc.com/askDDBC -
Hi,
I have to implement the following scenario in SSIS but don't know how to do since I never worked with SSIS before. Please help me.
I have 20 different text files in a single folder and 20 different tables corresponding to each text file in SQL Server 2008 R2 Database. I need to extract the data from each text file and
load the data into corresponding table in Sql Server Database. Please guide me in how many ways I can do this and which is the best way to implement this job. Actually I have to automate this job. Few files are in same format(with same column names
and datatypes) where others are not.
1. Do I need to create 20 different projects ?
or
Can I implement this in only one project by having 20 packages?
or
Can I do this in one project with only one package?
Thanks in advance.As I said I don't know how to use object data type, I just given a shot as below. I know the following code has errors can you please correct it for me.
Public
Sub Main()
' Add your code here
Dim f1
As FileStream
Dim s1
As StreamReader
Dim date1
As
Object
Dim rline
As
String
Dim Filelist(1)
As
String
Dim FileName
As
String
Dim i
As
Integer
i = 1
date1 =
Filelist(0) =
"XYZ"
Filelist(1) =
"123"
For
Each FileName
In Filelist
f1 = File.OpenRead(FileName)
s1 = File.OpenText(FileName)
rline = s1.ReadLine
While
Not rline
Is
Nothing
If Left(rline, 4) =
"DATE"
Then
date1 (i)= Mid(rline, 7, 8)
i = i + 1
Exit
While
End
If
rline = s1.ReadLine
End
While
Next
Dts.Variables(
"date").Value = date1(1)
Dts.Variables(
"date1").Value = date1(2)
Dts.TaskResult = ScriptResults.Success
End
Sub -
Use LINQ to extract the data from a file...
Hi,
I have created a Subprocedure CreateEventList
which populates an EventsComboBox
with a current day's events (if any).
I need to store the events in a generic List communityEvents
which is a collection of
communityEvent
objects. This List needs to be created and assigned to the instance variable
communityEvents.
This method should call helper method ExtractData
which will use LINQ to extract the data from my file.
The specified day is the date selected on the calendar control. This method will be called from the CreateEventList.
This method should clear all data from List communityEvents.
A LINQ
query that creates CommunityEvent
objects should select the events scheduled for selected
day from the file. The selected events should be added to List
communityEvents.
See code below.
Thanks,
public class CommunityEvent
private int day;
public int Day
get
return day;
set
day = value;
private string time;
public string Time
get
return time;
set
time = value;
private decimal price;
public decimal Price
get
return price;
set
price = value;
private string name;
public string Name
get
return name;
set
name = value;
private string description;
public string Description
get
return description;
set
description = value;
private void eventComboBox_SelectedIndexChanged(object sender, EventArgs e)
if (eventComboBox.SelectedIndex == 0)
descriptionTextBox.Text = "2.30PM. Price 12.50. Take part in creating various types of Arts & Crafts at this fair.";
if (eventComboBox.SelectedIndex == 1)
descriptionTextBox.Text = "4.30PM. Price 00.00. Take part in cleaning the local Park.";
if (eventComboBox.SelectedIndex == 2)
descriptionTextBox.Text = "1.30PM. Price 10.00. Take part in selling goods.";
if (eventComboBox.SelectedIndex == 3)
descriptionTextBox.Text = "12.30PM. Price 10.00. Take part in a game of rounders in the local Park.";
if (eventComboBox.SelectedIndex == 4)
descriptionTextBox.Text = "11.30PM. Price 15.00. Take part in an Egg & Spoon Race in the local Park";
if (eventComboBox.SelectedIndex == 5)
descriptionTextBox.Text = "No Events today.";Any help here would be great.
Look, you have to make the file a XML file type -- Somefilename.xml.
http://www.xmlfiles.com/xml/xml_intro.asp
You can use NotePad XML to make the XML and save the text file.
http://support.microsoft.com/kb/296560
Or you can just use Notepad (standard), if you know the basics of how to create XML, which is just text data that can created and saved in a text file, which, represents data.
http://www.codeproject.com/Tips/522456/Reading-XML-using-LINQ
You can do a (select new CommunityEvent) just like the example is doing a
select new FileToWatch and load the XML data into the CommunityEvent properties.
So you need to learn how to make a manual XML textfile with XML data in it, and you need to learn how to use LINQ to read the XML. Linq is not going to work against some flat text file you created. There are plenty of examples out on Bing and Google
on how to use Linq-2-XML.
http://en.wikipedia.org/wiki/Language_Integrated_Query
<copied>
LINQ extends the language by the addition of query
expressions, which are akin to
SQL statements, and can be used to conveniently extract and process data from
arrays, enumerable
classes, XML documents,
relational databases, and third-party data sources. Other uses, which utilize query expressions as a general framework for readably composing arbitrary computations, include the construction of event handlers<sup class="reference" id="cite_ref-reactive_2-0">[2]</sup>
or
monadic parsers.<sup class="reference" id="cite_ref-parscomb_3-0">[3]</sup>
<end>
<sup class="reference" id="cite_ref-parscomb_3-0"></sup> -
How to load data from a flat file which is there in the application server
HI All,
how to load data from a flat file which is there in the application server..Hi,
Firstly you will need to place the file(s) in the AL11 path. Then in your infopackage in "Extraction" tab you need to select "Application Server" option. Then you need to specify the path as well as the exact file you want to load by using the browsing button.
If your file name keeps changing on a daily basis i.e. name_ddmmyyyy.csv, then in the Extraction tab you have the option to write an ABAP routine that generates the file name. Here you will need to append sy-datum to "name" and then append ".csv" to generate complete filename.
Please let me know if this is helpful or if you need any more inputs.
Thanks & Regards,
Nishant Tatkar. -
Error while uploading data from a flat file to the hierarchy
Hi guys,
after i upload data from a flat file to the hierarchy, i get a error message "Please select a valid info object" am loading data using PSA, having activated all external chars still get the problem..some help on this please..
regards
Srithere is o relation of infoobject name in flat file and infoobjet name at BW side.
please check with the object in the BW and their lengths and type of the object and check your flat file weather u have the same type there,
now check the sequence of the objects in the transfer rules and activate them.
there u go. -
What is the best way to load and convert data from a flat file?
Hi,
I want to load data from a flat file, convert dates, numbers and some fields with custom logic (e.g. 0,1 into N,Y) to the correct format.
The rows where all to_number, to_date and custom conversions succeed should go into table STG_OK. If some conversion fails (due to an illegal format in the flat file), those rows (where the conversion raises some exception) should go into table STG_ERR.
What is the best and easiest way to archive this?
Thanks,
Carsten.Hi,
thanks for your answers so far!
I gave them a thought and came up with two different alternatives:
Alternative 1
I load the data from the flat file into a staging table using sqlldr. I convert the data to the target format using sqlldr expressions.
The columns of the staging table have the target format (date, number).
The rows that cannot be loaded go into a bad file. I manually load the data from the bad file (without any conversion) into the error table.
Alternative 2
The columns of the staging table are all of type varchar2 regardless of the target format.
I define data rules for all columns that require a later conversion.
I load the data from the flat file into the staging table using external table or sqlldr without any data conversion.
The rows that cannot be loaded go automatically into the error table.
When I read the data from the staging table, I can safely convert it since it is already checked by the rules.
What I dislike in alternative 1 is that I manually have to create a second file and a second mapping (ok, I can automate this using OMB*Plus).
Further, I would prefer using expressions in the mapping for converting the data.
What I dislike in alternative 2 is that I have to create a data rule and a conversion expression and then keep the data rule and the conversion expression in sync (in case of changes of the file format).
I also would prefer to have the data in the staging table in the target format. Well, I might load it into a second staging table with columns having the target format. But that's another mapping and a lot of i/o.
As far as I know I need the data quality option for using data rules, is that true?
Is there another alternative without any of these drawbacks?
Otherwise I think I will go for alternative 1.
Thanks,
Carsten. -
How to Extract data from a flat file and how to upload it into table
Hi
i want to extract the data from a web page, that data i want to keep in text file.
from the text file i want to read it and i want to upload into table
can any one help me its very urgenthere is my 20min try without debugging (needs a rs232 and loopback connector )
use the probe and highlight the dataflow to see how it works.
as always: there are many ways to solve your problem
Greetings from Germany
Henrik
LV since v3.1
“ground” is a convenient fantasy
'˙˙˙˙uıɐƃɐ lɐıp puɐ °06 ǝuoɥd ɹnoʎ uɹnʇ ǝsɐǝld 'ʎɹɐuıƃɐɯı sı pǝlɐıp ǝʌɐɥ noʎ ɹǝqɯnu ǝɥʇ'
Attachments:
read write file to RS232.vi 69 KB -
Step by Step details on how to load data from a flat file
hi can anyone explain how to load data from a flat file. Pls giv me step by step details. thnx
hi sonam.
it is very easy to load data from flat file. whn compared with other extrations methods...
here r the step to load transation data from a flat file.......
step:1 create a Flat File.
step:2 log on to sap bw (t.code : rsa1 or rsa13).
and observe the flat file source system icon. i.e pc icon.
step:3 create required info objects.
3.1: create infoarea
(infoObjects Under Modeling > infoObjects (root node)-> context menu -
> create infoarea).
3.2: create char /keyfig infoObject Catalog.(select infoArea ---.context menu --->create infoObject catalog).
3.3: create char.. infoObj and keyFig infoObjects accourding to ur requirement and activate them.
step:4 create infoSource for transaction data and create transfer structure and maintain communication structure...
4.1: first create a application component.(select InfoSources Under modeling-->infosources<root node>>context menu-->create applic...component)
4.2: create infoSource for transation data(select appl..comp--.context menu-->create infosource)
>select O flexible update and give info source name..
>continue..
4.4: *IMp* ASSIGN DATASOURCE..
(EXPAND APPLIC ..COMP..>EXPAND YOUR INFOSOURCE>CONTEXT MENU>ASSIGN DATASOURCE.)
>* DATASOURCE *
>O SOURCE SYSTEM: <BROWSE AND CHOOSE YOUR FLAT FILE SOURCE SYSTEM>.(EX:PC ICON).
>CONTINUE.
4.5: DEFINE DATASOURCE/TRANSFER STRUCTURE FOR IN FOSOURCE..
> SELECT TRANSFER STRUCTURE TAB.
>FILL THE INFOOBJECT FILLED WITH THE NECESSARY INFOOBJ IN THE ORDER OR SEQUENCE OF FLAT FILE STRUCTURE.
4.6: ASSIGN TRANSFER RULES.
---> NOW SELECT TRANSFER RULES TAB. AND SELECT PROPOSE TRANSFER RULES SPINDLE LIKE ICON.
(IF DATA TARGET IS ODS -
INCLUDE 0RECORDMODE IN COMMUNICATION STRUCTURE.)
--->ACTIVATE...
STEP:5 CREATE DATATARGET.(INFOCUBE/ODS OBJECT).
5.1: CREATE INFO CUBE.
-->SELECT YOUR INFOAREA>CONTEXT MENU>CREATE INFOCUBE.
5.2: CREATE INFOCUBE STRUCTURE.
---> FILL THE STRUCTURE PANE WILL REQUIRE INFOOBJECTS...(SELECT INFOSOURCE ICON>FIND UR INFOSOURCE >DOUBLE CLICK > SELECT "YES" FOR INFOOBJECT ASSIGNMENT ).
>MAINTAIN ATLEAST ON TIME CHAR.......(EX; 0CALDAY).
5.3:DEFINE AND ASSIGN DIMENSIONS FOR YOUR CHARACTERISTICS..
>ACTIVATE..
STEP:6 CREATE UPDATE RULES FOR INFOCUDE USING INFOSOURCE .
>SELECT UR INFOCUBE >CONTEXT MENU> CREATE UPDATE RULES.
> DATASOURCE
> O INFOSOURCE : _________(U R INFOSOURCE). AND PRESS ENTER KEY.......
>ACTIVATE.....UR UPDATE RULES....
>>>>SEE THE DATA FLOW <<<<<<<<----
STEP:7 SCHEDULE / LOAD DATA..
7.1 CREATE INFOPACKAGE.
--->SELECT INFOSOURCE UNDER MODELING> EXPAND UR APPLIC.. COMP..> EXPAND UR INFOSOURCE..> SELECT UR DATASOURCE ASSIGN MENT ICON....>CONTEXT MENU> CREAE INFOPACKAGE..
>GIVE INFOPACKAGE DISCREPTION............_________
>SELECT YOUR DATA SOURCE.-------> AND PRESS CONTINUE .....
>SELECT EXTERNAL DATA TAB...
> SELECT *CLIENT WORKSTATION oR APPLI SERVER >GIVE FILE NAME > FILE TYPE> DATA SAPARATER>
>SELECT PROCESSING TAB
> PSA AND THEN INTO DATATARGETS....
>DATATARGET TAB.
>O SELECT DATA TARGETS
[ ] UPDATE DATATARGET CHECK BOX.....
--->UPDATE TAB.
O FULL UPDATE...
>SCHEDULE TAB..
>SELECT O START DATA LOAD IMMEDIATELY...
AND SELECT "START" BUTTON........
>>>>>>>>>>
STEP:8 MONITOR DATA
> CHECK DATA IN PSA
CHECK DATA IN DATA TARGETS.....
>>>>>>>>>>> <<<<<<<<<----
I HOPE THIS LL HELP YOU..... -
Unable to extract the data from ECC 6.0 to PSA
Hello,
I'm trying to extract the data from ECC 6.0 data source name as 2LIS_11_VAHDR into BI 7.0
When i try to load Full Load into PSA , I'm getting following error message
Error Message: "DataSource 2LIS_11_VAHDR must be activated"
Actually the data source already active , I look at the datasource using T-code LBWE it is active.
In BI on datasource(2LIS_11_VAHDR) when i right click selected "Manage" system is giving throughing below error message
"Invalid DataStore object name /BIC/B0000043: Reason: No valid entry in table RSTS"
If anybody faced this error message please advise what i'm doing wrong?
Advance thanksECC 6.0 side
Delete the setup tables
Fill the data into setup tables
Schedule the job
I can see the data using RSA3 (2LIS_11_VAHDR) 1000 records
BI7.0(Service Pack 15)
Replicate the datasource in Production in Backgroud
Migrate Datasource 3.5 to 7.0 in Development
I did't migrate 3.5 to 7.0 in Production it's not allowing
When i try to schedule the InfoPakage it's giving error message "Data Source is not active"
I'm sure this problem relate to Data Source 3.5 to 7.0 convertion problem in production. In Development there is no problem because manually i convert the datasource 3.5 to 7.0
Thanks -
Data from a Flat file int a Cube
Hi experts!
Just a quick one, could we load data from a flat file directly to an infocube?
Or we woud need to create a ODS to load that from the flat file there and later on form the ODS to the cube?
Thanks you very much for your time!!Hi,
You can directly load the flat data into the info cube. This should not be a problem.
Create a flat file datasource according to the structure of the flat file. Create Transformations and DTP to the Cube.
Load the flat file data into the PSA and then DTP the request into the cube.
If the flat file load is a full load and one time load and data has to be deleted and loaded on the next load then above approach is fine.
But if your load is every day load and delta then it would be appropriate to have a DSO in between the data flow.
Hope it helps. -
Is it possible to Extract the Data from Website?
Dear Experts,
Is it possible to Extract the Data from Website and Upload it in the SAP Table?.It is very Urgent.Please help me.
Thanks & Regards,
Ashok.Hi Friend,
Generaly if it is one time activity you can do it manually by copy paste in excel.
But if it is weekly or monthly activity then you have to ask website provide to provide data in excel or CSV file and upload it into SAP.
I have a situtation like this, and they (Rapaport price) provide it in CSV format with defined columns.
So it is better to raise the issue to website provider.
Regards
Krishnendu -
Uploading Data from a Flat File
Hi
I am trying to Upload data from a Flat File to the MDS. I have a few questions on the Process.
a) XI would be the Interface, and one end would be a file adapter with the Flat File format. On the other end, which Interface should I use - ABA Business Partner In or MDM Business Partner In. I do not understand the differences between them and where should which one be used?
B) At the moment,I want to map the data to standard Object type, Business Partner BUS1006. This also has a staging area already defined in the System. Can I view the data which is imported into the Staging area ? How so ?
C) The struture (or data) that I wish to upload has few fields, and does not map to the BP structure easily. In such a scenario does it make sense to
Create a new Object type
(ii) Create a new Business Partner type with the appropriate fields only ..
What I need to know is if either of these options is feasible and what are the pros & cons of doing this, in terms of effort, skillset & interaction with SAP Development ?
Kindly do reply if you have any answers to these questions.
Regards,
GauravHi Markus,
Thanks for your inputs.
I have tried uploading some dats from a Flat file to the Business Partner Onject type, BUS1006. I initially got some ABAP Parsing errors on the MDM side, but after correcting that, I find my message triggers a short dump - with the Method SET_OBJECTKEYS, not finding any keys in the BP structure that has been created.
Q1 - How do I get around this problem ? Is it necessary for me to specify Keys in the PartyID node of the Interface ABABusinessPartnerIn. or is it something else ?
Q2 - How is this general process supposed to work? I would assume that for staging, I would get incomplete Master data or data from flat files, which need not neccesarily contain keys. The aim is to use the matching strategies in the CI to identify duplicates and consolidate them.
Thanks in advance for your reply.
Regards,
Gaurav
Maybe you are looking for
-
Re: purchasing info record.
Hi guru's, The specific vendor supplies different materils for diff., plants in a company code, Now the problem is how can I assign at a time a tax code, for diff., pur info record of material & vendor. waiting for replies tuljasingh.
-
Here's the problem: I am currently using a fax-switch that answers the incoming line, listens for a fax tone and, should it hear it, forwards the call to a fax machine. Without fax tone, the call is routed to the SPA-3102 and treated as voice. This s
-
Secure Empty Trash just gets stuck
Secure Empty Trash doesn't work. it just gets stuck/crashes. Why is this? 10.9.5 mavericks
-
Inventory: 13 Collection Task(s) failed.
I forced a H/W inventory on 1 Win7 machine. IN the InventoryAgent.log it says this: So far I've only seen this on 1 machine. And what else is odd is this very same machine did receive and run an advertisement 1 week ago. What would cause this
-
Changing DB_NAME after database installation
Hi, I installed Oracle10g on linux server. now I want to change the database name DB_NAME for security reasons. How can i do this? and where all i need to the changes for the database and EM to come back up successfully. Thanks in advance.