ABAP Objects - Obsolete StatementsIBM Global Services
© 2005 IBM Corporation
The participants will be able to :
Describe the context of obsolescence of certain syntax in ABAP
Language
Describe some of the most common examples of obsolete ABAP
syntax
Obsolete Declarations
IBM Global Services
© 2005 IBM Corporation
Context of Obsolescence of certain syntax in ABAP Language
SAP has carried out a clean-up of the ABAP language in ABAP
Objects. As part of this language clean-up, in ABAP Objects
stricter syntax checks are performed for constructs that were
previously allowed and sometimes obsolete statements are not
allowed at all.
For reasons of backward compatibility , obsolete statements are
still allowed outside of ABAP objects, but every effort should be
made not to use these obsolete statements in newly developed
programs.
ABAP Objects - Obsolete statements | 11.04.02
ABAP Objects are introduced in release 4.5. ABAP Objects contains a
complete set of object-oriented statements. Object orientation in
ABAP builds on existing language and is largely compatible with it.
Statements in ABAP Objects cover almost the complete ABAP language
set ; however , specific obsolete language constructs are not
allowed in connection with ABAP objects due to clean-up of the ABAP
language.
Statements those are made obsolete in ABAP OOP context are not
necessarily related to Unicode programs, though the introduction of
Unicode certainly changes the strictness of syntax checks. It is
important to note that the Unicode changes are a different set of
changes compare to changes in ABAP Objects.
IBM Global Services
© 2005 IBM Corporation
Defining a standard table with addition OCCURS is not
permitted.
Obsolete syntax :
New syntax :
DATA t_mara TYPE STANDARD TABLE OF mara INITIAL SIZE 0.
ABAP Objects - Obsolete statements | 11.04.02
TYPE | LIKE TABLE OF , the new additions of the DATA and TYPES
statements. For initial memory requirement use the INITIAL SIZE
addition.
This syntax change is not Unicode motivated and will be triggered
regardless of the status of the Unicode check flag.
This obsolete syntax is only flagged as a syntax error in OO
context.
Table types STANDARD,SORTED,HASHED,ANY,INDEX are valid in OO
context.
IBM Global Services
© 2005 IBM Corporation
Table declaration with header line is not permitted.
Obsolete syntax :
v_data(10) type c,
END OF t_info.
ABAP Objects - Obsolete statements | 11.04.02
Internal tables with header lines should not be declared in classes
because depending on the statement , the system may access tables
with a header either by accessing the table body, or by accessing
the header itself. The table name should signify the table
unambiguously. This makes programs easier to read. Tables with
headers do not offer any performance advantages.
In the new syntax , the roll of the header line is taken over by
the work area w_info.
Note:
When you call external procedures (subroutines and function
modules) that are contained in the parameter interface TABLES
parameter, be aware that this TABLES parameter always contains both
a table body and a header. When a table without a header is
transferred, the header of the TABLES parameter remains blank. When
calling these procedures in methods, you must check to see whether
the procedure expects to receive and evaluate the header. If
necessary, adapt or rewrite the procedure. Method interfaces do not
have TABLES parameters.
IBM Global Services
© 2005 IBM Corporation
Obsolete Internal table Processing
When reading an internal table you have to mention the work area
explicitly as table with header line is not supported in OO
context.
Obsolete syntax :
New syntax :
ABAP Objects - Obsolete statements | 11.04.02
The internal table read statement syntax is as follows
READ TABLE itab {table_key|free_key|index} result
The result portion of the syntax has the following options
{ INTO wa [ transport_options ] } | { ASSIGNING <fs> } | {
REFERENCE INTO dref } | { TRANSPORTING NO FIELDS }
The fact that internal table with header lines are not allowed in
the Object oriented context also effects the statement LOOP
AT.
Previously you could simply loop at the table and the header line
contained the table line reference. In the OO contaxt, the addition
of a result,
same as for the READ statement, is necessary to reference the data
during the loop.
IBM Global Services
© 2005 IBM Corporation
Obsolete syntax :
DATA: wa_range LIKE LINE OF r_vbeln.
wa_range-sign = 'I'.
wa_range-option = 'EQ'.
wa_range-high = '0000000234'.
wa_range-low = '0000000001'.
IBM Global Services
© 2005 IBM Corporation
Obsolete Flow Control : Relational Operators
Obsolete Relational Operators should be used only outside of ABAP
Objects in Logical expressions
Obsolete Operator
Valid Operator
ABAP Objects - Obsolete statements | 11.04.02
These new valid operators will work both in and out of the OO
context.
IBM Global Services
© 2005 IBM Corporation
Replacement of the ‘ON CHANGE OF’ Statement
‘ON CHANGE OF‘ statement should not be used in the OO context as it
has side-effect that produces wrong result.
Obsolete Syntax :
New Syntax :
Use IF control structure with an explicit buffer variable used to
track change.
ABAP Objects - Obsolete statements | 11.04.02
The problem is that using ON CHANGE OF does seem to work in loop
processing. However, it only works the first time the code is used,
and on the second pass you may get unexpected results. Look at the
code sample below :
DATA: i_tab LIKE STANDARD TABLE OF MARA,
w_tab LIKE MARA.
Example with Replacement Syntax using a Buffer (Auxiliary
field)
New Replacement Syntax :
FORM PRINT_ITAB.
ON CHANGE OF matnr.
ENDLOOP.
ENDFORM
The actual output is simply "5 6 7”, instead of "5 6 6 7" . What
happens during the ON CHANGE OF is that SAP holds the contents of
the last ON CHANGE OF variable in memory, and this does not get
refreshed or cleared during loop processing. For this reason you
should avoid using ON CHANGE OF when processing loops.
IBM Global Services
© 2005 IBM Corporation
Demonstration
Showing the syntax error when using obsolete statement (s) in ABAP
objects with suitable example.
ABAP Objects - Obsolete statements | 11.04.02
IBM Global Services
© 2005 IBM Corporation
Practice
Showing the syntax error when using obsolete statement (s) in ABAP
objects with suitable example.
ABAP Objects - Obsolete statements | 11.04.02
IBM Global Services
© 2005 IBM Corporation
Defining a standard table with addition OCCURS is not
permitted
Table declaration with header line is not permitted
Declaration of range table is changed
New syntax :
DATA r_vbeln LIKE RANGE OF vbap-vbeln.
ON CHANGE OF statement should not be used in the OO context as it
has side-effect that produces wrong result.
In stead of this statement use IF control structure when outside
the table loop and AT NEW and AT END OF statement when inside the
table loop
ABAP Objects - Obsolete statements | 11.04.02
IBM Global Services
© 2005 IBM Corporation
What side effect is produced by ‘ON CHANGE OF’ statement?
ABAP Objects - Obsolete statements | 11.04.02