DMEE Issues header and detail record
Hi Gurs,
I am working in DMME(PAYM) payment medium .
I have declared DMEE header structure(00000001000001 ) as level 1 and detail (050000010020192 XX110000001) as also level 1.
This is the output format i am getting.
00000001000001
05000001002000 XX110000001
00000001000001
05000001002012 XX110000002
00000001000001
05000001002012 XX110000003 00000001000001
05000001002011 XX110000004
But my requirment not lke this. i need to dispaly all detail items under one header also i need to increase the counter for every items starting from 2.
Both header and detail are at level 1.If i declared the detail as level 2 the output is not generated.
This is what i need.
00000001000001
05000002002000 XXX110000001
05000003002012 XXX110000002
05000004002012 XXX110000003
05000005002011 XXX110000004
Pls suggest me any solutions
Thanks .
Edited by: bala chandran on Oct 9, 2009 10:57 AM
NOT answered
Similar Messages
-
File content conversion - sender adapter for Header and detail records
Hi Experts,
I am receiving a field of fixed length content format.(Header)The first line of the file will follow the structure X having some fields and (DetailRecord)subsequent lines in the file will follow structure Y having somes fields.There is no record identifier for Header and Detail records.In one file first line is Header records and remaining subsequent line is DetailRecord.What are the parameters we have to set for sender file content conversion parameters as i donot have any key field and key field value.And in one file we have only one header records ( first line) and n number of detail records from 2nd line onwards.
Thanks
DeepakHi
Refer the below fourm link,
Flat file whitout id
Regards
Ramg. -
DMEE issue in header and detail record
Hi Gurs,
I am working in DMME payment medium .
I have declared DMEE header structure(00000001000001 ) as level 1 and detail (050000010020192 XX110000001) as also level 1.
This is the output format i am getting.
00000001000001
05000001002000 XX110000001
00000001000001
05000001002012 XX110000002
00000001000001
05000001002012 XX110000003 00000001000001
05000001002011 XX110000004
But my requirment not lke this. i need to dispaly all detail items under one header also i need to increase the counter for every items starting from 2.
Both header and detail are at level 1.If i declared the detail as level 2 the output is not generated.
This is what i need.
00000001000001
05000002002000 XXX110000001
05000003002012 XXX110000002
05000004002012 XXX110000003
05000005002011 XXX110000004
Pls suggest me any solutions
Thanks .NOT answered
-
Outbound file interface - Header and item record transfer issue
Hi.
Pls help me complete this work by today:
I have to pass header and item record into file in application server.
I am retrieving Header record from table MCHB & RESB
and item record from MKOL & LFA1
I have to create separate file per plant ( plant is multiple selection field)
I have a check box (p_sob) for special stock selection in my selection screen .
If p_sob is initial
Header record should come from MCHB and RESB
and corresponding item entries from MKOL and LFA1
If some batch entries entries only exists in MCHB and not in MKOL then item fields will be blank
However if some entries exists only in MKOL and not in MCHB then header fields will be filled by correponding item fields.
Can anyone tell me the basic frame of the program.
Regards,
Simran*& Form sub_populate_header
Subroutine to populate header table
FORM sub_populate_header.
DATA: l_clabs TYPE char13, "Valuated stock
l_bdmng TYPE char13, "Requirement quantity
l_avqty TYPE char13, "Available quantity
l_slabs TYPE char13. "Consignment stock
DATA: i_mkol_tmp type standard table of ty_mkol initial size 0.
LOOP AT i_mchb INTO wa_mchb.
READ TABLE i_mkol INTO wa_mkol WITH KEY matnr = wa_mchb-matnr
werks = wa_mchb-werks
lgort = wa_mchb-lgort
charg = wa_mchb-charg
BINARY SEARCH.
IF sy-subrc EQ 0.
*Mark those MKOL records for deletion
wa_mkol-mark = c_mark. "marked for deletion
ELSE.
*Population of Plant,material number,batch,storage location and
*valuated stock
wa_header-werks = wa_mchb-werks. "Plant
wa_header-matnr = wa_mchb-matnr. "Material number
wa_header-charg = wa_mchb-charg. "Charg
wa_header-lgort = wa_mchb-lgort. "Storage location
wa_header-clabs = wa_mchb-clabs. "Valuated stock
l_clabs = wa_header-clabs.
SHIFT l_clabs LEFT DELETING LEADING space.
*Population of material description
READ TABLE i_makt INTO wa_makt WITH KEY matnr = wa_header-matnr.
IF sy-subrc EQ 0.
wa_header-maktx = wa_makt-maktx. "Material description
ENDIF.
*Population of Requirement quantity
READ TABLE i_sum INTO wa_sum WITH KEY charg = wa_header-charg
BINARY SEARCH.
IF sy-subrc EQ 0.
wa_header-bdmng = wa_sum-bdmng. "Requirement quantity
l_bdmng = wa_header-bdmng.
SHIFT l_bdmng LEFT DELETING LEADING space.
ENDIF.
*Population of Available quantity
l_avqty = l_clabs - l_bdmng.
SHIFT l_avqty LEFT DELETING LEADING space.
wa_header-avqty = l_avqty. "Available quantity
APPEND wa_header TO i_header.
CLEAR wa_header.
ENDIF.
ENDLOOP.
*Deleting batches from MKOL which exists in MCHB
i_mkol_tmp[] = i_mkol[].
DELETE i_mkol_tmp WHERE mark = c_mark.
*Sorting I_MKOL
SORT i_mkol_tmp BY matnr werks charg lgort.
LOOP AT i_mkol_tmp INTO wa_mkol_tmp.
*Population of Plant,Material number,charg & Storage location
wa_header-werks = wa_mkol_tmp-werks. "Plant
wa_header-matnr = wa_mkol_tmp-matnr. "Material number
wa_header-charg = wa_mkol_tmp-charg. "Batch number
wa_header-lgort = wa_mkol_tmp-lgort. "Storage location
APPEND wa_header TO i_header.
CLEAR wa_header.
ENDLOOP.
ENDFORM. " sub_populate_header
*& Form sub_populate_item
Subroutine to populate item table
FORM sub_populate_item .
LOOP AT i_mkol INTO wa_mkol.
wa_item-lifnr = wa_mkol-lifnr. "Vendor number
wa_item-slabs = wa_mkol-slabs. "Consignment stock
READ TABLE i_lfa1 INTO wa_lfa1 WITH KEY lifnr = wa_mkol-lifnr
BINARY SEARCH.
IF sy-subrc EQ 0.
wa_item-name1 = wa_lfa1-name1. "Vendor name
ENDIF.
ENDLOOP.
ENDFORM. " sub_populate_item
*& Form sub_batch_stock
Subroutine to output batch record from table (MCHB & MKOL) into
file in application server
FORM sub_batch_stock .
DATA: l_record TYPE string, "String
l_clabs TYPE char13, "Valuated stock
l_bdmng TYPE char13, "Requirement quantity
l_avqty TYPE char13, "Available quantity
l_slabs TYPE char13, "Consignment stock
l_tabix TYPE sytabix. "Index
LOOP AT i_header INTO wa_header.
*Separate file per plant
AT NEW werks.
*Creation of file
PERFORM sub_create_file.
Open File on the application server for processing
OPEN DATASET g_file_name FOR APPENDING IN TEXT MODE
ENCODING DEFAULT.
IF sy-subrc NE 0.
*Display error message
MESSAGE e055 WITH g_file_name. " Error in opening file
ENDIF.
ENDAT.
AT NEW charg.
CONCATENATE c_header " Header indentification
wa_header-werks " Plant
wa_header-matnr " Material number
wa_header-maktx " Material description
wa_header-charg " Batch number
wa_header-lgort " Storage location
l_clabs " Valuated stock-unrestricted use
l_bdmng " Requirement quantity
l_avqty " Avalable quantity.
INTO l_record SEPARATED BY
cl_abap_char_utilities=>horizontal_tab.
Transfering header record to file
TRANSFER l_record TO g_file_name.
CLEAR: l_clabs,
l_bdmng,
l_avqty,
l_record.
ENDAT.
LOOP AT i_mkol INTO wa_mkol WHERE matnr = wa_header-matnr
AND werks = wa_header-werks
AND charg = wa_header-charg
AND lgort = wa_header-lgort.
*Population of Vendor number and consignment stock
wa_item-lifnr = wa_mkol-lifnr. "Vendor number
*Storing Consignment stock into local variable to change datatype
*from QUAN to CHAR
l_slabs = wa_mkol-slabs.
SHIFT l_slabs LEFT DELETING LEADING space.
wa_item-slabs = l_slabs. "Consignment stock
*Population of Vendor name
READ TABLE i_lfa1 INTO wa_lfa1 WITH KEY lifnr = wa_mkol-lifnr
BINARY SEARCH.
IF sy-subrc EQ 0.
wa_item-name1 = wa_lfa1-name1. "Vendor name
ENDIF.
CONCATENATE c_item " Item identification
wa_item-lifnr " Vendor number
wa_item-name1 " Vendor name
l_slabs " Consignment stock-unrestd. use
INTO l_record SEPARATED BY
cl_abap_char_utilities=>horizontal_tab.
*Transfering Item record into file
TRANSFER l_record TO g_file_name.
CLEAR: l_slabs,
l_record.
ENDLOOP.
AT END OF werks.
Close File
CLOSE DATASET g_file_name.
CLEAR g_file_name.
ENDAT.
ENDLOOP.
ENDFORM. " sub_batch_stock -
Keeping heading and detail on the same page
Hi, I have a report with a group header section and a detail section. How can I keep the heading section and all the detail section on the same page without starting each group on a new page?
The detail section will have either 2 or 3 records with some of the objects set to grow if the data doesn't fit on one line. This results in several changes of group appearing on the same page which is what I want. However, what I don't want is the header section on one page with the detail section on the next, or the header and some of the detail records on one page with the rest of the detail records on the next. What I would like is the report to start a new page if the header and all the detail records don't fit on the same page but without starting a new page for every group change. How can I achieve this?you can put the group header and details into a sub report on the old group header section.
then hide the details section -
Open Hub Header and Trailer Record.
Hi,
For the Open Hub Destination
Destination Type is File,
Application server.
Type of File Name: 2 Logical File name.
How to to the get the Header and Trailer Record which will contain Creation Date, Creation Time and Total number of records.
Header record Layput :
Creation Date (YYYYMMDD)
Creation Time (HHMMSS)
Total record Count
Trailer record Layout:
Total number of Records in the file and
XXXX( Key Figure ) Total.
Thanks in advance.
Regards,
Adhvi.Hi Venkat,
write a UDF in following way...
pass the first parameter as the detail node (cache the whole queue) to the UDF pass the second parameter as the trailer countto the UDF
now loop through the detail records get the count with a counter variable
check the counter against the trailer count outside the loop
if it doesnot match trigger the alert from the UDF itself
Check the below link for triggering alert from an UDF
/people/bhavesh.kantilal/blog/2006/07/25/triggering-xi-alerts-from-a-user-defined-function -
Hi,
I have an internal table with the value below. I need to populate to header data line (1 record only) and detail is an internal table
When there is a change of customer, i need to copy 123 to header and 2 records of material (abc & xed), sales (100 & 200) and qty (10 & 12) to detail internal table.
for customer 567, i need to copy to header and material aqs, sales 150 and qty 5 to detail internal table.
May I know how can I achieve this?
customer material sales qty
123 abc 100 10
123 xed 200 12
567 aqs 150 5
877 abc 140 8
Thanks
RgdsHello,
As per my understanding, your requirement is that you have an internal table which has a combined data and you want to split it into headr and detail internal tables, based on the change of the customer number which is the first field in the combined internal table. If so then assume that it_com is the combined internal table and it_head and it_det as the header and detail interbnal tables respectively.
First sor the combined internal table on customer number
sort it_com by kunnr.
Now loop across this table and on the event at new customer populate the header table and in the remaining loop populate the detail table.
loop at it_com into wa_com.
at new kunnr.
wa_head-kunnr = wa_com-kunnr.
append wa_head-kunnr to it_head-kunnr.
clear wa_head-kunnr.
endat.
append the records from the combined table into the item table, whatever fields required
endloop.
Regards,
Sachin -
I need to display data from both header and detail, details has to come from other table also
--CREATE TABLE
CREATE TABLE [dbo].[Table_Dept](
[DeptId] [int] NULL,
[DeptCode] [char](2) NULL,
[DeptName] [nvarchar](100) NULL
) ON [PRIMARY]
CREATE TABLE [dbo].[Table_Detail](
[Header_ID] [int] NOT NULL,
[Name] [nvarchar](50) NOT NULL,
[DescValue] [nvarchar](max) NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
CREATE TABLE [dbo].[Table_Header](
[Header_Id] [int] NULL,
[UserName] [nvarchar](50) NULL
) ON [PRIMARY]
--INSERT DATA
INSERT INTO Table_Dept (DeptId, DeptCode, DeptName)
VALUES (1, 'HO', N'Head Office'),
(2, 'BO', N'Branch Office'),
(3, 'RO', N'Reginal Office'),
(4, 'SO', N'Sub Division Office')
INSERT INTO Table_Header
(Header_Id, UserName)
VALUES (1, N'Ravi'), (2, N'Gopal'), (3, N'Deepa')
INSERT INTO Table_Detail
(Header_ID, Name, DescValue)
VALUES (1, N'ListNumber', N'1005'),
(1, N'PhaseCode', N'AA'),
(1, N'DeptCode', 'BO,RO'),
(1, N'City', 'Bangalore'),
(2, N'ListNumber', N'1006'),
(2, N'PhaseCode', N'AB'),
(2, N'DeptCode', 'SO,RO'),
(2, N'City', 'Delhi'),
(3, N'ListNumber', N'1007'),
(3, N'PhaseCode', N'AA'),
(3, N'DeptCode', 'HO'),
(3, N'City', 'Mumbai')
--EXPECTED RESULT
HeaderId
ListNumber
PhaseCode
DeptName
City
User
1
1005
AA
Branch Office, Reginal Office
Bangalore
Ravi
2
1006
AB
Sub Division Office,Reginal Office
Delhi
Gopal
3
1007
AA
HO
Mumbai
Deepa
ShanmugaRajsee below code
SELECT *,
STUFF((SELECT ',' + DeptName
FROM Table_Dept
WHERE ',' + t.DeptCode + ',' LIKE '%,' + DeptCode + ',%'
FOR XML PATH('')),1,1,'') AS DeptName
FROM
SELECT h.Header_ID,
td.ListNumber,
td.PhaseCode,
td.DeptCode,
td.City
FROM Table_header h
INNER JOIN (SELECT Header_ID,
MAX(CASE WHEN Name = 'ListNumber' THEN DescValue END) AS ListNumber,
MAX(CASE WHEN Name = 'PhaseCode' THEN DescValue END) AS PhaseCode,
MAX(CASE WHEN Name = 'DeptCode' THEN DescValue END) AS DeptCode,
MAX(CASE WHEN Name = 'City' THEN DescValue END) AS City
FROM Table_Detail
GROUP BY Header_ID)td
ON td.Header_ID = h.Header_ID
)t
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs
In case of not having department table...consider the dept code, where the values are now comming from table and
need result if the data is not displayed from table and they are static..
use case when 'Bo' then 'Branch Office'
when 'Ro' then 'Reginal Office'
when 'So' then 'Sub Division Office'
when 'Ho' then 'Head Office'
kindly suggest how to replace my above query
ShanmugaRaj -
XMLSequence EXTRACT HEAD and DETAIL in ORACLE 9.2
Hi, sorry about my english i am from argentine.
I have this XML:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<arrayOfServicio >
<Servicio>
<Nombre>Autenticacion</Nombre>
<Descripcion>ws</Descripcion>
<Activo>true</Activo>
<Version>1.0</Version>
<MetodosEntity>
<Metodo>
<Nombre>RequestTicket</Nombre>
<Activo>true</Activo>
<Version>1.0</Version>
</Metodo>
</MetodosEntity>
</Servicio>
<Servicio>
<Nombre>Consultas</Nombre>
<Descripcion>wsConsultas</Descripcion>
<Activo>true</Activo>
<Version>1.0</Version>
<MetodosEntity>
<Metodo>
<Nombre>GetVigencia</Nombre>
<Activo>true</Activo>
<Version>1.0</Version>
</Metodo>
<Metodo>
<Nombre>GetSiniestralidad</Nombre>
<Activo>true</Activo>
<Version>1.0</Version>
</Metodo>
<Metodo>
<Nombre>GetAgrupados</Nombre>
<Activo>true</Activo>
<Version>1.0</Version>
</Metodo>
<Metodo>
<Nombre>GetSiniestralidadPorCuil</Nombre>
<Activo>true</Activo>
<Version>1.0</Version>
</Metodo>
</MetodosEntity>
</Servicio>
<Servicio>
<Nombre>Referencias</Nombre>
<Descripcion>wsReferencias</Descripcion>
<Activo>true</Activo>
<Version>1.0</Version>
<MetodosEntity>
<Metodo>
<Nombre>TablaReferencia</Nombre>
<Activo>true</Activo>
<Version>1.0</Version>
</Metodo>
<Metodo>
<Nombre>ListadoReferencia</Nombre>
<Activo>true</Activo>
<Version>1.0</Version>
</Metodo>
</MetodosEntity>
</Servicio>
<Servicio>
<Nombre>General</Nombre>
<Descripcion>WsGeneral</Descripcion>
<Activo>true</Activo>
<Version>1.0</Version>
<MetodosEntity>
<Metodo>
<Nombre>GetServicios</Nombre>
<Activo>true</Activo>
<Version>1.0</Version>
</Metodo>
</MetodosEntity>
</Servicio>
<Servicio>
<Nombre>eServicios</Nombre>
<Descripcion>wseServicios</Descripcion>
<Activo>true</Activo>
<Version>1.0</Version>
<MetodosEntity>
<Metodo>
<Nombre>SetComunicacion</Nombre>
<Activo>true</Activo>
<Version>1.0</Version>
</Metodo>
</MetodosEntity>
</Servicio>
<Servicio>
<Nombre>VentanillaART</Nombre>
<Descripcion>wsVentanillaART</Descripcion>
<Activo>true</Activo>
<Version>1.0</Version>
<MetodosEntity>
<Metodo>
<Nombre>ObtenerNovedades</Nombre>
<Activo>true</Activo>
<Version>1.0</Version>
</Metodo>
</MetodosEntity>
</Servicio>
<Servicio>
<Nombre>Establecimientos</Nombre>
<Descripcion>wsEstablecimiento</Descripcion>
<Activo>true</Activo>
<Version>1.0</Version>
<MetodosEntity>
<Metodo>
<Nombre>GetConsultaPorCuit</Nombre>
<Activo>true</Activo>
<Version>1.0</Version>
</Metodo>
</MetodosEntity>
</Servicio>
</arrayOfServicio>
I am working in ORACLE 9.2 and i wrote this query but the result is not correct, i need to join HEAD and DETAIL in some way but cannot do that...
select extractvalue(value(head),'//Servicio/Nombre/text()') ,
extractvalue(value(head),'//Servicio/Descripcion/text()'),
extractvalue(value(head),'//Servicio/Activo/text()'),
extractvalue(value(head),'//Servicio/Version/text()')
,extractvalue(value(detail),'//Metodo/Nombre/text()')
,extractvalue(value(detail),'//Metodo/Activo/text()')
,extractvalue(value(detail),'//Metodo/Version/text()')
from arwt_ws_return x
, table(xmlsequence(extract (x.x_xmldoc, '/arrayOfServicio/Servicio'))) head
, table(xmlsequence(extract (x.x_xmldoc, '/arrayOfServicio/Servicio/MetodosEntity/Metodo'))) detail;
Ii really appreciate your help.
Thanks!Hi,
You can do that by passing the head element to the second XMLSequence. That way you maintain the correlation between the parent and its children :
select extractvalue(value(head), '/Servicio/Nombre') as srv_nombre
, extractvalue(value(head), '/Servicio/Descripcion') as srv_desc
, extractvalue(value(head), '/Servicio/Activo') as srv_activo
, extractvalue(value(head), '/Servicio/Version') as srv_version
, extractvalue(value(detail), '/Metodo/Nombre') as met_nombre
, extractvalue(value(detail), '/Metodo/Activo') as met_activo
, extractvalue(value(detail), '/Metodo/Version') as met_version
from arwt_ws_return x
, table(xmlsequence(extract(x.x_xmldoc, '/arrayOfServicio/Servicio'))) head
, table(xmlsequence(extract(value(head), '/Servicio/MetodosEntity/Metodo'))) detail
Please also note that :
- you don't need a descendant axis (//) if you know the exact path
- you don't need to go down to the text() node if you're using extractvalue
Hope that helps. -
Header and Trailer record validations
Hi
I have scenario file-xi-proxy. File contains the header record, detail record and trailer record
In header record i am getting date field, in header i have to do validation like header record exits and it should be in date format.
In Trailer record i have to do Total records and Total amount equals to Total records processed and total amount.
And amount value should be greater than zero..
My source structure
DT_ ACEAwardInformation
<b>Header</b>
BeginDate
EndDate
<b>DetailRecord</b>
Field1
Field2
Field3
Field4
<b>TrailerRecord</b>
TotalRecord
TotalAmount
Even content conversion parameters.
venkatHi Venkat,
write a UDF in following way...
pass the first parameter as the detail node (cache the whole queue) to the UDF pass the second parameter as the trailer countto the UDF
now loop through the detail records get the count with a counter variable
check the counter against the trailer count outside the loop
if it doesnot match trigger the alert from the UDF itself
Check the below link for triggering alert from an UDF
/people/bhavesh.kantilal/blog/2006/07/25/triggering-xi-alerts-from-a-user-defined-function -
Hi ,
I was trying to have a "SHOW ALL" feature on the master - detail page,
the detail table is an advancec table.
Please help me with inputs on how to have "SHOW ALL" feature,
Currently, we have to click on ":Show" for each record at master level to view the child data.
Trying to achive "Show All" Feature so that on click of this the master records on the page 'Expands" showiing all master records with respective detail records.
Regards
bhuvanmHi,
You should not set DetailFlag = "Y" in whereclause because there is no such record.
Also detail flag is transient attribute and not the query column, hence the error "Invalid indentifier".
I asked you to use DetailFlag as query column with static value "Y".
for example:
SELECT "Y" detail_flag
FROM <table_name>
This will display all the table records in expanded format. if you want it conditionally then use decode on some bind parameters.
For example:
SELECT DECODE(:1, "SHOWALL", "Y", "N") detail_flag
FROM <table_name>
This bind parameter should be passed whenever you want to execute query for the table.
Regards,
Sandeep M. -
Header and Trailer record handling in ODI
Hi All,
I have a delimited file which I am trying to load into Oracle DB using Oracle Data Integrator. We are using SQLLDR LKM for this. Since we have header, trailer have different format than the data records, so we have another interface which loads data. Since we have the requirement to load the data into another control table for audit purpose we have another interface.
What happens when we load the file, because of two interfaces the file scan happens 2 twice. This increases the overall turnaround time. Please note these interfaces work on filter basis for a field called record_type. 0,1,2 are the values for this field which mean header, data and trailer respectively. What we are looking for is how to restrict this double scanning of file for header-trailer and data records. What are the options which can be used here.
Regards,
PrashantHi Prashant
You can use a combination of external table and multi table insert. In ODI 11g there is a Oracle Multi Table Insert IKM. You will have to have one interface which has the source as the file and the target is a temporary target. The LKM will use LKM File to External Table, the IKM will use Oracle Multi Table IKM, and it will set DEFINE_QUERY. Also the LKM should set DELETE_TEMPORARY_OBJECTS to false. Then define 2 interfaces to load your 2 targets for example. The first target loading interface will use the 1st interface as a source and the MTI IKM again will use the MTI IKM and set IS_TARGET_TABLE to true and execute to false. Then the second target loading interface will use the 1st interface as a source and the MTI IKM again wil set IS_TARGET_TABLE to true and execute to true.
Cheers
David -
Mix overview and detail records in same report
Hello, in substance I need to mix results from overview table and records from details table in same report.
For creating the scenario:
CREATE TABLE ALPHA
ALPHA_ID NUMBER,
ALPHA_NR NUMBER,
ALPHA_TOTCT NUMBER,
ALPHA_FUND NUMBER
ALTER TABLE ALPHA ADD (
CONSTRAINT ALPHA_PK PRIMARY KEY (ALPHA_ID));
ALTER TABLE ALPHA ADD (
CONSTRAINT ALPHA_NR_UNI UNIQUE (ALPHA_NR));
INSERT INTO ALPHA(ALPHA_ID, ALPHA_NR)
VALUES( 1, 7 );
INSERT INTO ALPHA(ALPHA_ID, ALPHA_NR)
VALUES( 2, 11 );
INSERT INTO ALPHA(ALPHA_ID, ALPHA_NR)
VALUES( 3, 15 );
INSERT INTO ALPHA(ALPHA_ID, ALPHA_NR)
VALUES( 4, 17 );
CREATE TABLE HIST
HIST_ID NUMBER,
HIST_NR NUMBER,
HIST_ALPHA_NR NUMBER,
HIST_CT NUMBER,
HIST_VAL NUMBER,
HIST_DATE DATE
ALTER TABLE HIST ADD (
CONSTRAINT HIST_PK PRIMARY KEY (HIST_ID));
ALTER TABLE HIST ADD (
CONSTRAINT HIST_NR_UNI UNIQUE (HIST_NR));
ALTER TABLE HIST ADD (
CONSTRAINT HIST_ALPHA_NR_FK FOREIGN KEY (HIST_ALPHA_NR) REFERENCES ALPHA ( ALPHA_NR ) );
TRUNCATE TABLE HIST;
INSERT INTO HIST( HIST_ID ,HIST_NR ,HIST_ALPHA_NR ,HIST_CT ,HIST_VAL ,HIST_DATE )
VALUES ( 1 ,1 ,7 ,1 ,10 , TO_DATE('01.02.2009' , 'dd.mm.yyyy' ) );
INSERT INTO HIST( HIST_ID ,HIST_NR ,HIST_ALPHA_NR ,HIST_CT ,HIST_VAL ,HIST_DATE )
VALUES ( 2 ,6 ,7 ,1 ,10 , TO_DATE('01.05.2009' , 'dd.mm.yyyy' ) );
INSERT INTO HIST( HIST_ID ,HIST_NR ,HIST_ALPHA_NR ,HIST_CT ,HIST_VAL ,HIST_DATE )
VALUES ( 3 ,3 ,7 ,3 ,30 , TO_DATE('01.02.2010' , 'dd.mm.yyyy' ) );
INSERT INTO HIST( HIST_ID ,HIST_NR ,HIST_ALPHA_NR ,HIST_CT ,HIST_VAL ,HIST_DATE )
VALUES ( 4 ,4 ,11 ,1 ,10 , TO_DATE('01.03.2009' , 'dd.mm.yyyy' ) );
INSERT INTO HIST( HIST_ID ,HIST_NR ,HIST_ALPHA_NR ,HIST_CT ,HIST_VAL ,HIST_DATE )
VALUES ( 5 ,5 ,11 ,-2 ,-20 , TO_DATE('01.06.2010' , 'dd.mm.yyyy' ) );
INSERT INTO HIST( HIST_ID ,HIST_NR ,HIST_ALPHA_NR ,HIST_CT ,HIST_VAL ,HIST_DATE )
VALUES ( 6 ,8 ,11 ,1 ,10 , TO_DATE('01.02.2011' , 'dd.mm.yyyy' ) );
INSERT INTO HIST( HIST_ID ,HIST_NR ,HIST_ALPHA_NR ,HIST_CT ,HIST_VAL ,HIST_DATE )
VALUES ( 7 ,2 ,15 ,2 ,20 , TO_DATE('01.03.2009' , 'dd.mm.yyyy' ) );
INSERT INTO HIST( HIST_ID ,HIST_NR ,HIST_ALPHA_NR ,HIST_CT ,HIST_VAL ,HIST_DATE )
VALUES ( 8 ,7 ,15 ,5 ,50 , TO_DATE('01.06.2010' , 'dd.mm.yyyy' ) );
INSERT INTO HIST( HIST_ID ,HIST_NR ,HIST_ALPHA_NR ,HIST_CT ,HIST_VAL ,HIST_DATE )
VALUES ( 9 ,9 ,15 ,-4 ,-40 , TO_DATE('01.02.2011' , 'dd.mm.yyyy' ) );
INSERT INTO HIST( HIST_ID ,HIST_NR ,HIST_ALPHA_NR ,HIST_CT ,HIST_VAL ,HIST_DATE )
VALUES ( 10 ,10 ,17 ,1 ,10 , TO_DATE('01.03.2011' , 'dd.mm.yyyy' ) );For updating the overview table, I used a view
CREATE OR REPLACE VIEW HIST_AGG ( HIST_ALPHA_NR, TOT_CT , TOT_VAL )
AS
SELECT HIST_ALPHA_NR
,SUM ( NVL(HIST_CT, 0 ) ) TOT_CT
,SUM( NVL(HIST_VAL, 0) ) TOT_VAL
FROM HIST
GROUP BY HIST_ALPHA_NR;
DECLARE
CURSOR cur
IS
SELECT
HIST_ALPHA_NR
,TOT_CT
,TOT_VAL
FROM HIST_AGG
BEGIN
FOR rec IN cur
LOOP
UPDATE ALPHA
SET ALPHA_TOTCT = rec.TOT_CT
, ALPHA_FUND = rec.TOT_VAL
WHERE ALPHA_NR = rec.HIST_ALPHA_NR;
END LOOP;
END;First report should the overview line from table alpha followed by all detail records from
table HIST, and this for each alpha_nr. At the end of the report a total from the overview
table alpha.
"SUMMARY";"ALPHA_NR";"ALPHA_TOTCT";"ALPHA_FUND";
;7;5;50;
;7;1;10;01.02.2009
;7;1;10;01.05.2009
;7;3;30;
;11;0;0;
;11;1;10;01.03.2009
;11;-2;-20;01.06.2010
;11;1;10;01.02.2011
;15;3;30;
;15;2;20;01.03.2009
;15;5;50;01.06.2010
;15;-4;-40;01.02.2011
;17;1;10;
;17;1;10;01.03.2011
"TOTAL_ALPHA_NR";4;9;90;Second report should display the overview per time period (year), but the records from
e.g. year 2009 start counting in year 2010. At the end of each year again a summary for
the actual status.
"YEAR";"ALPHA_NR";"ALPHA_TOTCT";"ALPHA_FUND"
2009;7;0;0
;11;0;0
;15;0;0
;17;0;0
"Total 2009";4;0;0
2010;7;2;20
;11;1;10
;15;2;20
;17;0;0
"Total 2010";4;5;50
2011;7;5;50
;11;-1;-10
;15;7;70
;17;0;0
"Total 2011";4;11;110
2012;7;5;50
;11;0;0
;15;3;30
;17;1;10
"Total 2012";4;9;90Hi,
This is quite a different problem from what you first posted.
wucis wrote:
This is what I want to get
ALPHA_DATE ALPHA_NAME ALPHA_NR ALPHA_TOTCT ALPHA_FUND TRANS_DATE
01.01.2009 seven 7 5 50
7 1 10 01.02.2009
7 1 10 01.05.2009
7 3 30 01.02.2010
01.03.2009 eleven 11 0 0
11 1 10 01.03.2009
11 -2 -20 01.06.2010
11 1 10 01.02.2011
03.05.2010 twelve 12 0 0
02.02.2009 fifteen 15 3 30
15 2 20 01.03.2009
15 5 50 01.06.2010
15 -4 -40 01.02.2011
10.10.2010 seventeen 17 1 10
17 1 10 01.03.2011
TOTAL_ALPHA_NR 5 9 90
Do you really want to include alphr_nr=12? If so, what do you mean when you say
I have an approach but there are "unnecessary" rows ( the line with just alpha_nr = 12 ) and why don't you want alpha_nr=13?
so my join is buggyExactly! The join
... from hist, alpha b
WHERE b.alpha_nr = hist.hist_alpha_nr (+) ...means "include all rows from alpha, whether of not they have any corresponding rows in hist or not". If you want to exclude alpha_nrs 12 and 13, you probably want to do an inner join there.
You don't need any sub-queries to do that:
SELECT CASE
WHEN GROUPING (h.hist_alpha_nr) = 0
AND GROUPING (h.hist_date) = 1
THEN MAX (a.alpha_date)
END AS alpha_date
, CASE
WHEN GROUPING (h.hist_alpha_nr) = 1
THEN 'TOTAL_ALPHA_NR'
WHEN GROUPING (h.hist_date) = 1
THEN MAX (a.alpha_name)
END AS alpha_name
, CASE
WHEN GROUPING (h.hist_alpha_nr) = 0
THEN h.hist_alpha_nr
ELSE COUNT (DISTINCT (alpha_nr))
END AS alpha_nr
, SUM (h.hist_ct) AS alpha_totct
, SUM (h.hist_val) AS alpha_fund
, h.hist_date AS trans_date
FROM hist h
, alpha a
WHERE h.hist_alpha_nr = a.alpha_nr
AND a.active = 'Y'
GROUP BY ROLLUP ( hist_alpha_nr
, hist_date
ORDER BY GROUPING (h.hist_alpha_nr)
, h.hist_alpha_nr
, GROUPING (h.hist_date) DESC
, h.hist_date
;Output:
ALPHA ALPHA ALPHA
ALPHA_DATE ALPHA_NAME _NR _TOTCT _FUND TRANS_DATE
01.01.2009 seven 7 5 50
7 1 10 01.02.2009
7 1 10 01.05.2009
7 3 30 01.02.2010
01.03.2009 eleven 11 0 0
11 1 10 01.03.2009
11 -2 -20 01.06.2010
11 1 10 01.02.2011
02.02.2009 fifteen 15 3 30
15 2 20 01.03.2009
15 5 50 01.06.2010
15 -4 -40 01.02.2011
10.10.2010 seventeen 17 1 10
17 1 10 01.03.2011
TOTAL_ALPHA_NR 4 9 90If this is not what you want (e.g., if you want alpha_nr=12 in the results) then point out where these results are wrong, post the correct results, and explain how you get the correct results in those places. -
Master and Detail records in the same table
Hi Steve,
I have master and detail address records in the same table (self-reference). The master addresses are used as templates for detail addresses. Master addresses do not have any masters. Detail addresses have three masters: a master address, a calendar reference and a department. Addresses change from time to time and every department has its own email-account, but they refer to the same master to pre-fill some common values.
Now I need to edit the master and detail address records on the same web page simultaneously.
My question is: Can I implement a Master-View and Detail-View which refer to the same Entity-Object? Or should I implement a second Entity-Object? Or can it be done in a single Master-Detail-View?
Thanks a lot.
Kai.At a high level, wouldn't this be similar to an Emp entity based on the familiar EMP table that has an association from Emp to itself for the Emp.Mgr attribute?
You can definitely build a view object that references two entity usages of the same entity like this to show, say, an employee's ENAME and at the same time their manager's ENAME.
If there are multiple details for a given master, you can also do that with separate VO's both based on the same entity, sure. Again, just like a VO that shows a manager, and a view-linked VO of all the employees that report to him/her. -
Skipping header and footer records of source file
I have a CSV file which has a header and a trailer record
when i load it using LKM (sqlldr) , i want to skip this trailer/footer record.
Any suggestions?To add more info:
I will add two options in LKM
1.FOOTER : if this is set to true , the file contains a footer and it should be removed.
2.HEADER : if this is set to true , the file contains a header and it should be skipped.
if FALSE , the file does not have either a footer , header or both
Guys , help me with Ideas.
I have come across WHEN clause but i don't think it can be of much help in this scenario
Maybe you are looking for
-
my ipad was in recovery mode and it went back to the home screen and it found my info on itunes to the point where i can put music on it but it still says connect to itunes
-
.rcr file creation ..
Hi, I am getting some problem regarding XL REPORTER , I want to create/save query in .rcr file format . Please suggest me how to create that particular file . So that i could be able to import it in the XL Reporter Composer Window . Thanks Ashish
-
SolMan 7.1 SPS 11: Can not Maintain a solution
Hello, I have installed a SolMan 7.1 with SPS 11. I can not maintain any solution. When I click on Maintain a solution in System Monitoring -> Setup, a popup windows opens and close. In solman_ewa_admin, if I click on a solution, no new window is sta
-
I purchased a movie off of itunes, but somehow the file got deleted off my MacBook. Any idea how I can retrieve that (it is not in my garbage) or if apple will resend it to my itunes account? Thanks for your help in advance!
-
i can receive but cannot send mail. my account is a .mac account. i have the correct server settings mail.mac.com any suggestions? thanks