2006 Dec 20 2:47 PM
Hi Friends,
I wanted to move some data from my table to work area.
How can i will transfer it.
like
data: lt_kna1 like table of kna1,
ls_kna1 like line of lt_kna1.
Now i wanted to move some fields from lt_kna1 to ls_kna1.
How i can do it??
pls tell me asap.
2006 Dec 20 2:49 PM
2006 Dec 20 2:49 PM
Hi Neha,
Loop at lt_kna1 into ls_kna1.
ls_kna1 has the data.
Endloop.
Reward points if this Helps.
Manish
2006 Dec 20 2:50 PM
2006 Dec 20 2:51 PM
2006 Dec 20 9:42 PM
You can say:
Loop at itab into wa_itab,
Process data in wa_itab...
Endloop
2006 Dec 20 9:52 PM
HI,
Internal tables provide a means of taking data from a fixed structure and storing it in working memory in ABAP. The data is stored line by line in memory, and each line has the same structure. In ABAP, internal tables fulfill the function of arrays. Since they are dynamic data objects, they save the programmer the task of dynamic memory management in his or her programs. You should use internal tables whenever you want to process a dataset with a fixed structure within a program. A particularly important use for internal tables is for storing and formatting data from a database table within a program. They are also a good way of including very complicated data structures in an ABAP program.
Like all elements in the ABAP type concept, internal tables can exist both as data types and as data objects A data type is the abstract description of an internal table, either in a program or centrally in the ABAP Dictionary, that you use to create a concrete data object. The data type is also an attribute of an existing data object.
Internal Tables as Data Types
Internal tables and structures are the two structured data types in ABAP. The data type of an internal table is fully specified by its line type, key, and table type.
Line type
The line type of an internal table can be any data type. The data type of an internal table is normally a structure. Each component of the structure is a column in the internal table. However, the line type may also be elementary or another internal table.
<b>Access Using a Work Area</b>
When you access individual table entries using a work area, you are not working directly with the data in the table. Instead, you work with another data object as a work area. The work area is an interface to the entries in the internal table, and must be convertible into the line type of the internal table. The most efficient working method is to use a work area compatible with the line type of the internal table. When you read data from a table record, the data you are reading overwrites the current contents of the work area. You can then use this data in the program. When you write data to the internal table, this must first be placed in the work area. The system then transfers it from the work area to the appropriate table entry. Data transfer follows the rules of assigning data using MOVE.
<b>Access Using Field Symbols</b>
If you access an internal table using a field symbol , you do not need to copy the data into a work area. You can assign a line of an internal table to a field symbol. Ideally, the field symbol will have the same type as the line type of the internal table. Once you have assigned the entry to the field symbol, working with the field symbol has exactly the same effect as accessing the corresponding line directly.
Check the below links
http://help.sap.com/saphelp_47x200/helpdata/en/fc/eb35f8358411d1829f0000e829fbfe/content.htm
Regards,
Vara
2006 Dec 20 9:54 PM
Neha,
You can use loop statement but both table and work area should have the same structure and all the data would be moved. However if you want to move some data,
loop at it1.
it2-field1 = it1-field1.
it2-field2 = it1-field1.
append it2.
clear it2.
endloop.
hope this helps.
Shreekant.