Sunteți pe pagina 1din 82

ABAP Dictionary (SE11)

Introduction

Data Dictionary is an interface to data that is independent of platform.


It uses database to store everything(business data, programs, screen,
screen program('dynpros'), menus and other elements).

Three types of tables in the data dictionary


o Every field of a table in the Data Dictionary corresponds to a
real field in the database. So, all the tables in the Data
Dictionary are called transparent tables. A transparent
table has one-to-one relationship with a database table
(same table name; same field name; same number of
fields).
o Pooled tables (small tables like VIEWS ) holds
customizing data from many database tables and they have
many -to-one relationship with a database table . For one
database table, there are many tables in the dictionary
( with different table name; different field names and
different number of fields). Each pooled table contains table
description.
Many pooled tables are stored together in a database table
called a table pool which holds system data. You create
table definition for a table pool. When activated, an
associated single table will be created in the database.
Then you can defines pooled tables and assign the pooled
tables to the table pool.
o A Clustered table holds data from a few very large tables
(like joining tables on common part of primary key). It has
many-to-one relationship with a database table. Many
clustered tables are stored in a single database table called
a table cluster.
o (Pooled tables and clustered tables are usually used
only by SAP)

Create table definition(3 steps)


o Define table name ( table name begins with y or z)
o Define data elements for a field (data element name begins
with y or z)

Enter domain name (if the domain name exists)


Enter field labels (for labeling input fields)
Enter on-line documentation ( F1 help)
Define a domain for a field (domain name begins with y or
z)
short text (required)
data type
data length
output length(optional)
(domain and data elements are re-usable)

Data types in ABAP dictionary

Contains global data type


o Can create global data types in ABAP Dictionary
(Data types defined in ABAP program are mostly local
variables)

23 Predefined ABAP Dictionary types are built from ABAP data


types:

ABAP data type


(L=Length specified in
the domain)
n(6)
c(L)
c(3)
c(5)
p((L+2)/2)
d(8)
p((L+2)/2)

Predefined ABAP Dictionary types


(data types used in domain)
ACCP Accounting period YYYYMM
CHAR Character
CLNT Client
CUKY Currency key; referenced by a CURR
field
CURR Currency field is stored as DECIMALS m
[NO-SIGN]
DATS Date field YYYMMDD stored as CHAR(8)
-- a data element
DEC Decimal

f (8)
i
i
i
c(1)
c(L)
x(L)
n(L)
x(2)
p((L+2)/2)
x(L)
t(6)
c(L)
string
xstring

c(L)

FLTP Floating numbers with 8-byte accuracy


INT1 1 byte integer. Whole number <=255
INT2 2 byte integer. Only for length field before
LCHR or LRAW
INT4 4 byte integer. Whole number with plus or
minus signs
LANG Language key
LCHR Long character string. Must be preceded
by an INT2 field.
LRAW Long byte string. Must be byte an INT2
field
NUMC Character Strings containing only digits.
PREC Accuracy of QUAN field
QUAN Quantity field. Points to units fields with
type UNIT
RAW Uninterrupted byte sequence
TIMS Time field (HHMMSS), sorted as
CHAR(6)
VARC Long character string(not supported after
Release 3.0)
STRING Character string of variable length(not
elementary type)
RAWSTRING Byte sequence of variable length
(not elementary type)
UNIT
Unit key for a QUAN field

DATA TYPES IN ABAP

Elementary types
Structure
Internal tables (array)

Elementary types (Predefined ABAP data types)


a) Numeric

type i (whole numbers;


initial value is 0;
4 bytes long;
range: -2,147,483,648 to 2,147,483,647)
e.g. data: customerNumber type i,
loopCounter
type i,
wordLength
type i
value 15.
type f (floating-point numbers;
initial value is 0:
8 bytes long;
range: -1E**-307 to 1E308)
e.g. data: f1 type f,
f2 type f,
f3 type f.
f1 = 2.
f2 = '-16.34567'.
f3 = '-75E03'.

type p (packed number;


initial value is 0;
8 bytes long;
15 to 31 digits)
e.g. data: price type p decimals 2,
packed_16(16) type p.

b) Alphanumeric

type n (numeric string;


initial value is 00...0;
1 byte per digit;
range: 1 to 65535)
e.g. data vendorNumber type n "numeric text
vendorNumber= '12345'.
type c ( character string;
initial value is blank
one byte per character;
range: 1 to 65535)

e.g. data: name(25) type c,


" 77 name pic x(25).
city (25),
" 77 city pic x(25).
flag,
" 77 flag pic x(1).
oneCharacter value 'B', " 77 onCharacter pic x(1)
value 'B'.
language(2) value 'ABAP' " AB is stored in language
type string (character string;
initial value is empty;
range: 0 to any characters)
-- not for screen field
type d (date YYYYMMDD;
initial value is 00000000;
8 bytes long;
fixed-length digits)
e.g. " Get today from system's variable sy-datum
data today type d.
" mm/dd/yyyy in US; dd/mm/yyyy in Europe
" You can set your own date format from Layout button
write today.

type t (time HHMMSS;


initial value is 000000
6 bytes long;
fixed-length digits)

type x (hexadecimal code;


initial value is x'00' ;
one byte per digit
range: 1 to 65535)

xstring (hexadecimal code;


initial value is empty;
range: 0 to any characters)
-- not for screen field
e.g. data xstring(2) type x value 'F089'.
" 2 hex.digits per byte

USER-DEFINED DATA TYPES

Elementary type
e.g. constants: " cannot change constants
collegeName(6)
type c value 'Humber',
maxNumberOfSeats type i value 30.
data: maxReservations

type maxNumberOf Seats.

Complex type - Structured type


o component with a name (including another structure-nested structure)
-- predefined Dictionary type
-- a data element (semantic info. e.g. field label, help text,
...)
-- a structure type (record structure)
-- a table type (array)
o

e.g. 1. data:
begin of student, " student record structure
id(9)
type n,
name(25),
phone(10),
end of student.
data professor like student.
student-id = 123456789.
student-name = 'Tanya Davis'.
student-phone = '4166576622'.
move student to professor.

e.g.2.
types:
begin of phoneNumber,
countryCode(3) type n,
areaCode(3)
type n,

number(7)
type n,
end of phoneNumber,
begin of employee,
id(9)
type n,
name(25) type c,
cellPhone type phoneNumber occurs 2,
end of Employee.
data: employees type employee occurs 200.
TABLES TYPE

e.g.1. data customersArray like customer occurs 100.


e.g.2. data
begin of personalData,
name(25),
phone(10),
end of personalData.
data employee type personalData occurs 300.

