Rule Definition
This is one of the main benefit and principle of Object-Oriented design and coding: Encapsulation. If direct access to object members is allowed through Public members, there is a significant increase of the cost and risk of changes as well as an increase of security risks. However, a public member can be flagged with the READ-ONLY attribute in order to avoid external modification.
Remediation
General way is to implement methods to access Data Members. However, if the member is mainly read by external methods, then you can use the READ-ONLY attribute.
Violation Code Sample
CLASS table_content DEFINITION.
PUBLIC SECTION.
METHODS: calc_spfli,
calc__sflight.
DATA: wa_spfli TYPE spfli,
wa_sflight TYPE sflight.
wa_disp TYPE i.
ENDCLASS
Fixed Code Sample
CLASS table_content DEFINITION.
PUBLIC SECTION.
METHODS: calc_spfli,
calc__sflight,
* Define accessors to members
get_spfli,
get_sflight.
DATA: wa_disp TYPE i read-only.
PRIVATE SECTION.
DATA: wa_spfli TYPE spfli,
wa_sflight TYPE sflight.
ENDCLASS
Reference
ABAP Objects - An Introduction to Programming SAP Applications
Horst Keller & Sascha Kreger
SAP PRESS
Related Technologies
Technical Criterion
Programming Practices - Modularity and OO Encapsulation Conformity
About CAST Appmarq
CAST Appmarq is by far the biggest repository of data about real IT systems. It's built on thousands of analyzed applications, made of 35 different technologies, by over 300 business organizations across major verticals. It provides IT Leaders with factual key analytics to let them know if their applications are on track.