Documente Academic
Documente Profesional
Documente Cultură
Break Point:
===========
==>We use break point for debugger of code
==>Session Break Point -- this valid in that session alown
==>Defaut break point: This will valid 2 hr only
RESULT = LV_SORG.
ELSE.
RESULT='1010'.
ENDIF.
NOTE: IF YOU ARE USING SELECT SINGLE , SO ALL THE PRIMARIY keys SHOULD INCLUED IN
CODE
OTHER WISE IT WILL NOT WORK.
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
--------
SELECT statement: It is also used to read data from tables into IT . i.e VBAK
ABUP
================ We use SELECT to read data from stanard data base tables.
select
vbeln
eardat
netwer
kunnar
matnr
from VBAK into table it_vbak .
Eg:
Data:it_mara type table of mara.
Data:it_makt type table of makt.
select * from mara into table it_mara
where matnr = '100'.
Sort it_mara Ascending.
delete adjacent duplicates from it_mara comparing all fields.
If it_mara not intial
select * from makt into table it_makt
for all entries in it_mara
where matnr = '100'.
endif.
NOTE:
==>Parent internal table must not be empty ( If it is empty, where condition fails
and it will get all records from
database). IF IT_MARA NOT INTIAL.
==>Remove all duplicate entries in parent internal table.(DEL ADJACENT DUPLICATES)
==>Befour deleting duplicates you should do SORT in ASCENDING order.
SELECT INTO CORROSPONDING FIELDS :
==>Select into corresponding is used to get data from a data base table into a user
de??ned internal table or work area
with out specifying the list of fields.
Eg:
Types:begin of ty_mara,
matnr type mara-matnr,
mtart type mara--mtart,
mbrsh type mara-mbrsh,
meins type mara-meins,
end of ty_mara.
Data: it_mara type standard table of ty_mara.
wa_mara type ty_mara .
SELECT * from mara into corresponnding fields of table it_mara upto 50 rows.
if sy-subrc = 0.
loop at it_mara into wa_mara
write:/wa_mara-matnr , wa_mara-mtart.
end loop.
End if.
NOTE:
==>As per SAP standards select into corresponding statement is not advisable as it
effects the performance of an
application because it has to compare each ??eld with database.
-----------------------------------------------------------------------------------
----------------------------------------------------
FIELD SYMBOL:
=============
====> If you are using fields symbol we don't need to write MODIFIE statement ,
automaticaly the records in internal tabel changed.
====> We use ASSIGNING to assigning data to inernal table
====> UNASSIGN to cleare the data in field symbol
WORK AREA:
===========
====> If you are using WA so we need to write modifie statement
===> If it WA we use INTO key word (it_mara into wa_mara)
===> IF it WA we use CLEARE stamenent to cleare the work are.
-----------------------------------------------------------------------------------
------------------------------------------------------------
FOR ALL ENTRIES
===================================================================================
===================================================
By default 8kb memory will be allocated and it increases dynamically( +8kb +8kb).
Work area is an instance of database table.
Temporary memory locations which are used to store the data of database table.
==>INTO TABLE ITAB ==>Means getting data into an internal tableITAB from
database table
eg: data : it_mara type table of mara . " Declare internal table of type MARA
Select * from MARA into table it_mara . " Read all records from MARA table
and store in it_mara internal table
==>INTO WA ==>Means getting data into WAa work area ( Work area can
store only one record )
eg: data : wa_mara type mara . " Declare work area of type MARA, because we are
getting only one record
Select single * from MARA into wa_mara where matnr = '00001' . " Read one
records from MARA table and store in wa_mara work area
OR
data : it_mara type table of mara . " Declare internal table of type MARA
select * from MARA into table it_mara where matnr = '00001' . " Read all
records from MARA table where MATNR is 00001, MATNR is a key field .
SELECT * FROM MARA INTO CORRESPONDING FIELD OF TABLE IT_MARA . " Here we are
getting data from <code>MARA</code> table into internal table <code>IT_MARA
</code> which contains only four fields.
DATA : IT_MARA TYPE TABLE OF TY_MARA. " Declare a Internal table of user
defined type
SELECT MATNR, MTART, MEINS, MBRSH FROM MARA INTO TABLE IT_MARA. " Get list of
fields Data Into internal table
" Now data of four fields is available in IT_MARA .
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
-----------------
A work area (staging area) is required when working with an internal table
without a header line. This work area is defined as a Structure with the same
structure as the internal table. The work area is loaded and the table is
processed from the work area.
A summary of the statements used for internal tables without header lines is #the
following:
==>APPEND <work area> TO <internal table>
Appends the contents of the work area to the end of the internal table
==>COLLECT <work area> INTO <internal table>
Accumulates the values on a field into the table
==>INSERT <work area> INTO <internal table>
Inserts a new line with the contents of the work area before the #current
line
==>MODIFY <internal table> FROM <work area>
Overwrites a line in the table with the contents of the work area
==>READ TABLE <internal table> INTO <work area>
Reads a line from the table into the work area
==>LOOP AT <internal table> INTO <work area>
Processes an internal table. On each loop pass, a table entry is placed in the work
area.
==>The CLEAR <internal table> statement initialises all single fields in the header
line of an internal table according to type.
==>The REFRESH <internal table> statement deletes all table lines. The table
storage space is not released. The header line remains unchanged.
==>The FREE <internal table> statement releases the storage space required for a
table. The header line remains unchanged.
This statement is particularly useful for very large internal tables. You can
improve a program�s performance by �freeing� the memory space allocated for the
internal table.
Internal tables that are local to a subroutine are automatically �freed� upon
leaving the subroutine.
WARNING: If you are working with an internal table with a separate work area, and
you accidentally say CLEAR <internal table>rather than CLEAR <internal table work
area >, you will delete all the table lines. Use REFRESH to achieve this instead.
===================================================================================
=================================================================
===>Why would we choose to use an internal table without a header line when it is
easier to code one with a header line?
Separate Internal Table Work Area: The work area (staging area) defined for the
internal table is not limited to use with just one internal table.
Suppose you want two internal tables for EMPLOYEE � one to contain all records and
one to contain only those records where country = �USA�. You could create both of
these internal tables without header lines and use only one work area to load data
into both of them. You would append all records from the work area into the first
internal table. You would conditionally append the �USA� records from the same
work area into the second internal table.
Performance Issues: Using an internal table without a header line is more
efficient than one with a header line (see how to test this below).
Nested Internal Tables: If you want to include an internal table within a
structure or another internal table, you must use one without a header line.
Performance Tips:
To test efficiency issues, go to SYSTEM ? UTILITIES ? RUNTIME ANALYSIS and click on
the �Tips & Tricks� push-button. Here you can test various internal table
performance issues. The one dealing with header line versus no header line is
entitled �Using explicit work areas�. Within this area, you can measure the runtime
to see that internal tables without header lines are more efficient.
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
---------------------------------------------------------------------------------
TOP 10 TECHNIQUES :
=>When reading data from database table, never use SELECT *, always use select with
list of fields.
=>Always specify key fields in where conditions of SELECT statements, because these
will have primary index.
=>Sometimes we may need to use non-key fields in where conditions of SELECT
statements, in that case create secondary indexes and use.
=>Never use select with corresponding in SELECT statements.
=>Always use read table with binary search and make you have sorted the internal
table in ascending order before using read table binary search.
=>Never use select joins for more than 3 tables.
=>Always use select for all entries for more than 3 tables.
=>Always check whether the parent internal table is initial or not before using for
all entries.
=>Never use nested loops, instead use parallel cursor .
=>Never use select statements inside loops, instead use for all entries.
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
---------------------------------------------------------------------------------
BADI:
BADI (Business Add-in)
BADI is another way of implementing enhancements to the standard programs without
modifying the original code.
BADI's are implemented using Object Oriented Programming technique, Technically a
BADI is nothing but an interface.
Each BADI consists of the method without implementation called as BADI definition.
We need to create classes to write the abap code by implementing the methods called
as BADI implementation.
SE18 is the T-Code for BADI definition, SE19 is the T-Code for BADI implementation.
Advantages of BADI
The main advantage of using BADI is , we can create multiple implementations for a
single BADI definition.
Where as with the exits, we can create a single implementation.i.e a single project
for an enhancement.
We cannot create another project (implementation) for enhancement which is already
used. That is why we go for
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
--------