LINE TYPE
o defines attributes of individual fields i.e. array structure
ACCESS TYPE (
o Use index to access lines or access by key in certain kinds
of internal tables (arrays)
STANDARD TABLE OR INDEXED TABLE
o Mostly access by index
o Access by non-unique key via sequential search
o e.g.
types:
begin of customer,
id (9)
type n,
name(25)
type c,
end of customer,
"sequential table
customerStandardTable
type standard table of customer
with non-unique key id.
data:
"work area

wa_customer

type customer,

"internal table
myCustomerStandardTable
customersStandardTable,
tableIndex

type
type sy-tabix.

* Read first customer


read table myCustomerStandardTable into wa_customer index 1.

SORTED TABLE OR INDEXED TABLE


o Access by index
o Mostly access by unique key via binary search
Data:
" sflight is a database table name
wa_sflight
type sflight,
mySflightSortedTable type sorted table of sflight
with unique key carrid connid fldate.
select * from sflight into corresponding fields of table
mySflightSortedTable.

HASHED TABLE
o access by unique key only

types:
begin of customer,
id
type student-id,
name type student-name,
phone type student-phone,
end of customer,
customerHashedTable type hashed table of customer
with unique key id.
data:
wa_customer type customer,
myCustomerHashedTable type customerHashedTable .
parameters:
pa_id

type student-id.

select name, phone


from student
into corresponding fields of table myCustomerHashedTable.
read table myCustomerHasedTable
with table key id = pa_id
into wa_customer.
check sy-subrc = 0.
write:/ wa_city-name,
wa_city-phone.
FIND ACCESS TYPE OF AN INTERNAL TABLE AT RUNTIME
DESCRIBE TABLE internalTableName KIND charfield

key definition (key fields)


key type (unique or non-unique key)
(table type is not specified)
Reference type (pointer)

Type and Uses of Lock Objects in SAP


How many types of lock objects?
How to create Lock objects?
What is the main use of it in real time?
Lock objects are use in SAP to avoid the inconsistancy at the time of data is being
insert/change into database.
SAP Provide three type of Lock objects.
- Read Lock(Shared Locked)
protects read access to an object. The read lock allows other transactions read access
but not write access to
the locked area of the table
- Write Lock(exclusive lock)
protects write access to an object. The write lock allows other transactions neither read
nor write access to
the locked area of the table.
- Enhanced write lock (exclusive lock without cumulating)
works like a write lock except that the enhanced write lock also protects from further
accesses from the
same transaction.

You can create a lock on a object of SAP thorugh transaction SE11 and enter any
meaningful name start with EZ Example EZTEST_LOCK.
Use: you can see in almost all transaction when you are open an object in Change mode
SAP could not allow to any other user to open the same object in change mode.
Example: in HR when we are enter a personal number in master data maintainance screen
SAP can't allow to any other user to use same personal number for changes.
Technicaly:
When you create a lock object System automatically creat two function module.
1. ENQUEUE_<Lockobject name>. to insert the object in a queue.
2. DEQUEUE_<Lockobject name>. To remove the object is being queued through above
FM.

A Short Tutorial on User Exits


Content Author: Abhishek
User exits
1. Introduction
2. How to find user exits
3. Using Project management of SAP Enhancements
1. Introduction
User exits (Function module exits) are exits developed by SAP. The exit is implementerd
as a call to a functionmodule. The code for the function module is writeen by the
developer. You are not writing the code directly in the function module, but in the include
that is implemented in the function module.
The naming standard of function modules for functionmodule exits is:
EXIT_<program name><3 digit suffix>
The call to a functionmodule exit is implemented as:
CALL CUSTOMER.-FUNCTION <3 digit suffix>
Example:
The program for transaction VA01 Create salesorder is SAPMV45A
If you search for CALL CUSTOMER-FUNCTION i program
SAPMV45A you will find ( Among other user exits):
CALL CUSTOMER-FUNCTION '003'
exporting

xvbak = vbak
xvbuk = vbuk
xkomk = tkomk
importing
lvf_subrc = lvf_subrc
tables
xvbfa = xvbfa
xvbap = xvbap
xvbup = xvbup.
The exit calls function module EXIT_SAPMV45A_003
2. How to find user exits
Display the program where you are searching for and exit and search for CALL
CUSTOMER-EXIT
If you know the Exit name, go to transaction CMOD.
Choose menu Utillities->SAP Enhancements. Enter the exit name and press enter.
You will now come to a screen that shows the function module exits for the exit.
3. Using Project management of SAP Enhancements
We want to create a project to enahance trasnaction VA01
- Go to transaction CMOD
- Create a project called ZVA01
- Choose the Enhancement assign radio button and press the Change button
In the first column enter V45A0002 Predefine sold-to party in sales document . Note that
an enhancement can only be used i 1 project. If the enhancement is already in use, and
error message will be displayed
Press Save
Press Components. You can now see that enhancement uses user exit
EXIT_SAPMV45A_002. Double click on the exit.
Now the function module is displayed. Double click on include ZXVVAU04 in the
function module
Insert the following code into the include: E_KUNNR = '2155'.
Activate the include program. Go back to CMOD and activate the project.
Goto transaction VA01 and craete a salesorder.

Note that Sold-to-party now automatically is "2155"

Finding the user-exits of a SAP transaction code


*
*
*
*
*
*
*
*
*
*

Finding the user-exits of a SAP transaction code


Enter the transaction code in which you are looking for the user-exit
and it will list you the list of user-exits in the transaction code.
Also a drill down is possible which will help you to branch to SMOD.
Written by : SAP Basis, ABAP Programming and Other IMG Stuff
http://www.sap-img.com

report zuserexit no standard page heading.


tables : tstc, tadir, modsapt, modact, trdir, tfdir, enlfdir.
tables : tstct.
data : jtab like tadir occurs 0 with header line.
data : field1(30).
data : v_devclass like tadir-devclass.
parameters : p_tcode like tstc-tcode obligatory.
select single * from tstc where tcode eq p_tcode.
if sy-subrc eq 0.
select single * from tadir where pgmid = 'R3TR'
and object = 'PROG'
and obj_name = tstc-pgmna.
move : tadir-devclass to v_devclass.
if sy-subrc ne 0.
select single * from trdir where name = tstc-pgmna.
if trdir-subc eq 'F'.
select single * from tfdir where pname = tstc-pgmna.
select single * from enlfdir where funcname =
tfdir-funcname.
select single * from tadir where pgmid = 'R3TR'
and object = 'FUGR'
and obj_name eq enlfdir-area.
move : tadir-devclass to v_devclass.
endif.
endif.
select * from tadir into table jtab
where pgmid = 'R3TR'
and object = 'SMOD'
and devclass = v_devclass.
select single * from tstct where sprsl eq sy-langu and
tcode eq p_tcode.
format color col_positive intensified off.
write:/(19) 'Transaction Code - ',
20(20) p_tcode,
45(50) tstct-ttext.
skip.
if not jtab[] is initial.
write:/(95) sy-uline.
format color col_heading intensified on.

write:/1 sy-vline,
2 'Exit Name',
21 sy-vline ,
22 'Description',
95 sy-vline.
write:/(95) sy-uline.
loop at jtab.
select single * from modsapt
where sprsl = sy-langu and
name = jtab-obj_name.
format color col_normal intensified off.
write:/1 sy-vline,
2 jtab-obj_name hotspot on,
21 sy-vline ,
22 modsapt-modtext,
95 sy-vline.
endloop.
write:/(95) sy-uline.
describe table jtab.
skip.
format color col_total intensified on.
write:/ 'No of Exits:' , sy-tfill.
else.
format color col_negative intensified on.
write:/(95) 'No User Exit exists'.
endif.
else.
format color col_negative intensified on.
write:/(95) 'Transaction Code Does Not Exist'.
endif.
at line-selection.
get cursor field field1.
check field1(4) eq 'JTAB'.
set parameter id 'MON' field sy-lisel+1(10).
call transaction 'SMOD' and skip first
screen.
*---End of Program

What is User Exits?


The following document is about exits in SAP :The R/3 enhancement concept allows you to add your own functionality to SAPs
standard business applications without having to modify the original applications.
SAP creates user exits for specific programs, screens, and menus within standard R/3
applications. These exits do not contain any functionality. Instead, the customer exits act
as hooks. You can hang your own add-on functionality onto these hooks.
Types of Exits
There are several different types of user exits. Each of these exits acts as hooks where
you can attach or "hang" your own add-ons.

Menu Exits
Menu exits add items to the pulldown menus in standard SAP applications. You can use
these menu items to call up your own screens or to trigger entire add-on applications.
SAP creates menu exits by defining special menu items in the Menu Painter. These
special entries have function codes that begin with "+" (a plus sign). You specify the
menu items text when activating the item in an add-on project.
Screen Exits
Screen exits add fields to screens in R/3 applications. SAP creates screen exits by placing
special subscreen areas on a standard R/3 screen and calling a customer subscreen from
the standard screens flow logic.
Function Module Exits
Function module exits add functions to R/3 applications. Function module exits play a
role in both menu and screen exits.
When you add a new menu item to a standard pull down menu, you use a function
module exit to define the actions that should take place once your menu is activated.
Function module exits also control the data flow between standard programs and screen
exit fields. SAP application developers create function module exits by writing calls to
customer functions into the source code of standard R/3 programs.
These calls have the following syntax:
CALL CUSTOMER-FUNCTION 001.
Field Exits
Field exits allow you to create your own programming logic for any data element in the
Dictionary. You can use this logic to carry out checks, conversions, or business-related
processing for any screen field. Example: The data element BBBNR identifies a
companys international location number. You might want to set up your R/3 System so
that all international location numbers are larger than 100.
The field exit concept lets you create a special function module that contains this logic.
You assign the special function module to the data element BBBNR. You then assign the
module to any programs and screens in which users can add new international location
numbers. When you activate your field exit, the system automatically triggers your
special routine whenever a user enters a company location number.
In 4.6c, you can use "RSMODPRF" program to create field exits.
An example of a user exits :-

MODULE user_exit_0001 INPUT


CASE okcode.
WHEN 'BACK OR EXIT'.
CASE sy-dynnr.
WHEN '100'.
SET SCREEN 0.
LEAVE SCREEN.
WHEN '200'.
***********************************************************************
*******
**** Note that you can write any code that satisfy your
needs.
****
**** But in this case, this was wrote as a sample code for reference
sake.
****
**** And you can test
it.
****
***********************************************************************
*******
SET SCREEN 100.
LEAVE SCREEN.
ENDCASE.
ENDCASE.

What is the difference between SMOD and CMOD?


CMOD is the Project Management of SAP Enhancements (i.e., SMOD Enhancements).
SMOD contains the actual enhancements and CMOD is the grouping of those SMOD
enhancements.
User exits (Function module exits) are exits developed by SAP. The exit is implementerd
as a call to a function module. The code for the function module is written by the
developer. You are not writing the code directly in the function module, but in the include
that is implemented in the function module.
The naming standard of function modules for function module exits is:
EXIT_<program name><3 digit suffix>
The call to a functionmodule exit is implemented as:
CALL CUSTOMER.-FUNCTION <3 digit suffix>
For Example:
The program for transaction VA01 Create salesorder is SAPMV45A
1. If you search for CALL CUSTOMER-FUNCTION program SAPMV45A you will find
( Among other user exits):

CALL CUSTOMER-FUNCTION '003'


exporting
xvbak = vbak
xvbuk = vbuk
xkomk = tkomk
importing
lvf_subrc = lvf_subrc
tables
xvbfa = xvbfa
xvbap = xvbap
xvbup = xvbup.
The exit calls function module EXIT_SAPMV45A_003
2. How to find user exits
Display the program where you are searching for and exit and search for CALL
CUSTOMER-EXIT
If you know the Exit name, go to transaction CMOD. Choose menu Utillities->SAP
Enhancements.
Enter the exit name and press enter.
You will now come to a screen that shows the function module exits for the exit.
or use this ABAP program to search for user exits :Finding the user-exits of a SAP transaction code
3. Using Project management of SAP Enhancements
You want to create a project to enhance transaction VA01
- Go to transaction CMOD
- Create a project called ZVA01
- Choose the Enhancement assign radio button and press the Change button
In the first column enter V45A0002 Predefine sold-to party in sales document . Note that
an enhancement can only be used for 1 project. If the enhancement is allready in use, and
error message will be displayed
- Press Save
- Press Components. You can now see that enhancement uses user exit
EXIT_SAPMV45A_002.
- Double Click on the exit.
Now the function module is displayed. Double click on include ZXVVAU04 in the

function module
Insert the following code into the include: E_KUNNR = '2155'.
Activate the include program. Go back to CMOD and activate the project.
Goto transaction VA01 and create a salesorder. Note that Sold-to-party now automatically
is "2155"

Field exits (SMOD/CMOD) Questions and Answers


1. Field exit was created with CMOD, but is not processed when calling the screen.
o Since the field exit is not processed until PAI, an action must be
triggered on the screen (Return, Save, ...).
o Set profile parameter abap/fieldexit to YES and restart the
system.
o After activating the function module FIELD_EXIT... and the field
exit, leave the transaction on whose screen the field exit is to
be executed. The screen is not generated until the transaction is
started.
o Do not work on different application servers since there may be
some delay before the field exit is activated.
o The profile parameter must be set on all or none of the
application servers.
o If the field exit is to only be active on specific screens, check
whether you chose the correct program and the correct screen
number (take care with subscreens).
o Using SE51 -> Field list, check that the screen field does have a
reference to a data element. In the name of the field exit use the
name of the data element and not the field name.
o After transport, field exits are marked as active but will not be
processed. Tip: First try deactivating the field exit once more
and then afterwards, activate it again.
2. How is performance affected by setting abap/fieldexit?
o If a screen is generated and the profile parameter is set, a check
is run on 2 tables (TDDIR, TDDIRS) to see whether a field exit
must be generated for the respective field. In practice, the
screen load is not generated until the screen is selected after an

update. The user should not notice any difference because screen
generation is very fast.
3. Can you read the contents of other screen fields in the field exit?
o In principle, every field exit can store its value in the global
variables of the function group (TOP) and hence make them
available to other field exits. Note here that field exits are
always called and not only if an entry is made in the field or if
the field is empty. In addition, it is not possible to make any
assumptions about the order in which the field exits will be
called in the future.
4. How does the field exit behave on step loop fields ?
o After the user has entered data, the field exit is called in PAI
as often as there are visible fields in the step loop. The system
variable SY-STEPL is incremented each time. If a new value is
assigned to the field, it is displayed in the module between LOOP
and ENDLOOP. This module is also called once for each visible step
loop line.
5. Can field exits be debugged ?
o No. Field exits must be tested separately in the ABAP/4
Development Workbench. For errors which only occur in the screen
environment, it is helpful to write interesting variable to the
file system using TRANSFER... . These can then be analysed there.
6. What can you do if the field contents are no longer transported to to
ABAP/4.
o Check whether a value is assigned to the field OUTPUT.
7. When is the field exit called if a conversion exit is attached to the
data element ?
o The field exit is called after the conversion exit. This means
that the INPUT field receives the data in the same format as the
ABAP/4 program also receives it.
8. Although a global field exit is inactive, a function module is called
which does not exist (for example FIELD_EXIT_PROGRAMM_@)
o This is an error in the kernel which no longer occurs as of 3.0C.
As a temporary measure, it is useful to assign a program and a

screen which do not exist to the field exit and then activate the
field exit.
9. Field exit is not visible in CMOD, although created.
o If you want to create a field exit for a data element, a function
module is proposed with the name FIELD_EXIT_. This
function module must exist for the field exit to work. If you do
not create this function module, but do create one with a suffix,
the data element is not displayed in CMOD.
10.Field exit is not executed although it is active.
o Fields which do not have the 'Input field' attribute usually do
not trigger a field exit. The field exit is designed to allow an
extended input check. It is therefore only called for input fields
- even if they are not ready for input at runtime of the
application by LOOP AT SCREEN.
This rule does not apply, however, if the field is located within
a steploop. Here the field will be always activated, even if it is
invisible.
o Field exits can only be executed for fields that are directly
related tothe dictionary. If the relation is indirect, i.e. via an
ABAP declaration ( LIKE ), no field exit can be executed.
11.Field exits on check buttons do not work
o Field exits are only intended for input fields. As check buttons
count as graphical elements, you cannot install field exits on
them.
12.Field exits do not work on selection screens

Difference Between BADI and User Exits


Business Add-Ins are a new SAP enhancement technique based on ABAP Objects. They
can be inserted into the SAP System to accommodate user requirements too specific to be
included in the standard delivery. Since specific industries often require special functions,
SAP allows you to predefine these points in your software.
As with customer exits two different views are available:
In the definition view, an application programmer predefines exit points in a source that
allow specific industry sectors, partners, and customers to attach additional software to
standard SAP source code without having to modify the original object.

In the implementation view, the users of Business Add-Ins can customize the logic they
need or use a standard logic if one is available.
In contrast to customer exits, Business Add-Ins no longer assume a two-level
infrastructure (SAP and customer solutions), but instead allow for a multi-level system
landscape (SAP, partner, and customer solutions, as well as country versions, industry
solutions, and the like). Definitions and implementations of Business Add-Ins can be
created at each level within such a system infrastructure.
SAP guarantees the upward compatibility of all Business Add-In interfaces. Release
upgrades do not affect enhancement calls from within the standard software nor do they
affect the validity of call interfaces. You do not have to register Business Add-Ins in
SSCR.
The Business Add-In enhancement technique differentiates between enhancements that
can only be implemented once and enhancements that can be used actively by any
number of customers at the same time. In addition, Business Add-Ins can be defined
according to filter values. This allows you to control add-in implementation and make it
dependent on specific criteria (on a specific Country value, for example).
All ABAP sources, screens, GUIs, and table interfaces created using this enhancement
technique are defined in a manner that allows customers to include their own
enhancements in the standard. A single Business Add-In contains all of the interfaces
necessary to implement a specific task.
The actual program code is enhanced using ABAP Objects. In order to better understand
the programming techniques behind the Business Add-In enhancement concept, SAP
recommends reading the section on ABAP Objects.

Checking User Authorizations in your ABAP Program


How to set Authorization to an ABAP Programs?
Much of the data in an R/3 system has to be protected so that unauthorized users cannot
access it. Therefore the appropriate authorization is required before a user can carry out
certain actions in the system. When you log on to the R/3 system, the system checks in
the user master record to see which transactions you are authorized to use. An
authorization check is implemented for every sensitive transaction.
If you wish to protect a transaction that you have programmed yourself, then you must
implement an authorization check.
This means you have to allocate an authorization object in the definition of the
transaction.
For example:

program an AUTHORITY-CHECK.
AUTHORITY-CHECK OBJECT <authorization object>
ID <authority field 1> FIELD <field value 1>.
ID <authority field 2> FIELD <field value 2>.
...
ID <authority-field n> FIELD <field value n>.
The OBJECT parameter specifies the authorization object.
The ID parameter specifies an authorization field (in the authorization object).
The FIELD parameter specifies a value for the authorization field.
The authorization object and its fields have to be suitable for the transaction. In most
cases you will be able to use the existing authorization objects to protect your data. But
new developments may require that you define new authorization objects and fields.

Regarding Runtime creation of Check Boxes


For this...
Create an Internal table as :
data: Begin itab occurs 0,
cb_field type char1,
matnr like mara-matnr,
.....
end of itab.
Now you fetch the data into the internal table of itab using
some query...
select * ......
Now you are going to display it as....
Loop at itab.
write:/ cb_field as checkbox...
......
at this time only write the Hide statement.... as...
HIDE: values.... u want...
Endloop..

Now capturing of selected data process...


This can be done by clicking on some USER Command button...
for suppose you're clicking F8 means...
AT pf8.
IF SY-LSIND = 1.
describe table itab lines VARIABLE NAME.
cnt = 3. " Initiate value for Count 3 if you're including page header.
do VARIABLE NAME times.
read line cnt. " Above counter....
if sy-lisel(1) = 'X'.
WRITE:/ 'SELECTED RECORDS:', itab-cb_field,.....
endif.
COUNTER = COUNTER - 1.
cnt = cnt + 1.
enddo.
ENDIF.

Finding out a projection views


In addition to CLUSTER and POOLED tables ABAP forbids joins with projection views.
This type of data is also defined in DD02L, as tabclass = 'VIEW' and VIEWCLASS = 'P'.
Projection views are used to hide fields of a table. This can minimize interfaces; for
example when you access the database, you only read and write the field contents
actually needed.
A projection view contains exactly one table. You cannot define selection conditions for
projection views.
There is no corresponding object in the database for a projection view. The R/3 System
maps the access to a projection view to the corresponding access to its base table. You
can also access pooled tables and cluster tables with a projection view.

What's the purpose of using PACKAGE SIZE in select


statement?
Package size can be used if you for example only want to finish processing a limited
amount of data at a time due to lack of memory.
The example below read 50 records at a time from VBAK into an internal table, and
selects the corresponding entries from vbap into an internal table. Then the two internal

tables can be processed, and the next 50 records from VBAk can be read. Remember to
reinitialize tha tables before the next read.
REPORT z_test.
TYPES:
BEGIN OF t_vbak,
vbeln LIKE vbak-vbeln,
erdat LIKE vbak-erdat,
END OF t_vbak,
BEGIN OF t_vbap,
posnr LIKE vbap-posnr,
matnr LIKE vbap-matnr,
meins LIKE vbap-meins,
END OF t_vbap,
BEGIN OF t_report,
vbeln LIKE vbak-vbeln,
erdat LIKE vbak-erdat,
posnr LIKE vbap-posnr,
matnr LIKE vbap-matnr,
meins LIKE vbap-meins,
END OF t_report.
DATA:
li_vbak TYPE t_vbak OCCURS 0,
l_vbak TYPE t_vbak,
li_vbap TYPE t_vbap OCCURS 0,
l_vbap TYPE t_vbap,
li_report TYPE t_report OCCURS 0,
l_report TYPE t_report.
START-OF-SELECTION.
SELECT vbeln erdat
FROM vbak
INTO TABLE li_vbak PACKAGE SIZE 50.
SELECT posnr matnr meins
FROM vbap
INTO TABLE li_vbap
FOR ALL ENTRIES IN li_vbak
WHERE vbeln = li_vbak-vbeln.
IF sy-subrc = 0.
* Now you have the two internal tables li_vbak and li_vbap filled
* with data.
* Do something with the data - remember to reinitialize internal

* tables
ENDIF.
ENDSELECT.
*-- End of Program

Difference Between SAP and ABAP Memory


Can any one tell me what is the difference between ABAP Memory and SAP
Memory?
Answers 1:Within a main session, when ever you start an application program, it opens up an
internal sessions with in the main session. The internal session has a memory area that
contains the ABAP program and its associated data. So when ever you want to pass data
between two internal sessions, then you can use ABAP Memory (i.e import, export).
When comes to SAP memory (also known as global memory), if the data has to be passed
b/w two main sessions, we can use SAP Memory(SPA/GPA Parameters). SAP Memory
can also be used to pass data b/w internal sessions.
Neelima
Answers 2:SAP Memory
SAP memory is a memory area to which all main sessions within a SAPgui have access.
You can use SAP memory either to pass data from one program to another within a
session, or to pass data from one session to another. Application programs that use SAP
memory must do so using SPA/GPA parameters (also known as SET/GET parameters).
These parameters can be set either for a particular user or for a particular program using
the SET PARAMETER statement. Other ABAP programs can then retrieve the set
parameters using the GET PARAMETER statement. The most frequent use of SPA/GPA
parameters is to fill input fields on screens
ABAP/4 Memory
ABAP memory is a memory area that all ABAP programs within the same internal
session can access using the EXPORT and IMPORT statements. Data within this area
remains intact during a whole sequence of program calls. To pass data
to a program which you are calling, the data needs to be placed in ABAP memory before
the call is made. The internal session of the called program then replaces that of the
calling program. The program called can then read from the ABAP memory. If control is
then returned to the program which made the initial call, the same process operates in
reverse.

SAP memory
The SAP memory, otherwise known as the global memory, is available to a user during
the entire duration of a terminal session. Its contents are retained across transaction
boundaries as well as external and internal sessions. The SET PARAMETER and GET
PARAMETER statements allow you to write to, or read from, the SAP memory.
ABAP/4 memory
The contents of the ABAP/4 memory are retained only during the lifetime of an external
session (see also Organization of Modularization Units). You can retain or pass data
across internal sessions. The EXPORT TO MEMORY and IMPORT FROM MEMORY
statements allow you to write data to, or read data from, the ABAP memory.

Scrolling in Table Control


-----Original Message----Subject: Scrolling in Table Control
From: Amit Purohit
Hey,
I have defined a table control and scrolling is not possible in that even if
the number of entries exceeds the window height. Below is the flow logic
which I have attached
PROCESS BEFORE OUTPUT.
MODULE STATUS_0300.
LOOP AT IT1 CURSOR ZTR0300-CURRENT_LINE.
ENDLOOP.
*
PROCESS AFTER INPUT.
LOOP AT IT1.
MODULE USER_COMMAND_0300.
ENDLOOP.
What could I have done wrong ?
Thanks in advance.
Amit.
-----Reply Message----Subject: RE: Scrolling in Table Control
From: K.Hariprasad
Try defining the table control lines in PBO.

PROCESS BEFORE OUTPUT.


ZTR0300-CURRENT_LINE = 100.
-----Reply Message----Subject: RE: Scrolling in Table Control
From: K.Hariprasad
Iam sorry, i have typed ZTR0300-LINES as ZTR0300-CURRENT_LINE in previous
mail.
PROCESS BEFORE OUTPUT.
ZTR0300-LINES = 100
-----Reply Message----Subject: RE: Scrolling in Table Control
From amit.purohit
That worked.
Thank you for prompt reply.
Amit.
-----End of Reply Message-----

Interview Question on BAPI, RFC, ABAP Objects,


Tables
Content Author: Rashi agnihotri
1) What is the difference between RFC and BAPI ?
What are subclasses and super classes in BAPI and also what are the methods in
BAPI ?
2) Is it possible to connect SAP to Non-SAP systems to retrieve data using RFC
alone with out using BAPI ?
3) What is the difference between Function module and BAPI ?
4) What are the types of tables?
5) What are pooled table ?
6) What are Hashed Tables ?
7) What are advantages of using ABAP objects?
8) What is the advantage of using ABAP objects in Reports ?

