Monday, May 7, 2012

ABAP Dictionary

ABAP dictionary is the information base for all developers. This manages all the definitions required for different applications in SAP. ABAP dictionary is completely integrated into ABAP development workbench. All component of ABAP development workbench can access the data definitions stored in data dictionary.

OBJECTS TYPES OF ABAP DICTIONARY

  1. Domain
  2. Tables
  3. Data element
  4. Views
  5. Types
  6. Search help
  7. Lock object

DOMAIN
This describes the technical characteristic of a table field. Specifies the value range which describes allwed data for the fields.Fields referring to the same domain are changed when there is a change made to the domain.
TABLES
They are defined in ABAP dictionary independent of the database.A table having the same structure is then created from this table definition in the underlying database.

DATA ELEMENT
They defines role played by the field the technical context. Fields of the same semantic meaning can refer to the same data element.

TYPE GROUP
While waiting prog we use type command to define data. SAP has defined some frequently used types. For ex SLIS , ABAP. In a prog u can write type-pools and mention the name. Then u can use the types mention in the type goup.


SEARCH HELP
We can create search help for the ztables . U have to use the key field and other fields u wish to create help for.

LOCK OBJECT
In SAP when a person access a particular prog or table it immediately locks  that thing for the user. Similarly when u create a table or anything in SAP u should put a lock, u should also unlock the table after u execute it. 

VIEW
This is used to a view a table or multiple tables combined.



Tuesday, May 1, 2012

Lock Object

In a normal SAP screen. SAP will already have a lock on the screen. By lock we mean that when a user first clicks a prog, sap locks the prog for this user. When some other user tries to operate that same prog, then the user can not access the prog.
When u create a t code you have to put a lock for that t code. So to create a lock  go to se11 and click lock object. The name for lock object will always start with ez.
Then give a short description.
u should give the name of the table .
For ex the table name is zsc_data, the lock object name will be ezsc_data.

Now u should give whether it should be a write lock or read lock or exclusive lock.
Read lock means it will not display or let u change.
write lock means it will not let u change, it will display.
exclusive lock means it is exclusive lock.

Then go to the Lock parameter tab.
The mandt and the primary key will already be there, u want lock on any other field u should mention it.

When u create a lock there will be enque and deque object. Enque  is for locking and deque is for unlock.
In se38 u use call function

CALL FUNCTION 'ENQUEUE_EZSC_DATA1'
 EXPORTING
*   MODE_ZSC_DATA1       = 'E'
*   MANDT                = SY-MANDT
   MATNR                =
*   X_MATNR              = ' '
*   _SCOPE               = '2'
*   _WAIT                = ' '
*   _COLLECT             = ' '
 EXCEPTIONS
   FOREIGN_LOCK         = 1
   SYSTEM_FAILURE       = 2
   OTHERS               = 3
          .
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.


CALL FUNCTION 'DEQUEUE_EZSC_DATA1'
 EXPORTING
*   MODE_ZSC_DATA1       = 'E'
*   MANDT                = SY-MANDT
   MATNR                =
*   X_MATNR              = ' '
*   _SCOPE               = '3'
*   _SYNCHRON            = ' '
*   _COLLECT             = ' '
          .
If u want to view the lock object u need to go to sm12.
then enter the table name.and press f8.
if u want to delete the lock u can right click on it and release the lock. U can release the lock only when u have authorization to do that. U will have authorization release your own lock. But to release others lock u will need authorization.



ABAP SCREENS

TCODE SCREEN NAME
SE01/SE09 TRANSPORT ORGANISER
SE11 ABAP DICTIONARY
SE19 BADI BUILDER
SE21 CREATING A PACKAGE
SE24 CLASS BUILDER
SE37 FUNCTION MODULE BUILDER
SE38 ABAP EDITOR
SE80 OBJECT NAVIGATOR, MODULE POOL PROG
SE84 REPOSITORY INFORMATION SYSTEM
SE93 MAINTAIN TRANSACTION CODE (TCODE)
SHDB TRANSACTION RECORDER
MM01 MATERIAL CREATION
FI01 BANK CREATION
LSMW LSMW
SMARTFORMS SMARTFORMS
SAPSCRIPTS SAPSCRIPTS
I18N MSWORD AS SMARTFORM EDITOR
NACE OUTPUTCONTROL FOR DIFF MODULE CONFIG
NAST CHECK ENTRIES IN A LOG
SM30 MAINTAIN TABLE
SM12 LOCK OBJECTS
SPRO CUSTOMIZING TABLE
SU53 DISPLAY AUTHORIZATION DETAILS

How to create a functional module

A function module can only be created within a function group.
To create a function group click goto-function groups- create function group.
give a name for the function group then give a short text.

click Goto -main prog.
It will have 2 include prog.
1-maintop
1-mainuxx
in the first prog u can define variables and other things which u can use in the any of the function modules which come under that.
in the second one all the function module which falls under it will appear.

Go to SE37.
give a functional module name with z  and press f5 or press create.
In Import tab type parameter name type data element name in associated type and if you want to give it a default value. u can give it now in the default value column and u press enter, the short text will get filled automatically.


