Sei sulla pagina 1di 51

Creating Tables : Top Down Approach ................................................

2
Create from transaction SE11 ...................................................................................... 2
Enter Attributes ............................................................................................................ 2
Specify Columns .......................................................................................................... 3
Creating new data element .......................................................................................... 3
Creating Domain .......................................................................................................... 7
Data class in technical settings .................................................................................... 9
VIEWS ..................................................................................................................... 11
DATABASE VIEW ..................................................................................................... 11
PROJECTION VIEWS ............................................................................................... 13
MAINTENANCE VIEW .............................................................................................. 14
Structures .............................................................................................................. 15
Table Type ............................................................................................................ 20
Instructions ................................................................................................................ 22
Row type ....................................................................................................................... 23
Append Structure .............................................................................................. 25
Index ...................................................................................................................... 26
Indicator whether or not the index on the database is created as a unique index. .. 27
Create the index in the database (selection) .......................................................... 28
Data Element Supplement Documentation ...................................... 30
Text table ............................................................................................................... 33
Conversion Routine ( Domain) ................................................................. 35
CREATING LOCK OBJECTS ................................................................... 39
Flag if lock parameter wanted in the function module ............................................. 40
Maintaining Data Element Supplement Documentation .......... 43
for Data Elements............................................................................................. 43
Example Program For F1 Help ................................................................ 46
INSTRUCTIONS FOR CREATING A TABLE

Creating Tables : Top Down Approach


Create from transaction SE11

1. Go to transaction : SE11 . Click on the : Database Table radiobutton and write the
name of the table U want to create . Remember , your table must start with Y or Z as
starting alphabet .

2. Press the Create Pushbutton :

Enter Attributes

3 . Enter a brief description about the table in Short description field .The end user will
not see this description anywhere , but the developer will see it when bringing a list of
tables .

4. The value in the Delivery class identifies the owner of the data in the table . The
owner is responsible for maintaining the table contents . In customer tables , U can enter
A here .
5. Tickmark the table maintenance allowed checkbox as it will cause the menu path :
Utilities->Create Entries to be enabled , which will allow U to enter records into the table
.
Specify Columns

6. Click on the Fields Tabstrip button :-

Write the name of the field . Click on the Key checkbox if U want to declare it as primary
Key . Select the data element in the Field Type field .In the first field , I have selected a
data elemnt from existing list .

Creating new data element

What to do If I want to create a new data element ?


Let us take the case of second field : emp_name . Here , I will create a new data
element , say empname .I write empname in the Data Type field and press enter . If it
does not exist , a message will appear on the status bar informing that the data element
is not active .
I double click on the name of the new data type .

A prompt comes . Click on Yes .

A prompt comes for the development class . Save it as local object .


A prompt will come asking U to give U’r consent to create a new data element
.Click on Yes .

Note !!!!!
The system will prevent you from further processing . It is b’coz I
attempted to create a data element whose name does not start with Y
or Z . So, remember , the name of the data element and domain
should start with Y or Z . So, start creating the data element
yempname and proceed till this position and press Yes .

Enter the description of the Data element and select the domain . If U want to create a
new domain , enter the name of the domain in the domain field and press Enter .
If the domain does not exist , a message will inform U about that .

Double click on the name of the new domain when a prompt will appear :

Press Yes key .

Select Local Object .


Press Yes pushbutton .

Creating Domain

Type a description of the domain in the short text field .


Fill in the data type field .
Enter a field length .
The output length indicates the number of bytes needed to output the field to a list or a
screen , including commas , decimal point , sign and any other formatting characters .
For eg., on output , date and time fields are automatically formatted with separators .
Internally, a date is stored as eight characters , (YYYYMMDD) , but the output length of
the domain should be specified as 10 to enable two separators to be inserted .If the
output
Length is left blank , its values is automatically calculated by the system when U press
Enter .
For decimal fields , U can specify the number of decimal places in the Decimal Places
field .