1)BAPI are RFC enabled function modules. the difference between RFc and BAPI are
business objects. You create business objects and those are then registered in your BOR
(Business Object Repository) which can be accessed outside the SAP system by using
some other applications (Non-SAP) such as VB or JAVA. in this case u only specify the
business object and its method from external system in BAPI there is no direct system
call. while RFC are direct system call Some BAPIs provide basic functions and can be
used for most SAP business object types. These BAPIs should be implemented the same
for all business object types. Standardized BAPIs are easier to use and prevent users
having to deal with a number of different BAPIs. Whenever possible, a standardized
BAPI must be used in preference to an individual BAPI.
The following standardized BAPIs are provided:
Reading instances of SAP business objects
GetList ( ) With the BAPI GetList you can select a range of object key values, for
example, company codes and material numbers.
The BAPI GetList() is a class method.
GetDetail() With the BAPI GetDetail() the details of an instance of a business object
type are retrieved and returned to the calling program. The instance is identified via its
key. The BAPI GetDetail() is an instance method. BAPIs that can create, change or
delete instances of a business object type
The following BAPIs of the same object type have to be programmed so that they can be
called several times within one transaction. For example, if, after sales order 1 has been
created, a second sales order 2 is created in the same transaction, the second BAPI call
must not affect the consistency of the sales order 2. After completing the transaction with
a COMMIT WORK, both the orders are saved consistently in the database.
Create( ) and CreateFromData! ( )
The BAPIs Create() and CreateFromData() create an instance of an SAP business object
type, for example, a purchase order. These BAPIs are class methods.
Change( )
The BAPI Change() changes an existing instance of an SAP business object type, for
example, a purchase order. The BAPI Change () is an instance method.
Delete( ) and Undelete( ) The BAPI Delete() deletes an instance of an SAP business
object type from the database or sets a deletion flag.
The BAPI Undelete() removes a deletion flag. These BAPIs are instance methods.
Cancel ( ) Unlike the BAPI Delete(), the BAPI Cancel() cancels an instance of a business
object type. The instance to be cancelled remains in the database and an additional
instance is created and this is the one that is actually canceled. The Cancel() BAPI is an
instance method.

Add<subobject> ( ) and Remove<subobject> ( ) The BAPI Add<subobject> adds a


subobject to an existing object inst! ance and the BAPI and Remove<subobject> removes
a subobject from an object instance. These BAPIs are instance methods.
2) No it is not possible to connect SAP to Non-SAP systems to retrieve data using RFC
alone. RFC can acces the SAP from outside only through BAPI and same is for vice versa
access.
3) Each Bapi Object has Interface, Key Fields, Attributes,Methods and Events.
Bapi Function Modules can be attached to these Bapi objects .Function module has a
single bound functionality while a BAPI object can contain many functionalities
4) Transparent table, Pool table and cluster table are data dictionary table objects sorted
table, indexed table and hash table are internal tables.
5)Table pools (pools) and table clusters (clusters) are special table types in the ABAP
Dictionary. The data from several different tables can be stored together in a table pool or
table cluster. Tables assigned to a table pool or table cluster are referred to as pooled
tables or cluster tables.
A table in the database in which all records from the pooled tables assigned to the table
pool are stored corresponds to a table pool.
The definition of a pool consists essentially of two key fields (Tabname and Varkey) and
a long argument field (Vardata).
Table Clusters Several logical data records from different cluster tables can be stored
together in one physical
record in a table cluster.
A cluster key consists of a series of freely definable key fields and a field (Pageno) for
distinguishing continuation records. A cluster also contains a long field (Vardata) that
contains the contents of the data fields of the cluster tables for this key. If the data does
not fit into the long field, continuation records are created. Control information on the
structure of the data string is still written at the beginning of the Vardata field.
6) Hashed tables
This is the most appropriate type for any table where the main operation is key access.
You cannot access a hashed table using its index. The response time for key access
remains constant, regardless of the number of table entries. Like database tables, hashed
tables always have a unique key. Hashed tables are useful if you want to construct and
use an internal table which resembles a database table or for processing large amounts of
data.
Sample Prog: This does nothing.
REPORT Z_1 .

tables: mara.
data: i type hashed table of mara with unique key matnr
7) and 8) ABAP objects are root for your program and reports.
If you need to find out the Okcodes for BDC sessions, look for program RSBDCCUA
and run it for any platform say 'WN' for windows or MC for Mac and it will generate list
of function codes
**********
If you want to protect a program against debugging, you just have to set the STATUS = S
in the attributes view of the main program.
**********
**********
Find the Table Name For a Field.
I know couple of ways to find the table name for a field.
like.
1. Part the cursor at the field and press F1 & F9.
2. se84 or se15
3. st05 (sql trace).
4. Setting Break point in ABAP.
**********
Given a transaction code, how can I find the menu path?
In 4.6c, you can used tcode search_sap_menu to find the SAP MENU tcode.
Please note that there are no tcode available to find the path of the IMG transaction.
**********
Can line-size of abap report large than 255?
You can have line-size upto 1023.
Along with Report statement pass the line-size as 1023. Ex. Report xyz line-size 1023.
**********
How to find out the number of days between a given date, excluding Saturdays and
Sundays and public holidays?

Try functions,
=> DATE_CONVERT_TO_FACTORYDATE
=> HR_HK_DIFF_BT_2_DATES
**********

How to call one report to another?


Here ZREP2 CALLS report ZREP1 when you click on output of report ZREP2.

REPORT ZREP1.
parameter : paramet(18) type c.
write : paramet.

REPORT ZREP2 NO STANDARD PAGE HEADING.


tables: qals.
RANGES seltab for qals-prueflos.
WRITE: 'Select a Selection!',
/ '--------------------'.
SKIP.
FORMAT HOTSPOT COLOR 5 INVERSE ON.
WRITE: 'Selection 1',
/ 'Selection 2'.
AT LINE-SELECTION.
CASE SY-LILLI.
WHEN 4.
SUBMIT zrep1 VIA SELECTION-SCREEN
WITH PARAMET EQ 'Selection 1'
WITH SELECTO IN SELTAB
WITH SELECTO NE 3
AND RETURN.
WHEN 5.
SUBMIT zrep1 VIA SELECTION-SCREEN
WITH PARAMET EQ 'Selection 1'

AND RETURN.
ENDCASE.

SAP R/3 Programming

TOP

Indeed these powerful ABAP/4 functions are very interesting and can bring some
advantages. Improve your home development easily. They belong to standard objects and
should never be changed.

Bp_event_raise
Trigger an event from ABAP/4 program.

Bp_joblog_read
Fetch job log executions filling the structure TBTC5.

G_set_get_all_values
Fetch values from a set filling the structure RGSB4.

Popup_to_confirm_loss_of_data
Create a dialog box in which you make a question whether the user wishes to
perform a processing step with loss of data.

Popup_to_confirm_step
Create a dialog box in which you make a question whether the user wishes to
perform the step.

Popup_to_confirm_with_message
Create a dialog box in which you inform the user about a specific decision point
during an action.

Popup_to_confirm_with_value
Create a dialog box in which you make a question whether the user wishes to
perform a processing step with a particular object.

Popup_to_decide
Create a dialog box in which you require the user between the two processing
alternatives, or to cancel the action.

Popup_to_decide_with_message
Create a dialog box in which you inform the user about a specific decision point

via a diagnosis text.

Popup_to_display_text
Create a dialog box in which you display a two-line message.

Rfc_system_info
Fetch information from the current instance filling the structure FRCSI.

Rs_send_mail_for_spoollist
Send messages from ABAP/4 programs to SAPoffice. The structure SOLI may
contain the message.

Rzl_sleep
Hang the current application from 1 to 5 seconds.

Rzl_submit
Submit a remote report.

Sapgui_progress_indicator
Set progress indicator on the left lower corner of the current window.

Sd_print_terms_of_payment
Format terms of payment according to base line date and payment terms.

So_wind_spool_list
Browse printer spool numbers according to user informed.

So_spool_read
Fetch printer spool according to the spool number informed.

So_user_list_read
List of all users filling the structure SOUD3.

Spell_amount
Return the amount in words filling the structure SPELL.

Th_saprel
Gather information from the current system including upgrade activities. It
completes fields from the structure KKS03.

Th_server_list
Gather information of all instances filling the structure MSXXLIST.

Th_user_list
List of logged users filling the structure UINFO.

Th_user_info
Information about the current user. It completes fields from the structure KKS03.

Th_wpinfo
List of work processes filling the structure WPINFO.

Ws_upload
Transfer files from the frontend to the application server.

Ws_download
Transfer files from the application server to the frontend.

Ws_excel
Download files at the frontend in excel format.

Ws_execute
Execute an external program on the presentation server.

Ws_file_delete
Delete file at the frontend.

Ws_volume_get
Get the label from a frontend device.

Ws_msg
Create a dialog box in which you display an one-line message.

SAP R/3 Glossary

TOP

Information Technology has many key words and SAP R/3 has introduced many others. In order
to understand even better this field you should keep in mind those terms.

ALE (Application Link Enabling)


It provides integration for separate R/3 systems, keeping full interaction. This makes
possible distributed enterprise applications.
Application server
The application server is used to run the business application programs in the R/3
client/server concept. The application modules are loaded from the data base server to
the application server as required. Thus the application server requires only storage
capacity to accommodate UNIX, Swapping and the SAP runtime environment.
Batch Input
A technique to input data safely. It ensures application data integrity for background
interfaces. It pretends to be someone typing. See also direct input.
CATT (Computer Aided Test Tool)
It allows you to combine and automate sequences of repeatable transactions in test
procedures. CATT reduces the number of manual tests, and forces you to test
systematically, defining input values and expected test results.

CCMS (Computer Center Management System)


It allows you to monitor, control and configure your R/3 system. This toolset lets you
analyze and distribute client workloads and report on resource consumption for system
components.
Central System
In an R/3 central system, both application and data base software are run on one
computer.
Client
In commercial, organizational and technical terms, a self-contained unit in an R/3 system
with separate master records and its owns set of tables.
Client/Server System
Client/server systems are structured modularly, with components working in a
sender/receiver relationship. Software components can also be used in a client/server
relationship.
Communication Server
It provides the connection between local area and wide area networks and may be either
a router, a bridge or a gateway. In R/3 installations, the communication server must
support the TCP/IP protocol over wide area networks.
Company code
The smallest organizational unit for which a complete self-contained set of accounts can
be drawn up for purposes of external reporting. This involves recording all relevant
transactions and generating all supporting documents for legally-required financial
statements, such as balance sheets and profit and loss statements.
Computer type
The R/3 system supports various computer types of SAP's platform partners, such as
Bull, DEC, IBM and HP. The suitability of a particular computer type depends on sufficient
CPU performance.
CPI-C (Common Programming Interface-Communications)
Common Programming Interface of Communication has been introduced by IBM as a
high-level interface to SNA/LU6-2. CPI-C has become the subject of the X/Open
stardarlization and is used by SAP to facilitate program-to-program communication
between R/3 and external system. SAP offers CPI-C libraries based on TCP/IP.
Correction
It contains all the objects that a developer has changed or created. It also controls
customizing that has been maintained.
CSP
A system to help SAP employees to give comprehensive support to their clients.
Data base server
The data base server stores the SAP application programs and data in the R/3
client/server concept. It also handles the SAP update program and batch jobs.
Direct Input
A recent technique to input data safely. It ensures application data integrity for
background interfaces. See also batch input.
Dispatcher
The system R/3 agent that identifies the type of task (on-line, update, batch, etc.) and
sends the job to an idle work process.
EarlyWatch
It is a service that entails having your R/3 installation regularly inspected by SAP
employees, in other to ensure high system availability and high data throughput at all
time.
Ethernet
It is a LAN architecture using bus topology. The transmission speed is 10 MBit/s.

FDDI (Fiber Distributed Data Interchange)


It is a local high-speed network with ring topology based on light wave conductors. The
transmission speed is 100 MBit/s.
Field status
Indicator that specifies whether a field can take an entry in the entry screen or if it must
be filled.
Firewall
It is a means of controlling access through a public network to a private network.
FTP (File Transfer Protocol)
It is the most commonly used file transmission protocol of the TCP/IP protocol family.
GUI (Graphic User Interface)
A graphical interface used by SAP environment as part of the three tiers. It is normally
called user frontend.
IDES (International Demonstration and Education System)
It is a model of an international firm. It is a separate demonstration and education system
for speeding up the pilot process.
IMG (Implementation Management Guide)
It is a hierarchical structure that reflects the R/3 component hierarchy and contains every
configuration activity. Released from version 3.0 onwards.
Instance
It means application server and each one has its own set of work processes.
IDoc (Intermediate Document)
An IDoc is a data container for data exchange between SAP systems or between an SAP
system and an external system.
ITS (Internet Transaction Server)
It links the R/3 application server with one or more Web servers, thus enabling the R/3 to
communicate with the Internet.
Kernel
It means a standard core previously configured. A set of default parameters delivered
with the system.
LAN (Local Area Network)
It is a network foa a tightly limited area with high level data transmission performance.
Common LANs include Ethernet, Token Ring and FDDI. These LANs support different
transport protocols, such as TCP/IP and IPX.
Matchcode
A tool for finding specific record. It is made up of search terms. It is used to find possible
entries for an input field.
Number range
A range of numbers that are laid down per file for the assignment of document numbers.
It can be internal (carried out automatically by the system) or external (carried out
manually by the user).
OLE
It is a technique introduced by Microsoft to incorporate objects of one application into
another.
OSS (Online Service System)
SAP's Online Service System offers fast and effective help for R/3 System problems. It is
also the basic element of communications between customers, partners, and SAP.
Repair
It contains all the objects that a developer has changed but the originals of the objects
are located in another system.

RFC
A way to implement communication between application programs via Abap/4 function
call.
Semaphores
When a work process locks a resource, it sets a semaphore. Another work process that
also wants to access it must then wait.
SysID
A set of three letters or number that identify a system. Some sets are not allowed
because they are used by SAP. They are informed when the system is installed.
TCP/IP
It is the most widely used transport protocol for open systems. R/3 clients and servers
communicate using TCP/IP.
Telnet
It provides terminal access to hosts using TCP/IP protocol. It is a well-known command
among Systems Administrators.
Token Ring
It is a LAN architecture with ring topology. The transmission speed is 4 MBit/s or 16
MBit/s. This involves a 'free token' which circles the loop picking up transmissions. The
receiver station places a confirmation bit into the busy token. As soon as the busy token
reaches the sender station again, it is converted back to a free token and sent on to the
next station.
Transport
It is a request to transport objects from the software development environment, identified
as the source system, to the specified target system.
WAN (Wide Area Networks)
They are normally operated either by the telephone company or by private companies
that offer leased lines, switched lines or packet lines.
Work process
Work processes perform the bulk of the processing carried out by SAP systems. They
perform dialog steps in user transactions and carry out updates, lock management,
printing services, and so on.
Workbench
The ABAP/4 Workbench, a graphical programming environment, is used to create
application programs. The programming tools are accessed using buttons, dialogs and
windows.
Workflow
It consists of time and logical sequence of work items, which are precessed by human
agents or mechanical processing units.
X.25
It is a standardized network access protocol for the packet switching network. The
maximum transmission speed is 64 KBit/s.

