How to insert select columns from one internal table to another
Hi,
How to insert select columns from one internal table to another based on condition as we do from a standart table to internal table.
regards,
Sriram
Hi,
If your question is for copying data from 1 int table to other ;
we can use
APPEND LINES OF it_1 TO it_2.
or if they have different columns then:
loop at it_1 into wa_it1.
move wa_it1-data to wa_it2-d1.
apped wa_it2 to it_2.
clear wa_it2.
endloop.
thnxz
Similar Messages
-
How do i transfer data from one internal tabe to another.
Hi All,
How do i transfer data from one internal tabe to another.
Can i do it ebven if he tables are different in structure.
Please Advice.
Thanks in advance.Hi Saket Tiwari,
I hope the earlier post by kashyap is good enough an answer. anywas in addition to it let me give a detailed
explanation of how you can populate an internal table.
1) Append data line by line.
Syntax : APPEND [<wa> TO / INITIAL LINE TO] <itab>.
this appends new line to internal table <itab>.
2) Using COLLECT statement.
COLLECT is another form of statement used for populating the internal tables. Generally COLLECT is used while inserting lines into an internal table with unique standard key. The syntax for COLLECT statement is as shown
Syntax : COLLECT [<wa> INTO] <itab>.
3) Using INSERT statement
Syntax INSERT [<wa> INTO / INITIAL LINE INTO] <itab> [index <idx>].
INSERT statement adds a line/work area to the internal table. You can specify the position at which the new line is to be added by using the INDEX clause with the INSERT statement.
Now coming to your request..
To append part or all of an internal table
Syntax
APPEND LINES OF <itab1> [FROM <n1>] [TO <n2>] TO <itab2>.
* Note:
Without the FROM and TO options, this statement appends the entire table <itab1> to <itab2>.*
b) To insert part or all of an internal table into another internal table
Syntax
INSERT LINES OF <itab1> [FROM <n1>] [TO <n2>]
INTO <itab2> [INDEX <idx>].
c) Using Move statement.
To copy entire contents of one table into another in one execution
Syntax MOVE <itab1> To <itab2>.
OR
<itab1> = <itab2>.
but u hav to be careful because he contents of itab2 will eb overwritten on the execution of this statement.
These copy the contents of ITAB1 to ITAB2. Incase of internal tables with header line we have to use [] inorder to distinguish from work area. So, to copy contents of internal tables with header line the syntax becomes,
ITAB1[] = ITAB2[].
Coming to the letter part of your question, Yes, we can copy values between tables having different structures.
for this we use
MOVE-CORRESPONDING <itab1> TO <itab2>
this executes the statement for their header lines. Searches for the sub-fields which occur both in itab1 and itab2 and then generates, for all relevant field pairs which correspond to the
sub-fields ni , statements of the form MOVE itab1-ni TO itab2-ni. The other fields remain unchanged.
I hope the information provided has been of your help.
Reward if useful.
Regards,
Jose -
How to scan data from one internal table to another
Hi All,
let me know how to scan all from one internal table to another internal table. Pls provide me the syntax and code.
i am very thankful to you all in advance.
Thanks & Regards,
Nagarjuna.if u want to copy data from itab1 to itab2 then use
itab2[] = itab1[].
if u want to compare whether both itab1 and itab2 are same or not,use
if itab1[] = itab2[].
*--same
else.
*--not same
endif.
if u want to compare itabs based on primary key....
loop at itab1.
read table itab2 with key f1 = itab1-f1.
if sy-subrc <> 0.
*--not same....
endif.
endloop.
if u want to copy only few lines(say from 1 to 3) of itab1 to itab2 then use...
append lines of itab1 from 1 to 3 to itab2.
if internal tables don't have same structure,
say only fields f1 and f2 are common,then
loop at itab1.
itab2-f1 = itab1-f1.
itab2-f2 = itab1-f2.
append itab2.
clear itab2.
endloop.
if there are many common fields then...
loop at itab1.
move-corresponding itab1 to itab2.
append itab2.
clear itab2.
endloop.
Please don't forget to reward points....!!!
Regards
vasu -
How do I copy recordsets from one database table to another?
I am using the Database Connectivity Toolset, and would like to copy either one recordset or multiple recordsets from one Access table to a table in a different database. I would like to do it directly with the data in variant form, but I can't get it to work. I can get it to work(on a small test table) if I first convert my source variant data to a cluster, then insert that into the other database table. My real database has many items with a variety of date types. Can I copy directly variant to variant?
Is it necessary to read all the data back into LabVIEW first? The reason I'm asking is that it is much more efficient to just use SQL statements to get the data you need and write that directly to the second database. I did a quick Google search on it and came up with lots of responses on what the correct syntax is for setting that up. Using an SQL command to copy the data back and forth is analogous to copying data from one file to another using the Copy file function rather than reading the entire contents of the file, converting the file string to the data arrays, converting back to a string, and then writing it back to another file.
Chapter 5 of the Database Connectivity Toolset User Manual describes how to execute SQL queries.
If you do need to actually
see the data in LabVIEW first, then the only way to get it back into the other database is to convert those variants to LV datatypes and then cluster those values again and write them back out to the second database. -
Moving data from one internal table to another
Hi,
I have one internal table populated with a list of material codes and another with all the material numbers.
ITAB1: MCODE KSCHL KNUMH MATNR
ITAB2: MCODE MATNR
The matnr field in itab1 is blank initially. It needs to be populated with all the material numbers from itab2. How can I achieve this?
Thanks,
apHi
Lets say that there is only one record in itab1 and for that there is correspondingly 10 records in itab2.
that means that the one record in itab1 should be changed to the first material number in itab2 and there should be nine more records created in itab1 according to the values in itab2.
Hope this is what you mean.
If this is the logic then the following code should work
then lets have a third internal table the same type as itab1
Loop at itab1 into wa_itab1
*readt table itab2 into wa_itab2 with key mcode = wa_itab1-mcode.
*IF sy-subrc eq 0.
loop at itab2 into wa_itab2 where mcode = wa_itab1-mcode.
wa_itab1-matnr = wa_itab2-matnr
append wa_itab1 to itab3.
endloop.
*ENDIF.
*modify itab1 from wa_itab1.
endloop.
itab3 will contain all the values that you require -
How to copy data from one internal table to another
i am using some function module to get some data for my function module
and the retrieved data is not getting populated in mu fumctional module
i am sucessful in getting the data to an internal table in my function module but dont know how to pass it to my table parameter
thanks in advanceHi Naval,
Declare an internal table of type table parameter structure and pass it the table parameters of the Function module.
Check the code for this function module.
DATA IT_MARA LIKE MARA OCCURS 0 WITH HEADER LINE.
SELECT * FROM MARA UP TO 10 ROWS INTO TABLE IT_MARA.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
FILENAME = 'C:\TEST.TXT'. FILETYPE = 'ASC'
WRITE_FIELD_SEPARATOR = 'X'
<b> TABLES
DATA_TAB = IT_MARA</b>
EXCEPTIONS
FILE_WRITE_ERROR = 1
NO_BATCH = 2
GUI_REFUSE_FILETRANSFER = 3
INVALID_TYPE = 4
NO_AUTHORITY = 5
UNKNOWN_ERROR = 6
HEADER_NOT_ALLOWED = 7
SEPARATOR_NOT_ALLOWED = 8
FILESIZE_NOT_ALLOWED = 9
HEADER_TOO_LONG = 10
DP_ERROR_CREATE = 11
DP_ERROR_SEND = 12
DP_ERROR_WRITE = 13
UNKNOWN_DP_ERROR = 14
ACCESS_DENIED = 15
DP_OUT_OF_MEMORY = 16
DISK_FULL = 17
DP_TIMEOUT = 18
FILE_NOT_FOUND = 19
DATAPROVIDER_EXCEPTION = 20
CONTROL_FLUSH_ERROR = 21
OTHERS = 22.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Thanks,
Vinay -
HOW TO TRANSFER DATA FROM ONE INTERNAL TABLE TO ANOTHER
FOR PERTICULAR OBJECT ID ONE INT TABLE JTAB CONTAINS ONE RECORD(ROW) AND ANOTHER INT TABLE KTAB CONTAINS 3 RECORDS(ROWS). THEN HOW I SHOULD TRANSFER DATA FROM KTAB TO JTAB? WHAT R THE VARIOUS WAYS TO DO THAT. PLS HELP ME OUT. THANKS IN ADVANCE
Try something like
If you want one record per ktab :
LOOP AT jtab.
MOVE-CORRESPONDING jtab TO itab.
LOOP AT ktab WHERE id = jtab-id.
MOVE-CORRESPONDING ktab TO itab.
APPEND itab.
ENDLOOP.
ENDLOOP.
or
LOOP AT ktab.
READ TABLE jtab WITH KEY id = ktab-id. " binary implicit if sorted type
MOVE-CORRESPONDING jtab TO itab.
MOVE-CORRESPONDING ktab TO itab.
APPEND itab.
ENDLOOP.
If you want to sum ktab ratio into itab for each jtab
LOOP AT jtab.
MOVE-CORRESPONDING jtab TO itab.
LOOP AT ktab WHERE id = jtab-id.
ADD-CORRESPONDING ktab TO itab.
APPEND itab.
ENDLOOP.
ENDLOOP.
Use sorted type table when LOOP AT WHERE, else SORT table is enough.
Regards -
Transferring data from one internal table to another
Hi,
I have two internal tables it_acct and it_acct1 as below.
data: begin of it_acct occurs 0,
belnr like bkpf-belnr,
bldat like bkpf-bldat,
augcp like bseg-augcp,
vbeln like bseg-vbeln,
end of it_acct.
data: begin of it_acct1 occurs 0,
belnr like bkpf-belnr,
cpudt like bsad-cpudt,
vbeln like bseg-vbeln,
end of it_acct1.
select belnr cpudt vbeln into corresponding fields of table it_acct1
from bsad where cpudt in s_cpudt.
Now I want to move the data from it_acct1 to it_acct . I have no data in it_acct now.
i want to move it_acct1-belnr to it_acct-belnr,
move it_acct1-cpudt to it_acct-augcp,
move it_acct1-vbeln to it_acct-vbeln.
Can someone help me how to code to move the data from it_acct1 to it_acct.
Regards,
DHi Dev,
Just add an additional line in Naren's code to get proper results at any time.
LOOP AT IT_ACCT1.
IT_ACCT-BELNR = IT_ACCT1-BELNR.
IT_ACCT-VBELN = IT_ACCT1-VBELN.
it_acct-augcp = it_acct1-cpudt.
APPEND IT_ACCT.
<b>CLEAR IT_ACCT.</b>
ENDLOOP.
If you didnt include CLEAR statement, even if IT_ACCT1 doesnt have any values for all fields or few fields in the next record, it will take values of previous one and it may lead to improper results.So it is a good practise to have CLEAR statement after APPEND statement in LOOP...ENDLOOP.
Thanks,
Vinay -
Copy and Modify from one internal table to another.Please help.
Hi,
I have an internal table having a structure like below.
Account Entity Category period1value pd2value
10 A C 100 200.
where account corresponds to 10
entity A
category C
period1 value = 100
period2 value = 200.
Now I need to populate it into another table having structure like
Account Entity Category period Value
10 A C 1 100
10 A C 2 200.
If u see this carefully a new column, period is added in the database table and thus for each row there will be only 1value.
Instead of period1 value and period2 value being in the same row they will come in different rows.One row will be like the value for period1 and next for value like period2.
Pleadse help
AnkitHi,
u can do as follows,
LOOP AT itab1 into wa_itab1.
wa_itab2-account = wa_itab1-account.
wa_itab2-entity = wa_itab1-entity.
wa_itab2-category = wa_itab1-category.
if not wa_itab1-period1 is initial.
wa_itab2-period = wa_itab1-period1.
endif.
if not wa_itab1-period2 is intial.
wa_itab2-period = wa_itab1-period2.
endif.
wa_itab2-value = wa_itab1-value.
append wa_tab2 to itab2.
clear:wa_itab1-period1 ,
wa_itab2-period .
endloop. -
How to move a file from one internal drive to another
I have a Mac Pro with 10.6. My main drive is a 240 GB SSD. I would like to move files from it to another internal drive to free up space on the SSD. The only way I can figure out to do it is to copy a file to the other internal drive and then move it from the SSD to the trash and empty the trash. Is there a better way? TIA.
That's the way I would do it.
-
Select Data from 2 intern tables
Hi Experts,
how I can select Data from 2 intern Tables into another intern table?
For Example:
My Result Table has the fields: mandt, user, ID, ID_Name.
My select table no. 1 has the fields mandt, XYZ (like A_Name), ID, ID_Name, ...
My select table no. 2 has the fields mandt, A_Name, User, ...
I want to search for all entries in select table no. 1 and 2. where are a_name have the same worth.
How I can select my Dates?
Regards,
Mikehii
you can do it by using for all entries and with READ statement ..do like follow code
IF i_marc[] IS NOT INITIAL.
SELECT matnr " Material Number
werks " Plants
lgort " Storage Location
FROM mard
INTO TABLE i_mard
FOR ALL ENTRIES IN i_marc
WHERE matnr EQ i_marc-matnr
AND werks EQ i_marc-werks
AND lgort IN s_lgort.
ENDIF. " IF i_mara[] IS NOT INITIAL
IF sy-subrc EQ 0.
LOOP AT i_output INTO wa_output.
READ TABLE i_mard INTO wa_mard WITH KEY matnr = wa_output-matnr.
wa_output-lgort = wa_mard-lgort.
MODIFY i_output FROM wa_output.
CLEAR wa_output.
ENDLOOP. " LOOP AT i_output
ENDIF. " IF sy-subrc EQ 0
regards
twinkal -
How to select data from an internal table
material norm date last modified
B2-SP HEAT 50.000 20090420
BF COKE 575.000 20090419
GROSS COKE 200.000 20090419
B2-SP HEAT 100.000 20090419
TWT 33.000 20090330
B7-SP HEAT 2.000 20090310
B1-SP HEAT 1.000 20090309
B7-SP HEAT 615.000 20090308
B2-SP HEAT 585.000 20090308
B1-SP HEAT 100.000 20090308
B3-SP HEAT 610.000 20090308
BF COKE 68.500 20090308
GROSS COKE 72.600 20090308
B8-SP HEAT 600.000 20090308
B9-SP HEAT 625.000 20090308
BX-SP HEAT 615.000 20090308
B9-SP HEAT 58.000 20090307
B1-SP HEAT 100.000 20090307
B6-SP HEAT 350.000 20090306
B2-SP HEAT 888.000 20090306
Like above there r numerous data in a table :
how will i select data into another internal table where material above is not repeated with latest modified date.please help.Hi Sonu,
The main task is to move the contents of the one internal table to another with some condition.
First sort and delete the duplicate entries from the First Internal table like below :
sort it_tab by material ascending date_modified descending.
delete adjacent duplicates from it_tab.
Then move that Internal table contents to another internal table.
Define another internal table with the same structure as you have first internal table and then
Second Step :
it_itab1 = it_itab.
If you are using seperate Header line and Body then you can do like below :
it_itab1[] = it_itab[].
This will fix the issue.
Please let me know if you need any further explonation.
Regards,
Kittu
Edited by: Kittu on Apr 24, 2009 12:21 PM -
How to pass data from one internal session to another internal session
hi all sap experts ,
How to pass data from one internal session to another internal session and from oneExternal session to another external session.
Except : Import and Export parameters and SPA/GPA parameters.
Tell me the otherWay to pass data ..
Plz
Thanks in advancehi,
abap memory management u will understand about this concept.
the import /export parameter will help u that passing data between two internal sessions by using abap memory.
for syntax
Passing Data Between Programs
There are two ways of passing data to a called program:
Passing Data Using Internal Memory Areas
There are two cross-program memory areas to which ABAP programs have access (refer to the diagram in Memory Structures of an ABAP Program) that you can use to pass data between programs.
SAP Memory
SAP memory is a memory area to which all main sessions within a SAPgui have access. You can use SAP memory either to pass data from one program to another within a session, or to pass data from one session to another. Application programs that use SAP memory must do so using SPA/GPA parameters (also known as SET/GET parameters). These parameters can be set either for a particular user or for a particular program using the SET PARAMETER statement. Other ABAP programs can then retrieve the set parameters using the GET PARAMETER statement. The most frequent use of SPA/GPA parameters is to fill input fields on screens (see below).
ABAP Memory
ABAP memory is a memory area that all ABAP programs within the same internal session can access using the EXPORT and IMPORT statements. Data within this area remains intact during a whole sequence of program calls. To pass data to a program which you are calling, the data needs to be placed in ABAP memory before the call is made. The internal session of the called program then replaces that of the calling program. The program called can then read from the ABAP memory. If control is then returned to the program which made the initial call, the same process operates in reverse. For further information, refer to Data Clusters in ABAP Memory.
Filling Input Fields on an Initial Screen
Most programs that you call from other programs have their own initial screen that the user must fill with values. For an executable program, this is normally the selection screen. The SUBMIT statement has a series of additions that you can use to fill the input fields of the called program:
Filling the Selection Screen of a Called Program
You cannot fill the input fields of a screen using additions in the calling statement. Instead, you can use SPA/GPA parameters. For further information, refer to Filling an Initial Screen Using SPA/GPA Parameters.
Message was edited by:
sunil kumar
Message was edited by:
sunil kumar -
How do I transfer selected photos from one iPhoto library to another?
How do I transfer selected photos from one iPhoto library to another?
iPhoto Library Manager - http://www.fatcatsoftware.com/iplm/ -
Generally it is not advised to have multiple Photo libraries - but if you do you need IPLM to manage them
LN -
How can I select columns from a table EMP, using Select statement?.
Hi Friends,
How can I select columns from a table EMP?.
I want to select columns of EMP table, using select statement.
Please reply me urgently.
ShahzadSomething like this:
scott@DBA> select empno,ename,job from emp;
EMPNO ENAME JOB
7369 SMITH CLERK
7499 ALLEN SALESMAN
7521 WARD SALESMAN
7566 JONES MANAGER
7654 MARTIN SALESMAN
7698 BLAKE MANAGER
7782 CLARK MANAGER
7788 SCOTT ANALYST
7839 KING PRESIDENT
7844 TURNER SALESMAN
7876 ADAMS CLERK
7900 JAMES CLERK
7902 FORD ANALYST
7934 MILLER CLERK
14 rows selected.Check the documentation:
http://download-east.oracle.com/docs/cd/B19306_01/server.102/b14200/statements_10002.htm#sthref9697
Message was edited by:
Delfino Nunez
Maybe you are looking for
-
Help Required : Formatting issue in pdf
I generate a pdf using acrobat distiller from a .ps file. The pdf displays everything perfect but : 1. The character "N" and the phrases that contain "N" is not getting recognized in a search conducted in pdf. For example, if we search a wor
-
Re-sorting albums in chronological order?
I used to have all my iPhoto '09 albums organized in chronological order, I just added a new one to the bottom every month or so. Unfortunately, I did something and now they're all in alphabetical order: April 2008 April 2009 August 2008 August 2009
-
Scripts not showing up in console
Hi all I have put my folder scripts in the correct location as far as I know but I can't get any scripts to show up. See the screenshot below Any Ideas? Trevor
-
Viewing files in homefolder (with filevault on) through time machine
I was told by an Apple tech that I cannot view a back up of filevault items THROUGH time machine if the back up was created in the account where filevault is turned on. I'd like to better VERY clear on what I'm asking so I'll give an illustration. Ac
-
Interlligent agent problem ,when start it.
when i start interlligent agent ,it is report that ????.lib has bad magic. how do make deal it. thank in advance