Character fields are usually converted to upper case before they are stored in the
database . U can turn this conversion off by tick marking the Lowercase Letters Check
box .

After filling the fields properly , click on the Activate pushbutton on Application Toolbar
and save the domain as Local Object .

After activating , Press the Return Button (or Press F3) and return to the data element
screen .

Activate the data element .

After activating the data element , click on the Documentation pushbutton from
Application Toolbar , when the following pad will open before U . Remember , whatever
U write over here will be displayed when any user will press F1 help for fields having this
data element .

Do not disturb the &DEFINITION& . Make the pad clear and write what U feel to be
documented . After writing , activate the script .
Click Return to come to the data element screen . Click on the Field Label tabstrip
control and enter the labels for the field(headings for the data element) .
Then activate the data element and come out of the data element maintenance screen
by pressing F3 . You will land at tables field maintenance screen .

Then create the other fields for the tables as required .

After completing all the column creation , save the table and Press the Technical
Settings Pushbutton from Application Toolbar .

Data class in technical settings

The data class defines the physical area of the database (for ORACLE the TABLESPACE) in which your
table is logically stored. If you choose a data class correctly, your table will automatically be assigned to the
correct area when it is created on the database.

The most important data classes are (other than the system data):

 APPL0 Master data

 APPL1 Transaction data

 APPL2 Organizational and customizing data

Master data is data which is frequently read, but rarely updated. Transaction data is data which is frequently
updated. Organizational und customizing data is data which is defined when the system is initialized and
then rarely changed.

There are two more data classes available, USR and USR1. These are reserved for user developments.
The tables assigned to these data classes are stored in a tablespace for user developments.

Size Category : Enter the size category from the list :-


The size category determines the probable space requirement for a table in the database.

You can select the categories 0 to 4 for your table. Each category is assigned a specific fixed storage area
value in the database. When you create a table, initial space is saved for it in the database. If more space is
required later as a result of data that has been entered, the storage space is increased in accordance with
the category selected.

Press F4 on the field Size category to see the number of data records that can be maintained for the
individual categories of your table without complications ensuing. These complications could be for example
a reorganization becoming necessary because the maximum space to be reserved for the table was
exceeded due to the maintained size category.

Save the Technical Settings and come out by pressing Return key(or press F3) .

Check the tasks U have done by pressing the Check key(Ctrl-F2) at the application
toolbar . If no inconsistencies are found , then press the Activate (Ctrl-F3) button at
application toolbar .

Now , your table creation is complete .


VIEWS

DATABASE VIEW

1. Go to SE11 , choose View Radiobutton , enter the name of the view U want to
create and press the Create button .

2. Choose Database View Radiobutton and click on the Copy pushbutton .

3. Enter a short description for the view , mention the name of the tables on which
the view will be placed and mention the join conditions .
4.

Click on the View flds tabpage and mention the columns and their source tables which U
want to include in the view .

5.

Select the Selection Conditions Tab page and fill in the selection criteria .

6. Save the view , Check it , make proper corrections and then activate it .
(Data can only be read from database view)
PROJECTION VIEWS

1. Go to SE11 , click on the View Radiobutton , enter the name of the view to be
created and press Create key . Choose Projection View Radiobutton from the list
appearing and press Copy key .

2.

Enter the short text for description , then enter the name of the table on which U want to
create the projection view and mention the columns which U want to place in the view .

3. Save the view , check , make proper corrections , and further save , check and
ultimately activate the view .

[ For database view/projection view , it is advisable to include the mandt column into
the view for client dependent tables . Also base columns and reference columns
should also be included into the view , otherwise system will issue warning message
at the time of saving ]
MAINTENANCE VIEW

1. The first step is similar to the above one . Create as usual by choosing
Maintenance View Radio Button from the screen appearing after pressing the
Create button .
Structures
 Go to SE11 .

 Enter the structure name in the data type field and click on the Data type