SAP R/3 Troubleshooting

TOP

System gets stuck


It happens mostly when archive area is overloaded. Run the program brarchive with
deletion option to release disk space.
Short dump
Not always the problem is technical. Try to create all SAPoffice users through transaction
SO32 (create all SAPoffice users) and review your application data carefully.

Field exits are completely ignored


Make sure your SAP profile parameter contains the option abap/fieldexit = yes.
Transaction SE16 (table contents) does not work properly
Make usage of the menu option to regenerate the display program. You can also try
changing key words according to field names. Choose Option -> Parameters users.
Rollback segments are too small
Before increasing up the rollback segment size you should verify your programs. Very
often the problem belongs to them.
Files for rollback segments are already enormous
Check the rollback segments configuration. It has to match the allocated area on
tablespaces. Changes have to be done using Oracle tools.
Extended help under windows does not link correctly
Check the file sapdoccd.ini under your presentation server. It must be present in the main
windows directory and should assign to help files directory.
Release procedure with classification does not work
As a matter of fact you are not the only one to notice it. It hardly works. Before using
release strategy you should apply all notes on OSS. Pray might be useful too.
Transport area is overloaded
The command tp clearold SysID cleans up the transport area according to parameters
previously set on the plain file TPPARAM.
Instance does not establish communication
Shutdown the whole system and check the Interprocess Communication Facilities. Any
references should be found. Either the command IPCS (UNIX) or showipc INSTANCE
NUMBER (SAP) show all message queue, semaphore set and shared memory
identifier. Before trying again you have to remove them using the command IPCRM
(UNIX) or cleanipc INSTANCE NUMBER (SAP).

SAP R/3 Tips & Tricks

TOP

Logging on without being authorized


Client 066 usually exists in a SAP system because of EarlyWatch services. Often
this client does not have master users. If it is true, anyone can log into the system
using the client 066, user SAP*, and password PASS. Enjoy yourself.

Special copy and paste


Click on the area and press CTRL+Y. It allows you to copy many lines at once
and paste them afterwards.

Long messages on footer


Click on the message and hold the mouse button. After moving the mouse to the
left side.

Direct input logs


The transaction BMV0 (direct input logs) shows all direct input logs.

Graphics on SAPscript
The program RSTXLDMC can be used to upload graphics (file extension .tif on
PC files) into individual standard text.

Adding icons
The include ICON can be easily used in your programs. All icons can be
checked through the transaction ICON. Sequences of characters begin and finish
with the symbol @. Even plain files under operating system can contain those
strings.

Adding symbols
The include SYMBOL can be easily used in your programs. It makes available
a great number of symbols.

Filling up an empty date field quickly


Strike the key F4 (or click on matchcode symbol) and press ESCAPE. The current
date is automaticly set.

Setting up module FI/CO without using IMG


Almost all parameters can be set using the transactions ORFA (Asset Accounting),
ORFB (Financial Accounting), and ORKS (Cost Center Accounting).

Deleting cost elements and cost centers


Since they have no postings you can use the transaction KA04 for deleting cost
elements and KS04 for deleting cost centers.

Displaying check object when not authorized


Soon after the lock try to access the transaction SU53. It reports the last objects
verified and also the respective values.

Table analyses between two systems


The contents of a table between two systems can be checked through the
transaction OY19.

Correction and transport system


The transaction SE10 provides the easiest way to manage any request/transport
and corrections.

General command field formats


/n
Skip to the next record if you are processing one batch input session
/bend Cancel a batch input foreground process
/nend Close all R/3 sessions and logoff
/nxxxxCall the transaction xxxx in the same session
/o
Generate a session list
/oxxxxCall the transaction xxxx in an additional session
/i
Delete the current session
/h
Turn the debug mode on
/$tab Reset all buffers (for System Administrators)
/$sync Synchronize instances buffers (for System Administrators)
Report command field formats

%pri
Print the current report
%pc
Download the current report
%sc
Call the find function
p+
Go to the next page
pGo to the previous page
p++
Go to the last page
p-Go to the first page
Helpful reports
RSCLTCOP Copy tables across clients
RSAVGL00 Table adjustment across clients
RSINCL00 Extended program list
RSBDCSUB Release batch-input sessions automaticly
RSTXSCRP Transport SAPscript files across systems
RSORAREL Get the Oracle Release
RGUGBR00 Substitution/Validation utility
RSPARAM Display all instance parameters
RSUSR003 Check the passwords of users SAP* and DDIC in all clients
RSUSR006 List users last login
Meaning of info structures' first letter
A
B
C
D
E
F
G
H
I
S
X

Pricing
Output determination
Account determination
Material determination
Rebates
Index
Listing and Exclusion
Batch determination
Profile determination
Statistics
Statistics extra

1. What is the typical structure of an ABAP/4 program?


ANS:HEADER ,BODY,FOOTER.
2. What are field symbols and field groups.?
Have you used "component idx of structure" clause with field groups?
ANS:Field symbols:Field groups :3. What should be the approach for writing a BDC program?
ANS:-

STEP 1: CONVERTING THE LEGACY SYSTEM DATA TO A FLAT FILE to internal


table CALLED "CONVERSION".
STEP 2: TRANSFERING THE FLAT FILE INTO SAP SYSTEM CALLED "SAP DATA
TRANSFER".
STEP 3: DEPENDING UPON THE BDC TYPE i)call transaction(Write the program
explicity)
ii) create sessions (sessions are created and processed.if success data will transfer).
4. What is a batch input session?
ANS:BATCH INPUT SESSION is an intermediate step between internal table and database
table.
Data along with the action is stored in session ie data for screen fields, to which screen it
is passed,program name behind it, and how next screen is processed.
5. What is the alternative to batch input session?
ANS:Call transaction.
6. A situation: An ABAP program creates a batch input session.
We need to submit the program and the batch session in back ground. How to do
it?
ANS:go to SM36 and create background job by giving
job name,job class and job steps (JOB SCHEDULING)
8. What are the problems in processing batch input sessions?
How is batch input process different from processing online?
ANS:PROBLEMS:i) If the user forgets to opt for keep session then the session will be automatically
removed from the session queue(log remains). However if session is processed we may
delete it manually.
ii)if session processing fails data will not be transferred to SAP database table.
10. What are the different types of data dictionary objects?
ans:tables, structures, views, domains, data elements, lock objects, Matchcode objects.
11. How many types of tables exists and what are they in data dictionary?
ans :4 types of tables
i)Transparent tables - Exists with the same structure both in dictionary as well as in
database exactly with the same data and fields. Both Opensql and Nativesql can be used.

ii)Pool tables & iii)Cluster tables These are logical tables that are arranged as records of transparent tables.one cannot use
native sql on these tables
(only opensql).They are not managable directly using database system tools.
iv)Internal tables - .
12. What is the step by step process to create a table in data dictionary?
ans:step 1: creating domains(data type,field length,range).
step 2: creating data elements(properties and type for a table
field).
step 3: creating tables(SE11).
13. Can a transparent table exist in data dictionary but not in the data base
physically?
ANS:- NO.
TRANSPARENT TABLE DO EXIST WITH THE SAME STRUCTURE BOTH IN THE
DICTIONARY AS WELL AS IN THE DATABASE,EXACTLY WITH THE SAME
DATA AND FIELDS.
14. What are the domains and data elements?
ANS:DOMAINS : FORMAL DEFINITION OF THE DATA TYPES.THEY SET
ATTRIBUTES SUCH AS DATA TYPE,LENGTH,RANGE.
DATA ELEMENT : A FIELD IN R/3 SYSTEM IS A DATA ELEMENT.
15. Can you create a table with fields not referring to data elements?
ANS:YES. eg:- ITAB LIKE SPFLI.here we are referening to a data object(SPFLI) not data
element.
16. What is the advantage of structures? How do you use them in the ABAP
programs?
ANS:Adv:- GLOBAL EXISTANCE(these could be used by any other program without
creating it again).
17. What does an extract statement do in the ABAP program?
ANS:Once you have declared the possible record types as field groups and defined their
structure, you can fill the extract dataset using the following statements:
EXTRACT <fg>.

When the first EXTRACT statement occurs in a program, the system creates the extract
dataset and adds the first extract record to it. In each subsequent EXTRACT statement,
the new extract record is added to the dataset
EXTRACT HEADER.
When you extract the data, the record is filled with the current values of the
corresponding fields.
As soon as the system has processed the first EXTRACT statement for a field group
<fg>, the structure of the corresponding extract record in the extract dataset is fixed. You
can no longer insert new fields into the field groups <fg> and HEADER. If you try to
modify one of the field groups afterwards and use it in another EXTRACT statement, a
runtime error occurs.
By processing EXTRACT statements several times using different field groups, you fill
the extract dataset with records of different length and structure. Since you can modify
field groups dynamically up to their first usage in an EXTRACT statement, extract
datasets provide the advantage that you need not determine the structure at the beginning
of the program.
18. What is a collect statement? How is it different from append?
ANS:If an entry with the same key already exists, the COLLECT statement does not append a
new line, but adds the contents of the numeric fields in the work area to the contents of
the numeric fields in the existing entry.
19. What is open sql vs native sql?
ANS:20. What does an EXEC SQL stmt do in ABAP? What is the disadvantage of using
it?
ANS:21. What is the meaning of ABAP/4 editor integrated with ABAP/4 data dictionary?
ANS:22. What are the events in ABAP/4 language?
ANS:Initialization, At selection-screen,Start-of-selection,end-of-selection,top-of-page,end-ofpage, At line-selection,At user-command,At PF,Get,At New,At LAST,AT END, AT
FIRST.
23. What is an interactive report?
What is the obvious diff of such report compared with classical type reports?
ANS:-

An Interactive report is a dynamic drill down report that produces the list on users choice.
diff:a) THE LIST PRODUCED BY CLASSICAL REPORT DOESN'T allow user to interact
with the system
the list produced by interactive report allows the user to interact with the system.
b) ONCE A CLASSICAL REPORT EXECUTED USER LOOSES CONTROL.IR USER
HAS CONTROL.
c) IN CLASSICAL REPORT DRILLING IS NOT POSSIBLE.IN INTERACTIVE
DRILLING IS POSSIBLE.
24. What is a drill down report?
ANS:Its an Interactive report where in the user can get more relavent data by selecting
explicitly.
25. How do you write a function module in SAP? describe.
ANS:creating function module:called program - se37-creating funcgrp,funcmodule by assigning
attributes,importing,exporting,tables,exceptions.
calling program - SE38-in pgm click pattern and write function name- provide
export,import,tables,exception values.
26. What are the exceptions in function module?
ANS:COMMUNICATION_FAILURE
SYSTEM_FAILURE
27. What is a function group?
ANS:GROUP OF ALL RELATED FUNCTIONS.
28. How are the date and time field values stored in SAP?
ANS:DD.MM.YYYY. HH:MM:SS
30. Name a few data dictionary objects? //rep//
ANS:TABLES,VIEWS,STRUCTURES,LOCK OBJECTS,MATCHCODE OBJECTS.
31. What happens when a table is activated in DD?
ANS:It is available for any insertion,modification and updation of records by any user.

32. What is a check table and what is a value table?


Check table will be at field level checking.
Value table will be at domain level checking ex: scarr table is check table for carrid.
33. What are match codes? describe?
ans:It is a similar to table index that gives list of possible values for either primary keys or
non-primary keys.
34. What transactions do you use for data analysis?
ANS:35. What is table maintenance generator?
ANS:36. What are ranges? What are number ranges?
ANS:max,min values provided in selection screens.
37. What are select options and what is the diff from parameters?
ANS:select options provide ranges where as parameters do not.
SELECT-OPTIONS declares an internal table which is automatically filled with values or
ranges
of values entered by the end user. For each SELECT-OPTIONS , the system creates a
selection table.
SELECT-OPTIONS <SEL> FOR <field>.
A selection table is an internal table with fields SIGN, OPTION, LOW and HIGH.
The type of LOW and HIGH is the same as that of <field>.
The SIGN field can take the following values: I Inclusive (should apply) E Exclusive
(should not apply)
The OPTION field can take the following values: EQ Equal GT Greater than NE Not
equal BT Between LE Less
than or equal NB Not between LT Less than CP Contains pattern GE Greater than or
equal NP No pattern.
diff:PARAMETERS allow users to enter a single value into an internal field within a report.
SELECT-OPTIONS allow users to fill an internal table with a range of values.
For each PARAMETERS or SELECT-OPTIONS statement you should define text
elements by choosing
Goto - Text elements - Selection texts - Change.

Eg:- Parameters name(30).


when the user executes the ABAP/4 program,an input field for 'name' will appear on the
selection screen.You can change the comments on the left side of the input fields by using
text elements as described in Selection Texts.
38. How do you validate the selection criteria of a report?
And how do you display initial values in a selection screen?
ANS:validate :- by using match code objects.
display :- Parameters <name> default 'xxx'.
select-options <name> for spfli-carrid.
39. What are selection texts?
ANS:40. What is CTS and what do you know about it?
ANS:The Change and Transport System (CTS) is a tool that helps you to organize development
projects in the ABAP Workbench and in Customizing, and then transport the changes
between the SAP Systems and clients in your system landscape.
This documentation provides you with an overview of how to manage changes with the
CTS and essential information on setting up your system and client landscape and
deciding on a transport strategy. Read and follow this documentation when planning your
development project.
For practical information on working with the Change and Transport System, see Change
and Transport Organizer and Transport Management System.
41. When a program is created and need to be transported to prodn does selection
texts always go with it? if not how do you make sure? Can you change the CTS
entries? How do you do it?
ANS:42. What is the client concept in SAP? What is the meaning of client independent?
ANS:43. Are programs client dependent?
ANS:Yes.Group of users can access these programs with a client no.
44. Name a few system global variables you can use in ABAP programs?
ANS:SY-SUBRC,SY-DBCNT,SY-LILLI,SY-DATUM,SY-UZEIT,SY-UCOMM,SY-TABIX.....
SY-LILLI IS ABSOLUTE NO OF LINES FROM WHICH THE EVENT WAS
TRIGGERED.

45. What are internal tables? How do you get the number of lines in an internal
table?
How to use a specific number occurs statement?
ANS:i)It is a standard data type object which exists only during the runtime of the program.
They are used to perform table calculations on subsets of database tables and for reorganising the contents of database tables according to users need.
ii)using SY-DBCNT.
iii)The number of memory allocations the system need to allocate for the next record
population.
46. How do you take care of performance issues in your ABAP programs?
Performance of ABAPs can be improved by minimizing the amount of data to be
transferred.
The data set must be transferred through the network to the applications, so reducing the
amount OF time and also reduces the network traffic.
Some measures that can be taken are:
- Use views defined in the ABAP/4 DDIC (also has the advantage of better reusability).
- Use field list (SELECT clause) rather than SELECT *.
- Range tables should be avoided (IN operator)
- Avoid nested SELECTS.
i)system tools
ii)field symbols and field groups.
ans:Field Symbols : Field symbols are placeholders for existing fields. A Field Symbol does
not physically reserve space for a field,but points to a field which is not known until
runtime of the program.
eg:- FIELD-SYMBOL <FS> [<TYPE>].
Field groups : A field group combines several fields under one name.At runtime,the
INSERT command is used to define which data fields are assigned to which field group.
There should always be a HEADER field group that defines how the extracted data will
be sorted,the data is sorted by the fields grouped under the HEADER field group.
47. What are datasets?
ANS:The sequential files(ON APPLICATION SERVER) are called datasets. They are used for
file handling in SAP.
48. How to find the return code of a statement in ABAP programs?
ANS:Using function modules.

