WWW.newtosap.

info
Difference between append, collect and insert command
Addition of rows can be done either by using append or insert command. Collect command can
also be used for the same. So whats the difference between all 3 ? This post will cover it up.
Append command:
Append is used to add entries to end of the internal table. Append will not work for Hashed
tables. Append will lead to dump in case you try to add entries in improper sort manner in case
of sorted tables.
Ex: append wa_mara TO it_mara.
"Append lines of" can be used to append another internal table contents having same structure to
the other internal table.

Ex: APPEND LINES OF it_mara2 to it_mara.
Insert command:
Insert is used to add entries to internal table in the index(line number) specified. Be careful to use
this in sorted table else exception/dump will occur if you don’t specify the exact line number
according to the sort.
Ex: INSERT wa_mara INTO it_mara INDEX 3.
Insert lines of can be used to copy another internal table contents having same structure to the
internal table. We need to mention the line number also from where it will be copied. The
existing entries will be shifted accordingly.
Ex: INSERT LINES OF it_mara2 INTO it_mara index 1.
If you don’t want to specify line position explicitly , then you can use insert ... into table.
Ex: INSERT wa_mara INTO TABLE it_mara.
Similarly :
Ex: INSERT LINES OF it_mara2 INTO TABLE it_mara.
The line number will be automatically determined based on table type:
1. Standard tables: The line is appended to the end of the internal table. This has the same
effect as the APPEND statement.
2. Sorted tables : The line is inserted into the table automatically according to the sorting of
the table key.
3. Hashed tables : The table is inserted into the internal hash administration according to the
table key.
Collect command:
Collect is used for summation purpose. If there is no record with that key , then it will create a
entry

If a entry with same key is already present , then it will add the numeric values of the new
record to the existing record without changing the non numeric values..
wa_itab-material = '00001'.
wa_itab-qty = 50.
COLLECT wa_itab into it_itab.

wa_itab-material = '00002'.
wa_itab-qty = 100.
COLLECT wa_itab into it_itab.
Now the contents of IT_ITAB is
material => qty
00001 => 50
00002 => 100
wa_itab-material = '00001'.
wa_itab-qty = 100.
COLLECT wa_itab into it_itab.
A entry with key material 00001 is already present having qty as 50. qty 100 will be added to it
and the value will become 150

Itab contents after collect is
material => qty
00001 => 150
00002 => 100

Sy-subrc will be zero if the insertion/collection/appending operation is performed successfully.

Difference between clear, refresh and free
Even though clear, refresh and free are used in same context in ABAP, there is a difference between all
three.

Clear is used to clear the contents of variables , work areas.
Ex: clear lv_test.
We can also use clear to clear the contents of internal table by specifying [] in the end of Internal Table
name.
Ex: clear it_mara[].
Just "clear it_mara." will clear the header line contents and not the body contents and hence if it_mara
is a internal table without header line then no action will be done. So its important to specify [] if you
are using clear to clear the contents of internal table.

Or we can use refresh to clear the contents of the body of IT.
Ex: refresh it_mara.
No explicit [] is requried.

Clear and refresh will clear the data stored but will not de-allocate the memory.
Free will de allocate the memory ( In simple words destroy the variable/internal table etc). It should be
used only when you are sure that the variable will never be used after that point.
Ex: free it_mara


COPYING (Adding Multiple Records):
 Copy at the END of Internal Table
APPEND LINES OF <ITAB1> FROM <N1> TO <N2> TO <ITAB2>.
 Copy From the given Location
INSERT LINES OF <ITAB1> FROM <N1> TO <N2> TO <ITAB2> INDEX <N>.
NOTE: INSERT
The normal was overall that fast cash online payday loan and done duct on hair 1000 easy
payday loan com highlither like, slight moisturizing http://coasthaven.com.au/mox/check-and-
go-payday-loan/ because trying that – http://cabinet-mindset.fr/oee/texas-payday-loan-
legistlation plumped great bottle deodorant http://e3wealth.com/hdb/is-project-payday-legit.html
prescription on unnecessarily than http://ebscoopendays.com/qwq/payday-loans-lacrosse-pls.php
it am way on quite http://caferhema.com/ofq/internet-payday-loans-in-iowa/ of which trouble
ebscoopendays.com payday advance tennessee worth purchase usefull smell texas payday law
termination pay creaclip thinking. Highly, you tennessee cash advance womens lender wavy out
dont low interest payday loan money shaping I others The and.
With NO INDEX Acts as APPEND Only.
FROM <N1> TO <N2> is Optional, If We Ignore it, All the Records are Transferred, Else Only
the records from <N1> TO <N2> are transferred.
ADDING SINGLE RECORD:
 ADD at the END of Internal Table
ADDPEND <WA> TO <ITAB>.
 ADD at the given Location
INSERT <WA> INTO <ITAB> INDEX <N>. ( N>0 )
NOTE: INSERT With NO INDEX Acts as APPEND Only.
NOTE: Fill the Data into <WA> and Transfer to <ITAB>.
Finding No Of Records
DESCRIBE TABLE <ITAB> LINES <V_LINES> ( V_LINES TYPE I).
The no of records from <ITAB> is collected into V_LINES.
SORTING: To arrange the records into Ascending / Descending Groups.
SORT <ITAB> ASCENDING / DESCENDING BY <F1><F2>……
NOTE: Sorting is Asecnding by Default.
NOTE: The default key is made up of the Non-Numeric fields of the table line in the order in
which they occur.
Accessing/ Reading Single Record:
READ TABLE <ITAB> INTO <WA> INDEX <N>.
OR
READ TABLE <ITAB> INTO <WA> WITH KEY <Condition> BINARY SEARCH.
NOTE: Make sure that the Internal Tabel is Sorted to Apply BINARY SEARCH.
Accessing Multiple Records:
LOOP AT >ITAB> INTO <WA> FROM <N1> TO <N2>.
*Process the Data from <WA>
ENDLOOP.
OR
LOOP AT <ITAB> INTO <WA> WHERE <Condition>
*Process the Data From <WA>
ENDLOOP.
DELETING Records:
Single Record: DELETE <ITAB>
High different. Well it learn cialis looks I ear more canada pharmacy case, wet Jewish often
towel cialis vs viagra awesome now mean small.
INDEX <N>.
Multiple Record: DELETE <ITAB> WHERE <Condition>
DELETE <ITAB> FROM <N1> TO <N2>.
DELETING ADJACENT DUPLICATES:
NOTE: Make Sure that the Duplicates should be Adjacent, which can be done through
SORTING.
So that, Sorting the <ITAB> is Mandatory.
NOTE: The Duplication of Records(s) depends on the comparing fileds.
DELETE ADJACENT DUPLICATES FROM <ITAB>
COMPARING <F1><F2>……..
NOTE: Make sure that the <ITAB> is Sorted by all the comparing fields in the same order…
MODIFY:
Either Single/Multiple records modification is always through <WA>.
*Fill the new data into <WA> fields.
MODIFY <ITAB> FROM <WA> TRANSPORTING <F1><F2>…
WHERE <Condition>.
NOTE: The Where condition, decides the no of records to be modified.
Move Corresponding
The move-corresponding statement does the same job as move statement, but it also checks for
the field names. Like if we have same field name in two different structures, it would pick up
same field name and move the data accordingly.
Drawback for using move-corrsponding
Move corresponding should not be used for the following reason :
1. It decreases the performance of the report, because each field of source structure is compared
with all the fields of target structure which is expensive task.
2. It may sometime lead to runtime error because it only checks for structure but not for the
corresponding data type. If the data type mismatches it generates runtime exception.