radiobutton . Then press Create pushbutton .

 A dialog box appears in which you must select the type category.

 The maintenance screen for structures appears. Enter an explanatory


short text in field Short text.
 Enter a name in column Components.

If you want to use the structure as an include in a transparent table at


a later time, the component names may not be longer than 16 characters.

 Enter the name of the type whose attributes should be used in the
component in field Component name. You can enter any type (data
element, structure or table type) here.

 You can also add components by directly specifying the data type and
length. Choose Built-in type. You can now enter values for fields DTyp,
Length, Dec .places and Short description. With Component type you can
switch back to the screen for entering references to existing types.You can
combine components with direct type definition and components that are
defined by referencing an existing type as you like.
 The reference field and reference table must be specified for components
of type CURR (currency) and QUAN (quantity).

Double click on any currency/quantity field . You will get a screen for
mentioning the reference table and field .

 Now maintain the foreign keys of the structure. Proceed as when


maintaining the foreign keys of a table

Select a field and press the Foreign Key pushbutton .


Now, the name of the check table appears .

 Save your entries once you have defined all the components of the
structure.
 You are asked to assign the structure a development class. You can
change the development class later with Goto  Change object directory
entry.

 Choose Activation key.


Table Type

Creating Table Types


Procedure

1. In the initial screen of the ABAP Dictionary, enter the table type name in field Data type
and choose Create.

A dialog box appears in which you must define the type category.

2. Select Table type and choose Choose.

The maintenance screen for table types appears.

3. Enter an explanatory short text in the field Short text.

You can for example find the table type at a later time using this short text.
Now define the structure of a row of the table type (row type), the options for accessing
data in the defined internal table (access mode) and the key of the table type.

4. Enter the row type of the table type on the Row type and Access tab page. You can refer
to an existing type (data element, structure, table, view, table type) or directly enter the
row type.

If you want to refer to an existing type, you must set the Row type flag and enter the
name of the type in the field below it.

If you want to enter the data type, field length and possibly the number of decimal places
directly, you must set the Built-in type flag. Entries are now possible in the fields Data
type, Number of places and Decimal places.

5. Define the access mode of the table type.

This defines how to access the data in an internal table defined by the table type in ABAP
programs.

6. Define the key of the table type on the Key tab page.

The key of a table type is defined by the key definition and the key category.

If you select Key components, you can define the key of the table type directly in the
input area with the same name. This option is only possible if the row type of the table
type is a structure, table or view.

You can display all the components of the row type with Select components. Select the

components you want to copy to the key and choose .

7. Save the table type.

You are asked to assign the table type a development class. You can change this
development class later with Goto Object directory entry.

8. Choose .

Result

The table type is now activated. The runtime object of the type is created. At activation, a log is
written; it can be displayed with Utilities  Activation log. If errors occurred during activation, the
activation log is automatically displayed.

Other Options

 You can enter an explanatory text for the table type with Goto Documentation. This is
purely technical documentation that is not displayed in the online help system.
 You can display the runtime object of the table type with Utilities Runtime object 
Display. With Utilities Runtime object Check you can check if the runtime object of
the table type is consistent with its definition in the maintenance screen of the ABAP
Dictionary.

Instructions

1. Go to SE11 . Click on Data type Radiobutton and enter the name of the object U
want to create .Click on Create pushbutton .

2. A selection box appears asking U to choose one of the following options :-

Data Element
Structure
Table type

Choose Table type to create one table type .

The following screen appears before U :-


Row type

The row type of a table type can be defined by:

Direct type entry, where the data type, number of places and possibly the decimal
places are directly specified.

Specifying an existing type (data element, structure, table type,table, view) whose
attributes are used as the attributes of the defined table row.

Specifying a reference type, that is a reference to a class or an interface or a


generic reference to DATA.