49. What are interface/conversion programs in SAP?


ANS :
CONVERSION : LEGACY SYSTEM TO FLAT FILE.
INTERFACE : FLAT FILE TO SAP SYSTEM.
50. Have you used SAP supplied programs to load master data?
51. What are the techniques involved in using SAP supplied programs?
Do you prefer to write your own programs to load master data? Why?
52. What are logical databases? What are the advantages/disadvantages of logical
databases?
ANS:To read data from a database tables we use logical database.
A logical database provides read-only access to a group of related tables to an ABAP/4
program.
adv:The programmer need not worry about the primary key for each table.Because Logical
database knows how the different tables relate to each other,and can issue the SELECT
command with proper where clause to retrieve the data.
i)An easy-to-use standard user interface.
ii)check functions which check that user input is complete,correct,and plausible.
iii)meaningful data selection.
iv)central authorization checks for database accesses.
v)good read access performance while retaining the hierarchical data view determined by
the application logic.
disadv:i)If you donot specify a logical database in the program attributes,the GET events never
occur.
ii)There is no ENDGET command,so the code block associated with an event ends with
the next event
statement (such as another GET or an END-OF-SELECTION).
53. What specific statements do you using when writing a drill down report?
ans:AT LINE-SELECTION,AT USER-COMMAND,AT PF.
54. What are different tools to report data in SAP? What all have you used?
ans:55. What are the advantages and disadvantages of ABAP/4 query tool?
56. What are the functional areas? User groups? and how does ABAP/4 query work
in relation to these?

57. Is a logical database a requirement/must to write an ABAP/4 query?


59. What are Change header/detail tables? Have you used them?
60. What do you do when the system crashes in the middle of a BDC batch session?
ans:we will look into the error log file (SM35).
61. What do you do with errors in BDC batch sessions?
ANS:We look into the list of incorrect session and process it again. To correct incorrect session
we analyize the session to determine which screen and value produced the error.For small
errors in data we correct them interactively otherwise
modify batch input program that has generated the session or many times even the
datafile.
62. How do you set up background jobs in SAP? What are the steps? What are the
event driven batch jobs?
ans:go to SM36 and create background job by giving job name,job class and job steps(JOB
SCHEDULING)
63. Is it possible to run host command from SAP environment? How do you run?
64. What kind of financial periods exist in SAP? What is the relavent table for that?
65. Does SAP handle multiple currencies? Multiple languages?
ans:Yes.
66. What is a currency factoring technique?
67. How do you document ABAP/4 programs? Do you use program documentation
menu option?
68. What is SAPscript and layout set?
ans:The tool which is used to create layout set is called SAPscript. Layout set is a design
document.
69. What are the ABAP/4 commands that link to a layout set?
ans:control commands,system commands,
70. What is output determination?

71. What are IDOCs?


ans:IDOCs are intermediate documents to hold the messages as a container.
72. What are screen painter? menu painter? Gui status? ..etc.
ans:dynpro - flow logic + screens.
menu painter GUI Status - It is subset of the interface elements(title bar,menu bar,standard tool
bar,push buttons) used for a certain screen.
The status comprises those elements that are currently needed by the transaction.
73. What is screen flow logic? What are the sections in it? Explain PAI and PBO.
ans:The control statements that control the screen flow.
PBO - This event is triggered before the screen is displayed.
PAI - This event is responsible for processing of screen after the user enters the data and
clicks the pushbutton.
74. Overall how do you write transaction programs in SAP?
ans:Create program-SE93-create transcode-Run it from command field.
75. Does SAP has a GUI screen painter or not? If yes what operating systems is it
available on? What is the other type of screen painter called?
76. What are step loops? How do you program pagedown pageup in step loops?
ans:step loops are repeated blocks of field in a screen.
77. Is ABAP a GUI language?
ANS:Yes.
ABAP IS AN EVENT DRIVEN LANGUAGE.
78. Normally how many and what files get created when a transaction program is
written?
What is the XXXXXTOP program?
ans:ABAP/4 program.
DYNPRO
79. What are the include programs?
ANS:When the same sequence of statements in several programs are to be written repeadly

they are coded in include programs (External programs) and are included in ABAP/4
programs.
80. Can you call a subroutine of one program from another program?
ans:- Yes- only external subroutines Using 'SUBMIT' statement.
81. What are user exits? What is involved in writing them? What precations are
needed?
82. What are RFCs? How do you write RFCs on SAP side?
83. What are the general naming conventions of ABAP programs?
ANS:Should start with Y or Z.
84. How do you find if a logical database exists for your program requrements?
ans:SLDB-F4.
85. How do you find the tables to report from when the user just tell you the
transaction he uses? And all the underlying data is from SAP structures?
ans:Transcode is entered in command field to open the table.Utilities-Table contents-display.
86. How do you find the menu path for a given transaction in SAP?
ans:87. What are the different modules of SAP?
ans:FI,CO,SD,MM,PP,HR.
89. How do you get help in ABAP?
ans:HELP-SAP LIBRARY,by pressing F1 on a keyword.
90. What are different ABAP/4 editors? What are the differences?
ans:91. What are the different elements in layout sets?
ans:PAGES,Page windows,Header,Paragraph,Character String,Windows.
92. Can you use if then else, perform ..etc statements in sap script?
ans:yes.

93. What type of variables normally used in sap script to output data?
94. How do you number pages in sapscript layout outputs?
95. What takes most time in SAP script programming?
ANS:LAYOUT DESIGN AND LOGO INSERTION.
96. How do you use tab sets in layout sets?
97. How do you backup sapscript layout sets? Can you download and upload?
How?
98. What are presentation and application servers in SAP?
ANS:The application layer of an R/3 System is made up of the application servers and the
message server. Application programs in an R/3 System are run on application servers.
The application servers communicate with the presentation components, the database,
and also with each other, using the message server.
99. In an ABAP/4 program how do you access data that exists on a presentation
server vs on an application server?
ans:i)using loop statements.
ii)flat
100. What are different data types in ABAP/4?
ans:Elementary predefined C,D,F,I,N,P,T,X.
userdefined TYPES.
ex: see in intel book page no 35/65
Structured predefined TABLES.
userdefined Field Strings and internal tables.
101. What is difference between session method and Call Transaction?
ans:102. Setting up a BDC program where you find information from?
ans:103. What has to be done to the packed fields before submitting to a BDC session.
ans:fields converted into character type.

104. What is the structure of a BDC sessions.


ans:BDCDATA (standard structure).
105. What are the fields in a BDC_Tab Table.
ans:program,dynpro,dynbegin,fnam,fval.
106. What do you define in the domain and data element.
Technical details like
107. What is the difference between a pool table and a transparent table and how
they are stored at the database level.
ans:ii)Pool tables is a logical representation of transparent tables .Hence no existence at
database level. Where as transparent tables are physical tables and exist at database level.
108. What is cardinality?
For cardinality one out of two (domain or data element) should be the same for Ztest1
and Ztest2 tables. M:N
Cardinality specifies the number of dependent(Target) and independent (source) entities
which can be in a relationship.

Estimate Guidelines for ABAP programs


1. Follow the naming standards (of the company or client you are working)
2. Use select field one field two etc do not use select *
3. Avoid unnecessary loops. If requirec use loop with where clause or Read with binary
search
4. Use case statement in place of if else
5. use clear table before select single or where ever applicable.
6. check for sy-subrc where ever applicable
7. avoid collect statement if possinble
8. do proper documentation of the program inside abap editor and also in se38
(screen-documentation radio button )
9. try to use views rather than nested select statement
10. use ABAP TRACE try to work on those SQL statements to improve performance

11. use index only if it is required


12. in internal table declaration try to use correct occurs number say occurs 1000.
Otherwise use occurs 0.
13. while using select statements use single select, select * upto 5 rows ,etc based on
the requirement.use select options wisely taking performance into account.
14. declare variables / parameters with meaningful words like v_matnr for material
number or v_bukrs for plant or at least v_matnum for material number etc.
15. Beautify the code using pretty printer, pattens(***** ----- etc)

Answers to some ABAP Interview Questions


Questions which I have faced in an interview:
1) What is runtime analysis? Have you used this?
2) What is meant by performance analysis? Have done anything to improve the
performance?
3) How to transfer the objects? Have to transferred any objects?
4) How did you test the developed objects?
5) What is the difference between SAP Memory and ABAP Memory?
6) In order to upload Purchase order details, how you handle multiple values for a
single field?
Eg: Item field may contain no. of values for a record
7) What is the procedure you followed to upload the data?
8) How did you handle errors in Call Transaction?
9) Among the Call Transaction and Session Method, which is faster?
10) What are the difference between Interactive and Drill Down Reports?
11) How to pass the variables to forms?
12) How to create a link between modified form and modified print program?
13) What is the table, which contain the details of all the name of the programs and
forms?
14) How did you test the form u developed? How did you taken print?
15) What are Standard Texts?
16) What is the difference between Clustered Tables and Pooled Tables?
17) What is pf-status?
18) Among "Move" and "Move Corresponding", which is efficient one?
19) What are the output type and Tcodes?
20) Where we use Chain and Endchain?
21) Do you use select statement in loop endloop, how will be the performance? To
improve the performance?
22) In select-options, how to get the default values as current month first date and
last date by default?
Eg: 1/12/2004 and 31/12/2004

Go thru these answers:


1) What is runtime analysis? Have you used this?
It's checks program execution time in microseconds. When you go to se30.if you give
desired program name in performance file. It will take you to below screen. You can get
how much past is your program.
2) What is meant by performance analysis? Have done
3) How to transfer the objects? Have you transferred any objects?
4) How did you test the developed objects?
I was testing a developed object. There are two types of testing
- Negative testing
- Positive testing
In negative testing we will give negative data in input and we check any errors occurs.
In positive testing we will give positive data in input for checking errors.
8) How did you handle errors in Call Transaction?
We can create a internal table like 'bsgmcgcoll'. All the messages will go to internal table.
We can get errors in this internal table.
Below messages are go to internal table. when you run the call transaction.
- Message type
- Message id
- Message Number
- Variable1
- Variable2
- Variable3
9) Among the Call Transaction and Session Method, which is faster?
Call transaction is faster then session method. But usually we use session method in real
time...because we can transfer large amount of data from internal table to database and if
any errors in a session. Process will not complete until session get correct.
10) What are the difference between Interactive and
Drill Down Reports?

ABAP/4 provides some interactive events on lists such as AT LINE-SELECTION


(double click) or AT USER-COMMAND (pressing a button). You can use these events to
move through layers of information about individual items in a list.
Drill down report is nothing but interactive report...drilldown means above paragraph
only.
11) How to pass the variables to forms?
12) What is the table, which contain the details of all the name of the programs and
forms?
Table contains vertical and horizontal lines. We can store the data in table as blocks. We
can scroll depends upon your wish. And these all are stored in database (data dictionary).
Which contain the details of all the name of the programs and forms? (I don't know).
13) How did you test the form u developed? How did you taken print?
14) What are Standard Texts?
16) What is the difference between Clustered Tables and Pooled Tables?
A pooled table is used to combine several logical tables in the ABAP/4 dictionary. Pooled
tables are logical tables that must be assigned to a table pool when they are defined.
Cluster table are logical tables that must be assigned to a table cluster when they are
defined.
Cluster table can be used to store control data they can also used to store temporary data
or text such as documentation.
17) What is pf-status?
Pf status is used in interactive report for enhancing the functionality. If we go to se41, we
can get menus, items and different function keys, which we are using for secondary list in
interactive report.
18) Among "Move" and "Move Corresponding", which is efficient one?
I guess, 'move corresponding' is very efficient then 'move' statement. Because usually we
use this stamtent for internal table fields only...so if we give move corresponding. Those
fields only moving to other place (what ever you want).
19) What are the output type and Tcodes?

20) Where we use Chain and End chain?


21) Do you use select statement in loop end loop, how will be the performance? To
improve the performance?
22) In select-options, how to get the default values as current month first date and last
date by default?
Eg: 1/12/2004 and 31/12/2004

Common Questions and Answers about ABAP/4 and


Developments
1. What is the difference between external & internal subroutine?
2. Why do we use ALV?
3. Why do we use GET CURSOR and what is it?
4. Both the events AT SELECTION-SCREEN and AT USER-COMMAND are
processed after user input.
Then what is the difference between these and when we should use what?
Sudeshna
Answer 1:
1) Internal subroutines in the sense ..subroutines which are defined and used in a same
program...external in the sense if you create a sub routine in one program and you're
calling this subroutine in another program ..then this is external subroutine.
2) ALV gives many advantages than a list like sorting summing getting graphics like that
stuff
3) While generating a interactive report we will use get cursor..use is to get the value of
the fiel under the cursor..
4) At selection screen is used to validate the fields in a selection screen...and at user
command is used to modify the screen in a selection screen and in genarating secondary
lists..
Sarath Reddy
Answer 2:
1. The name itself implies the internal subroutines defined by form /perform.. can be
called within the same prog in which they were declared.....external subroutines can be
called outside the program.......

2. SAP LIST VIEWER is ALV . its main advantage is by using ALV technique we can
find totals ,subtotals ,sort in any order etc there itself in the list output of course we need
to write all those functionalities while using ALV...also many functional modules are
defined under ALV concept...
3. GETCURSOR is used to trace the position of the cursor in the list ..
suppose we want to double click on any filled in the list and want to trace data using that
field we use getcursor .....
4.AT SELECTION-SCREEN is used where you have a seperate selection screen using
select-options or parameters where as AT USER-COMMAND is used where no selection
screen exists....at.user-command is mainly used while setting pf-status which means
creating our own menu with function codes etc...
Shiva
I had seen some of the standard abap that the table name had *, like *ekpo. What is
the meaning? What is the difference between with * and without * ?
It just lets you use the table a second time. For example:
select single * from ekpo where ebeln = '12345' and ebelp = '1'.
select single * from *ekpo where ebeln = '67890' and ebelp = '1'.
You now have two separate records, one in ekpo and one in *ekpo.
Another way to do this is to simply use the 'into' argument in the 'select' statement to read
the second ekpo record into some other field. The '*' format can be confusing, I think it
may be left over from earlier releases, like 2.2.
EKPO is database table and *EKPO is internal table.
Once you select into EKPO, you can use it the same way as *EKPO.
How do I use variables in the FORMAT command?
DATA COLORID TYPE I VALUE 4.
FORMAT INTENSIFIED ON COLOR = COLORID.
When using CALL 'SYSTEM' id 'COMMAND' field unix-command, how does one
capture the results of the command? For example, if the unix-command were the
date?

You capture the results in the table e.g TABL, like this
DATA: BEGIN OF TABL OCCURS 0,
LINE(560),
END OF TABL.
REFRESH TABL.
CALL 'SYSTEM' ID 'COMMAND' FIELD PARCOM_LOC
ID 'TAB' FIELD TABL-*SYS*.
I am working on a program that needs to show number of days between 2 dates.
When I scanned the function library, I only found a function to give you the number
of years between dates. I can probably code this in ABAP but does anyone know if a
function exists to do this.
I wrote this example for you. I think this is what you need.
DATA: DATE_1 LIKE SY-DATUM,
DATE_2 LIKE SY-DATUM.
DATA DAYS TYPE I.
DATE_1 = SY-DATUM.
DATE_2 = SY-DATUM + 65.
DAYS = DATE_2 - DATE_1.
WRITE:/ 'DATE_2=',DATE_2,'DATE_1=',DATE_1,'DAYS=',DAYS.
Run this code and then you will understand.
How do I concatenate two strings in Abap/4?
For all SAP Versions
STR_LENGTH = STRLEN( STRING1 ).
MOVE STRING1 TO STRING3.
WRITE STRING2 TO STRING3+STR_LENGTH.
For SAP Version 3.0 choose:
CONCATENATE STRING1 STRING2 INTO STRING3.
If you want a space between both fields:
CONCATENATE STRING1 STRING2 INTO STRING3 SEPARATED BY ' '.
For SAP Version 2.2 choose Functions:

