Pl/Sql for creating Multiple record type file
Hi all,
I have a scenario where I need to create a flat file that contains two different record types in the same file. Basically, a way of getting both the header record and the corresponding detail records. Following are the details:
Table A (Header Records)
"REC_TYPE" "M_ID" "DATE" "*C_ID*"
1 123 090807 *222*
1 345 090907 *333*
Table B (Detail Records)
"REC_TYPE" "A_NO" "LINE_NO" "*C_ID*"
2 7564 1 *222*
2 4535 2 *222*
2 4656 1 *333*
2 6576 2 *333*
In the output file, the resultset should be as:
222, 123, 090807 (Header Record)
*222, 7564, 1* (Detail Record)
*222, 4535, 2* (Detail Record)
333, 345, 090907 (Header Record)
*333, 4656, 1 (Detail Record)*
*333, 6576, 2 (Detail Record)*
Any input is greatly appreciated.
Thank you!
NOT TESTED ! Don't remember when I used loops for the last time. I won't have database access until september (on vacation).
declare
type header_t is record
c_id ... ,
type detail_t is record
c_id ... ,
header_r header_t;
detail_r detail_t;
cursor c_h is select c_id, ...
from ...
order by 1; -- header cursor
cursor c_d is select c_id, ...
from ...
order by 1; -- detail cursor
end_line varchar2(2) := chr(13) || chr(10); -- chr(10) to be used for non Windows
a_separator varchar2(1) := ',';
a_buffer varchar2(32767);
l_buffer constant number := 32767;
f_handle utl_file.file_type;
procedure buffer_put(p_line in varchar2) is
begin
if length(a_buffer) + length(p_line) < l_buffer then
a_buffer := a_buffer || p_line;
else
utl_file.put(f_handle,a_buffer);
a_buffer := p_line;
end if;
end;
function build_header_record(p_record in header_t) return varchar2 is
retval varchar2(4000) := '';
begin
retval := retval || to_char(p_record.c_id) || a_separator;
retval := retval || ... || a_separator;
retval := retval || ... || end_line;
return retval;
end;
function build_detail_record(p_record in detail_t) return varchar2 is
retval varchar2(4000) := '';
begin
retval := retval || to_char(p_record.c_id) || a_separator;
retval := retval || ... || a_separator;
retval := retval || ... || end_line;
return retval;
end;
begin
f_handle := utl_file.fopen ('THE_DIRECTORY','the_file.ext','w',l_buffer);
open c_h;
open c_d;
loop
fetch c_h into header_r;
exit when c_h%notfound;
buffer_put(build_header_record(header_r));
if c_h%rowcount > 1 and (header_r.c_id = detail_r.c_id) then
buffer_put(build_detail_record(detail_r));
end if;
loop
fetch c_d into detail_r;
exit when c_d%notfound or (detail_r.c_id != header_r.c_id);
buffer_put(build_detail_record(detail_r));
end loop;
end loop;
if length(a_buffer) > 0 then
utl_file.put(f_handle,a_buffer);
end if;
utl_file.fflush(f_handle);
utl_file.fclose(f_handle);
end;Regards
Etbin
utl_file.fclose(f_handle); instead of utl_file.fclose;
Edited by: Etbin on 11.8.2009 8:54
Similar Messages
-
File Adapter - Multiple Record Types to same Target
I am currently reading in a fixed length file and loading into a table.
The issue is, some of the lines in my file differ by two spaces at the end. See example below.
For example,
Record 1 might look like :
DD/MM/YY - length of 8
Record 2 might look like:
DD/MM/YY{space}{space} - length of 10
and they both go into the same date column of my target
Question 1) Is there a way for BPEL to skip the two spaces at the end of each line for Record 2
Queston 2) I have currently created multiple record types for the two types but it won't allow me in my transformation to map them both to the "date" column in the target table. It says multiple nodes cannot be mapped to the target
Any help would be appreciated.Hi,
Unfortunately the IKM SQLDR doesn't have the "when" condition to be wrote at ctl file.
If you wish a simple solution, just add an option (drop me a email if you want a LKM with this)
The point is:
With a single option, you will control the when ctl clause and, for instance, can define:
1) create 2 datastores (1 for each file)
2) the first position will be a column at each datastore
3) write the when condition to this first column at the LKM in the interface.
Does it help you? -
Creating multiple records from 1 record in the source file for Import DM
Hi Experts,
Today I am working on an interface/import where I want to get the following result:
Source file contains a records like:
Account, Entity, DriverX
Sales,EntityA,ZZ
The BPC appset contains the 2 dimensions Account and Entity next to CostCenter dimension. The DriverX field in the source file is just additional information in the source file. However based on this DriverX we need to determine what CostCenter to choose but we also need to have the same record assigned to a second record in BPC.
Following my example, based on DriverX value I need to create 2 records:
Account, Entity, CostCenter,
Sales,EntityA,CC1
Sales,EntityA,CC2
I don't have a problem assigning the record to 1 CostCenter based on DriverX value but I have a problem creating my second record. Does any of you have had the same "challenge" and if so would you like to share the solution for this?
Best regards,
Johan
PS: I am working on SAP BPC, version 7.0 Microsoft version.Hi Greg,
Many thanks for your answer. And yes this would be a solution. However I just simplified my case as the decision to create an second record and where to post is depending on more than 1 field in the source.
But I will keep it in mind, because I also can opt for a solution to store data differently in BPC fac-tabels which will help me to use script logic.
If it is not possible to create multiple records from a single records in the standard functionality in the Transformation and/or Conversion file, I have to create a custom DTSX or change my way of storing data.
Anyone else who is having an alternative idea like Greg came up with?
Please let it know!
Best regards,
Johan -
Flat File with multiple record types (OWB 10.2.0.2)
Hi!
I`m using OWB 10.2.0.2 and I`m trying to load a flat file with multiple record types, using SQL LOADER.
In the flat file editor in the Record tab, I`ve set the type values and the corresponding record names like this:
Type Value Record Name
======== ===========
T TRAILER
0 DETAILS
1 DETAILS
2 DETAILS
When using this flat file in a mapping to load the data in a staging table, the generated code looks like this:
INTO TABLE TRAILER
TRUNCATE
REENABLE DISABLED_CONSTRAINTS
WHEN (1:1) = 'T'
INTO TABLE DETAILS
APPEND
REENABLE DISABLED_CONSTRAINTS
WHEN (1:1) = '0,1,2'
The above clause (WHEN (1:1) = '0,1,2') is wrong as I expect one "INTO TABLE..." clause for each record type.
Could this be a bug or am I doing something wrong?
Thanks a lot for your help,
YorgosWe`re using two target tables, one for the trailer record and the other for the details records.
We are facing this problem from the moment we upgraded from OWB 10.1 to OWB 10.2.0.2, so we think it must be something with the way the sql loader code is generated in the new version.
As our data sources are mainly flat files coming from mainframes, this is a huge problem for us. We even asked an expert in DW from Oracle to help us on this, but still haven`t found a solution.
Is there any workaround for this or should we forget sql loader and go with an external tables + custom PL/SQL code solution?
Your help is greatly appreciated Jean-Pierre.
Regards,
Yorgos -
How create a record type and a pl/sql table of that record type in database
Hi
I want to create a record type and then I want to create a PL/SQL table in the oracle 9i database.
I have done it in PL/SQL block.
But when I am trying to do it in database it is throwing me some error.
Could you please tell me how can I do that?
Regardsuser576726 wrote:
Hi
I want to create a record type and then I want to create a PL/SQL table in the oracle 9i database.
I have done it in PL/SQL block.
But when I am trying to do it in database it is throwing me some error.
Could you please tell me how can I do that?
RegardsRECORD type is supported only in PL/SQL for SQL you need to use OBJECT type. -
Creating Multiple XML target file
HI Experts,
I would require some guidance from you. I have a situation whereby, I have to create multiple XML target file based on records.
The job in my hand is to extract the customer master from ECC and load it into XML files. But the catch is I need to create one XML file per customer. ie if my source has 500 customer then i have to create 500 XML and each XML file should contain all the information for that customer.
Can anyone guide me how to split the target XML in a single job. i.e. One XML per record of source data.Hi Dirk,
Please find the below screenshot of job
workflow
Initialization Script
While LOOP
Increment Script
data flow
Target XML
Please help me with this. -
FM for creating Condition Records
Is there FM for creating Condition Records for output type like transaction VV11 (Create Output - Condition Records: Sales)
Hi there,
FM for condition records? Why do you want to think of a FM for creating conditon records?
Condition records is a master data that has to be manually created as per the business requirement.
But what we can do is that if the data ia existing in an external legacy system, we can migrate that into SAP through a BAPI / BDC or LSMW depending on the volume of data.
But in other cases condition records are manually created in SAP system.
If at all you have a function module to create condition records, how would you ensure that it feeds correct data into the condition records? What key combination would the system take & what data would you want the FM to upload?
How will you monitor what data is uploaded,.
Regards,
Sivanand -
How to create multiple Tree Type Region In Tabular Form ?
Dear Friends,
i have to design tabular form to Distribute User Rioght to emp to access application
eg if i have Three module in application
1.Administration
2.Attendance
3.Accounts
Module
1 Administration have 5 Pages A,B,C,D,E.
Module
2 Attendance HAVE 4 Pages F,G,H,I
Module
3 Accounts HAVE 7 Pages J,K,L,M,N,O,P
I need these three module divided into three section in tabular form as a tree Type like
Module 1 Tree Open in Tabular Form like
- (Tree Mark Open )
=======================================================
PAGE_ID-------------SUBPAGE_ID-------VIEW-------------------MODIFY-------------------CREATE----------------------------TABLE COLUMN NAME
========================================================
Administration-----------A------------------CHECK bOX------------CHECK BOX-------------CHECK BOX
Administration-----------B------------------CHECK bOX------------CHECK BOX-------------CHECK BOX
Administration-----------C------------------CHECK bOX------------CHECK BOX-------------CHECK BOX
Administration-----------D------------------CHECK bOX------------CHECK BOX-------------CHECK BOX
Administration-----------E------------------CHECK bOX------------CHECK BOX-------------CHECK BOX
- (Tree Mark Open )
Module 2 Tree Open in Tabular Form like
Attendance-----------F------------------CHECK bOX------------CHECK BOX-------------CHECK BOX
Attendance-----------G------------------CHECK bOX------------CHECK BOX-------------CHECK BOX
Attendance-----------H------------------CHECK bOX------------CHECK BOX-------------CHECK BOX
Attendance-----------I------------------CHECK bOX------------CHECK BOX-------------CHECK BOX
- (Tree Mark Open )
Module 3 Tree Open in Tabular Form like
Accounts-------------J------------------CHECK bOX------------CHECK BOX-------------CHECK BOX
Accounts-------------K------------------CHECK bOX------------CHECK BOX-------------CHECK BOX
Accounts-------------L------------------CHECK bOX------------CHECK BOX-------------CHECK BOX
Accounts-------------M------------------CHECK bOX------------CHECK BOX-------------CHECK BOX
Accounts-------------N------------------CHECK bOX------------CHECK BOX-------------CHECK BOX
Accounts-------------O------------------CHECK bOX------------CHECK BOX-------------CHECK BOX
Accounts-------------P------------------CHECK bOX------------CHECK BOX-------------CHECK BOXi need divided these three Module in Tabular form in three region as tree.
Table APPLICATION_PAGE_DETAILS
ID NUMBER
PAGE_ID NUMBER
SUB_PAGE_ID NUMBER
========================
TABLE USER_RIGHT
======================
ID NUMBER
EMP_ID NUMBER
PAGE_ID NUMBER
SUB_PAGE_ID NUMBER
VIEW VARCHAR2(1)
MODIFY VARCHAR2(1)
CREATE VARCHAR2(1)How to create multiple Tree Type Region In Tabular Form ?
How can i do this ?
Thanks
Edited by: Vedant on Oct 4, 2011 3:21 AM
Edited by: Vedant on Oct 4, 2011 9:09 PM
Edited by: Vedant on Oct 13, 2011 8:57 PMWell think of it I believe the scenario is too bird viewed hence the solution can't be exact.
But thinking of a possible solution every time a child operation fails have a catch block where you you go back to system if the parent needs to be deleted if yes, call Delete Method on the parent.
Note: Make sure that the decision on whether or not the parent record needs to be deleted will depends on the question "Does Parent Record already has several other children associated to it or not"
Hope this clarifies.
Regards,
Messer -
Dynamic PL/SQL for Deletion of Records
Dear all,
I am using Dynamic PL/SQL for Deletion of Records,In that PL/SQL, i have to get the no.of records deleted and send a report with the no.of rows deleted.
Please help me on this..
Thanks,
MurugesanHi,
Try this:
SQL> SELECT * FROM T;
DT CODE
14-FEB-07 1
14-FEB-07 1
14-FEB-07 1
14-FEB-07 2
14-FEB-07 2
SQL>
SQL> ed
Wrote file afiedt.buf
1 BEGIN
2 EXECUTE IMMEDIATE ' DELETE FROM T WHERE CODE = 1';
3 DBMS_OUTPUT.PUT_LINE(' Total Deleted Rows :'||SQL%ROWCOUNT);
4* END;
SQL> /
Total Deleted Rows :3
PL/SQL procedure successfully completed.
SQL> Regards
Avinash -
When creating multiple records in a table using a SBO object eg invoice object, do you have to create a new business object for each record that is created? There is a lot of overhead in doing this (eg each object takes about 1MB of mem so to create 1000 invoices would hog 1GB of mem). Is there a way to create just one instance of the object and use it to create many records? How is the object cleared in between each record creation?
Greg,
Everytime you call GetBusinessObject() you should, at the end, also release the acquired memory.
This can be done with the following code in .net (C#):
System.GC.Collect();
System.GC.WaitForPendingFinalizers();
Another way to clear all the data is to call the <b>GetByKey(-1)</b>; the document with docentry '-1' does never exists and the fields of the object are normally cleared.
Regards,
Jurgen -
Posting multiple records from file to idoc
Hi Exerts,
i have done scenario to post one record from file to IDOC, to post multiple records from file to idoc what are the options to be modified in the scenario.
thanks,
dhanushHi Dhanush,
You need to change the occurance of idoc to 0 to unbounded ie need to opt idoc packaging.
Just download the xsd of you idoc to the desktop and change the occurance tag as "<xsd:element name="IDOC" type="COND_A.COND_A02" maxOccurs="unbounded" />" and then reimport it into External definition and use it in your message mapping and then map it with you source structure.
Regards,
Prasanthi. -
HCM Processes and Forms - Create multiple records of one infotype (eg 0008)
Dear all,
I'm trying to create two new records in infotype 0008 (basic pay). Regarding it's time constraint 1 it should like the following:
Before
01.01.2010 - 31.12.9999 - 2000u20AC
After
01.01.2010 - 08.11.2010 - 2000u20AC
09.11.2010 - 31.12.2010 - 2500u20AC
01.01.2010 - 31.12.9999 - 3000u20AC
So I want to add two splits two the record. One is easy, as it's done by the SAP_PA operation. I experimented with the record indices and duplicating my fields, but it didn't work. Another idea would be to retriggerd the SAP_PA several times using scenario steps.
Can you give me a hint, by which lever multiplee splits can be achieved? Or is this not possible at all?
Thanks in advance,
PeterThanks for your fast reply.
Knowing this as a fallback is comforting. I just want to ensure, that I don't apply any coding, if a task is also possible by customizing.
Another idea I had in the meantime was to execute the SAP_PA several times. Do you have any experience, if this works to create multiple records in one infotype?
Edited by: Peter Gilberg on Nov 9, 2010 2:34 PM -
JDev 11g: Create Multiple Record.
Hi,
I have a requirement to create multiple record by clicking the create button multiple times and on one click it should save all the records. Everything is working fine, but the issue is,
when user created 4 records and the 5th record he doesn't want to create then issue is comming. Application is forcing him to enter the data, is there is any way to handle this situation.
I mean, if the 5th record doesn't contain any data.. it should save 4 records only. Please suggest me the solution to achieve this.
Thanks,
RajeshHi Shay,
Thanks for your reply. But your second solution will never occur in my case because validator methods will not allow user to click on save button without entering the proper data.
Is there any otherway instead of deleting the record to achieve this functionality.
Thanks,
Rajesh -
Can we create multiple records before navigation to that block
Can we create multiple records and assign values in Forms, before navigation to that block (in a trigger ), and populate ?
Hello,
No you cannot. You need to be inside the block in order to use the Create_Record built-in.
Francois -
Postings in SAP HR for creating delta records for Time Management
Hi Experts,
I am trying to test delta load for SAP HR Time Management Datasources. I am fairly new to SAP HR and need some help.
Where do we create postings in SAP HR for creating delta records which can be imported to BW. This is for the data sources 0HR_PT_1 and 0HR_PT_2.
Any help is appreciated. Will assign full points
Regards
Sunil Kumar.Hi,
In order to test the above data sources you need to have some employee enter his time details or change the entered time details. That will create some delta records for the planned or actual times. CAT2 transaction should help entering the time details in SAP.
Hope it helps.
Maybe you are looking for
-
How do I make multiple buttons in my flash animation?
I am new to flash, and I have no training in it whatsoever. I created a flash animation with flash CS3 for my photography website, and I want to link each of the images to different galleries on my site. When I created my first button it worked fine,
-
I don't know any other details.
-
How to set a selected checkbox in output internal table of oops ALV grid
Hi All, i have a checkbox as first column in my ALV grid output using oops alv, when i select some checkbox, that rows have to be selected and i need to process only selected rows in user command. i have given the below code also in fieldcatolg. f_fl
-
FCC: Problems with content conversion
Dear all, I have a receiver FTP adapter with content conversion. In RWB I'm facing following error message: Adapter Framework caught exception: Exception in XML Parser (format problem?):'java.lang.Exception: Message processing failed in XML parser: '
-
Flash video / autohide question
Hi, I'm building a website in Flash 8 which plays a number of videos. I have the choice of playing the videos using FLVPlayback components built into each video's .swf, or just creating a custom controller skin (the client wants a skin which resemble