You can define the name of a type in the input field for the row type flag of the
maintenance screen. If the row type is a reference type, this input field may contain the
name of a class or an interface or DATA.
U can also specify the key type in tab page : Key .
Append Structure
Go to transaction SE11 and enter into a table in Display/Change mode .

Choose the Manu Path : Goto->Append Structure .

Write the name of the structure to be appended starting with Y or Z .


Then a screen will appear where U add the columns-names and data elements . Then
activate the append structure and come out .
Index
Follow the steps mentioned below if U are going to create an index for the first time in
your life .

For theory , refer to the slide show / help library in SAP .

Dummy Project : Let us assume that we want to create an index on yemployee based on
werks(plant code , assumed to be the brcode of the employee) . U san build indexes on
SAP standard tables also .

1. Go to SE11 . Write the name of the table and enter in Change/Display mode .

2. Now Press the Indexes pushbutton or choose from the menupath : Goto-
>Indexes … .
(Brief Documentation on Index Id: The three-place index ID uniquely identifies an index within a
table.

The index ID may only contain letters and digits. The ID '0 ' is reserved for the primary index. The name
ranges 'Y..' and 'Z..' are reserved for customer indexes.

Enter an index id , say Y01 and click on the tick marked button .

Enter a short description for the index . Click the radiobuttons for Unique/Non
Unique Index .

( Short Documentation on Unique Index :-

Indicator whether or not the index on the database is created as a


unique index.
For a unique index, each value combination for the index fields can be contained at most once in the table.
The index fields in this case have key attribute, that is they already uniquely identify each record of the table.
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.

Note: A UNIQUE index for a client-specific table must contain the client field.

Create the index in the database (selection)


Whether an index improves or worsens performance often depends on the database system. You can
therefore set whether an index defined in the ABAP Dictionary should be created in the database.

This makes it easier to install a platform-specific customer system.

You can set this option as follows:

 Index in all database systems: The index is always created in the database.

 In selected database systems: The index is created depending on the database system used. In
this option, you must specify the databases in which the indexes are to be created. You can do this
either on an inclusive (list of systems on which it should be created) or an exclusinve (list of
systems on which it should not be created) basis. In either case, you can list up to four different
database systems.

 No database index:: The index is not created in the database. If you set this option for an index that
already exists in the database, it is deleted when you activate the table in the ABAP Dictionary.

Note: Unique indexes have an extra function, and must therefore always be created in the database. The
database system prevents entries or index fields being duplicated. Since programs may rely on this
database function, you cannot delete unique indexes from the database.

Enter the name of the fields in the table field below on which U wat to develop
the index .

3. Press the Save key , then check the index and at last , activate it .

Your index is created . The next time when you want to create/modify indexes by
pressing the Indexes pushbutton or from menu path , U will see the list of existing
indexes :-
From here , U can delete one index , create one or edit one .
Data Element Supplement Documentation

1. Go to any field for the data element . Press F1 key and then press F7 key .

Enter the Data Element supplement number and press Enter .


Enter the modification name and click on the : Template(with headers) radiobutton .
Press Enter .

The following format comes b4 U . Enter the documentation and save and activate it .
Then come out . The next time you press F1 for that field in that transaction , you will get
your documentation . If U do not get it , press F7 key and enter proper Data Element
supplement no and press Enter . Then come out and press F1 again .
The Data element Supplements are recorded in THLPF table .
Text table

Table 1 is a text table of table 2 if :-


Key of 1 comprises the key of 2 and an additional language key field (field of data type LANG)
 Table2 is the check table for table 1 sharing the common columns.
The foreign key field type for the foreign keys in table 1 referring table 2 should be marked as :
Key fields of text table .

Example : Let us assume that table ysecretcode contains column scode and amount . Table
ysecretcode_text contains columns : scode , spras(language key) and name(description for
scode) . Now, w.r.t. scode column of table ysecretcode_text , table ysecretcode is used as a
check table as follows:-

Now , when a field will be constructed in some program referring scode column of table
ysecretcode_text , the entries in table : ysecretcode along with the descriptions from
table ysecretcode_text will be shown .
F4 help for the parameter in the selection-screen will show entries in table : ysecretcode
with corresponding descriptions from table ysecretcode_text:-

So , table ysecretcode_text is now a text table for table ysecretcode .


Conversion Routine ( Domain)

Input and Output Conversions

Depending on the data type of the field, there is a conversion when the contents
of a screen field are converted from display format to SAP-internal format and
vice versa. If this standard conversion is not suitable, it can be overridden by
defining a conversion routine in the underlying domain.

Conversion routines are identified by a five-place name and are stored as a


group of two function modules. The function modules have a fixed naming
convention. The following function modules are assigned to conversion routine
xxxxx:

 CONVERSION_EXIT_xxxxx_INPUT
 CONVERSION_EXIT_xxxxx_OUTPUT

The INPUT module converts from display format to internal format, and the
OUTPUT module converts from internal format to display format.

When is a Conversion Routine Executed?

If a screen field refers to a domain with a conversion routine, this conversion


routine is executed automatically when entries are saved in this screen field or
when values are displayed in this screen field. The conversion routine of the
domain is also triggered when the field contents are output with the WRITE
statement.
Example :-

Let us assume a fictitious demand where user will enter some name of students
and a ‘Mr.’ Will be prefixed before the name .

Let us create a domain ZSUBDOMAIN of 40 characters and place a conversion


routine YINI for that .

Before that , two function modules : CONVERSION_EXIT_YINIT_INPUT and


CONVERSION_EXIT_YINI_OUTPUT should be ready .
Now , let us create a table : YSTUDENT with c column : NAME with domain :
ZSUBDOMAIN . Let us create a parameter transaction for maintaining it and after that
let us make an entry:-

The moment we press Enter , it is translated as :-

In the database also, it is saved with the prefix ‘Mr.’ . In the database also, it is saved in
the same format .
CREATING LOCK OBJECTS
Go to SE11 . Write the name of the lock object, click on the lock object radio button and
press Create button .

2.Write a short description .In the Tables tabstrip control , write the name of the primary
table , set the lock mode for it . In the bottom portion of the screen , click on the Add
pushbutton and select the secondary table(linked to the primary table by a foreign key)
and choose the lock mode for it .
3. Go to the Lock Parameter tabstrip control .The key columns for the primary and
secondary tables will automatically appear over there .

U see a checkbox as the leftmost column .

Flag if lock parameter wanted in the function module


If this flag is set, two parameters S and X_S are inserted for lock parameter S in the function modules
generated when the lock object is generated.

These parameters are used to copy the key to be locked or to control the lock behavior when the initial value
is passed.
The flag is set by default. If you do not need the lock parameter in the generated function modules, you can
cancel the flag. In this case this parameter is always locked generically.

5. Save,check and activate the lock object .

Now, I will write a program which will take wastage code as input and display the details
of the code . It will make use of ENQUEUE and DEQUEUE function to lock the details of
the wastage code for further use by other users .As U give the wastage code and
execute the report , a message will appear , asking U to execute the same report in
another session . Now, if U execute the report in another session using the same
wastage code, U will face a lock .

The report is as follows:-

REPORT YSUBLCKWST .

tables : ysale_tbl .

parameters : wast_cd like ysale_tbl-wast_cd .

data : begin of intsale occurs 0 .


include structure ysale_tbl .
data : end of intsale .

CALL FUNCTION 'ENQUEUE_EYSALE'


EXPORTING
MODE_YWAST_MST = 'E'
MODE_YSALE_TBL = 'E'
WAST_CD = wast_cd
* NAME =
* MEMO_NO =
* GPASS_NO =
X_WAST_CD = 'X'
* X_NAME = ' '
* X_MEMO_NO = ' '
* X_GPASS_NO = ' '
* _SCOPE = '2'
_WAIT = 'X'
* _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.

select * from ysale_tbl into table intsale


where wast_cd = wast_cd .

write:/5 ' Details of sale for wastage code : ' , wast_cd .


skip 3 .

format color col_negative .


write:/10 'Memo No' , 27 'Gpass No' ,
40 'Plant' , 48 'Stlocn' , 58 'Qty' , 70 'Value' .
format reset .

skip 2 .

loop at intsale .

write:/15 intsale-memo_no ,
27 intsale-gpass_no ,
40 intsale-werks , 48 intsale-lgort ,
58 intsale-qty , 70 intsale-value .

endloop .

message i398(00) with 'Now open another session and run the same report'
' to get the effect of lock object' '. If same code is used,U will face
a lock' .

CALL FUNCTION 'DEQUEUE_EYSALE'


EXPORTING
MODE_YWAST_MST = 'E'
MODE_YSALE_TBL = 'E'
WAST_CD = wast_cd
* NAME =
* MEMO_NO =
* GPASS_NO =
X_WAST_CD = 'X'
* X_NAME = ' '
* X_MEMO_NO = ' '
* X_GPASS_NO = ' '
* _SCOPE = '3'
* _SYNCHRON = ' '
* _COLLECT = ' '
.
Maintaining Data Element Supplement Documentation
for Data Elements

2. Go to any field for the data element . Press F1 key and then press F7 key .

Enter the Data Element supplement number and press Enter .


Enter the modification name and click on the : Template(with headers) radiobutton .
Press Enter .

The following format comes b4 U . Enter the documentation and save and activate it .
Then come out . The next time you press F1 for that field in that transaction , you will get
your documentation . If U do not get it , press F7 key and enter proper Data Element
supplement no and press Enter . Then come out and press F1 again .
The Data element Supplements are recorded in THLPF table .
Example Program For F1 Help

REPORT demo_dynpro_f1_help .

DATA: text(30) TYPE c ,


var(4) TYPE c ,
int TYPE i,
links TYPE TABLE OF tline,
field3(10) TYPE c, field4(10) TYPE c.

TABLES demof1help.

text = text-001.

CALL SCREEN 100.

MODULE cancel INPUT.


LEAVE PROGRAM.
ENDMODULE.

MODULE f1_help_field2 INPUT.


int = int + 1.
CASE int.
WHEN 1.
var = '0100'.
WHEN 2.
var = '0200'.
int = 0.
ENDCASE.
ENDMODULE.

MODULE f1_help_field3 INPUT.


CALL FUNCTION 'HELP_OBJECT_SHOW_FOR_FIELD'
EXPORTING
doklangu = sy-langu
doktitle = text-002
called_for_tab = 'DEMOF1HELP'
called_for_field = 'FIELD1'.
ENDMODULE.

MODULE f1_help_field4 INPUT.


CALL FUNCTION 'HELP_OBJECT_SHOW'
EXPORTING
dokclass = 'TX'
doklangu = sy-langu
dokname = 'DEMO_FOR_F1_HELP'
doktitle = text-003
TABLES
links = links.
ENDMODULE.
Let us look at the screen flow logic of the program :-

PROCESS BEFORE OUTPUT.

PROCESS AFTER INPUT.


MODULE CANCEL AT EXIT-COMMAND.

PROCESS ON HELP-REQUEST.
FIELD DEMOF1HELP-FIELD2 MODULE F1_HELP_FIELD2 WITH VAR.
FIELD FIELD3 MODULE F1_HELP_FIELD3.
FIELD FIELD4 MODULE F1_HELP_FIELD4.

The text symbol for the program is as follows:-


MD_POPUP_SHOW_INTERNAL_TABLE.
We can display a set of custom values for a particular parameter field on the selection screen
when the user presses F4 for that particular field. This can be done by using a function module
'MD_POPUP_SHOW_INTERNAL_TABLE'.
This function module will display a list of values from which the user can select a value. The
particular parameter becomes populated by the selected value in the selection screen. If the user
presses the ‘Cancel’ icon, the value in the parameter remains unaltered.

A sample code makes use of the above function module is given below:

Here, this technique is being used to populate a parameter (p_scrt1) representing the field, which
would provide the sort criteria for a report.

We need to write the ‘perform’ under the following event in the report.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_scrt1.

* Get the values for sort criteria


PERFORM get_value_for_sort_criteria CHANGING p_scrt1.

FORM get_value_for_sort_criteria CHANGING p_sortcrt.

* Type for internal table to store possible values for selection field
TYPES : BEGIN OF ty_value,
value(30) TYPE c,
END OF ty_value.

* Internal table to store type of fields to be displayed


DATA : i_column TYPE STANDARD TABLE OF help_value INITIAL SIZE 0 WITH
HEADER LINE.
* Internal table to store possible values for selection field
DATA : i_value TYPE STANDARD TABLE OF ty_value INITIAL SIZE 0 WITH
HEADER LINE.

DATA : l_index LIKE sy-tabix. "index value

* Populate the parameters for use in function module


* MD_POPUP_SHOW_INTERNAL_TABLE

i_column-tabname = ‘DD03L’. “Table name


i_column-fieldname = ‘Fieldname’. “Field name
i_column-selectflag = ‘X’. “Column to be displayed
APPEND i_column.
CLEAR i_column.

* Get allowed values for sort criteria

CLEAR i_value.
i_value-value = ‘Shipping point’.
APPEND i_value.

CLEAR i_value.
i_value-value = ‘Route’.
APPEND i_value.
CLEAR i_value.
i_value-value = ‘Customer’.
APPEND i_value.

CLEAR i_value.
i_value-value = ‘Carrier’.
APPEND i_value.

* Call function module 'md_popup_show_internal_table

CALL FUNCTION 'MD_POPUP_SHOW_INTERNAL_TABLE'


EXPORTING
title = 'Values for Sort Criteria'
IMPORTING
index = l_index
TABLES
values = i_value
columns = i_column
EXCEPTIONS
leave = 1
OTHERS = 2.

IF sy-subrc = 0.

IF l_index > 0.

* This check is required as user may choose the ‘Cancel’ icon, in which case,
* value of l_index will be 0.

* Get the value of the field corresponding to user selection


READ TABLE i_value INDEX l_index.
IF sy-subrc = 0.
p_sortcrt = i_value-value.
ENDIF.
ENDIF.
ENDIF.

ENDFORM. " get_value_for_sort_criteria


We can have multiple columns whose values can be displayed. In that case the type declaration
for ‘Value’ table will be a bit different and the population of the ‘Column’ and ‘Value’ tables will be
as shown below:

TYPES : BEGIN OF TY_VALUE,


VALUE1 LIKE KNA1-KUNNR,
VALUE2 LIKE MARA-MATNR,
END OF ty_value.

I_COLUMN-TABNAME = 'KNA1'. "Table name


I_COLUMN-FIELDNAME = 'KUNNR'. "Field name
i_column-selectflag = 'X'. "Column to be displayed
APPEND i_column.
CLEAR i_column.

I_COLUMN-TABNAME = 'MARA'. "Table name


I_COLUMN-FIELDNAME = 'MATNR'. "Field name
i_column-selectflag = 'X'. "Column to be displayed
APPEND i_column.
CLEAR i_column.

* Get allowed values for sort criteria

CLEAR i_value.
I_VALUE-VALUE1 = '00011234567'.
I_VALUE-VALUE2 = '2343242342'.
APPEND i_value.

CLEAR i_value.
I_VALUE-VALUE1 = '00011234568'.
I_VALUE-VALUE2 = '2343242343'.
APPEND i_value.

Potrebbero piacerti anche