STRING_CONCATENATE for 2 Strings and


STRING_CONCATENATE_3 for 3 Strings.
Has anyone been successful in suppressing the selection screen that is automatically
displayed when using logical data bases. I want to run a job in the background using
a logical database and I do not want the user prompted for the parameters. I want
to pass the parameters in the program.
Try using the SUBMIT rep USING SELECTION-SET 'variant' WITH ....
command in the report to pass the variant thru the program
I would like to know how to execute from ABAP code an external Unix program and
check for a return code?
There are different ways to this:
(1) OPEN DATASET <file> FOR OUTPUT 'unix command'
CLOSE DATASET <file>
This command executes the unix command and writes the output into <file>
Look into OSS Note 9391.
(2) or try the following program but unfortunately the command CALL SYSTEM is
not supported by SAP. If you are on R/3 2.1 - 2.2x you can get some idea's from the
program SAPMSOS0.
REPORT ZUNIXCOM .
DATA: U_COMMAND(200).
* Table for system messages
DATA: BEGIN OF RT OCCURS 100 ,
LINE(100) ,
END OF RT .
START-OF-SELECTION .
MOVE 'unix command' to U_COMMAND .
REFRESH RT.
CALL 'SYSTEM' ID 'COMMAND' FIELD U_COMMAND
ID 'TAB' FIELD RT-*SYS* .
LOOP AT RT.
WRITE : / RT-LINE .
ENDLOOP.

General - TABStrips in ABAP

*
* Different Selection Options separated by Tabstrips 1,2 and 3
*
* Written by : SAP Basis, ABAP Programming and Other IMG Stuff
*
http://www.sap-img.com
*
REPORT ZTABSTRIPS LINE-SIZE 120
NO STANDARD PAGE HEADING.
TABLES: ekko, ekpo, eket, marc, t134h.
*---------------------------------------------------------------------*
*
Tab Strips 1
*---------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF SCREEN 101 AS SUBSCREEN.
SELECTION-SCREEN BEGIN OF BLOCK vendor WITH FRAME TITLE text-t00.
SELECT-OPTIONS vendor FOR ekko-lifnr.
SELECTION-SCREEN SKIP.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT (10) text-m01.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN SKIP.
SELECT-OPTIONS vplant FOR ekko-reswk.
SELECTION-SCREEN END OF BLOCK vendor.
SELECTION-SCREEN END OF SCREEN 101.
*---------------------------------------------------------------------*
*
Tab Strips 2
*---------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF SCREEN 102 AS SUBSCREEN.
SELECTION-SCREEN BEGIN OF BLOCK data1 WITH FRAME TITLE text-t02.
SELECT-OPTIONS: busarea FOR t134h-gsber,
plant
FOR ekpo-werks,
puorg
FOR ekko-ekorg.
SELECTION-SCREEN END OF BLOCK data1.
SELECTION-SCREEN SKIP.
SELECTION-SCREEN BEGIN OF BLOCK data2 WITH FRAME TITLE text-t03.
SELECT-OPTIONS sched
FOR ekko-ebeln.
SELECT-OPTIONS matl
FOR ekpo-matnr.
SELECTION-SCREEN END OF BLOCK data2.
SELECTION-SCREEN END OF SCREEN 102.
*---------------------------------------------------------------------*
*
Tab Strips 3
*---------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF SCREEN 103 AS SUBSCREEN.
SELECTION-SCREEN BEGIN OF BLOCK rype WITH FRAME TITLE text-t04.
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS del RADIOBUTTON GROUP one.
SELECTION-SCREEN COMMENT 4(35) text-c05 FOR FIELD del.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS fix RADIOBUTTON GROUP one.
SELECTION-SCREEN COMMENT 4(35) text-c06 FOR FIELD fix.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK rype.
SELECTION-SCREEN SKIP.
SELECTION-SCREEN BEGIN OF BLOCK interval WITH FRAME TITLE text-t05.
SELECTION-SCREEN BEGIN OF LINE.

PARAMETERS mon RADIOBUTTON GROUP two.


SELECTION-SCREEN COMMENT 4(15) text-c01 FOR FIELD mon.
PARAMETERS evalmon TYPE spbup.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS wek RADIOBUTTON GROUP two.
SELECTION-SCREEN COMMENT 4(15) text-c02 FOR FIELD wek.
PARAMETERS evalweek TYPE sptag.
SELECTION-SCREEN COMMENT 35(30) text-i01.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK interval.
SELECTION-SCREEN SKIP.
SELECTION-SCREEN BEGIN OF BLOCK type WITH FRAME TITLE text-t01.
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS ext RADIOBUTTON GROUP thr.
SELECTION-SCREEN COMMENT 4(15) text-c08 FOR FIELD int.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS int RADIOBUTTON GROUP thr.
SELECTION-SCREEN COMMENT 4(15) text-c07 FOR FIELD ext.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK type.
SELECTION-SCREEN BEGIN OF BLOCK pre WITH FRAME TITLE text-t06.
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS vn RADIOBUTTON GROUP slv.
SELECTION-SCREEN COMMENT 4(15) text-c09 FOR FIELD vn.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
PARAMETERS bp RADIOBUTTON GROUP slv.
SELECTION-SCREEN COMMENT 4(17) text-c10 FOR FIELD bp.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK pre.
SELECTION-SCREEN END OF SCREEN 103.
SELECTION-SCREEN BEGIN OF TABBED BLOCK uno FOR 20 LINES.
SELECTION-SCREEN TAB (15) name1 USER-COMMAND ucomm1
DEFAULT SCREEN 101.
SELECTION-SCREEN TAB (17) name2 USER-COMMAND ucomm2
DEFAULT SCREEN 102.
SELECTION-SCREEN TAB (23) name3 USER-COMMAND ucomm3
DEFAULT SCREEN 103.
SELECTION-SCREEN END OF BLOCK uno.
INITIALIZATION.
name1 = text-n01.
name2 = text-n02.
name3 = text-n03.

A demo program to create subscreen in your ABAP


Program
*
* A demo program to create subscreen in your ABAP Program
*
* This report will display the user last login date and time.

*
* Subscreen selection 1 : User Name
*
2 : Last Login Date
*
3 : Class Belong To
*
* Written by : SAP Basis, ABAP Programming and Other IMG Stuff
*
http://www.sap-img.com
*
REPORT ZSUBSCREEN.
TABLES: USR02,
"Logon data
SSCRFIELDS. "FIELDS ON SELECTION SCREENS
*--------------------------------------------------------------* SUBSCREEN 1
*--------------------------------------------------------------SELECTION-SCREEN BEGIN OF SCREEN 100 AS SUBSCREEN.
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-010.
SELECT-OPTIONS: USERNAME FOR USR02-BNAME.
SELECTION-SCREEN END OF BLOCK B1.
SELECTION-SCREEN END OF SCREEN 100.
*--------------------------------------------------------------* SUBSCREEN 2
*--------------------------------------------------------------SELECTION-SCREEN BEGIN OF SCREEN 200 AS SUBSCREEN.
SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME TITLE TEXT-020.
SELECT-OPTIONS: LASTLOGI FOR USR02-TRDAT.
SELECTION-SCREEN END OF BLOCK B2.
SELECTION-SCREEN END OF SCREEN 200.
*--------------------------------------------------------------* SUBSCREEN 3
*--------------------------------------------------------------SELECTION-SCREEN BEGIN OF SCREEN 300 AS SUBSCREEN.
SELECTION-SCREEN BEGIN OF BLOCK B3 WITH FRAME TITLE TEXT-030.
SELECT-OPTIONS: CLASSTYP FOR USR02-CLASS.
SELECTION-SCREEN END OF BLOCK B3.
SELECTION-SCREEN END OF SCREEN 300.
* STANDARD SELECTION SCREEN FOR SCROLLING LEFT AND RIGHT
SELECTION-SCREEN: FUNCTION KEY 1,
FUNCTION KEY 2.
SELECTION-SCREEN: BEGIN OF TABBED BLOCK SUB FOR 15 LINES,
END OF BLOCK SUB.
START-OF-SELECTION.
SELECT * FROM USR02 WHERE BNAME IN USERNAME
AND ERDAT IN LASTLOGI
AND CLASS IN CLASSTYP.
WRITE: / 'User ', USR02-BNAME,
'Last Login Date ', USR02-TRDAT,
'Last Login Time ', USR02-LTIME,
'CLASS ', USR02-CLASS.

ENDSELECT.
END-OF-SELECTION.
INITIALIZATION.
* SCREEN ICON LEFT AND RIGHT
SSCRFIELDS-FUNCTXT_01 = '@0D@'.
SSCRFIELDS-FUNCTXT_02 = '@0E@'.
SUB-PROG = SY-REPID.
SUB-DYNNR = 100.
AT SELECTION-SCREEN.
CASE SY-DYNNR.
WHEN 100.
IF SSCRFIELDS-UCOMM = 'FC01'.
SUB-DYNNR = 300.
ELSEIF SSCRFIELDS-UCOMM = 'FC02'.
SUB-DYNNR = 200.
ENDIF.
WHEN 200.
IF SSCRFIELDS-UCOMM = 'FC01'.
SUB-DYNNR = 100.
ELSEIF SSCRFIELDS-UCOMM = 'FC02'.
SUB-DYNNR = 300.
ENDIF.
WHEN 300.
IF SSCRFIELDS-UCOMM = 'FC01'.
SUB-DYNNR = 200.
ELSEIF SSCRFIELDS-UCOMM = 'FC02'.
SUB-DYNNR = 100.
ENDIF.
ENDCASE.

List Box in ABAP Report


*
* List Box in ABAP Report
*
* Written by : SAP Basis, ABAP Programming and Other IMG Stuff
*
http://www.sap-img.com
*
REPORT ZLIST.
TYPE-POOLS: VRM.
DATA: NAME TYPE VRM_ID,
LIST TYPE VRM_VALUES,
VALUE LIKE LINE OF LIST.
PARAMETERS: PS_PARM(10) AS LISTBOX VISIBLE LENGTH 10.
AT SELECTION-SCREEN OUTPUT.
NAME = 'PS_PARM'.
VALUE-KEY = '1'.

VALUE-TEXT = 'LINE 1'.


APPEND VALUE TO LIST. VALUE-KEY = '2'.
VALUE-TEXT = 'LINE 2'.
APPEND VALUE TO LIST.
CALL FUNCTION 'VRM_SET_VALUES' EXPORTING ID = NAME VALUES = LIST.
START-OF-SELECTION.
WRITE: / 'PARAMETER:', PS_PARM.

Auto Disallowed Back Posting to Previous Period

***********************************************************************
* AUTO DISALLOWED BACK POSTING TO PREVIOUS PERIOD
***********************************************************************
REPORT ZBDCMMRV.
TABLES: MARV.
* Batch Input Name
PARAMETERS P-BTCHSN(12)
DEFAULT 'MMRVCHANGE'.
* Company Code
PARAMETERS P-BUKRS LIKE MARV-BUKRS.
* Auto / Manual run the Batch Input Program
PARAMETERS P-RUN
AS CHECKBOX
DEFAULT 'X'.
* INTERNAL TABLE FOR DATA
DATA: BEGIN OF ULTAB OCCURS 50,
BUKRS LIKE MARV-BUKRS,
END OF ULTAB.

"Company Code

* INTERNAL TABLE FOR BATCH INPUT DATA


DATA: BEGIN OF IPUTTAB OCCURS 50.
INCLUDE STRUCTURE BDCDATA.
DATA: END OF IPUTTAB.
* INTERNAL TABLE FOR BATCH INPUT ERROR MESSAGE.
DATA: BEGIN OF MESSTAB OCCURS 50.
INCLUDE STRUCTURE BDCMSGCOLL.
DATA: END OF MESSTAB.
DATA: C_TAXKM LIKE MG03STEUER-TAXKM VALUE '1',
W-LINE-NO TYPE I.
REFRESH ULTAB.
SELECT * FROM MARV WHERE BUKRS = P-BUKRS.
ULTAB-BUKRS = MARV-BUKRS.
APPEND ULTAB.
ENDSELECT.
* CHECK WHETHER TABLE IS EMPTY
IF ULTAB[] is initial.
WRITE: / 'TABLE EMPTY'.
ENDIF.

* Create Batch session


PERFORM CRE-BATCH-SESS.
** LOOP TABLE TO CREATE SCREEN INPUT
SORT.
LOOP AT ULTAB.
REFRESH IPUTTAB.
PERFORM SCREEN1.
PERFORM SCREEN2.
PERFORM PRN_ULTAB.
PERFORM CLOSE-SESS.
ENDLOOP.
CALL FUNCTION 'BDC_CLOSE_GROUP'.
* END OF MAIN PROGRAM
FORM SCREEN1.
* SCREEN #1: INITAL SCREEN FOR MAINTAINING SOURCE LIST
CLEAR IPUTTAB.
IPUTTAB-PROGRAM = 'SAPMM03Y'.
IPUTTAB-DYNPRO = '100'.
IPUTTAB-DYNBEGIN = 'X'.
APPEND IPUTTAB.
* MMRV ENQUIRY BY COMPANY CODE
CLEAR IPUTTAB.
IPUTTAB-FNAM = 'MARV-BUKRS'.
IPUTTAB-FVAL = ULTAB-BUKRS.
APPEND IPUTTAB.
ENDFORM.
***********************************************************************
* FORM
: SCREEN1
*
***********************************************************************
FORM SCREEN2.
* MODIFY SCREEN IN MMRV
CLEAR IPUTTAB.
IPUTTAB-PROGRAM = 'SAPMM03Y'.
IPUTTAB-DYNPRO = '110'.
IPUTTAB-DYNBEGIN = 'X'.
APPEND IPUTTAB.
* UNTICK ALLOWED POSTING TO PREVIOUS PERIOD
CLEAR IPUTTAB.
IPUTTAB-FNAM = 'MARV-XRUEM'.
IPUTTAB-FVAL = ' '.
APPEND IPUTTAB.
* DISALLOWED BACKPOSTING GENERALLY
CLEAR IPUTTAB.
IPUTTAB-FNAM = 'MARV-XRUEV'.
IPUTTAB-FVAL = 'X'.
APPEND IPUTTAB.
* Specify that we are now done with this screen (Save it with F11)

CLEAR IPUTTAB.
IPUTTAB-FNAM = 'BDC_OKCODE'.
IPUTTAB-FVAL = '/11'.
APPEND IPUTTAB.
ENDFORM.
***********************************************************************
* FORM
: CLOSE-SESS
*
* DESCRIPTION : CLOSE THE SESSION
*
***********************************************************************
FORM CLOSE-SESS.
* closing the session.
IF P-RUN = 'X'.
* Auto run the Batch Input Program
CALL TRANSACTION 'MMRV'
USING IPUTTAB
MODE
'E'
UPDATE 'S'
MESSAGES INTO MESSTAB.
ELSE.
* Maual run the Batch Input Program
CALL FUNCTION 'BDC_INSERT'
EXPORTING
TCODE
= 'MMRV'
TABLES
DYNPROTAB = IPUTTAB.
ENDIF.
ENDFORM.
***********************************************************************
* FORM
: PRN-ULTAB
*
* DESCRIPTION : PRINT OK TABLE
*
***********************************************************************
FORM PRN_ULTAB.
WRITE: / ULTAB-BUKRS.
W-LINE-NO = W-LINE-NO + 1.
WRITE: '
RECORD# ', W-LINE-NO.
ENDFORM.
***********************************************************************
* FORM
: CRE-BATCH-SESS
*
* DESCRIPTION : CREATE BATCH SESSION
*
***********************************************************************
FORM CRE-BATCH-SESS.
** Create BTCI session **
CALL FUNCTION 'BDC_OPEN_GROUP'
EXPORTING
CLIENT = SY-MANDT
GROUP = P-BTCHSN
USER
= SY-UNAME
KEEP
= 'X'.
ENDFORM.

