How to transfer data between two tables
Hi friends i have got a new problem actually i'm a fresher in this SAP so i have a doubt in SAP Smart Forms the problem is like this
I have a data element common in both of the tables BSEG and KNA1 and the common data element is KUNNR so i want to transfer all the data in the table BSEG to KNA1 of the same data element(KUNNR) in which there is data regarding customer information so i want to transfer the single customer data into another table KNA1 and i want to display the data in the output plz any one can help me.
hi.
the below metjhod u can adopt.
1)
select data from 1st zable to internal table.
2)insert data from internal table to 2nd ztable simple.
data:begin of itab occurs 0.
include structure ztable_structure1.
data:end of itab.
select * from ztable into table itab.
modify ztable1 FROM TABLE itab.
3 ) ike that u can catch date from other table.
4) if any condition is there u can check it in the internal table.
Rgds
Anver
if hlped pls mark points
Similar Messages
-
How to compare data between two tables?
Hi,
My team is trying to develop a SAP data migration tool (DMT) using ABAP.
One of the functionalities in the DMT is to validate the data in the staging area against the loaded SAP data.
The tables in the stagin area are customer tables (i.e. user-defined tables starting with Y, Z).
How do I compare the data in the staging area against data that are loaded into SAP tables? Are there some built-in SAP functions to do this? Or, are there some better ways of doing this (e.g. instead of comparing against data in the SAP tables, we compare with some INTERNAL tables)?
Any help would be greatly appreciated, thanks!Hi Kian,
Use <b>SCMP</b> transaction to compare data between two tables and you can not use this for comparing internal tables.
Thanks,
Vinay -
How to transfer data between different tables in an Oracle 10g databse?
I have to do the following: there are 5 database tables in our Oracle 10g database that store certain data. Then there are 2 new tables where we want the data to go to. My task is to somehow transfer all the data that is in the first 5 tables and insert it in the 2 new ones. All tables are in the same database. The challenge lies in the fact that the structures of the tables are very dissimilar so it won't be a matter of a simple INSERT SQL query.
The data access tier of our application is developed in JAVA. We use EJB. So one way I am thinking of doing the above mentioned data transfer is to simply code it in the JAVA backed. But that might be to slow, there are millions of records in those first 5 tables. What is the best way to do something like that? Perhaps a custom (Perl?) script or some such?
Thanks.The problem is that the way the data is stored in the old tables you cannot write a query that would return it in such a format that you could immediately insert it in the new table without some formatting. Let me illustrate with an example. To pull the data from the old tables I use this query:
SELECT
SXML_DOCUMENT_DATA.VALUE As DocumentValue,
SXML_ELEMENT.NAME As ElementName
FROM
SXML_DOCUMENT,
SXML_DOCUMENT_DATA,
SXML_DOCUMENT_DETAIL,
SXML_ELEMENT,
SXML_TYPE
WHERE
SXML_TYPE.XML_TYPE_KEY = SXML_DOCUMENT.XML_TYPE_KEY
AND SXML_DOCUMENT.XML_DOCUMENT_KEY = SXML_DOCUMENT_DETAIL.XML_DOCUMENT_KEY
AND SXML_DOCUMENT_DETAIL.XML_DOCUMENT_DETAIL_KEY = SXML_DOCUMENT_DATA.XML_DOCUMENT_DETAIL_KEY
AND SXML_ELEMENT.XML_ELEMENT_KEY = SXML_DOCUMENT_DATA.XML_ELEMENT_KEY
AND SXML_TYPE.NAME = 'DA_UNIT_COMMITMENT'
AND (SXML_ELEMENT.NAME = 'resource'
OR SXML_ELEMENT.NAME = 'resourceType'
OR SXML_ELEMENT.NAME = 'commitmentType'
OR SXML_ELEMENT.NAME = 'startTime'
OR SXML_ELEMENT.NAME = 'endTime'
OR SXML_ELEMENT.NAME = 'schedulingCoordinator')
ORDER BY
SXML_DOCUMENT.NAME,
SXML_DOCUMENT_DETAIL.XML_DOCUMENT_DETAIL_KEY,
SXML_DOCUMENT_DATA.XML_DOCUMENT_DATA_KEY,
SXML_ELEMENT.NAME;
The results from the SQL query above look like this:
DOCUMENTVALUE | ELEMENTNAME
1 | ALAMIT_7_UNIT_1 | resource
2 | GEN | resourceType
3 | BRS8 | schedulingCoordinator
4 | IFM | commitmentType
5 | 2008-07-29T18:00:00:00 | startTime
6 | 2008-07-30T00:00:00 | endTime
7 | ALAMIT_7_UNIT_1 | resource
8 | GEN | resourceType
9 | BRS8 | schedulingCoordinator
10 | IFM | commitmentType
11 | 2008-07-29T00:00:00 | startTime
12 | 2008-07-29T04:00:00 | endTime
and so on. The type of data repeats every 6 records. And the values of each 6 records corresponds to 1 row in the new table, which looks like this:
schedulingCoordinator | resource | resourceType | commitmentType | startDate | endDate
1| 1 | 27 | GEN | IFM | 2008-07-29T18:00:00:00 | 2008-07-30T00:00:00
2| 1 | 27 | GEN | | 2008-07-29T00:00:00 | 2008-07-29T04:00:00
So hopefully now you see the challenge. It is not as simple as writing a SQL query that returns result rows corresponding 1 to 1 to a row in the new table. Somehow I need to take the first 6 result rows from that big SQL query and put them in the first row of the new table. Then the next 6 and put them in the second row and so on. And also, we are talking about millions of records. What happens if I process the first 2 million and then some error occurs? Do I start from the beginning again? One idea I have is to process the data in chunks, say process 500 results, commit, process another 500, commit, and so on.
Edited by: 799984 on Oct 11, 2010 9:08 AM -
How to copy data between two tables row by row
Hi All,
I have three tables TableA and TableB and TableC
I wanted to write a stored procedure to copy data row by row from TableA to TableB and then update TableC by replacing any record that has the old id (before copying) to the new id after copying the data.
here is the steps
iterate throw all the rows in tableA ( probably with a foreach)
in each iteration we will do the following:
Get current ID (identity) for each record in TableA ( will call it @oldID)
Insert the row in TableB
Get the new ID for the row from TableB will call it (@NewID)
find rows in tableC that has the (@oldID)
replace all ids in tableC with @oldID to @NewID
Thanks in advance0
TableA and TableB are identical they should have the same columns
TableC columns will be ( ID, TableA_ID , Notes) -
Use of SAP memory to transfer data between two different sessions.
Hello experts,
I wish to know how to use SAP memory to transfer data between two different sessions.
The scenario is that when I run a report and change a variable, the value of changed variable should be availabe to another user on another terminal.
Thanks & Regards!
SumitHello,
Just to add what Max has already mentioned. IMPORT TO / EXPORT FROM DATABASE statements can be used to store data in special "cluster" tables (you can't use any DDIC table) e.g., INDX.
@OP: You can opt for Shared Memory(SHM) for this specific requirement as well. In my opinion SHM is a bit tricky to code, but it is easier to monitor. The opposite holds true for "data clusters".
You should remember SHM is app-server specific. So if you've a load balancing scenario, using SHM can cause problems.
Hope i'm clear.
BR,
Suhas
Edited by: Suhas Saha on Nov 19, 2010 4:12 PM -
How to pass data between two internal sessions using ABAP memory?
Hi,
How to pass data between two internal sessions using ABAP memory?
It would be fine if you could explain with an example.
And also let me clear about the data passing between two main sessions and two external sessions with specific examples.
Thanks.Hi ,
check the example.
Reading Data Objects from Memory
To read data objects from ABAP memory into an ABAP program, use the following statement:
Syntax
IMPORT <f1> [TO <g 1>] <f 2> [TO <g 2>] ... FROM MEMORY ID <key>.
This statement reads the data objects specified in the list from a cluster in memory. If you do not use the TO <g i > option, the data object <f i > in memory is assigned to the data object in the program with the same name. If you do use the option, the data object <f i > is read from memory into the field <g i >. The name <key> identifies the cluster in memory. It may be up to 32 characters long.
You do not have to read all of the objects stored under a particular name <key>. You can restrict the number of objects by specifying their names. If the memory does not contain any objects under the name <key>, SY-SUBRC is set to 4. If, on the other hand, there is a data cluster in memory with the name <key>, SY-SUBRC is always 0, regardless of whether it contained the data object <f i >. If the cluster does not contain the data object <f i >, the target field remains unchanged.
In this statement, the system does not check whether the structure of the object in memory is compatible with the structure into which you are reading it. The data is transported bit by bit. If the structures are incompatible, the data in the target field may be incorrect.
PROGRAM SAPMZTS1.
DATA TEXT1(10) VALUE 'Exporting'.
DATA ITAB LIKE SBOOK OCCURS 10 WITH HEADER LINE.
DO 5 TIMES.
ITAB-BOOKID = 100 + SY-INDEX.
APPEND ITAB.
ENDDO.
EXPORT TEXT1
TEXT2 FROM 'Literal'
TO MEMORY ID 'text'.
EXPORT ITAB
TO MEMORY ID 'table'.
SUBMIT SAPMZTS2 AND RETURN.
SUBMIT SAPMZTS3.
The first part of this program is the same as the example in the section Saving Data Objects in Memory. In the example, the programs SAPMZTS1 and SAPMZTS2 are called using SUBMIT. You can create and maintain the programs called using the SUBMIT statement by double-clicking their names in the statement. For further information about the SUBMIT statement, refer to Calling Executable Programs (Reports)
Example for SAPMZTS2:
PROGRAM SAPMZTS2.
DATA: TEXT1(10),
TEXT3 LIKE TEXT1 VALUE 'Initial'.
IMPORT TEXT3 FROM MEMORY ID 'text'.
WRITE: / SY-SUBRC, TEXT3.
IMPORT TEXT2 TO TEXT1 FROM MEMORY ID 'text'.
WRITE: / SY-SUBRC, TEXT1.
Example for SAPMZTS3:
PROGRAM SAPMZTS3.
DATA JTAB LIKE SBOOK OCCURS 10 WITH HEADER LINE.
IMPORT ITAB TO JTAB FROM MEMORY ID 'table'.
LOOP AT JTAB.
WRITE / JTAB-BOOKID.
ENDLOOP.
The output is displayed on two successive screens. It looks like this:
and
The program SAPMZTS2 attempts to read a data object TEXT3 from the data cluster "text", which does not exist. TEXT3 therefore remains unchanged. The existing data object TEXT2 is placed in TEXT1. In both cases, SY-SUBRC is 0, since the cluster "text" contains data.
The program SAPMZTS3 reads the internal table ITAB from the cluster "table" into the internal table JTAB. Both tables have the same structure, namely that of the ABAP Dictionary table SBOOK.
Pls. reward if useful..... -
In jsp file, how to transfer parameter between two javabean?
In jsp file, how to transfer parameter between two javabean?
for example
Bean1 has a attribute A
Bean2 has a attribute B
how to transfer the value of A to BHave you tried something like...
<jsp:setProperty name="Bean2" property="B" value="<jsp:getProperty name="Bean1" property="A" />" /> -
Query the data between two tables
Need help for query the data between two tables
Table 1: Time sheet
P.ID P.Name EmpID HoursSpend DateTime
c12234 Test 25 4 06/12/2013
c12234 Test 25 7 06/13/2013
c12234 Test 25 8 06/15/2013
c12234 Test 5 3 06/21/2013
c12234 Test 2 5 07/15/2013
c12234 Test 25 4 07/21/2013
Table 2: cost table
EmpID FromDate ToDate Rate
25 05/01/2013 06/30/2013 250
2 04/01/2013 05/31/2013 150
25 07/01/2013 09/30/2013 300
Output
P.ID P.Name EmpID HoursSpend DateTime Rate Total (HoursSond x Rate)
c12234 Test 25 4 06/12/2013 250 1000 (4*250)
c12234 Test 25 7 06/13/2013 250 1750
c12234 Test 25 8 06/15/2013 250
2000
c12234 Test 25 4 07/21/2013 300
1200
c12234 Test 2 5 07/15/2013 150
750
===========================================
Total 28
6700
============================================
Here EmpID =2 don't have rate in the cost table on july month should be pick from last entry from cost table.Hi Gopal,
According to your description, it seems that the output needn’t include the row when EmpID=2. Because the DateTime for it in Table1 doesn’t included between FromDate column and ToDate column. After testing the issue in my environment, we can refer to the
query like below to achieve your requirement:
SELECT time.*,cost.EmpID,cost.Rate,(time.HoursSpend * cost.Rate)as [Total (HoursSond x Rate)]
FROM [Time sheet] as time
INNER JOIN
[cost table]as cost
ON time.EmpID = cost.EmpID
AND time.DateTime BETWEEN cost.FromDate AND cost.ToDate
If there are any other questions, please feel free to ask.
Thanks,
Katherine Xiong
Katherine Xiong
TechNet Community Support -
How to check relation between two tables in same database
How to check relation between two tables in same database using Oracle SQL developer. Version 2.1.1.64
Hi,
Try this,
SELECT cons.owner AS child_owner, cons.table_name AS child_table,
cons.constraint_name constaint_name,
cons.constraint_type constraint_type, col.owner parent_owner,
col.table_name parent_table, col.column_name column_name
FROM dba_cons_columns col, dba_constraints cons
WHERE cons.r_owner = col.owner
AND cons.r_constraint_name = col.constraint_name
AND col.owner = 'MY_USER'
ORDER BY child_table;Thanks,
Shankar -
Transaction to see common data between two tables
Is there any transaction to see common data between two tables with out creating views.
what is the transaction to see the link between two tables
regards
pavanHi,
Go to a transparent table for which you want to know the common fields, from there click the button GRAPHICS (shortcut Ctrl + Shift + F11) in the application tool bar. Then you are redirected to a list containing the tables belonging to the same group. There select whatever tables you would like to see and click COPY. A window will pop-up and will show the relationship between the fields of the tables in a flow chart format.
see to this link also.
Common fields b/w tables
Regards,
Revathi Bhoopal. -
How to insert data into two tables linke with foreign key..
I have two tables
1)EMP(emp_ID,username,emp_type_code)
emp_ID is primary key, emp_type_code is a foreign key references emptype table.
2)emptype(emp_type_code,emp_type_descripton)
emp_type_code is primary key
Could anyone help me ..how to insert data into EMP table. How to insert data into two tables linke with foreign key..CREATE TABLE "CATDB"."DWDIMUSER"
"USER_ID" NUMBER(10,0) NOT NULL ENABLE,
"SPECIALTY_ID" NUMBER(10,0),
"FULLNAME" VARCHAR2(20 BYTE),
"FNAME" VARCHAR2(20 BYTE),
"LNAME" VARCHAR2(20 BYTE),
"USER_SUBTYPE" VARCHAR2(20 BYTE),
CONSTRAINT "DIMUSER_PK" PRIMARY KEY ("USER_ID") USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT) TABLESPACE "CATDB" ENABLE,
CONSTRAINT "DIMUSER_DIMSPECIALTY_FK" FOREIGN KEY ("SPECIALTY_ID") REFERENCES "CATDB"."DWDIMSPECIALTY" ("SPECIALTY_ID") DISABLE
CREATE TABLE "CATDB"."DIMSPECIALTY"
"SPECIALTY_ID" NUMBER(10,0) NOT NULL ENABLE,
"SPECIALTY_NAME" VARCHAR2(100 BYTE),
CONSTRAINT "DIMSPECIALTY_PK" PRIMARY KEY ("SPECIALTY_ID") USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT) TABLESPACE "CATDB" ENABLE
INSERT INTO DIMUSER (FullName, FNAME, LNAME, USER_TYPE, USER_SUBTYPE)
SELECT DISTINCT
Engineer AS FullName,
regexp_substr(Engineer , '[^,| ]+', 1, 1) as FName,
regexp_substr(Engineer , '[^,| ]+', 1, 2) as LName ,
'Engineer'
FROM EMPLOYEELOOKUP;
INSERT INTO DIMSPECIALTY (SPECIALTY_NAME)
SELECT DISTINCT SPECIALITY
FROM EMPLOYEELOOKUP;
COMMIT;
CREATE TABLE employeelookup ...IS A TABLE THAT HAS ALL THE DATA NEDED TO BE FILLED IN BOTHE TABLES...
CREATE TABLE "CATDB"."EMPLOYEELOOKUP"
"EMPLOYEELOOKUP_ID" NUMBER(10,0) NOT NULL ENABLE,
"ENGINEER" VARCHAR2(25 BYTE),
"SPECIALTY" VARCHAR2(20 BYTE),
CONSTRAINT "DIMSPECIALTY_PK" PRIMARY KEY ("EMPLOYEELOOKUP_ID") USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT) TABLESPACE "CATDB" ENABLE
DATA IN EMPLOYEELOOKUP
Engineer, Specialty,
John, Dow, Electronis,
Dow, Jons, Technician
Stan Smithers Sales
Mark, Richards Marketing
Jenny, Lane Marketing
John, Lee Sales
I NEED TO LOAD THE FOREIGN KEY IN DIMUSER FROM THE DIMSPECIALTY TABLE?
BY USING THE LOOKUP TABLE TO MARCH THE NAMES UNDER THE Engineer COLUMN, SPECIALTY COLUMNE DISTICTIVLY BY JOINING THE DIMSPECILTY TO RISTIVE THE PRIMARY KEY AND FILL IT IN THE DIMUSER TABLE AS A FOREIGNE KEY. -
How to separate data between two colons
Hi,
how to separate data between two colons?
ex: 'ABC:1234:1-ss-2:0:0:0:0-DEF:5678:0:0:0:0'
how to access these 1234, 5678 and 1-ss-2 ?
there may be any string.
please helpHi,
The string 'ABC:1234:1-ss-2:0:0:0:0-DEF:5678:0:0:0:0' contains 11 colons, and 10 sub-strings that are between colons. How do you distinguish the ones you want,
(1) 1234
(7) 5678
(2) 1-ss-2
from the ones you don't want
(3) 0
(4) 0
(5) 0
(6) 0-DEF
(8) 0
(9) 0
(10) 0
Anyhow, in Oracle 10 (and up) you can easily get the n-th item from a :-delimited list by saying:
REGEXP_SUBSTR ( txt
, '[^:]+
, 1
, n
)First use REGEXP_REPLACE to remove anything before the first colon and anything after the last one. -
ODI: How to transfer data between Essbase apps
Hi,
I'm using old Planning version 3.5 on Essbase 7.1.6. It has no partition options between apps. XREF function work slowly. I need to transfer data with transformations between two Essbase Apps. I'd like to use ODI 10.1.3.6.4 to do it. I'd like to transfer data between essbase apps via Staging Area.
1. What units of LKM, IKM, RKM to me need to be used?
2. How to create datasource for Essbase in ODI?I've found "Compatible software: Essbase 7.1.6 (Data Load & Data/Metadata Extract Only)" information here
http://download.oracle.com/docs/cd/E15985_01/doc.10136/readme/DIHER.pdf
John, I use your blog as a short ODI guide. Thanx a lot of!
Besides, I've found "Getting Started with Oracle Data Integrator Adapter for Hyperion Essbase" - informative source
http://download.oracle.com/docs/cd/E15985_01/doc.10136/getstart/DIAHE.pdf -
It is easy to transfer data between a simple input/output dll build with LV and an external code like C++, but when data are available inside a loop running in the dll(in fact thread running in LV); How can I read them or receive an handle pointer to the calling C++ application when new data are ready.
If you're using LabVIEW 7, you can use the PostLVUserEvent function to fire an event for an event structure in LV. Refer to the Using External Code in LV manual.
Or you could use datasocket for this. The datasocket activex dll is nids.dll. You could have the class wizard generate wrappers for you or if you have Measurement Studio, you could use the custom wrappers it provides to communicate between the VI and dll.
I hope this helps
Bilal Durrani
NI
Bilal Durrani
NI -
How to insert data into two tables at once using XSJS
Hello Experts,
My requirement is to insert data into two tables at once. I have a XS JS app and want to update these tables via xsjs. How can I do this ?
Is there any mechanism like sql 'transactions' also in Hana ? If yes, how can I call it via xsjs ? If not, what are the ways to populate two different tables at once.
Please advice. Any help is really appreciated.
Thanks !There is nothing special about inserting into two tables at once in XSJS. Just issue two separate SQL Statements. Don't execute the COMMIT until after both commands. That way they are all one transaction.
Maybe you are looking for
-
The apple genius said I can easily buy one online and a 10 year old could put it in. However, all of the hard drives I'm seeing mention PC rather than Mac.
-
Passwords removed from Pages and Numbers when opened in iOS
I'm I missing something or is it expected that passwords will be removed from Pages and Numbers files once they are opened in iOS? gbs
-
Purchase order, sales order documents
hi all, can any one give me the format of purchase order n sales order . i want sap script for those two documents [pictorial presentation]. if possible send me screen shots to [email protected] thanks n regards, suresh babu aluri.
-
How can I find the AR receipt corresponding the receipt batch in R11?
Dear all: As the topic, how can I find the AR receipt corresponding the receipt batch in R11? Any SQL can supply to check? Thank you !! Regards
-
Hi Semi finish is at Standard Price and issue on finish material Process order at standard price. At month end semi finish variance settled. How I can charge the semi finish variance on finish Process order. regards