Abap Datadictionary
Abap Datadictionary
Abap Datadictionary
2. Enter the description, Delivery class and check on table maintenance allowed. Then click on the
tab Fields.
3. Enter the ZCHAR in fields tab and ZCHAR_DE in field type tab.
4. Double click on ZCHAR_DE. Then it will ask for Save. Press ‘YES”.
9. Double click on that zchar_d to create domain, then it will ask for save before going next screen.
Press Yes.
10. Save it as a local object.
11. Now it will ask for domain creation. Press Yes.
12. Give short description for that domain which you are creating. And mention the data type in data
type field and length in no. characters field an press ENTER.
13. Then press Ctrl+F3. It will ask for save before activation. Save it as a local Object.
14. Press Enter.
20. Now it will ask for the data element creation. Press Yes.
Give short description of the data element. And give the lengths and field labels accordingly in
Field label tab.
22. Press on Definition tab and give the domain name in Domain field. Double click on ZNUM_D.
23. It will ask for save. Press Yes.
26. Give short description in short text field. Enter the data type and no. characters, Press Enter.
Now we have to maintain the technical settings. Press on Technical settings button.
34. Give the data class and size category of the table as per the requirement.
Go to transaction SE11 and select the radio button “Data type”. Enter a structure name starting with Y or
Z.
A pop-up screen appears with 3 different options. Select the radio button structure.
Go To SE11 T-code.
Press enter.
Provide the Values
Then provide search help name, which is already define by the same fields.
1) Elementary search helps describe a search path. The elementary search help must
define where the data of the hit list should be read from (selection method), how the
exchange of values between the screen template and selection method is implemented
(interface of the search help) and how the online input help should be defined (online
behavior of the search help).
2) Collective search helps combine several elementary search helps. Collective search
help thus can offer several alternative search paths.
4) A collective search help combines several elementary search helps. The user can thus
choose one of several alternative search paths with collective search help.
5) A collective search help comprises several elementary search helps. It combines all
the search paths that are meaningful for a field.
6) Both elementary search helps and other search helps can be included in a collective
search help. If other collective search helps are contained in collective search help, they
are expanded to the level of the elementary search helps when the input help is called.
Creating a secondary index
By Neha Kapoor
There are two types of indexes: Primary index and secondary index. Primary index is
automatically created using the primary keys defined.
Secondary index could be created as per the user requirement. This article discusses about
creating a secondary index.
Go to transaction SE11.
For our demo purpose, we have considered the table ZAUTHOR.
To know if there are any secondary indexes available, click on Goto à Indexes
Following popup appears:
From the above screenshot, it is evident that there are no secondary indexes already created.
Click on Create à Create Index
Enter the name of the index.
Fill in the details – Short description and the fields in the index.
Save and activate.
Now you can observe the index created above in the list now:
Maximum number of secondary indexes we can have are 9.
How to make SELECT statement to make use of any particular secondary index?
Consider the following example:
SELECT * FROM SPFLI
%_HINTS ORACLE 'INDEX("SPFLI" "SPFLI~001")'
.......
ENDSELECT.
In the above example, 001 is the secondary index of the table SPFLI. It's a well-known fact that
the efficient way of retrieving data from the database tables is by using secondary indexes. Many
database vendors provide the optimizer hints for the same. From SAP® v4.5, optimizer hints can
be provided by the %_HINTS parameter. This is dependent on the database systems that support
optimizer hints. The point to be noted here is these optimizer hints are not standardized by the
SQL standards. Each database vendor is free to provide the optimizer hints.
Now to know which index to use for our table:
1. Go to SE11 and there specify the table name
2. Now from the menu, goto --> indexes
3. select the required index.
Now suppose that the identifier 001 represents a non-unique secondary index comprising of the
columns CITYFROM and CITYTO. The index name should be defined as:
<tablename>~<Index Identifier>
like SPFLI~001 in the above example.
The sequence of fields in the WHERE condition is of no relevance in using this optimizers index.
If you specify hints incorrectly, ABAP ignores them but doesn't return a syntax error or runtime
TM
error.
The code was written in R/3 4.6C.
Code
REPORT Suresh_test.
TABLES: spfli.
LOOP AT t_spfli.
WRITE :/ t_spfli.
ENDLOOP.
Working with Table Maintenance Generator
By Rakhi Bose, Capgemini
Go to SE11 and enter the Z table name for which the table maintenance generator has to be generated.
Click on Change.
Click on Utilities à Table Maintenance Generator
Enter Authorization group (For e.g. &NC&)
Function group (go to SE80 for creating function group)
You can select either one step or two step. Assign Screen numbers (To assign Screen numbers click on
the button 'Find Scr no'. It will propose screen no's)
Single step: Only overview screen is created i.e. the Table Maintenance Program will have only one
screen where you can add, delete or edit records.
Two step: Two screens namely the overview screen and Single screen are created. The user can see the
key fields in the first screen and can further go on to edit further details.
You can now create TCode for the table maintenance generator. Enter the TCode to be created and click
on Create.
Select “Transaction with parameters (Parameter transaction)”
Click on save.
Creation of a Logical Database
By Kameswara Rao, IBM India
If we are using Logical Database for HR purpose, we should check the check Box “Info types (HR only).
Press CREATE Button as shown above.
We can maintain search help for the fields for the tables defined in structure.
For our demo purposes, let us provide search help for MATNR and WERKS.
Let us use the standard search help available for MATNR and WERKS.
The currency and quantity fields are automatically maintained here.
Go back to the main screen
Here we can design our own selection screen as per the requirements.
Automatically created include with naming convention.
Here by using above marked statement we can create Dynamic selection screen for different tables as
per the requirements.
Database program (with some includes) are automatically created upon the creation of logical database:
Go back to the main screen.
View Cluster
A view cluster is the set of objects, such as views, reports or tables, which belong to one business
function. The data can be arranged either hierarchically or non-hierarchically in view cluster. A view-
cluster transaction edits the complex cross-table data in a view cluster. The transaction navigation box
shows the complex business object with its components or sub objects.
Example:
Let us create a View Cluster on Material Details. The view cluster would include three tables namely,
MARA, MARC and MARD. We need to create maintenance views for each of these tables.
To create maintenance view for the table MARA follow the procedure below. Go to transaction SE11. Give
a view name say ZMM_V_MARA and click on ‘Create’. Give a short description, enter the table name as
MARA and click on the tab View fields.
By default all the key fields would be added. We can add more fields by clicking on the button Table fields.
Now Save and activate the view.
Follow the same procedure as above. In the Tab View fields, give ‘S’ in the column ‘P’ for the fields
MANDT and MATNR as shown in the screen shot below:
This is because the fields MANDT and MATNR would be filled in the view for MARA and thus they act as
subsets and appear as header data when we create entries in view cluster.
Follow the same procedure as above. In the Tab View fields, give ‘S’ in the column ‘P’ for the fields
MANDT, MATNR and WERKS as shown in the screen shot below:
This is because the fields MANDT, MATNR and WERKS would be filled in the view for MARC and thus
they act as subsets and appear as header data when we create entries in view cluster.
Now, for each view we need to create a table maintenance generator, which has to be done as follows:
The table maintenance screen appears. Here give the details as in the screen shot below. This table
maintenance is for the view ZMM_V_ MARA.
Before creating a table maintenance generator, create a function group say ZFG_MATERIAL from the
transaction SE80. After the function group is successfully created, enter the function group name as
shown in the screen shot. Also select Maintenance type as ‘One Step’ and give the Maintenance Screen
no. as ‘1’ in the Overview screen and click on the button ‘Create’.
Similarly, create the Table maintenance Generators for the views ZMM_V_MARC and ZMM_V_MARD.
The screen shots for these views would be as follows:
The pre-requisites for creating the View Cluster are now ready. Go to transaction SE54 and select the
button ‘Edit View Cluster’. Enter the view cluster name as say ‘ZMM_VC_MATERIAL’ and click on
‘Create’.
An information message would pop up saying
Continue by pressing ‘Enter’. The following screen appears. Give a short description and click on ‘Object
Structure’ as shown in the screen shot below:
On Clicking the ‘Object Structure’ the following screen appears. Select the ‘New Entries’ button to enter
the maintenance views created to form a cluster.
Enter the values as shown below:
The entries would be entered in a hierarchical manner. The short text is the description of the view. The
‘Predecess’ column specifies the predecessor of that view. So in this case, the predecessor of
ZMM_V_MARA is ZMM_V_MARA itself. The predecessor of ZMM_V_MARC is ZMM_V_MARA and the
predecessor of ZMM_V_MARD is ZMM_V_MARC. The ‘DEP’ column explains whether the entry is a
Header entry or a Dependent entry. It is ‘R’ for the view ZMM_V_MARA, because it is a header entry and
does not depend on any other view. Whereas, it is ‘S’ for ZMM_V_MARC and ZMM_V_MARD, because
ZMM_V_MARC is dependent on ZMM_V_MARA and ZMM_V_MARD is dependent on ZMM_V_MARC.
The column ‘POS’ specifies the sequence of the views. In the column ‘Start’ select the radio button
against the entry for ZMM_V_MARA as it comes first in the hierarchy.
After entering the above entries, press ‘Enter’. Three pop-ups for each view would appear as shown
below. Proceed further by clicking on ‘Enter’ key.
Now select each line and click on ‘Field-dependence’ button. A pop-up appears saying ‘Field
dependencies successfully generated’.
Generate the field dependence for the views ZMM_V_MARC and ZMM_V_MARD in the same way. Now,
save the entries and go back to ‘Header Entry’ folder. Activate the view cluster. A pop-up appears as
shown below. Click on ‘Yes’.
The view cluster is now created successfully.
Note:
1. The view cluster can be created on the tables whose data has to be stored in a hierarchical
manner.
2. One has to check whether proper foreign key relationships are maintained between the tables
appearing in the cluster. Sometimes while generating the Field-dependencies, errors may occur if
the foreign keys are not maintained properly.
From the initial screen of the transaction ‘SE54’ give the view cluster name and click on ‘Test’.
Since we have created the view cluster on standard tables MARA, MARC and MARD we observe that all
the existing entries would appear. The screen shot below shows all the existing entries of the table
MARA. In order to see the corresponding Plant details for the material, just select an entry and double
click on Plant details as shown below.
The plant details would appear. In the same way for the corresponding storage location details,
select an entry and double click on Storage details as shown below.
In the above screen shot the material selected in the Material details view would appear as a header
entry. The storage location details are as follows:
In the above screen shot the material selected in the Material details view and the plant selected in the
Plant details view would appear as header entry.
Row level locking of database table
By Swetabh Shukla, Infosys Technologies
Normally if a person opens table maintenance generator and tries to maintain the table, no one
else can maintain the same table at the same time. This is because of table level lock by default
in SAP. Only one user can maintain any table at a time through SM30 or any transaction that
calls table maintenance generator. In the tutorial below we will see how to remove table level
lock and apply row level lock. This way any number of users can modify the table at same time.
But any particular row can be modified by only one user at a time. We will create a transaction
for this purpose. The transaction will call our custom report. This custom report will call the
table maintenance generator of the table after deleting table level lock.
Report: ZREP_SHUKS3
Transaction: ZTEST_SHUKS3
Using transaction ZTEST_SHUKS3 we will delete the table level lock and put row level lock so that
multiple users can maintain table at same time. Rows locked by one user will not be editable by other
user.
4. Now create a report ZREP_SHUKS3 and transaction code ZTEST_SHUKS3 to call this report. This
tcode will call table maintenance generator of table ZTEST_SHUKS3 .
5. Normally if a person opens table maintenance generator and tries to maintain the table, no one else
can maintain table at the same time. This is because of table level lock by default in SAP. Only one
user can maintain any table at a time. In report ZREP_SHUKS3 we will delete the table level lock and
put row level lock so that multiple users can maintain table at same time. Rows locked by one user
will not be editable by other user. Check the report and comments given below.
*&---------------------------------------------------------------------*
*& Report ZREP_SHUKS3
*&
*&---------------------------------------------------------------------
*& Author : Swetabh Shukla
*& Date : 05/22/2009
*& Description : To delete table level lock from table.
*&---------------------------------------------------------------------*
REPORT zrep_shuks3.
*We will search entry for table level lock for our table
LOOP AT lt_enq_read INTO lw_enq_read
WHERE gname EQ 'RSTABLE'
AND garg CS 'ZTEST_SHUKS3'.
MOVE-CORRESPONDING lw_enq_read TO lw_enq_del.
APPEND lw_enq_del TO lt_enq_del.
ENDLOOP.
Just one more change in table maintenance screen. Now open table maintenance function
group(ZTEST_SHUKS3) in SE80.We know for table maintenance SAP automatically creates code in
the function group. Now we will make some modification in that existing code to change the behavior.
Open the screen you created through table maintenance and add one module.
Open the screen 0001 and add one module in PBO of the screen as shown in figure below.
Check the code below to be added in the module m_change_locking.
7. Now we are ready for testing. Call the transaction once and make some entries in table. In below
screenshot I have entered some random values. Since we have not maintained any check tables etc,
so values may be invalid. That can be taken care in real scenario.
Save data.
Session 1
In first session we will call the transaction ZTEST_SHUKS3 and try to open some existing values for table
maintenance.
Now open a second session of the transaction and see. Now the same material and plant combination
can not be changed by any other user or session.
Session 2
In this Tutorial, we create a Table pool first and then create/ (add a table to Table pool) a Pooled Table.
Step 1:
Step 2:
Select Radio button Table pool/Cluster Give table Pool Name: ZTBL_POOL.
Step 4:
Step 6:
Step 7:
Create a Z table.
Step 8:
Step 9:
Step 10:
Step 11:
Contain a single table. They are used to hold a They are used to hold
Used to store master large number of very data from a few number
data small tables(stores of large tables.(stores
customizing data or system data)
system data)
For each transparent It is stored with other Many cluster tables are
table there is one pooled tables in a single stored in a single table
associated table in the table called table pool in in the database called a
database the database table cluster
The database table has The database table has The database table has
the same name, same different name, different different name, different
number of fields and the number of fields and number of fields and
fields have the same fields have different fields have different
names names names
Single table can have Primary key of each Primary key of each
one or more primary key table does not begin table begins with same
with same fields or fields fields or fields
USE: They are used to USE: They reduce the USE: They would be
hold master data e.g. amount of database used when the tables
Table vendors or table resources needed when have primary key in
of customers. Example many small tables have common and data in
of transaction data is to be opened at the these tables are all
orders placed by same time accesses
customers simultaneously
Creating a projection view
By Gokul R, Iteanz Technologies
We use projection view to mask unwanted fields and display only relevant fields in a table. Basically View
acts like a database table only, the difference is view will not occupy storage space.
2. Choose Projection View in the pop up which appears when you click on create
3. Give Description & base Table name(In this example we have taken KNA1)
4. After giving table name click on Table fields button
5. Choose the fields which you want to be displayed in output and click copy
6. Now Save, Activate & execute it, output will be
Summary
In standard SAP tables we will have many fields, of which we will use only few fields. whenever we go
and view the data we have to come across unwanted data, to avoid this and get display of field which
relevant to scenario we use this projection view.
Providing multiple selection options in Search help
By Virendra Soni, Zaffera Softwares
This document specifies how to include multiple select options for the given fields in the search help. For
example below we can see that for material we have single selection possible.
We need to create a “Search Help Exit” in search help. Search help exit is a function module with the
same interface like “F4IF_SHLP_EXIT_EXAMPLE”.
Double click in the search help exit name and paste the following code lines:
callcontrol-no_maxdisp = 'X'.
IF callcontrol-step EQ 'SELECT'.
callcontrol-step = 'DISP'.
ENDIF.
callcontrol-step = 'RETURN'.
REPORT zmat_search.
TABLES: mara,makt.
TYPE-POOLS: slis.
DATA: gs_fcat TYPE slis_fieldcat_alv ,
gt_fcat TYPE STANDARD TABLE OF slis_fieldcat_alv ,
gs_layout TYPE slis_layout_alv .
DATA:BEGIN OF gs_output,
matnr TYPE matnr,
brand_id TYPE mara-brand_id,
saiso TYPE mara-saiso,
saisj TYPE mara-saisj,
saity TYPE mara-saity,
maktx TYPE makt-maktx,
chk TYPE c,
END OF gs_output,
gt_output LIKE STANDARD TABLE OF gs_output.
START-OF-SELECTION.
SELECT mara~matnr
mara~matkl
mara~brand_id
mara~saiso
mara~saisj
mara~saity
makt~maktx
FROM mara INNER JOIN makt ON mara~matnr = makt~matnr AND makt~spras EQ sy-
langu
INTO CORRESPONDING FIELDS OF TABLE gt_output
WHERE mara~matkl IN matkl AND
mara~brand_id IN brand AND
mara~saiso IN saiso AND
mara~saisj IN saisj AND
mara~saity IN saity .
gs_layout-box_fieldname = 'CHK'.
gs_layout-colwidth_optimize = 'X'.
*&---------------------------------------------------------------------*
*& Form build_fcat
*&-------------------------------------------------------------------FORM build_fcat USING us_fieldname T
YPE c
us_seltext_m TYPE c
us_key TYPE c.
gs_fcat-fieldname = us_fieldname .
gs_fcat-seltext_l = us_seltext_m .
gs_fcat-key = us_key .
APPEND gs_fcat TO gt_fcat .
CLEAR gs_fcat .
*&---------------------------------------------------------------------*
*& Form pf_status_alv
*&-------------------------------------------------------------------
*&---------------------------------------------------------------------*
*& Form user_command_alv
*&-------------------------------------------------------------------
FORM user_command_alv USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
CASE r_ucomm.
WHEN 'EXC'.
WRITE gs_output-matnr
TO gs_record-string(18).
LEAVE PROGRAM.
WHEN '&IC1'.
WRITE gs_output-matnr
TO gs_record-string(18).
LEAVE PROGRAM.
ENDIF.
WHEN '&FB03'.
SET SCREEN 0 .
LEAVE SCREEN.
ENDCASE.
ENDFORM. "user_command_alv
Save and activate both Search help and Search help exit and run the search help.
Screen – 1
Press enter,
Screen – 2
Press Enter.
Screen - 3
Give the selection values and press F8. Output will show in ALV. Select any line and find the values in the
corresponding selection box.
This search help can be attached to the standard search help say MATNR search help in MM01. BASIS
will perform this action.
Automatically populating the search help values into
different fields on the selection screen by using search help
exit
By Krishna Chaitanya Gogineni, Deloitte Consulting
Requirement overview:
I have a selection screen with some fields. For scheduling agreement field I have given the F4 help by
using search help exit.
When user clicks on F4 for scheduling agreement, in the search results along with the scheduling
agreement I’m giving Item, date, and some other fields.
Now, the requirement is when ever user selects a scheduling agreement from F4 help I need to populate
the corresponding item automatically from the search help on to the Item field on the selection screen.
Solution:
In the above screen shot if I select 30000018 and click enter, corresponding item (000020) should get
populated into the Item field on the selection screen.
After displaying the search help values, when CALLCONTROL-STEP = ‘RETURN’ we need to call the
function module ‘DYNP_UPDATE_FIELDS’.
IF callcontrol-step = 'RETURN'.
DATA : i_dynp TYPE STANDARD TABLE OF dynpread.
DATA : w_dynp TYPE dynpread.
w_dynp-fieldname = 'S_POSNR-LOW'.
w_dynp-fieldvalue = gv_posnr.
APPEND w_dynp TO i_dynp.
CLEAR : w_dynp.
CALL FUNCTION 'DYNP_UPDATE_FIELDS'
EXPORTING
dyname = 'SAPMZKLIM_HUREPORT'
dynumb = '0300'
request = 'A'
TABLES
dynpfields = i_dynp
EXCEPTIONS
invalid_abapworkarea = 1
invalid_dynprofield = 2
invalid_dynproname = 3
invalid_dynpronummer = 4
invalid_request =5
no_fielddescription = 6
undefind_error =7
OTHERS = 8.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
EXIT.
ENDIF.
Result:
When I select the agreement, corresponding item (20) will get populate into item field in the selection
screen.
Creating custom search help for transaction MM03
By Debarun Battabyal, TCS
Step-2: Enter the selection method as ‘ MARA’. Write the search help parameter as required.
Save and activate.
Step-3: Go back to main screen of SE11 and change The MAT1_A search help (standard search help).
Step-4: Go to tab-‘Included Search Help’ and add the above created Search help (e.g.: zkh_size).
Step-4: Selecting the added search help, go to Parameter Assignment button. Enter the reference
parameter as required.
Demo on Search help exit for the material
By Naveen Kumar Kusuma, OpenText Technologies
Search help exits are used to restrict the standard search help returned values according to users’
requirement.
Example:
Scenario: When User1 require only Material type as Finished goods and User2 require only Material type
as Raw material, for this scenario we can use search help exit.
To restrict the values for Material by Material type search help name is: MAT1T_E
For this create a function module, write the logic according to the requirement and place the function
module in marked location.
Function module structure definition: Create a parameters in changing and Tables tabs as follows.
Write the following code in the source code tab.
Code:
Testing:
2. Give the function group name and short text. And click on Save.
8. Now it will ask for the function group. Enter the function group and give the short text. Press Save.
11. Click on Export tab and enter the Parameter name, Type and reference type of RES.
12. Click on Exceptions tab and enter the Exception and short text for that exception.
13. Now click on the Source code tab and write the following lines as shown bellow.
14. Press syntax check button or Ctrl+F2.
DS3 – Calling system (an RFC call is made from this system to D05)
Scenario:
We would develop a small RFC function module in D05 system, which would add two
variables. We would pass two variables from DS3 to D05 and get back the sum of those
two variables back to DS3.
Go to SE37.
Under Utilities > Create Function Group (say ZGB_FUNC), if doesn’t exists.
Now set the function module as “Remote-enabled module” in the attributes tab.
Activities to be performed in the System DS3
Connection Type: 3
Click on Save. A Popup will imply that connection has been created
Now Press the TEST CONNECTION to check the connection.
This means the connection to the remote system was successful.
However establishing a connection will not ensure logging on to the target system. For that we have to
test REMOTE LOGON.
And this
However if we see the screen as shown below then there is an authentication failure (user-id or password
is wrong).
The new connection will become visible in the SM59 list like this.
After establishing the connection, let us create a program, which would trigger the RFC in D05 system.
This document provides the step-by-step procedure to merge multiple transport requests into single
transport request.
Transport requests are available to transport the developed objects/Configurations from one system to
another system. In general, we develop the objects first in Development system and later move it to
Quality and Production system.
Workbench request records client independent objects like reports, Functions, tables. Client independent
objects are available across the system irrespective of client.
Customizing Request:
Customizing request records client dependent objects like table entries, SPRO configurations. Client
dependent objects are only available to particular client.
SE01, SE09 and SE10 are the transaction codes for SAP Transport Management system.
***You can only merge multiple Workbench transport requests in Workbench request and same applicable
to Customizing request.
Execute transaction code SE10, select the radio button “Workbench Requests” and click on display.
With same steps you can add more transport requests in your request.
Above steps holds good if you need to add/merge one or two transport requests. Sometimes there might
be a requirement to merge more requests in one. In such cases, proceed as mentioned below:
First create a new transport request and click on merge as specified in above steps. Now select ‘Object
lists from multiple requests’ and press on green tick.
Following screen is displayed:
Now enter all the transports requests numbers which need to be merged and execute.
Click on “Merge”