Delimiter for BDC Program

I use (tab and ,) delimeter for bdc but I could not upload data from note pad to sap.
As you mentioned that you have used ( tab & , ) this is wrong you have to use TAB OR ,
(comma) .
Use , (comma). While executing bdc you have to mention delimiter factor at bdc screen.
Nitin
Can anybody tell me, if we are using excel sheet as a data provider for BDC
Program, then how to define a delimiter so that my BDC programe should
automatically split the field.
You either save the excel sheet as Tab delimited file or .csv file. and declare your internal
table to get the corresponding the contents from the file. Then when its tab delimited or
.csv, SPLIT the contents into respective fields.
Here is a sample for CSV file :
*declaration of internal tables.
DATA : BEGIN OF IT_DUMMY OCCURS 0,
TEXT(500),
END OF IT_DUMMY.
DATA : BEGIN OF IT_MAIN OCCURS 0,
MATNR LIKE RMMG1-MATNR,
"material selection to change
DISLS LIKE MARC-DISLS,
"lot size key
END OF IT_MAIN.
*uploading the input file***********************************************
CALL FUNCTION 'UPLOAD'
EXPORTING
FILENAME
= INPUT
TABLES
DATA_TAB
= IT_DUMMY
EXCEPTIONS
CONVERSION_ERROR = 1
INVALID_TABLE_WIDTH = 2
INVALID_TYPE
=3
NO_BATCH
=4
UNKNOWN_ERROR
=5
OTHERS
= 6.
*appending it_main by splitting the uploaded file
LOOP AT IT_DUMMY.
SPLIT IT_DUMMY AT ',' INTO IT_MAIN-MATNR IT_MAIN-DISLS.

APPEND IT_MAIN.
ENDLOOP.

Example how Views are dealt in BDC


Can any body tell me some views of MM that we can use in BDC?
Rashi
Well here is an example for you to see how the views are dealt with in BDC's...
*****************************************************
****This is a BDC for Semi finished Materials********
report ZBDC_SEMIFIN
no standard page heading line-size 255.
include bdcrecx1.
Tables: Mara,"General Material Data
mard,"Storage Location Data for Material
mvke,"Sales Data for Material
Makt,"Material Descriptions
marc,"Plant Data for Material
mbew,"Material Valuation
rlgrap."Program Fields/Screen Fields for SAPLGRAP
Data: begin of ITAB occurs 0,"Internal table for Semi-Finished Material
*

Initial data
matnr like mara-matnr,
mbrsh like mara-mbrsh,
mtart like mara-mtart,

"Material Code
"Industry Data
"Material Type

Org Data
Werks
lgort
vkorg
vtweg

"Plant
"Storage Location
"Sales Orgnization
"Distribution Chanel

Basic 1
Maktx Like makt-maktx, "Description
meins like mara-meins, "Uom
matkl like mara-matkl, "Material Group
BISMT LIKE MARA-BISMT, " Old Material Number
spart like mara-spart, "Division
brgew(7),"like mara-brgew, "Gross Weight
gewei like MARA-GEWEI, "Weight Unit
ntgew(7)," like mara-ntgew, "Net Weight

like
like
like
like

marc-werks,
mard-lgort,
mvke-vkorg,
mvke-vtweg,

* Purchasing
MAKTL LIKE MARA-MATKL, "Material Group
ekwsl like MARA-EKWSL, " Purchasing Value Key
ekgrp like MARC-EKGRP, " Purchasing Group

*
*

Mrp 1
disgr
ekgrp
dismm
dispo
disls
BSTMI
BSTMA
BSTRF
BSTFE

like
like
like
like
like
like
like
like
like

MARC-DISGR,
MARC-EKGRP,
MARC-DISMM,
MARC-DISPO,
MARC-DISLS,
MARC-BSTMI,
MARC-BSTMA,
MARC-BSTRF,
MARC-BSTFE,

"Mrp Group
"Purchasing group
"Mrp Type
"Mrp Controller
"Lot Size

Mrp 2
beskz like MARC-BESKZ, "Procurement type
lgpro like MARC-LGPRO, "Production Storage Location
dzeit(3),"like MARC-DZEIT, "In house Production time
plifz(3),"like MARC-PLIFZ, "Planned delivery time
fhori(3),"like MARC-FHORI, "Sched margin key
eisbe like MARC-EISBE, "Safety stock

Mrp 3
PERKZ LIKE MARC-PERKZ,
vrmod like MARC-VRMOD, "Consumption mode
vint1(3)," like MARC-VINT1, "Backward Consumption period
vint2(3),"like MARC-VINT2, "Forward Consumption period
mtvfp like MARC-MTVFP, "Availability Check

Mrp 4
sbdkz like MARC-SBDKZ,
SAUFT like MARC-SAUFT,
SFEPR like MARC-SFEPR,

Work Scheduling View


ausme like MARC-AUSME, "Unit of issue
FEVOR LIKE MARC-FEVOR, "Production Scheduler
SFCPF like MARC-SFCPF, "Production Scheduler Profile
umren(5)," like RMMZU-UMREN, "Val for base uom
umrez(5) ,"like RMMZU-UMREz, "Value for uo issue

* Accounting 1
bklas like
vprsv like
verpr(7),"
STPRS like

"Individual/ Collective
"Repetitive Manufacturing
"REM Profile

MBEW-BKLAS, "Valuation Class


MBEW-VPRSV, "Price Control Indicator
like MBEW-VERPR, "Value/Price
MBEW-STPRS,

*COSTING
EKALR LIKE MBEW-EKALR," With qty str
LOSGR like MARC-LOSGR, " Costing Lot size
end of ITAB.
**********************************************************
Data: W_record type I, "Record Allready exists.
w_trecord type I. "Total record processed
start-of-selection.
perform upload.

"Upload Data from Text File

Perform Open_group.

"Create a session

clear : w_record,w_trecord.
perform semi. "Create Semi Finish Materials
if w_trecord gt 0 or w_record gt 0.
perform batch_job.
endif.
perform close_group.

"Close session

FORM SEMI.
loop at ITAB.
*
Check for material in master *************************
select single * from mara where matnr eq ITAB-matnr.
if sy-subrc ne 0.
w_trecord = w_trecord + 1.
*Initial Screen
perform bdc_dynpro
perform bdc_field

using 'SAPLMGMM' '0060'.


using 'BDC_CURSOR'
'RMMG1-MTART'.
perform bdc_field
using 'BDC_OKCODE'
'=AUSW'.
perform bdc_field
using 'RMMG1-MATNR'
ITAB-MATNR.
perform bdc_field
using 'RMMG1-MBRSH'
'M'.
perform bdc_field
using 'RMMG1-MTART'
'HALB'.
***********************Views**********************************
*Select Views
perform bdc_dynpro
using 'SAPLMGMM' '0070'.
perform bdc_field
using 'BDC_CURSOR'
'MSICHTAUSW-DYTXT(17'.
perform bdc_field
using 'BDC_OKCODE'
'/00'.
perform bdc_field
using 'MSICHTAUSW-KZSEL(01)'
'X'.
perform bdc_field
using 'MSICHTAUSW-KZSEL(09)'
'X'.
perform bdc_field
using 'MSICHTAUSW-KZSEL(12)'
'X'.
perform bdc_field
using 'MSICHTAUSW-KZSEL(13)'
'X'.
perform bdc_field
using 'MSICHTAUSW-KZSEL(14)'
'X'.
perform bdc_field
using 'MSICHTAUSW-KZSEL(15)'
'X'..
perform bdc_field
using 'MSICHTAUSW-KZSEL(17)'
'X'.
***********************Views**********************************
*perform bdc_dynpro
*perform bdc_field

using 'SAPLMGMM' '0070'.


using 'BDC_CURSOR'

*
*perform
*
*perform
*perform
*
*perform
*
*perform
*
*perform
*perform
*
*perform
*
*perform
*perform
*
*perform
*
*perform
*

bdc_field
bdc_dynpro
bdc_field
bdc_field
bdc_field
bdc_dynpro
bdc_field
bdc_field
bdc_dynpro
bdc_field
bdc_field
bdc_field

*Org Data
perform bdc_dynpro
perform bdc_field
perform bdc_field
perform bdc_field
perform bdc_field
*Basic 1
perform bdc_dynpro
perform bdc_field
perform bdc_field
perform bdc_field
perform bdc_field
perform bdc_field
perform bdc_field
perform bdc_field
perform bdc_field
perform bdc_field
perform bdc_field
perform bdc_field

'MSICHTAUSW-DYTXT(01)'.
using 'BDC_OKCODE'
'/00'.
using 'SAPLMGMM' '0070'.
using 'BDC_CURSOR'
'MSICHTAUSW-DYTXT(17)'.
using 'BDC_OKCODE'
'/00'.
using 'MSICHTAUSW-KZSEL(17)'
ITAB-KZSEL_17_011.
using 'SAPLMGMM' '0070'.
using 'BDC_CURSOR'
'MSICHTAUSW-DYTXT(01)'.
using 'BDC_OKCODE'
'/00'.
using 'SAPLMGMM' '0070'.
using 'BDC_CURSOR'
'MSICHTAUSW-DYTXT(13)'.
using 'BDC_OKCODE'
'=ENTR'.
using 'MSICHTAUSW-KZSEL(13)'
ITAB-KZSEL_13_012.
using 'SAPLMGMM' '0080'.
using 'BDC_CURSOR'
'RMMG1-LGORT'.
using 'BDC_OKCODE'
'=ENTR'.
using 'RMMG1-WERKS'
ITAB-WERKS.
using 'RMMG1-LGORT'
ITAB-LGORT.
using 'SAPLMGMM' '4004'.
using 'BDC_OKCODE'
'=SP09'.
using 'MAKT-MAKTX'
ITAB-MAKTX.
using 'MARA-MEINS'
ITAB-MEINS.
using 'MARA-MATKL'
ITAB-MATKL.
using 'MARA-BISMT'
ITAB-BISMT.
using 'MARA-SPART'
ITAB-SPART.
using 'MARA-MTPOS_MARA'
'NORM'.
using 'BDC_CURSOR'
'MARA-NTGEW'.
using 'MARA-BRGEW'
ITAB-BRGEW.
using 'MARA-GEWEI'
ITAB-GEWEI.
using 'MARA-NTGEW'

ITAB-NTGEW.
*Purchasing
perform bdc_dynpro
perform bdc_field
perform bdc_field
perform bdc_field
perform bdc_field
perform bdc_field
perform bdc_field
perform bdc_field

using 'SAPLMGMM' '4000'.


using 'BDC_OKCODE'
'=SP12'.
using 'MAKT-MAKTX'
ITAB-MAKTX.
using 'MARA-MEINS'
ITAB-MEINS.
using 'MARC-EKGRP'
ITAB-EKGRP.
using 'MARA-MATKL'
ITAB-MATKL.
using 'BDC_CURSOR'
'MARA-EKWSL'.
using 'MARA-EKWSL'
ITAB-EKWSL.

*MRP 1
perform bdc_dynpro
perform bdc_field

using 'SAPLMGMM' '4000'.


using 'BDC_OKCODE'
'=SP13'.
perform bdc_field
using 'MAKT-MAKTX'
ITAB-MAKTX.
perform bdc_field
using 'MARA-MEINS'
ITAB-MEINS.
perform bdc_field
using 'MARC-EKGRP'
ITAB-EKGRP.
perform bdc_field
using 'MARC-DISMM'
ITAB-DISMM.
perform bdc_field
using 'MARC-DISPO'
ITAB-DISPO.
perform bdc_field
using 'BDC_CURSOR'
'MARC-DISLS'.
perform bdc_field
using 'MARC-DISLS'
ITAB-DISLS.
IF ITAB-DISLS EQ 'EX'
.
perform bdc_field
using 'MARC-BSTMI'
ITAB-BSTMI."MIN LOT SIZE
perform bdc_field
using 'MARC-BSTMA'
ITAB-BSTMA."MAX LOT SIZE
perform bdc_field
using 'MARC-BSTRF'
ITAB-BSTRF."RNDING
ELSEIF ITAB-DISLS EQ 'FX'.
perform bdc_field
using 'MARC-BSTFE'
ITAB-BSTFE.
ENDIF.
*MRP 2
perform bdc_dynpro
perform bdc_field
perform bdc_field
perform bdc_field

using 'SAPLMGMM' '4000'.


using 'BDC_OKCODE'
'=SP14'.
using 'MAKT-MAKTX'
ITAB-MAKTX.
using 'MARC-BESKZ'

perform bdc_field
perform bdc_field
perform bdc_field
perform bdc_field
perform bdc_field
perform bdc_field
*MRP 3
perform bdc_dynpro
perform bdc_field
perform bdc_field
perform bdc_field
perform bdc_field
perform bdc_field
perform bdc_field
perform bdc_field
perform bdc_field
*MRP 4
perform bdc_dynpro
perform bdc_field
perform bdc_field
perform bdc_field
perform bdc_field
perform bdc_field
perform bdc_field

*Work Scheduling
perform bdc_dynpro
perform bdc_field
perform bdc_field
perform bdc_field

ITAB-BESKZ.
using 'MARC-LGPRO'
ITAB-LGPRO.
using 'MARC-DZEIT'
ITAB-DZEIT.
using 'MARC-PLIFZ'
ITAB-PLIFZ.
using 'MARC-FHORI'
ITAB-FHORI.
using 'BDC_CURSOR'
'MARC-EISBE'.
using 'MARC-EISBE'
ITAB-EISBE.
using 'SAPLMGMM' '4000'.
using 'BDC_OKCODE'
'=SP15'.
using 'MAKT-MAKTX'
ITAB-MAKTX.
using 'MARC-PERKZ'
ITAB-PERKZ.
using 'MARC-VRMOD'
ITAB-VRMOD.
using 'MARC-VINT1'
ITAB-VINT1.
using 'MARC-VINT2'
ITAB-VINT2.
using 'BDC_CURSOR'
'MARC-MTVFP'.
using 'MARC-MTVFP'
ITAB-MTVFP.
using 'SAPLMGMM' '4000'.
using 'BDC_OKCODE'
'=SP17'.
using 'MAKT-MAKTX'
ITAB-MAKTX.
using 'MARC-SBDKZ'
ITAB-SBDKZ.
using 'BDC_CURSOR'
'MARC-SFEPR'.
using 'MARC-SAUFT'
ITAB-SAUFT.
using 'MARC-SFEPR'
ITAB-SFEPR.

using 'SAPLMGMM' '4000'.


using 'BDC_OKCODE'
'=SP24'.
using 'MAKT-MAKTX'
ITAB-MAKTX.
using 'BDC_CURSOR'
'MARC-SFCPF'.

perform bdc_field
perform bdc_field
perform bdc_field
perform bdc_field
perform bdc_field

using 'MARA-MEINS'
ITAB-MEINS.
using 'MARC-FEVOR'
ITAB-FEVOR.
using 'MARC-LGPRO'
ITAB-LGPRO.
using 'MARC-SFCPF'
ITAB-SFCPF.
using 'MARC-DZEIT'
ITAB-DZEIT.

*Check for Conversation Factor


if ITAB-MEINS ne iTAB-ausme and iTAB-umren gt
and iTAB-umrez gt
perform bdc_dynpro
perform bdc_field

endif.
perform bdc_field
perform bdc_field
*Accounting
perform bdc_dynpro
perform bdc_field
perform bdc_field
perform bdc_field
perform bdc_field
perform bdc_field
perform bdc_field
perform bdc_field
perform bdc_field
IF ITAB-VPRSV = 'S'.
perform bdc_field

using 'SAPLMGMM' '0510'.


