chapter 03abap objects obsolete statements

14
IBM Global Services ABAP Objects - Obsolete sta tements | 11.04.02 March-2005 © 2005 IBM Corporation ABAP Objects – Obsolete Statements

Upload: sastry

Post on 26-Dec-2015

7 views

Category:

Documents


3 download

DESCRIPTION

Ya

TRANSCRIPT

Page 1: Chapter 03ABAP Objects Obsolete Statements

IBM Global Services

ABAP Objects - Obsolete statements | 11.04.02

March-2005 © 2005 IBM Corporation

ABAP Objects – Obsolete Statements

Page 2: Chapter 03ABAP Objects Obsolete Statements

IBM Global Services

© 2005 IBM Corporation2 March-2005ABAP Objects - Obsolete statements | 11.04.02

Objectives

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

Obsolete Flow control

Obsolete Internal Table Processing

Page 3: Chapter 03ABAP Objects Obsolete Statements

IBM Global Services

© 2005 IBM Corporation3 March-2005ABAP Objects - Obsolete statements | 11.04.02

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.

Page 4: Chapter 03ABAP Objects Obsolete Statements

IBM Global Services

© 2005 IBM Corporation4 March-2005ABAP Objects - Obsolete statements | 11.04.02

Obsolete Declarations : Internal Standard Tables

Defining a standard table with addition OCCURS is not permitted.

Obsolete syntax : DATA t_mara LIKE mara OCCURS 10.

New syntax : DATA t_mara TYPE STANDARD TABLE OF mara INITIAL SIZE 0.

Page 5: Chapter 03ABAP Objects Obsolete Statements

IBM Global Services

© 2005 IBM Corporation5 March-2005ABAP Objects - Obsolete statements | 11.04.02

Obsolete Declarations : Internal Standard Tables

Table declaration with header line is not permitted.

Obsolete syntax : DATA : BEGIN OF t_info OCCURS 10, v_data(10) type c, END OF t_info. New syntax: DATA : BEGIN OF w_info, v_data(10) type c, END OF w_info.

DATA t_info LIKE STANDARD TABLE OF w_info.

Page 6: Chapter 03ABAP Objects Obsolete Statements

IBM Global Services

© 2005 IBM Corporation6 March-2005ABAP Objects - Obsolete statements | 11.04.02

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 :READ TABLE t_spfli WITH KEY carrid = ‘AA’.

New syntax :READ TABLE t_spfli WITH KEY carrid = ‘AA’ INTO w_spfli.

Page 7: Chapter 03ABAP Objects Obsolete Statements

IBM Global Services

© 2005 IBM Corporation7 March-2005ABAP Objects - Obsolete statements | 11.04.02

Obsolete Declarations : Ranges Tables

Declaration of range table is changed.

Obsolete syntax : RANGES r_vbeln FOR vbap-vbeln.

New syntax : DATA r_vbeln LIKE RANGE OF vbap-vbeln INITIAL SIZE 10.DATA: wa_range LIKE LINE OF r_vbeln.

wa_range-sign = 'I'.wa_range-option = 'EQ'.wa_range-high = '0000000234'.wa_range-low = '0000000001'.

APPEND wa_range TO r_vbeln.

Page 8: Chapter 03ABAP Objects Obsolete Statements

IBM Global Services

© 2005 IBM Corporation8 March-2005ABAP Objects - Obsolete statements | 11.04.02

Obsolete Flow Control : Relational Operators

Obsolete Relational Operators should be used only outside of ABAP Objects in Logical expressions

Obsolete Operator Valid Operator

>< <> , NE

=< <= , LE

=> >= , GE

Page 9: Chapter 03ABAP Objects Obsolete Statements

IBM Global Services

© 2005 IBM Corporation9 March-2005ABAP Objects - Obsolete statements | 11.04.02

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 :ON CHANGE OF dobj.statement block.ENDON.

New Syntax :Use IF control structure with an explicit buffer variable used to track change.

Page 10: Chapter 03ABAP Objects Obsolete Statements

IBM Global Services

© 2005 IBM Corporation10 March-2005ABAP Objects - Obsolete statements | 11.04.02

Replacement of the ‘ON CHANGE OF’ Statement (Contd.)

Example with Replacement Syntax using a Buffer (Auxiliary field)

New Replacement Syntax :CLEAR carrid_buffer.SELECT * FROM spfliINTO spfli_waORDER BY carrid deptime.IF spfli_wa-carrid <> carrid_buffer.carrid_buffer = spfli_wa-carrid.append spfli_wa to t_spfli.ENDIF.ENDSELECT.

Page 11: Chapter 03ABAP Objects Obsolete Statements

IBM Global Services

© 2005 IBM Corporation11 March-2005ABAP Objects - Obsolete statements | 11.04.02

Demonstration

Showing the syntax error when using obsolete statement (s) in ABAP objects with suitable example.

Page 12: Chapter 03ABAP Objects Obsolete Statements

IBM Global Services

© 2005 IBM Corporation12 March-2005ABAP Objects - Obsolete statements | 11.04.02

Practice

Showing the syntax error when using obsolete statement (s) in ABAP objects with suitable example.

Page 13: Chapter 03ABAP Objects Obsolete Statements

IBM Global Services

© 2005 IBM Corporation13 March-2005ABAP Objects - Obsolete statements | 11.04.02

Summary

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

Page 14: Chapter 03ABAP Objects Obsolete Statements

IBM Global Services

© 2005 IBM Corporation14 March-2005ABAP Objects - Obsolete statements | 11.04.02

Questions

What is the new syntax for range table?

What side effect is produced by ‘ON CHANGE OF’ statement?