How to join cluster table?
How to join the cluster table with the transparent table?In specific ,can you pls tell me how can i join bkpf and bseg?
Hi Aravind,
Check this code,
tables : bkpf,
bseg.
INTERNAL TABLE AND WORK AREA FOR THE FIELDS IN BKPF TABLE *
data : begin of itab_bkpf occurs 0,
bukrs like bkpf-bukrs, "Company Code.
gjahr like bkpf-gjahr, "Fiscal Year.
budat like bkpf-budat, "Posting Date in the Document.
belnr like bkpf-belnr, "Accounting document number.
blart like bkpf-blart, "Document Type.
end of itab_bkpf.
data : wa_bkpf like line of itab_bkpf.
INTERNAL TABLE AND WORK AREA FOR THE FIEDLS IN BSEG TABLE *
data : begin of itab_bseg_debit occurs 0,
bukrs like bseg-bukrs, "Company Code.
gjahr like bseg-gjahr, "Fiscal Year.
belnr like bseg-belnr, "Accounting Document Number.
buzei like bseg-buzei, "Line Item.
hkont like bseg-hkont, "General Leadger Account.
shkzg like bseg-shkzg, "Credit/Debit Indicator.
wrbtr like bseg-wrbtr, "Amount in Document Currency.
pswsl like bseg-pswsl, "Update Currency for Gen.Ledger
dmbtr like bseg-dmbtr, "Amount in local currency.
sgtxt like bseg-sgtxt, "Item Text.
zuonr like bseg-zuonr, "Assignment Number.
end of itab_bseg_debit.
data : itab_bseg_credit like standard table of itab_bseg_debit with
header line.
FINAL OUTPUT INTERNAL TABLE *
data : begin of itab_output occurs 0,
belnr(08) ,
bukrs(04) ,
budat like bkpf-budat,
buzei(03) ,
hkont(07) ,
blart(02) ,
shkzg(01) ,
wrbtr(08) ,
pswsl(05) ,
dmbtr(10) ,
sgtxt(19) ,
zuonr(10) ,
end of itab_output.
constants : c_debit type c value 'S',
c_credit type c value 'H'.
SELECT-OPTIONS *
selection-screen begin of block input with frame title text-t01.
select-options : s_bukrs for bkpf-bukrs.
parameters : p_year like bkpf-gjahr visible length 2.
select-options : s_budat for bkpf-budat,
s_dbacct for bseg-hkont,
s_cracct for bseg-hkont,
s_amt for bseg-dmbtr.
selection-screen end of block input.
SELECTING RECORDS FROM BKPF TABLE BASED ON THE CONDITION *
select bukrs gjahr budat belnr blart
from bkpf into table itab_bkpf
where bukrs in s_bukrs and
gjahr eq p_year and
budat in s_budat.
SELECTING DEBIT LINE ITEMITEMS FROM BSEG FOR THE DOCUMENT *
NUMBER SELECTED FROM BKPF *
if not itab_bkpf[] is initial.
select bukrs gjahr belnr buzei
hkont shkzg wrbtr pswsl
dmbtr sgtxt zuonr
from bseg into table itab_bseg_debit
for all entries in itab_bkpf
where bukrs eq itab_bkpf-bukrs and
belnr eq itab_bkpf-belnr and
gjahr eq itab_bkpf-gjahr and
hkont in s_dbacct and
shkzg eq c_debit and
dmbtr in s_amt.
SELECTING CREDIT LINE ITEMITEMS FROM BSEG FOR THE DOCUMENT *
NUMBER SELECTED FROM BKPF *
select bukrs gjahr belnr buzei
hkont shkzg wrbtr pswsl
dmbtr sgtxt zuonr
from bseg into table itab_bseg_credit
for all entries in itab_bkpf
where bukrs eq itab_bkpf-bukrs and
belnr eq itab_bkpf-belnr and
gjahr eq itab_bkpf-gjahr and
hkont in s_cracct and
shkzg eq c_credit and
dmbtr in s_amt.
endif.
sort itab_bkpf by bukrs gjahr belnr.
sort itab_bseg_credit by bukrs gjahr belnr.
LOOPING THE DEBIT ENTRIES *
loop at itab_bseg_debit.
READING THE CREDIT ENTRIES WHICH MATCHES WITH HE CURRENT DOC. NUMBER *
read table itab_bseg_credit with key
bukrs = itab_bseg_debit-bukrs
gjahr = itab_bseg_debit-gjahr
belnr = itab_bseg_debit-belnr binary search.
if sy-subrc eq 0.
*READING THE POSTING DATE AND DOCUMENT TYPE FOR THE CURRENT DOUCMENT *
AND APPENDING THE DEBIT AND CREDIT ENTRIES *
read table itab_bkpf into wa_bkpf with key
bukrs = itab_bseg_debit-bukrs
gjahr = itab_bseg_debit-gjahr
belnr = itab_bseg_debit-belnr binary search.
itab_output-belnr = itab_bseg_debit-belnr.
itab_output-bukrs = itab_bseg_debit-bukrs.
itab_output-budat = wa_bkpf-budat.
itab_output-buzei = itab_bseg_debit-buzei.
itab_output-hkont = itab_bseg_debit-hkont.
itab_output-blart = wa_bkpf-blart.
itab_output-shkzg = itab_bseg_debit-shkzg.
itab_output-wrbtr = itab_bseg_debit-wrbtr.
itab_output-pswsl = itab_bseg_debit-pswsl.
itab_output-dmbtr = itab_bseg_debit-dmbtr.
itab_output-sgtxt = itab_bseg_debit-sgtxt.
itab_output-zuonr = itab_bseg_debit-zuonr.
append itab_output.
itab_output-belnr = itab_bseg_credit-belnr.
itab_output-bukrs = itab_bseg_credit-bukrs.
itab_output-budat = wa_bkpf-budat.
itab_output-buzei = itab_bseg_credit-buzei.
itab_output-hkont = itab_bseg_credit-hkont.
itab_output-blart = wa_bkpf-blart.
itab_output-shkzg = itab_bseg_credit-shkzg.
itab_output-wrbtr = itab_bseg_credit-wrbtr.
itab_output-pswsl = itab_bseg_credit-pswsl.
itab_output-dmbtr = itab_bseg_credit-dmbtr.
itab_output-sgtxt = itab_bseg_credit-sgtxt.
itab_output-zuonr = itab_bseg_credit-zuonr.
append itab_output.
endif.
endloop.
sort itab_output by belnr budat shkzg.
LOOPING OUTPUT INTERNAL TABLE *
*FORMAT INTENSIFIED INPUT.
*FORMAT INVERSE ON.
loop at itab_output.
format hotspot on.
format color 5 inverse.
write :/ sy-vline,
000 itab_output-belnr, 12 sy-vline,
013 itab_output-bukrs, 17 sy-vline,
019 itab_output-budat, sy-vline,
034 itab_output-buzei, 40 sy-vline,
042 itab_output-hkont, sy-vline,
054 itab_output-blart, 60 sy-vline,
065 itab_output-shkzg, 70 sy-vline,
072 itab_output-wrbtr, sy-vline,
085 itab_output-pswsl, sy-vline,
093 itab_output-dmbtr, sy-vline,
106 itab_output-sgtxt, sy-vline,
itab_output-zuonr, sy-vline.
format hotspot off.
endloop.
uline 0(139).
<b>Regards,
Jackie.</b>
Similar Messages
-
Re: join cluster table into transperant table in ABAP Queries
Hi gurus
How to join cluster tables into transperant tables in ABAP Queries,
I want to join KNA1, KNB2, BSEG(cluster table)
pls explain me
amkHi
You can use join for KNA1 and KNB1 which will much faster
then use for all entries of this itab to get the BSEG to improve the performance
here you need to do some trial and error method by joining removing the tables and also for all entries
regards
Shiva -
How to join four tables in Update query??
Please how to join four tables in a single query to update one table row??
You can use this syntax to update. Here updation of 1 column to a constant value (50) in multiple rows in Table A based on an associated 'SOURCE' value in table B
Table A joins to Table B based on the TableA.definition_id = TableB.Att_Def_id
like..
update TableA
set value =50
where
TableA.definition_id = TableB.Att_Def_id
and TABLEB.Source = 'NEWPRODUCT' -
hi
how to join two tables using inner join if the first table has two primary keys and second table has 3 primary keysWould describe type of joins in ABAP, which might differ with other joins.
The join syntax represents a recursively nestable join expression. A join expression consists of a left-hand and a right- hand side, which are joined either by means of INNER JOIN or LEFT OUTER JOIN. Depending on the type of join, a join expression can be either an inner (INNER) or an outer (LEFT OUTER) join. Every join expression can be enclosed in round brackets. If a join expression is used, the SELECT command circumvents SAP buffering.
On the left-hand side, either a single database table, a view dbtab_left, or a join expression join can be specified. On the right-hand side, a single database table or a view dbtab_right as well as join conditions join_cond can be specified after ON. In this way, a maximum of 24 join expressions that join 25 database tables or views with each other can be specified after FROM.
AS can be used to specify an alternative table name tabalias for each of the specified database table names or for every view. A database table or a view can occur multiple times within a join expression and, in this case, have various alternative names.
The syntax of the join conditions join_cond is the same as that of the sql_cond conditions after the addition WHERE, with the following differences:
At least one comparison must be specified after ON.
Individual comparisons may be joined using AND only.
All comparisons must contain a column in the database table or the view dbtab_right on the right-hand side as an operand.
The following additions not be used: NOT, LIKE, IN.
No sub-queries may be used.
For outer joins, only equality comparisons (=, EQ) are possible.
If an outer join occurs after FROM, the join condition of every join expression must contain at least one comparison between columns on the left-hand and the right-hand side.
In outer joins, all comparisons that contain columns as operands in the database table or the view dbtab_right on the right-hand side must be specified in the corresponding join condition. In the WHERE condition of the same SELECT command, these columns are not allowed as operands.
Resulting set for inner join
The inner join joins the columns of every selected line on the left- hand side with the columns of all lines on the right-hand side that jointly fulfil the join_cond condition. A line in the resulting set is created for every such line on the right-hand side. The content of the column on the left-hand side may be duplicated in this case. If none of the lines on the right-hand side fulfils the join_cond condition, no line is created in the resulting set.
Resulting set for outer join
The outer join basically creates the same resulting set as the inner join, with the difference that at least one line is created in the resulting set for every selected line on the left-hand side, even if no line on the right-hand side fulfils the join_cond condition. The columns on the right-hand side that do not fulfil the join_cond condition are filled with null values.
Note
If the same column name occurs in several database tables in a join expression, they have to be identified in all remaining additions of the SELECT statement by using the column selector ~.
Example
Join the columns carrname, connid, fldate of the database tables scarr, spfli and sflight by means of two inner joins. A list is created of the flights from p_cityfr to p_cityto. Alternative names are used for every table.
PARAMETERS: p_cityfr TYPE spfli-cityfrom,
p_cityto TYPE spfli-cityto.
DATA: BEGIN OF wa,
fldate TYPE sflight-fldate,
carrname TYPE scarr-carrname,
connid TYPE spfli-connid,
END OF wa.
DATA itab LIKE SORTED TABLE OF wa
WITH UNIQUE KEY fldate carrname connid.
SELECT ccarrname pconnid f~fldate
INTO CORRESPONDING FIELDS OF TABLE itab
FROM ( ( scarr AS c
INNER JOIN spfli AS p ON pcarrid = ccarrid
AND p~cityfrom = p_cityfr
AND p~cityto = p_cityto )
INNER JOIN sflight AS f ON fcarrid = pcarrid
AND fconnid = pconnid ).
LOOP AT itab INTO wa.
WRITE: / wa-fldate, wa-carrname, wa-connid.
ENDLOOP.
Example
Join the columns carrid, carrname and connid of the database tables scarr and spfli using an outer join. The column connid is set to the null value for all flights that do not fly from p_cityfr. This null value is then converted to the appropriate initial value when it is transferred to the assigned data object. The LOOP returns all airlines that do not fly from p_cityfr.
PARAMETERS p_cityfr TYPE spfli-cityfrom.
DATA: BEGIN OF wa,
carrid TYPE scarr-carrid,
carrname TYPE scarr-carrname,
connid TYPE spfli-connid,
END OF wa,
itab LIKE SORTED TABLE OF wa
WITH NON-UNIQUE KEY carrid.
SELECT scarrid scarrname p~connid
INTO CORRESPONDING FIELDS OF TABLE itab
FROM scarr AS s
LEFT OUTER JOIN spfli AS p ON scarrid = pcarrid
AND p~cityfrom = p_cityfr.
LOOP AT itab INTO wa.
IF wa-connid = '0000'.
WRITE: / wa-carrid, wa-carrname.
ENDIF.
ENDLOOP. -
Hi
this is fazil.
Please tell me any body how to create cluster table.
Thanks & Regards
Fazil
[email protected]Hi,
1. In the initial screen of the ABAP Dictionary select object type Table, enter a table name and choose Create.
The field maintenance screen for the table is displayed. Table type Transparent table is set as default.
2. Make the necessary entries in the Short description and Delivery class fields on the Attributes tab page. Then define the fields of the table.
Proceed as when creating a transparent table. Save your entries.
3. Choose Extras ® Change table category.
A dialog box appears in which you have to select the table type Pooled table or Cluster table.
4. Choose Select.
You return to the field maintenance screen for the table. Field Pool/cluster name is displayed on the Attributes tab page in addition to the standard fields.
5. Enter the name of the table pool or table cluster to which you want to assign the pooled table or cluster table in field Pool/cluster name
Note that the total key length of a pooled table may not exceed the key length of the associated table pool. The key of a cluster table must correspond to the key of the associated table cluster.
6. Proceed as when creating a transparent table (see Creating Tables). Remember that you cannot create indexes for pooled or cluster tables.
All the attributes of the technical settings can be maintained for pooled tables and cluster tables. Before you can access these attributes, however, you must convert the table to a transparent table.
Rgds,
P.Naganjana Reddy -
How do we join cluster table bseg?
Friends ,
i just wanna know as 2 how can we combine bseg and bkpf tables.
since bkpf is a transparent table and bseg is a cluster table.
regards
Essam
[email protected]Hi Essam,
REPORT ztestport_01.
TABLES : bkpf,
bseg.
INTERNAL TABLE AND WORK AREA FOR THE FIELDS IN BKPF TABLE *
DATA : BEGIN OF itab_bkpf OCCURS 0,
bukrs LIKE bkpf-bukrs, "Company Code.
gjahr LIKE bkpf-gjahr, "Fiscal Year.
budat LIKE bkpf-budat, "Posting Date in the Document.
belnr LIKE bkpf-belnr, "Accounting document number.
blart LIKE bkpf-blart, "Document Type.
END OF itab_bkpf.
DATA : wa_bkpf LIKE LINE OF itab_bkpf.
INTERNAL TABLE AND WORK AREA FOR THE FIEDLS IN BSEG TABLE *
DATA : BEGIN OF itab_bseg_debit OCCURS 0,
bukrs LIKE bseg-bukrs, "Company Code.
gjahr LIKE bseg-gjahr, "Fiscal Year.
belnr LIKE bseg-belnr, "Accounting Document Number.
buzei LIKE bseg-buzei, "Line Item.
hkont LIKE bseg-hkont, "General Leadger Account.
shkzg LIKE bseg-shkzg, "Credit/Debit Indicator.
wrbtr LIKE bseg-wrbtr, "Amount in Document Currency.
pswsl LIKE bseg-pswsl, "Update Currency for Gen.Ledger
dmbtr LIKE bseg-dmbtr, "Amount in local currency.
sgtxt LIKE bseg-sgtxt, "Item Text.
zuonr LIKE bseg-zuonr, "Assignment Number.
END OF itab_bseg_debit.
DATA : itab_bseg_credit LIKE STANDARD TABLE OF itab_bseg_debit WITH
HEADER LINE.
FINAL OUTPUT INTERNAL TABLE *
DATA : BEGIN OF itab_output OCCURS 0,
belnr(08) ,
bukrs(04) ,
budat LIKE bkpf-budat,
buzei(03) ,
hkont(07) ,
blart(02) ,
shkzg(01) ,
wrbtr(08) ,
pswsl(05) ,
dmbtr(10) ,
sgtxt(19) ,
zuonr(10) ,
END OF itab_output.
CONSTANTS : c_debit TYPE c VALUE 'S',
c_credit TYPE c VALUE 'H'.
SELECT-OPTIONS *
SELECTION-SCREEN BEGIN OF BLOCK input WITH FRAME TITLE text-t01.
SELECT-OPTIONS : s_bukrs FOR bkpf-bukrs.
PARAMETERS : p_year LIKE bkpf-gjahr visible length 2.
SELECT-OPTIONS : s_budat FOR bkpf-budat,
s_dbacct FOR bseg-hkont,
s_cracct FOR bseg-hkont,
s_amt FOR bseg-dmbtr.
SELECTION-SCREEN END OF BLOCK input.
SELECTING RECORDS FROM BKPF TABLE BASED ON THE CONDITION *
SELECT bukrs gjahr budat belnr blart
FROM bkpf INTO TABLE itab_bkpf
WHERE bukrs IN s_bukrs AND
gjahr EQ p_year AND
budat IN s_budat.
SELECTING DEBIT LINE ITEMITEMS FROM BSEG FOR THE DOCUMENT *
NUMBER SELECTED FROM BKPF *
IF NOT itab_bkpf[] IS INITIAL.
SELECT bukrs gjahr belnr buzei
hkont shkzg wrbtr pswsl
dmbtr sgtxt zuonr
FROM bseg INTO TABLE itab_bseg_debit
FOR ALL ENTRIES IN itab_bkpf
WHERE bukrs EQ itab_bkpf-bukrs AND
belnr EQ itab_bkpf-belnr AND
gjahr EQ itab_bkpf-gjahr AND
hkont IN s_dbacct AND
shkzg EQ c_debit AND
dmbtr IN s_amt.
SELECTING CREDIT LINE ITEMITEMS FROM BSEG FOR THE DOCUMENT *
NUMBER SELECTED FROM BKPF *
SELECT bukrs gjahr belnr buzei
hkont shkzg wrbtr pswsl
dmbtr sgtxt zuonr
FROM bseg INTO TABLE itab_bseg_credit
FOR ALL ENTRIES IN itab_bkpf
WHERE bukrs EQ itab_bkpf-bukrs AND
belnr EQ itab_bkpf-belnr AND
gjahr EQ itab_bkpf-gjahr AND
hkont IN s_cracct AND
shkzg EQ c_credit AND
dmbtr IN s_amt.
ENDIF.
SORT itab_bkpf BY bukrs gjahr belnr.
SORT itab_bseg_credit BY bukrs gjahr belnr.
LOOPING THE DEBIT ENTRIES *
LOOP AT itab_bseg_debit.
READING THE CREDIT ENTRIES WHICH MATCHES WITH HE CURRENT DOC. NUMBER *
READ TABLE itab_bseg_credit WITH KEY
bukrs = itab_bseg_debit-bukrs
gjahr = itab_bseg_debit-gjahr
belnr = itab_bseg_debit-belnr BINARY SEARCH.
IF sy-subrc EQ 0.
*READING THE POSTING DATE AND DOCUMENT TYPE FOR THE CURRENT DOUCMENT *
AND APPENDING THE DEBIT AND CREDIT ENTRIES *
READ TABLE itab_bkpf INTO wa_bkpf WITH KEY
bukrs = itab_bseg_debit-bukrs
gjahr = itab_bseg_debit-gjahr
belnr = itab_bseg_debit-belnr BINARY SEARCH.
itab_output-belnr = itab_bseg_debit-belnr.
itab_output-bukrs = itab_bseg_debit-bukrs.
itab_output-budat = wa_bkpf-budat.
itab_output-buzei = itab_bseg_debit-buzei.
itab_output-hkont = itab_bseg_debit-hkont.
itab_output-blart = wa_bkpf-blart.
itab_output-shkzg = itab_bseg_debit-shkzg.
itab_output-wrbtr = itab_bseg_debit-wrbtr.
itab_output-pswsl = itab_bseg_debit-pswsl.
itab_output-dmbtr = itab_bseg_debit-dmbtr.
itab_output-sgtxt = itab_bseg_debit-sgtxt.
itab_output-zuonr = itab_bseg_debit-zuonr.
APPEND itab_output.
itab_output-belnr = itab_bseg_credit-belnr.
itab_output-bukrs = itab_bseg_credit-bukrs.
itab_output-budat = wa_bkpf-budat.
itab_output-buzei = itab_bseg_credit-buzei.
itab_output-hkont = itab_bseg_credit-hkont.
itab_output-blart = wa_bkpf-blart.
itab_output-shkzg = itab_bseg_credit-shkzg.
itab_output-wrbtr = itab_bseg_credit-wrbtr.
itab_output-pswsl = itab_bseg_credit-pswsl.
itab_output-dmbtr = itab_bseg_credit-dmbtr.
itab_output-sgtxt = itab_bseg_credit-sgtxt.
itab_output-zuonr = itab_bseg_credit-zuonr.
APPEND itab_output.
ENDIF.
ENDLOOP.
SORT itab_output BY belnr budat shkzg.
then loop your final itab_output
and give write command to print
your fields.
<b>Regards,
Jackie.</b>
Message was edited by:
Jackie -
Hi
I would like to make a joint with a table cluster (bseg) but the system put an error compilation. what a solution? Thank you for answer.
Even the creation of a view does not make with the tables cluster.Hi,
You cannot write join for cluster tables like BSEG..Instead you can use FOR ALL ENTRIES options..
EX..
DATA: T_BKPF TYPE STANDARD TABLE OF BKPF,
T_BSEG TYPE STANDARD TABLE OF BSEG.
SELECT * FROM BKPF
INTO TABLE T_BKPF
WHERE....
IF NOT T_BKPF IS INITIAL.
SELECT * FROM BSEG
INTO TABLE T_BSEG
FOR ALL ENTRIES IN T_BKPF
WHERE BUKRS = T_BKPF-BUKRS
AND BELNR = T_BKPF-BELNR
AND GJAHR = T_BKPF-GJAHR..
ENDIF.
Thanks,
Naren -
How to Join 2 tables if datetime diff is within range?
Hi, problem figuring out how to join tables if the datediff ? is within range.
There are 3 tables a main table then 2 sub tables, these are measurements with a date/time value. Im trying to take the datetime entries from the 2 sub tables and match them, then add them to the main table
subtable1 has SampleID, datetime,
subtable2 has TesterID, datetime
maintable has SampleID, datetime, TesterID, datetime
so the maintable would always have the sampleID value and datetime regardless. but it would only JOIN the testerID and its datetime, only IF these 2 datetime values were close, and the datediff interval was set to 1 second.
its a function call that fills the main tables matching columns but only if the testerIDs datetime is close to the sampleIDs time????
thanksPlease post DDL, so that people do not have to guess what the keys, constraints, Declarative Referential Integrity, data types, etc. in your schema are. Learn how to follow ISO-11179 data element naming conventions and formatting rules. Temporal data should
use ISO-8601 formats. Code should be in Standard SQL as much as possible and not local dialect.
This is minimal polite behavior on SQL forums. Thanks for making us do your typing and DDL for you :(
>> There are 3 tables; a main table then 2 sub tables, <<
Really? Main table? Sub-tables? There are no such terms in SQL. Trust me on that; I helped with the Standards :) We have referenced referencing tables in the DRI model of SQL.
>> these are measurements with a date/time value. <<
++Both of them, the measurementID and otherID have a millisecond timestamp, the goal is to associate these 2 measurements, they are coming from different systems.
Do you really need the full timestamp down to nanoseconds and not just a DATE? Oh, we also have no sample data :( So we have to guess at precision, constraints, keys, etc.
See why we need DDL? Is this relationship 1:1, 1:M OR N:1? My guess is that a tester can do many samples, but a sample has only one tester. And what were those two timestamps? Not redundant copies from the referenced tables!! That would non-normalized.
>> so the Sample_Tester_Relationship would always have the sample_nbr value and <something>_timestamp regardless. But it would only JOIN the tester_id and its DATETIME, only IF these 2 DATETIME values were close, and the DATEDIFF interval was set
to 1 second. <<
No, you do not do a JOIN inside a base table. That is VIEW.
>> It is a function [sic: procedure, Functions return scalar values] call that fills the main tables matching columns but only if the tester_id DATETIME is close to the sample_id time? <<
No sample data, no sample code and no business rules about ties. Here is my final guess at normalizing this problem:
CREATE TABLE Samples
(sample_nbr CHAR(12) NOT NULL PRIMARY KEY,
CREATE TABLE Testers
(tester_id CHAR(10) NOT NULL PRIMARY KEY,
CREATE TABLE Sample_Tester_Relationship --- needs a real name!
(sample_nbr CHAR(12) NOT NULL PRIMARY KEY
REFERENCES Samples
ON UPDATE CASCADE
ON DELETE CASCADE,
tester_id CHAR(10) NOT NULL
REFERENCES Testers
ON UPDATE CASCADE
ON DELETE CASCADE,
PRIMARY KEY (sample_nbr, tester_id),
tester_timestamp DATETIME2(1) DEFAULT CURRENT_TIMESTAMP NOT NULL,
sample_timestamp DATETIME2(1) DEFAULT CURRENT_TIMESTAMP NOT NULL,
CHECK (ABS (DATEDIFF (SECOND, tester_timestamp, sample_timestamp) <= 1) );
Most of the work in SQL is in DDL, not DML.
I will try this out and advise.
--CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking in
Sets / Trees and Hierarchies in SQL
Dear Celko
thank you for this constructive feedback, clearly you're an expert and I am going to be better for following this advice. In the 1970s I was told to avoid going into software because Japan had invented a way for computers to write their own code, so
programmers would be out of a job and the field would be a dead-end. I didnt formally begin training in sw until the 90s. SQL is one of those last frontiers i never trained in. but now Im trying to learn and find anything i can read to absorb
it.
I posted in laymans words because i thought thats how you experts would prefer it described, clearly not. I will now take the time to read each reference to the standards... -
How to join two tables using EJB-QL
Hi There,
How to join tables using EJB-QL ?
Thanks.
Edited by: vamseebobby on Nov 6, 2007 8:12 AMYou might try
SELECT b.entity2property FROM Entity1 a JOIN a.entity2 b
for example, to retrieve players names, from a Players table, that belong to the team 'My Team' in the Teams table
SELECT b.playerName FROM Teams a JOIN a.players b WHERE a.teamName = 'My Team' -
Hi ,
I have a requirement to read cluster tables data using import statement . I have to access cluster tables data based on selection criteria . Any body help me regarding this isuue .
Regards
UdayHi Uday,
Check this one:
[Extraction from cluster tables through function module|https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/a0f46157-e1c4-2910-27aa-e3f4a9c8df33]
Re: BW extractor for ERP cluster tables
Regards,
Chandra Sekhar -
How to replicate cluster table into BW on HANA using SLT?
Hi Members,
We have a requirement to replicate cluster table from SAP ECC (Ex:BSEG) into BW 7.4 on HANA using SLT. We know that HANA SLT is capable of replicating cluster table but it looks like BW-SLT is not capable of doing the same.
Please clarify on this and any documentation in this regard will be very helpful.
Also wondering if the current release of BW-SLT can be used to replicate Cluster tables from SAP?
Thanks & Regards
Shankar ChintadaHi Shankar,
I dont understand , why you have doubt on BW-SLT???
Using SLT you can replicate the tables pool or cluster .
If you have more specific requirment please share the details
As per above information in your enviorment it is possible.
You can check below thread for more infor.
SLT: Mass Tables for Replication to HANA
BR
AKJ -
How to join KNA1 table with SOOD, SOST or SOES table?
Hi,
I am creating an infoset and I cant join KNA1 with any of the following tables: SOST, SOES or SOOD.
I am looking to get the following fields from the following table:
KNA1 - KUNNR: Customer Number
SOES - STATUS: Status
SOOD- OBJNAM : Send Method
SOOD - OBJDES : Document Title
SOOD - CRONAM : Created by
SOES- MSGV1 : Recipient
SOST - STAT - DATE : Send date
SOST - STAT - TIME : Send time
I tried adding knvp table to find a common field but cant seem to join them. SOST, SOES and SOOD are easily joined with each other but KNA1 or KNVP cannot be joined, is there any intermediate table that I should use to join these tables to get the customer number against them or is there any other solution. kindly help.
Regards,
MoazHi,
please try to connect KNA1 with SOOD using
CALL METHOD cl_binary_relation=>read_links
EXPORTING
is_object = ls_lpor
it_relation_options = lt_relat
IMPORTING
et_links = lt_links.
where ls_por-instid = kna1-kunnr, ls_por-typeid = 'KNA1' and ls_por-catid = 'BO'
and lt_relat contains a line option 'I' 'EQ' 'NOTE'.
Regards,
Klaus -
How to join three tables?
I have used this query to join three tables but it displays an error : field vbak-vbeln is unknown.
please help me out..
SELECT vbak-vbeln vbak-bstnk vbap-matnr vbap-zmeng makt-maktx
INTO CORRESPONDING FIELDs OF TABLE itab FROM vbak
inner JOIN vbap ON vbak-vbeln eq vbap-vbeln
inner JOIN makt ON vbap-matnr eq makt-matnr
WHERE vbak-bstnk = s_bstnk.Hi mohan kumar ,
just follow the Syntax
SELECT FLD1 FLD2 FLD3 FLD4 FLD5 INTO CORRESPONDING FIELDS OF TABLE ITAB FROM TABLE1 INNER JOIN TABLE2 ON
TABLE1FLD1 = TABLE2FLD1 INNER JOIN TABLE3 ON TABLE2FLD2 = TABLE3FLD2 INNER JOIN TABL4 ON TABLE3FLD3 = TABLE4FLD3
WHERE FLD1 = 'AA'
Hope this may be helpful.
Please reward points if found ok.
Thanks and regards,
Rajeshwar. -
How to join multiple tables !
Give me the Example to join multiple tables 1
Inner join
IF p_bsart IS INITIAL.
SELECT ekko~bukrs
ekko~lifnr
ekko~ebeln
ekko~waers
ekko~bsart
ekko~ekorg
ekko~ekgrp
ekpo~ebelp
ekpo~txz01
ekpo~matnr
ekpo~werks
ekpo~menge
ekpo~meins
ekpo~netpr
ekpo~netwr
INTO TABLE t_itab1 FROM
ekko INNER JOIN ekpo ON ekkoebeln = ekpoebeln
WHERE ekko~ebeln IN s_ebeln AND
ekko~bukrs IN s_bukrs AND
ekko~lifnr IN s_lifnr AND
ekko~ekorg IN s_ekorg AND
ekko~ekgrp IN s_ekgrp AND
ekpo~matnr IN s_matnr.
The difference between an INNER JOIN and an OUTER JOIN is the following. If a query on an INNER JOIN of VBAK (outer table) and VBAP (inner table) finds a record in VBAK but no matching records in VBAP, then no data is retrieved from the database because the inner table is empty. If you still want to keep VBAK rows for which there are no matching VBAP rows, you need to use the OUTER JOIN construct available in ABAP/4 Open SQL in 4.x..
Hi
Syntax
... [(] {dbtab_left [AS tabalias_left]} | join
{[INNER] JOIN}|{LEFT [OUTER] JOIN}
{dbtab_right [AS tabalias_right] ON join_cond} [)] ... .
Effect
The join syntax represents a recursively nestable join expression. A join expression consists of a left-hand and a right- hand side, which are joined either by means of [INNER] JOIN or LEFT [OUTER] JOIN . Depending on the type of join, a join expression can be either an inner ( INNER) or an outer (LEFT OUTER) join. Every join expression can be enclosed in round brackets. If a join expression is used, the SELECT command circumvents SAP buffering.
On the left-hand side, either a single database table, a view dbtab_left, or a join expression join can be specified. On the right-hand side, a single database table or a view dbtab_right as well as join conditions join_cond can be specified after ON. In this way, a maximum of 24 join expressions that join 25 database tables or views with each other can be specified after FROM.
AS can be used to specify an alternative table name tabalias for each of the specified database table names or for every view. A database table or a view can occur multiple times within a join expression and, in this case, have various alternative names.
The syntax of the join conditions join_cond is the same as that of the sql_cond conditions after the addition WHERE, with the following differences:
At least one comparison must be specified after ON.
Individual comparisons may be joined using AND only.
All comparisons must contain a column in the database table or the view dbtab_right on the right-hand side as an operand.
The following language elements may not be used: BETWEEN, LIKE, IN.
No sub-queries may be used.
For outer joins, only equality comparisons (=, EQ) are possible.
If an outer join occurs after FROM, the join condition of every join expression must contain at least one comparison between columns on the left-hand and the right-hand side.
In outer joins, all comparisons that contain columns as operands in the database table or the view dbtab_right on the right-hand side must be specified in the corresponding join condition. In the WHERE condition of the same SELECT command, these columns are not allowed as operands.
Resulting set for inner join
The inner join joins the columns of every selected line on the left- hand side with the columns of all lines on the right-hand side that jointly fulfil the join_cond condition. A line in the resulting set is created for every such line on the right-hand side. The content of the column on the left-hand side may be duplicated in this case. If none of the lines on the right-hand side fulfils the join_cond condition, no line is created in the resulting set.
Resulting set for outer join
The outer join basically creates the same resulting set as the inner join, with the difference that at least one line is created in the resulting set for every selected line on the left-hand side, even if no line on the right-hand side fulfils the join_cond condition. The columns on the right-hand side that do not fulfil the join_cond condition are filled with null values.
Example
Join the columns carrname, connid, fldate of the database tables scarr, spfli and sflight by means of two inner joins. A list is created of the flights from p_cityfr to p_cityto. Alternative names are used for every table.
PARAMETERS: p_cityfr TYPE spfli-cityfrom,
p_cityto TYPE spfli-cityto.
DATA: BEGIN OF wa,
fldate TYPE sflight-fldate,
carrname TYPE scarr-carrname,
connid TYPE spfli-connid,
END OF wa.
DATA itab LIKE SORTED TABLE OF wa
WITH UNIQUE KEY fldate carrname connid.
SELECT ccarrname pconnid f~fldate
INTO CORRESPONDING FIELDS OF TABLE itab
FROM ( ( scarr AS c
INNER JOIN spfli AS p ON pcarrid = ccarrid
AND p~cityfrom = p_cityfr
AND p~cityto = p_cityto )
INNER JOIN sflight AS f ON fcarrid = pcarrid
AND fconnid = pconnid ).
LOOP AT itab INTO wa.
WRITE: / wa-fldate, wa-carrname, wa-connid.
ENDLOOP.
Example
Join the columns carrid, carrname and connid of the database tables scarr and spfli using an outer join. The column connid is set to the null value for all flights that do not fly from p_cityfr. This null value is then converted to the appropriate initial value when it is transferred to the assigned data object. The LOOP returns all airlines that do not fly from p_cityfr.
PARAMETERS p_cityfr TYPE spfli-cityfrom.
DATA: BEGIN OF wa,
carrid TYPE scarr-carrid,
carrname TYPE scarr-carrname,
connid TYPE spfli-connid,
END OF wa,
itab LIKE SORTED TABLE OF wa
WITH NON-UNIQUE KEY carrid.
SELECT scarrid scarrname p~connid
INTO CORRESPONDING FIELDS OF TABLE itab
FROM scarr AS s
LEFT OUTER JOIN spfli AS p ON scarrid = pcarrid
AND p~cityfrom = p_cityfr.
LOOP AT itab INTO wa.
IF wa-connid = '0000'.
WRITE: / wa-carrid, wa-carrname.
ENDIF.
ENDLOOP. -
How to join two tables in a cursor
i have a cursor that selects data from one table,
i want it to select data from one other table also.. how i can do that.. is there any alternate way to do that if yes then suggest .. waiting for ur reply....employee_number" and other has column name as "comp_employee_number" .. Well that would be quite simple ....
SELECT e1.foo, e2.bar
FROM employees e1, staff_members e2
WHERE e1.employee_number = e2.comp_employee_number;.... unless what you're really expecting is for the datbase to somehow figure out by itself that although those columns have different names they actually represent the same data and magically derive the join for you.
Perhaps, you really need to explain in more detail precisely what your problem is.
Cheers, APC
Maybe you are looking for
-
Indesign CS4 won't open or create new files. Why???
I'm using Indesign CS4 and all of a sudden it won't open old files or creat new ones. I've restarted my machine and program and it still won't do anything. Any ideas?
-
Problem creating spatial index(ora 29855) on 10g 2r
hello i use oracle 10g r2 and have problems by creating my index (ora 29855). The weird thing is that similar kinds of creating indices make one time problems and in the other time not ??? First example - it's no problem to create this index and ever
-
Sales, costs and Operating Earnings Report
Hi Experts, I have been asked to create a report on Sales, costs and Operating Earnings and i have no experience with the reporting side of BW yet. Can you please give me a step by step guide on how to go about completing this task? Thank you.
-
Why does my touch do completely random things when im not even touching it?
I just got a new 2nd gen 16gb ipod touch that is really bugging me. It doesn't respond to what i tell it to do and does random things when im not even using it. Like if i set it down on my desk and just look at it without touching it, it might random
-
JDBC adapter to SAP: select & join from multiple tables ???
Hello, I have a task to get an aggregating information from two tables and send it into SAP. I use XI JDBC sender adapter to access to MSSQL DB. I know how to construct SQL quiery: (something like that) SELECT table1.Date SUM(table1.sum) from table