using:
'BDC_OKCODE'
'=ENTR',
'RMMZU-UMREN'
ITAB-UMREN,
'RMMZU-UMREZ'
ITAB-UMREZ.

using 'MARC-LGPRO'
itab-LGPRO.
using 'MARC-DZEIT'
itab-DZEIT.
using 'SAPLMGMM' '4000'.
using 'BDC_OKCODE'
'=SP26'.
using 'MAKT-MAKTX'
ITAB-MAKTX.
using 'MARA-MEINS'
ITAB-MEINS.
using 'MARA-SPART'
ITAB-SPART.
using 'BDC_CURSOR'
'MBEW-STPRS'.
using 'MBEW-BKLAS'
ITAB-BKLAS.
using 'MBEW-VPRSV'
ITAB-VPRSV.
using 'MBEW-STPRS'
ITAB-STPRS.
using 'MBEW-STPRS' "FILLS STD PRICE
ITAB-VERPR.

ELSEIF ITAB-VPRSV ='V'.


perform bdc_field
using 'MBEW-VERPR' "FILLS VALUE
ITAB-VERPR.
ENDIF.
*Cost Estimate
perform bdc_dynpro
perform bdc_field

0
0.

using 'SAPLMGMM' '4000'.


using 'BDC_OKCODE'
'=BU'.

perform bdc_field
perform

using 'MAKT-MAKTX'
ITAB-MAKTX.
bdc_field
using 'BDC_CURSOR'
'MARC-PRCTR'.
bdc_field
using 'MARA-MEINS'
ITAB-MEINS.
bdc_field
using 'MBEW-EKALR'
ITAB-EKALR.
bdc_field
using 'MARC-LOSGR'
ITAB-LOSGR.
bdc_transaction using 'MM01'.

perform
perform
perform
perform

REFRESH BDCDATA.
*

*************************************************************
else.
w_record = w_record + 1.
endif.

ENDLOOP.
ENDFORM.
form Upload.
CALL FUNCTION 'UPLOAD'
EXPORTING
CODEPAGE
FILENAME
FILETYPE
TABLES
DATA_TAB
EXCEPTIONS
CONVERSION_ERROR
INVALID_TABLE_WIDTH
INVALID_TYPE
NO_BATCH
UNKNOWN_ERROR
GUI_REFUSE_FILETRANSFER
OTHERS
ENDFORM.

= ' '
= ' '
= ' '
= ITAB
=
=
=
=
=
=
=

1
2
3
4
5
6
7.

form batch_job.
uline.
format color col_heading.
if w_trecord gt 0.
Write:/ 'Background Job has been Created for ',
w_trecord right-justified, 'Semi-Fin', 80 ''.
write:/ 'Please follow the following steps to run this job',
80 ''.
write:/ 'as listed below.', 80 ''.
format color col_normal.
skip.
write:/05 '1.Goto Transaction SM35', 80 ''.
write:/05 '2.Select your Session Name', 80 ''.
write:/05 '3.Click On Execute Button', 80 ''.

endif.
if w_record gt 0.
format color col_negative.
write:/ w_record ,'records already existed', 80 ''.
format color off.
endif.
uline.
endform.

Determine the number of lines on a screen for


programming BDC
Is there a way to determine the number of lines on a screen for programming BDC?
Many users have different size fonts and resolutions on each screen. The number of lines
vary.
Many ABAPERS have this problem, if a batch input has a table control, then the font size
changes from machine to machine as a result the no of entries keeps changing, so how to
determine the number of available lines depending on the font size.
Here is the solution code for this :***********************************************************************
*
* data for controlling paging on screen 0102
DATA: W_MAXLINES(2) TYPE N,
W_NEXT_LINE(3) TYPE N,
W_PAGE(1), "y = page forward, n otherwise
W_SCRLEN(2) TYPE I,
W_SCRLINE(2) TYPE I.
DATA: BEGIN OF W_HDR.
INCLUDE STRUCTURE D020S.
DATA: END OF W_HDR.
DATA: BEGIN OF W_FLD OCCURS 100.
INCLUDE STRUCTURE D021S.
DATA: END OF W_FLD.
DATA: BEGIN OF W_LOG OCCURS 20.
INCLUDE STRUCTURE D022S.
DATA: END OF W_LOG.
DATA: BEGIN OF W_MC OCCURS 20.
INCLUDE STRUCTURE D023S.
DATA: END OF W_MC.
DATA: BEGIN OF W_DYNPRONAME,
PROGRAM(8) VALUE 'SAPMM60X',
DYNPRO(4) VALUE '0102',
END OF W_DYNPRONAME.
***********************************************************************
*

FORM GET_MAX_LINES.
* set w_maxlines to the number of var-loop occurrences on the screen so
* that we know when to page forward on screen 0102
* also initialise w_next_line to zero for GET_NEXT_LINE
* this subroutine caters for all cases - including screens without loops
CLEAR: W_MAXLINES,
W_NEXT_LINE.
IMPORT DYNPRO W_HDR
W_FLD
W_LOG
W_MC
ID W_DYNPRONAME.
LOOP AT W_FLD WHERE LTYP EQ 'L'.
MOVE W_FLD-LINE TO W_SCRLINE. "first var-loop line
MOVE W_FLD-LBLK TO W_SCRLEN. "depth of loop block
EXIT.
ENDLOOP.
IF SY-SUBRC EQ 0
AND W_SCRLEN NE 0.
* sy-srows = total no of lines on screen
* w_scrline = actual first line of loop so that
* w_scrline - 1 = number of heading lines (before loop)
* 4 = no of lines at top of screen - command line, pushbuttons, 2 ulines
* 3 = no of lines after loop - uline & Page count
* w_scrlen = no of lines in loop block
* w_maxlines = sy-srows - ( wscrline - 1 ) - 4 - 3
* and then 1 less but not sure why!
W_MAXLINES = SY-SROWS - W_SCRLINE - 1 - 4 - 3.
W_MAXLINES = W_MAXLINES - 1.
W_MAXLINES = W_MAXLINES DIV W_SCRLEN.
ELSE.
MOVE 99 TO W_MAXLINES. "this required if no screen loop
ENDIF.
ENDFORM.
***********************************************************************
*
FORM GET_NEXT_LINE.
* set w_page if page forward is required
W_NEXT_LINE = W_NEXT_LINE + 1.
IF W_NEXT_LINE GT W_MAXLINES.
W_NEXT_LINE = 1.
W_PAGE = 'Y'.
ELSE.
W_PAGE = 'N'.

ENDIF.
ENDFORM.
***********************************************************************
*

How to used 3 tables for inner joins?


Inner joins using 3 tables
Try this :SELECT stpo~stlnr stpo~idnrk mast~matnr mara~mtart stpo~menge
INTO CORRESPONDING FIELDS OF TABLE zmat1 FROM mast
JOIN stpo ON stpo~stlnr = mast~stlnr
JOIN mara ON mara~matnr = mast~matnr
WHERE stpo~stlty = 'M' "AND stpo~idnrk IN s_matnr
AND mast~werks = 1000.
Here s_matnr is a select-options on the selection-screen.
Or this.
Code:
Select single Vbrk~Bukrs Vbrk~Kunrg Vbrk~Vbeln
Vbrk~Fkdat Vbrk~Bstnk_Vf Vbrk~Zterm
Tvzbt~Vtext
Vbak~Vbeln Vbak~Bstdk
Likp~Vbeln Likp~lfdat Likp~Lfuhr
into w_vbrk
from vbrk
inner join
Tvzbt on Tvzbt~Zterm
= Vbrk~Zterm and
Tvzbt~Spras
= sy-langu
Inner join
Vbfa as SalesLnk
on SalesLnk~vbeln = pu_vbeln
and
SalesLnk~vbtyp_v = c_order
inner join Vbak on Vbak~Vbeln
= SalesLnk~Vbelv
Inner join
Vbfa as DeliveryLnk
on DeliveryLnk~vbeln = pu_vbeln
and
DeliveryLnk~vbtyp_v = c_Delivery
inner join Likp on Likp~Vbeln
= DeliveryLnk~Vbelv
where vbrk~vbeln = pu_Vbeln.
This code locates sales, delivery and payment terms info from a billing document
number.

or
Here, this one also works fine :
select zfpcd~cadivi zfpcd~proforma zfpcd~factura zfpcd~aniofactura
zfpcd~montousd zfpcd~montoap zfpcd~ebeln zfpcd~inco1
zfpcd~lifnr lfa1~name1 zcdvs~status zfpcd~conint
into it_lista
from zfpcd inner join zcdvs
on zfpcd~ebeln = zcdvs~ebeln
and zfpcd~proforma = zcdvs~proforma
and zfpcd~lifnr = zcdvs~lifnr
inner join lfa1
on zfpcd~lifnr = lfa1~lifnr
where zcdvs~status = '04'.

Inner Join to retrieve the Material Valuation Class


*
* Inner Join to retrieve the Material Valuation Class pointing to
* which General Ledger.
*
* Based on transaction OBYC - Inventory Posting - BSX
*
* If you use inner join to read data from several logically
* connected tables instead of nested Select statements.
* It will reduce your network load.
*
* Written by : SAP Basis, ABAP Programming and Other IMG Stuff
*
http://www.sap-img.com
*
REPORT ZVALGL.
TABLES: MARA,
MAKT,
MBEW,
SKAT,
T025T,
T030.

"General Material Data


"Material Descriptions
"Material Valuation
"G/L Account Master Record
"Valuation Class Descriptions
"Standard Accounts Table

DATA: BEGIN OF WA,


BKLAS TYPE MBEW-BKLAS,
BKBEZ TYPE T025T-BKBEZ,
MTART TYPE MARA-MTART,
MATNR TYPE MARA-MATNR,
MAKTX TYPE MAKT-MAKTX,
END OF WA,
ITAB LIKE SORTED TABLE OF WA
WITH NON-UNIQUE KEY BKLAS MATNR.
SELECT-OPTIONS: PLANT
FOR MBEW-BWKEY MEMORY ID PLT,
MATLTYPE FOR MARA-MTART MEMORY ID TYP,
MATERIAL FOR MBEW-MATNR MEMORY ID MAT,

CHARTACC FOR T030-KTOPL MEMORY ID KTO.


SELECT P~BKLAS
F~MATNR F~MTART
G~MAKTX
T~BKBEZ
INTO CORRESPONDING FIELDS OF TABLE ITAB
FROM ( ( ( ( MBEW AS P
INNER JOIN MARA AS F ON P~MATNR = F~MATNR )
INNER JOIN MAKT AS G ON P~MATNR = G~MATNR )
INNER JOIN T025T AS T ON P~BKLAS = T~BKLAS ) )
WHERE P~BWKEY IN PLANT
AND F~MTART IN MATLTYPE
AND P~MATNR IN MATERIAL
AND G~SPRAS = 'E'.
LOOP AT ITAB INTO WA.
CLEAR: T030, SKAT.
SELECT SINGLE * FROM T030 WHERE BKLAS = WA-BKLAS
AND KTOSL = 'BSX'.
SELECT SINGLE * FROM SKAT WHERE SAKNR = T030-KONTS
AND SPRAS = 'E'.
WRITE: / WA, T030-KONTS, SKAT-TXT20.
ENDLOOP.
***************************************************

Select statement with inner join is taking forever


Following is the select stmt which is taking forever.
SELECT MKPF~BUDAT MKPF~CPUTM
MSEG~MATNR MSEG~WERKS MSEG~EBELN
MSEG~EBELP MSEG~ERFMG
INTO CORRESPONDING FIELDS OF TABLE
W_DTL_INVOICE
FROM MKPF INNER JOIN MSEG
ON MKPF~MBLNR = MSEG~MBLNR
AND MKPF~MJAHR = MSEG~MJAHR
WHERE MKPF~BUDAT > '20040721' AND
MSEG~BWART = '101'
AND
MSEG~BUKRS = '1733'.
It does not have much records.
Can somebody let me know how to fine tune this statement.
Kasi
I have gone through the same problem last year. This is the solution I made. My program
spended more than an hour to
select 5000 records from mkpf inner mseg(From a range of 100000 records) .

Now it needs less than 15 seconds to perform the same task.


Try this changes
** in global data add these two hashed tables
data: begin of wa_mkpfmseg,
mblnr like mkpf-mblnr,
mjahr like mkpf-mjahr,
zeile like mseg-zeile,
bukrs like mseg-bukrs
bwart like mseg-bwart,
budat like mkpf-budat,
cputm like mkpf-cputm,
matnr like mseg-matnr,
werks like mseg-werks,
ebeln like mseg-ebeln,
ebelp like mseg-ebelp,
erfmg like mseg-erfmg,
end of wa_mkpfmseg.
data ht_mkpfmseg like hashed table of wa_mkpfmseg
with unique key mblnr mjahr zeile
with header line.
data: begin of wa_mkpfmsegSel,
budat like mkpf-budat,
cputm like mkpf-cputm,
matnr like mseg-matnr,
werks like mseg-werks,
ebeln like mseg-ebeln,
ebelp like mseg-ebelp,
erfmg like mseg-erfmg,
end of wa_mkpfmseg.
data ht_mkpfmsegSel like hashed table of wa_mkpfmsegSel
with unique key budat cputm matnr werks ebeln ebelp
with header line.
** change your select sentence to look like this:
select mkpf~mblnr
mkpf~mjahr
mseg~zeile
mseg~bukrs
mseg~bwart
MKPF~BUDAT MKPF~CPUTM
MSEG~MATNR MSEG~WERKS MSEG~EBELN
MSEG~EBELP MSEG~ERFMG
INTO TABLE ht_mkpfmseg
FROM MKPF INNER JOIN MSEG
ON
mkpf~mandt = mseg~mandt
AND
MKPF~MBLNR = MSEG~MBLNR
AND MKPF~MJAHR = MSEG~MJAHR
where mkpf~budat > '20040721'.
loop at ht_mkpfmseg.

= '101'

cputm

werks

check ht_mkpfmseg-bukrs = '1733' and ht_mkpfmseg-bwart


read table ht_mkpfmsegsel with table key
budat = ht_mkpfmseg-budat
cputm = ht_mkpfmsegmatnr
werks

= ht_mkpfmseg-matnr
= ht_mkpfmseg-

ebeln = ht_mkpfmseg-ebeln
ebelp = ht_mkpfmseg-ebelp
transporting erfmg.
if sy-subrc <> 0.
move-corresponding ht_mkpfmseg to ht_mkpfmsegsel.
insert table ht_mkpfmsegsel.
else.
ht_mkpfmsegSel-budat = ht_mkpfmseg-budat.
ht_mkpfmsegSel-cputm = ht_mkpfmseg-cputm.
ht_mkpfmsegSel-matnr = ht_mkpfmseg-matnr,
ht_mkpfmsegSel-werks = ht_mkpfmseg-werks.
ht_mkpfmsegSel-ebeln = ht_mkpfmseg-ebeln.
ht_mkpfmsegSel-ebelp = ht_mkpfmseg-ebelp.
add ht_mkpfmseg-erfmg to ht_mkpfmsegSel-erfmg.
modify table ht_mkpfmsegSel transporting erfmg.
endif.

endloop.
" at this point ht_mkpfmsegSel has the data collected that you want.
loop at ht_mkpfmsegSel.
.... Here put the code between your select ... endselect.
endloop.

This should run faster because of the next reasons:


1. you're not distracting the sql optimizer when it analizes the sql where clause. It makes
use of the first index declared
on mkpf (budat-mblnr)2. the data is selected into a hashed table which are the faster access tables provided by
SAP from 4.0 up to 4.6c
(I don't know about 4.7)
3. As the select isn't restricting bukrs and bwart (but there is a good reason on this: it's
faster to read 100000 records into
a hashed table and then filter the 80000 unwanted than to select the 20000 records via
non index fields in the where clause.
I tested it in my own programs).
I hope this help you. If not, just let us know.
Kind regards
***********************************

S-ar putea să vă placă și