In export tab give a it table name. For that create a table type in se11.
Creating in se11.
click on table type. give a name with z  and press f5 or press create.
in short text  give a short description. In line type give the table name, u want it to take the structure of .
and press activate and save.

now go to se37 screen and give the table type in the function module creation screen and press enter.

go to exceptions. Give the possible exceptions that the system will throw out.
now goto source code and do a  select command. write a sy-subrc in that in the else command give RAISE and the name of the exception.

In Attributes, u can select either normal function module or remote enabled module(RFC).
If it is RFC then it can be accessed by softwares other than SAP. It is mainly helpful for BAPI.
If it is rfc the all the field in the function module should be passed only by value.
That means in Import , export and other tabs u should put tick on pass by value field.
If it is not rfc it is not nessary to pass by value.
Now save and activate.




Monday, April 30, 2012

How to Create a Database Table in SAP?

Always start the name with z or y.

Type the table name u want to create and press f5 for create. [ f6 is for change and f7 is for display].
Give a short descriptions of the table.
Select a delivery class. [Mostly it will be a or c. where a is application table for master or transaction data or c for customizing table].
Then give table maintenance [ give either table maintenace with restriction or no restrictions or no maintenance].
Then go to the field tab.
Always the first field is mandt, data elemnt is also mandt.
Then give afield name and give an existing data element name and press enter. If the data element is correct then the details about the element will appear immediately.
u need to mark the mandt and the one other field as key field.
save then execute.

In the top there will be a button for technical settings.
U need to select the data class , u press f4 it will give u options such as master data, transaction data, etc
U need to select the size category, telling it how many record they r likely to have. u press f4, it will give u details.
U need to select an option for buffering. Buffering means the copy of the table gets stored in the RAM for easy access.
buffering is allowed for tables which are standard in nature and which do not gets updated / change often.
the file will also be smaller.
buffering is not allowed for transaction tables as they gets updated very often.
the file will also be bigger.


In the top there will be another button for Index.
From the right 3rd button there will be an icon for creating an index.
click on that and click create.
it will ask for index name. Index name should start with z and usually has 3 character like zsc or z001.
Then give a short descrption of the field.
There are 2 types of index.
First is unique index.The uniqueness of the value combinations for the index fields is checked automatically by the database system. If there is a violation (for example in an INSERT operation) an error message (DUPLICATE RECORD) is given. The database system thus prevents you from inserting duplicate records for the index fields of a unique index. This function requires that you always create a unique index in the database.
It is of no importance for the accessing speed whether or not an index is defined as a unique index

Second it is Nonunique index. It does not matter to sap whether is a duplication of record or not.

Now when u come down there is a Table fields .push button . When u select that then u will be able to select the field from the table which u refer in the index.
Then save and activate.



SAP FLOW

In an organisation when an end user wants any details  or any particular change he tells that to the power user. Power user tries to fix the problem with change in settings and other minor changes. But when he is not able to fix, he raises a ticket .Functional receives the ticket and tries to locate the solution. When he thinks that there needs to be a program or a development or report then he forwards the request to the technical lead. The technical lead then decides the best resource to perform the task. Then he assigns it to him/her.

The technical person takes the ticket assigned to him. Then he works out a prog or a report or whatever is required then he does the unit testing then he forwards that to the functional. When they says its ok, then the technical goes ahead and releases the request/task. Then he sends an email to basis who moves it to q for testing. Then it is moved to production from q, if it is correct.
If u do not have authorization for a particular screen then go to su53, it will tell you what authorizations are provided for you.

There are 3 boxes in an organisation. They are development, q and production.
Development will have various clients in 1 box. For example 1 client for technical, 1 client for functional etc.
When u create any table in 1 client it will be available in all clients in that box.


Sunday, February 19, 2012

DAy 5

Sy-Index is for the no of loops in a do or where command.
Sy-Tabbix is for No.of rows in an internal table.

U CAN ALSO USE HEADER LINE INSTEAD OF WORK AREA
DATA: BEGIN OF STU,
CARRID TYPE SCARR-CARRID,
CARRNAME TYPE SCARR-CARRNAME,
END OF STU.
data: itab like stu OCCURS 0 with HEADER LINE.
SELECT CARRID CARRNAME FROM SCARR INTO TABLE ITAB.
LOOP AT ITAB.
WRITE:/ ITAB-CARRID, ITAB-CARRNAME.
ENDLOOP.

There are few changes when compared
to a normal Internal table report, as it does not use workarea.

U can also write occurs 0 at begin
of stu, but if that is the case u can not use headerline. Then u need to go for
wa. But u can still continue with data instead of changing it to types.

Create a function module Z_ADD
Import
A type i
B type i
C type i
Export
D type i


Source code
D = ( ( ( A + 5 ) * 4 ) / 2 ).
WRITE: d.
CLEAR D.
D = ( ( ( B + 5 ) * 4 ) / 2 ).
WRITE: d.
CLEAR D.
D = ( ( ( C + 5 ) * 4 ) / 2 ).
WRITE: d.

Now g to se38 ABAP Editor
Parameters : X TYPE I,
Y TYPE I,
Z TYPE I.
DATA: R TYPE I.
CALL FUNCTION 'Z_ADD'
EXPORTING
A = X
B = Y
C = Z
IMPORTING
D = R
.