Write fields from two tables in one line??
Hi friends,
I want to write some fields from bkpf and bseg in one line...
My report should like something like this:
****some text*****
*for first document******* bkpf-bldat kunnr bseg-belnr bseg-gsber bseg-wrbtr
*for second document*** bkpf-bldat kunnr bseg-belnr bseg-gsber bseg-wrbtr
*for third document****** bkpf-bldat kunnr bseg-belnr bseg-gsber bseg-wrbtr
etc.
What should I change in order to get this form in report output?? Can I put these fields in some table so that it looks like excel table??Could you please check out the code below?
loop at it_bkpf into wa_bkpf.
loop at it_bseg into wa_bseg.
write: wa_bseg-gsber, wa_bseg-belnr, wa_bseg-wrbtr.
endloop.
write: wa_bkpf-bldat.
read table it_bsid with key bukrs = wa_bkpf-bukrs
belnr = wa_bkpf-belnr
gjahr = wa_bkpf-gjahr
cpudt = wa_bkpf-cpudt.
if sy-subrc = 0.
write: it_bsid-kunnr.
endif.
endloop.
Thanks,
Nihad
hi nihad,
define positions on where to write data like this.
LOOP AT it_bkpf INTO wa_bkpf.
LOOP AT it_bseg INTO wa_bseg WHERE belnr EQ wa_bkpf-belnr.
WRITE: /5 wa_bkpf-bldat.
READ TABLE it_bsid
WITH KEY bukrs = wa_bkpf-bukrs
belnr = wa_bkpf-belnr
gjahr = wa_bkpf-gjahr
cpudt = wa_bkpf-cpudt.
IF sy-subrc EQ 0.
WRITE: 20 it_bsid-kunnr.
ENDIF.
WRITE: 35 it_bseg-belnr,
50 it_bseg-gsber,
60 it_bseg-wrbtr.
ENDLOOP.
ENDLOOP.
regards,
Peter
Similar Messages
-
Delete from two tables in one statement
Hi,
Is there a way to delete from two tables in one statement?
Actually I have two tables:
1. Base table (id, name, age)
2. Person table (id, city, street)
The id in both tables is identical.
I would like to delete using something like a join:
Delete from base, person where id=2;
Thanks
dyahavHi,
If you want to delete records both at a time them your table must use ON DELETE CASCADE. See the below example.
CREATE TABLE supplier
( supplier_id numeric(10) not null,
supplier_name varchar2(50) not null,
contact_name varchar2(50),
CONSTRAINT supplier_pk PRIMARY KEY (supplier_id)
CREATE TABLE products
( product_id numeric(10) not null,
supplier_id numeric(10) not null,
CONSTRAINT fk_supplier
FOREIGN KEY (supplier_id)
REFERENCES supplier(supplier_id)
ON DELETE CASCADE
In this example, we've created a primary key on the supplier table called supplier_pk. It consists of only one field - the supplier_id field. Then we've created a foreign key called fk_supplier on the products table that references the supplier table based on the supplier_id field.
Because of the cascade delete, when a record in the supplier table is deleted, all records in the products table will also be deleted that have the same supplier_id value.
Thank you. -
Retrive data from two tables into one internal table.
Hi SDN,
I am downloading the Assets data from two tables ANLA,ANLZ.
there is a common field ANL1in both tables and i have to retrive the data by using anl1 into the internal table.
can you please send me the SELECT Syntax for this probl.....
Thank you & Regards,
ManojHi manoj,
Please see the following sample code. But kindly don't use join as it may hamper ur performance. No trouble in using two select query.
data: begin of itab occurs 0,
BUKRS like anla-BUKRS,
ANLN1 like anla-ANLN1,
BDATU like anlz-BDATU,
end of itab.
select anlabukrs anlaANLN1 anlzBDATU into corresponding fields of table itab from anla inner join anlz on anlaanl1 eq anlz~anl1 where (logexp).
Please come back for any clarification.
Thanks and Regards,
saurabh -
Generate delta records by comparing multiple fields from two tables?
I have two tables with similar fields. Let's say Table 1 (T1) has fields Customer, A, B and C. Table 2 (T2) has fields Customer0002, A0002, B0002 and C0002. For each customer (each record) I want to check whether there is any difference in field A and A0002 or B and B0002 or C and C0002. If there is a difference between any of these pairs of fields then I will update that customer's record. Currently I have a piece of code
DATA: ls_source TYPE y_source_fields,
ls_target TYPE y_target_fields.
LOOP AT it_source INTO ls_source.
if not ( ls_source-A = ls_source-A0002 ).
MOVE-CORRESPONDING ls_source TO ls_target.
APPEND ls_target TO et_target.
endif.
ENDLOOP.
This checks for the difference between one pair - A and A0002. How can I make it check 3 pairs and update when any of them have differences?Hello Khaled
Why don't you add B and B0002 - C and C0002 fields into your if declaration?
LOOP AT it_source INTO ls_source.
if not (
ls_source-A = ls_source-A0002 and
ls_source-B = ls_source-B0002 and
ls_source-C = ls_source-C0002
MOVE-CORRESPONDING ls_source TO ls_target.
APPEND ls_target TO et_target.
endif.
ENDLOOP.
I think you have more than 3 fields and the count of these fields are dynamic right?
Do you about the ASSIGN COMPONENT x OF STRUCTURE y TO <field_symbol>. usage?
Can you explain your need in detail please.
Edited by: Bulent Balci on Jul 27, 2010 4:18 PM -
Retriving single field from two tables which are unrelated
Hi experts..
i would like to retrieve a field say X from two database tables TAB1 and TAB2 which are unrelated . Can you give me a way to retrive the field X from TAB1 and TAB2 in a single select statement on perticular condition.
Reward points if aswered..Hi,
If the field is in two tables,you can use for all entries. But anyway two select statemetns are needed.
If you want single select statement, try using subquery. -
SSAS Tabular - Merge data from two tables to one
Hi,
I have two ReportServer databases in two different instances of SQL Server. I want to extract the ExecutionLog3 data to a Tabular model. Now, I have two separate tables in Tabular with duplicated measures but I want to have the data from two ReportServer in
the same table.
Any idea?
Regards.Hi Numero4,
According to your description, there are two Reporting Services databases, and you want to merge the data in a tabular model, right?
As per my understanding, you can create a link server on one of the server, and then merge the data in database lever other than in tabular mode. In this case, import the merged data into the tabular model. Here are some useful links for you reference.
http://msdn.microsoft.com/en-IN/library/ff772782.aspx
http://support.flexquarters.com/esupport/index.php?/Default/Knowledgebase/Article/View/2458/52/how-to-create-link-server-with-ms-sql-200520082012-64-bit-using-qodbcqremote
Regards,
Charlie Liao
TechNet Community Support -
Query works fine when I query one table. When I add the
second it generates the following error.
-1:[Macromedia][SequeLink JDBC Driver][ODBC
Socket][Microsoft][ODBC Microsoft Access Driver] Could not find
file 'C:\CFusionMX7\db\slserver54\logging\mob.mdb'
See code.
Thank youAlso does Access understand this way of joining tables? I do
not
believe I have very seen Access SQL that did not use INNER
JOIN syntax.
I.E.
FROM mob_user JOIN mob_user_type ON mob_user.user_type_id =
mob_user_type.user_type_id -
Need of SQL query in selecting distinct values from two tables
hi,
I need a query for selecting distinct values from two tables with one condition.
for eg:
there are two tables a & b.
in table a there are values like age,sex,name,empno and in table b valuses are such as age,salary,DOJ,empno.
here what i need is with the help of empno as unique field,i need to select distinct values from two tables (ie) except age.
can anybody please help me.
Thanks in advance,
RatheeshNot sure what you mean either, but perhaps this will start a dialog:
SELECT DISTINCT a.empno,
a.name,
a.sex,
b.salary,
b.doj
FROM a,
b
WHERE a.empno = b.empno;Greg -
ALV OOps report- getting data from two tables and adding issue
Hi,
This is sales employee performance report.
I need to select all the fields from two tables based on user input ie VKorg, sales employee .
There is one field callled " Net sales"in both the tables.
Based on sales employee number, i need to add that net sales which i get from two tables.
I need to generate single report.
Can you give some inputs reg. the select query.
My idea is select all the data from both tables using join statement.
ThanksHi,
I have written like this:
select * from S002 as a join S006 as b
into table ME->SS002_RAW[]
where vkorg in me->select_parameters->SO_VKORG[] = vkorg in me->select_parameters->SO_VKORG[]
and ZZSLSEMP01 in me->select_parameters->SO_so_empl[] = ZZSLSEMP02 in me->select_parameters->SO_so_empl[].
when i do like that,
I am getting error
Incorrect structure of FROM clause . . . .
If you give some idea on this
Edited by: Raja on Apr 22, 2009 11:19 AM -
To Select the data from two table one is transp table and onther is cluster
Hi All,
I want to select the data from two tables
Here i am giving with an example.
Fileds: kunnr belnr from bseg. table bseg
fields: adrnr from kna1 table: kna1.
Know i want to put these into one internal table based on kunnr and belnr.
Thanks in advance.
RameshHi,
U cant use joins on cluster table and BSEG is a cluster table so use FOR ALL ENTRIES for taht
refer this code
*& Form sub_read_bsak
text
--> p1 text
<-- p2 text
FORM sub_read_bsak.
*--Select data from BSAK Table
SELECT lifnr
augdt
augbl
gjahr
belnr
xblnr
blart
dmbtr
mwskz
mwsts
sgtxt
FROM bsak
INTO CORRESPONDING FIELDS OF TABLE it_bsak
WHERE belnr IN s_belnr
AND augdt IN s_augdt.
IF sy-subrc EQ 0.
*--Sort table by accounting document and vendor number
SORT it_bsak BY belnr lifnr.
ENDIF.
ENDFORM. " sub_read_bsak
*& Form sub_read_bseg
text
--> p1 text
<-- p2 text
FORM sub_read_bseg.
IF NOT it_bsak[] IS INITIAL.
*--Select data from BSEG table
SELECT belnr
gjahr
shkzg
kostl
hkont
ebeln
ebelp
FROM bseg
INTO CORRESPONDING FIELDS OF TABLE it_bseg
FOR ALL ENTRIES IN it_bsak
WHERE belnr EQ it_bsak-belnr
AND gjahr EQ it_bsak-gjahr
AND shkzg EQ 'S'.
IF sy-subrc EQ 0.
*--Sort table by accounting document
SORT it_bseg BY belnr.
ENDIF.
ENDIF.
ENDFORM. " sub_read_bseg -
Selecting from two tables but making it just one selection
Is there a way to select from two tables and just have one selection appear?
Specifically I have a fact_install_unit, and a fact_install_arch table.
Sometimes the value exists in fact_install_unit.factory_timestamp, and sometimes when fact_install_unit.factory_timestamp is null I need to pull it from the fact_install_arch.factory_timestamp.
sort of like:
(select fact_install_unit.factory_timestamp
from fact_install_unit, fact_install_arch
where fact_install_unit.fl_unit_sak = fact_install_arch.fl_unit_sak
and where fact_install_unit.factory_timestamp is null then display fact_install_arch.factory_timestamp)> I was just stating that I do not have sufficient priveleges to create views in this database.
>
nm means "no more" than that
And how are we supposed to know that? You seem to have changed the thread subject to "unfortunately I only have read-only and insufficient priveleges", which is not even a question.
nm means "New Mexico":
http://www.myshortpencil.com/schooltalk/messages/85/515.html?971794944 -
I need to add a single field from with_item table . need to write select query with reference to company code , account doc no , fiscal year
Hi Arun ,
Can you explain little bit more ??
what is account doc no?
what are the transactions should be displayed in your output??
-Rajesh N -
Capture from Two Tables and Apply in one Table
Hi All,
Is it possible to capture from two tables (master and child table) and apply in one table?
For example,
1. DEPT and EMP tables in source database with relation
DEPT table structure is like DEPT_ID, DEPT_NAME, LOC_NAME
EMP table structure is like EMP_ID, EMP_NAME, EMP_DOJ, EMP_SAL, DEPT_ID
2. EMP_DEPT_STAGING in destination database
EMP_DEPT_STAGING table structure is like EMP_ID, EMP_NAME, EMP_DOJ, EMP_SAL, DEPT_ID. DEPT_NAME, LOC_NAME
if there is any update in DEPT table, EMP_DEPT_STAGING should get populated with Department and its employee details. Similarly, if there is any update in EMP table EMP_DEPT_STAGING table should get populated with Employee details and along with department detail.
Is it possible to accomplish this? If yes, could you please provide me some examples?
Thanks & Regards
Thiyagu
Edited by: mt**** on Sep 4, 2011 11:22 PMlike this
INSERT @PlantNew (PlantID, PlantName, PlantDirExists, PlantAssistantDirID, PlantDirID)
SELECT p.PlantID,
p.PlantName,
CASE WHEN pd.PlantID IS NULL THEN 0 ELSE 1 END,
PlantAssistantDirID,
PlantDirID
FROM @Plant p
LEFT JOIN (SELECT PlantID,
MAX(CASE WHEN Assistant = 1 THEN PlantDirectorID END) AS PlantAssistantDirID,
MAX(CASE WHEN Assistant = 0 THEN PlantDirectorID END) AS PlantDirID
@PlantDirector
GROUP BY PlantID)pd
ON pd.PlantID = p.PlantID
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs
You're missing a FROM
insert into @PlantNew
SELECT p.PlantID,
p.PlantName,
CASE WHEN pd.PlantID IS NULL THEN 0 ELSE 1 END,
PlantAssistantDirID,
PlantDirID
FROM @Plant p
LEFT JOIN (SELECT PlantID,
MAX(CASE WHEN Assistant = 1 THEN PlantDirectorID END) AS PlantAssistantDirID,
MAX(CASE WHEN Assistant = 0 THEN PlantDirectorID END) AS PlantDirID
from @PlantDirector
GROUP BY PlantID)pd
ON pd.PlantID = p.PlantID -
Help with listing records from two tables
Hi: I have two tables joined by the first field. The field is primary key in first table. Need help listing records from both tables with each record one line/record.
create table EVENTS (
event_key varchar2(64) primary key,
event_description varchar2(64),
create_time int
create table EVENT_UPDATES (
event_key varchar2(64) NOT NULL ,
update_description varchar2(64),
update_time int
insert into EVENTS values('Event1', 'This is event1', 1);
insert into EVENT_UPDATES values('Event1', 'Ticket created', 3);
insert into EVENT_UPDATES values('Event1', 'Event cleared', 10);
insert into EVENTS values('Event2', 'This is event2', 4);
insert into EVENT_UPDATES values('Event2', 'Ticket created', 6);
insert into EVENT_UPDATES values('Event2', 'Event cleared', 8);I want to print each record in EVENTS table as one line and corresponding records in EVENT_UPDATES as one line/record like this
Event1 1 This is event1
3 Ticket created
10 Event cleared
Event2 4 This is event2
6 Ticket created
8 Event clearedTIA
Raviselect case weight
when 1 then event_key
end key,
time_val,
description
from (
select event_key,
create_time time_val,
event_description description,
1 weight
from events
union all
select event_key,
update_time,
update_description,
2 weight
from event_updates
order by event_key,
weight
KEY TIME_VAL DESCRIPTION
Event1 1 This is event1
3 Ticket created
10 Event cleared
Event2 4 This is event2
6 Ticket created
8 Event cleared
6 rows selected.
SQL> SY. -
Hi There,
In SAP GRC 10.0, our team had an issue where we could not add duplicate fields from separate table (see ERROR: Select Currency/UoM field for the selected analyzed fields). This was resolved by the SAP Note 1904313/ 1904314 (http://service.sap.com/sap/support/notes/1904313).
We upgraded our system to SAP GRC 10.1 SP05 and could now add the duplicate fields from separate tables. SAP Note 1904313/ 1904314 was part of SAP GRC 10.1 SP03 so it makes sense that we, in a higher version (SP05), would be able to do this.
The issue now is when we add the duplicate fields from different tables and run the Ad-hoc Query to test if the data source works correctly, the No Data Selected warning persists. This means that the data source provides no data for analysis, which is required to write our business rules.
Below is an example:
Basic data source with just one currency reference field EBAN-WAERS.
When you run the Ad-Hoc Query you receive data.
Basic data source with second currency reference field EKKO-WAERS.
When you run the Ad-Hoc Query no data is found.
Please also make reference to the following thread logged by my colleague (ERROR: Select Currency/UoM field for the selected analyzed fields)
Any assistance to receive data with duplicate fields from separate tables will be highly appreciated.
Thanking you in advance.
Regards
Gary KhanHi
following are the error messages from dump
hrtText
There is already a line with the same key.
hat happened?
Error in ABAP application program.
The current ABAP program "SAPLCKMS" had to be terminated because one of the
statements could not be executed.
This is probably due to an error in the ABAP program.
rror analysis
You wanted to add an entry to table "\FUNCTION-POOL=CKMS\DATA=T_DYN_CKMLCR",
which you declared
with a UNIQUE KEY. However, there was already an entry with the
same key.
This may have been in an INSERT or MOVE statement, or within a
SELECT ... INTO statement.
In particular, you cannot insert more than one initial line into a
table with a unique key using the INSERT INITIAL LINE... statement.
rigger Location of Runtime Error
Program SAPLCKMS
Include LCKMSF01
Row 226
Module type (FORM)
Module Name DYNAMIC_PERIOD_CLOSING
Source code where dump ocured
222
223 APPEND ht_ckmlpp TO t_add_ckmlpp.
224 APPEND LINES OF ht_ckmlcr TO t_add_ckmlcr.
225 INSERT ht_ckmlpp INTO TABLE t_dyn_ckmlpp.
>>>> INSERT LINES OF ht_ckmlcr INTO TABLE t_dyn_ckmlcr.
227 ENDWHILE.
Also I guess there is problem with material ledger in R/3 side
I have never worked on material ledger before so dont hav idea of Tcode and tables in SAP R/3 for material ledger.
Thanks
Navneet
Maybe you are looking for
-
Can I connect multiple monitors to a MBP MD102?
I have a Mid-2012 13 inch Macbook Pro MD102. I have one external monitor connected through the mini display port but I have three more monitors laying around the house I would like to put to use. I tried connecting them through USB adaptors but the
-
Is it a MUST to have both itunes library and itunes music folder?
I just noticed I have 22 GB of music in itunes library (itunes application) and also 22GB of music in itunes music folder. Do I need to have both folders active? What would happen if I delete all the music in itunes music folder? Should that delete a
-
I have a apple iPad mini I bought new last year in November. I don't know much of anything else except it has 16GB. There aren't any other problems besides me forgetting the passcode. I have tried to get help from apple support but seemed to go in c
-
Dbx SIGSEGV (no mapping at the fault address)
Hello, I have the following error on Suse 10.0 (32bit and 64bit also) which is appear when I try to load a program with lots of linked libraries for debug. Reading libEG.so Reading libHtml.so Reading libGeom.so Reading libGraf3d.so Reading libGpad.so
-
Hi, I have few questions regarding manual payment run: 1.Whats the difference between manual payment run and automatic payment run 2.Which tables get updated through both payment runs. 3.In which tables are all bank details updated through manual pay