12   Output Data On The Screen Feedback

12 Output Data On The Screen Feedback

How to Output "Hello World" in Different Ways

Introduction to Output Techniques

  • The lesson covers various methods for outputting the "Hello World" string, including non-translatable and translatable techniques.
  • A link is provided for additional help through the ASAP help portal, emphasizing the importance of structured code with comments.

Hard-Coded Text Output

  • The first method demonstrated is hard-coded text output using a simple write statement to display "Hello World".
  • To print "Hello World" on a new line, a slash is used within the write statement.
  • Chained hard-coded text can be displayed by using one write statement with multiple strings combined using colons and slashes.

Using Variables for Output

  • A string variable named GB_hello_world_string is introduced, allowing for dynamic content without hard-coding.
  • The variable must be declared with a type (string), and initialized with the value "Hello World".
  • An example of character variables is given, where a character type must have its length defined; default length is 1.

Syntax Checking and Limitations

  • After coding, syntax checking ensures that outputs are correctly displayed. Hard-coded text limits language support since changes require source code modifications.

Translatable Techniques Overview

  • Transitioning to translatable techniques allows for better multilingual support without altering source code directly.

Creating Text Elements

  • Text elements are standalone data dictionary objects that facilitate translation management separate from program logic.
  • Instructions on creating text elements include naming conventions and activation processes before they can be utilized in code.

Implementing Text Elements in Code

  • To use a defined text element in code, it’s referenced by its name; if not found, fallback to hard-coded strings occurs.
  • This technique encourages best practices by separating translatable content from core programming logic.

How to Define and Use Text Elements in SAP

Creating Text Elements

  • The speaker demonstrates how to create a text element by double-clicking on its name, which prompts the system to check for its existence. If not found, it offers to create one.
  • Upon creation, the text element is prefilled with hard-coded text, allowing for easier activation of the code compared to previous methods.

Handling Undefined Text Elements

  • When attempting to output an undefined text element (e.g., number three), if it doesn't exist, the system will display a hard-coded string instead of nothing.
  • This approach is beneficial when customers log in using different languages (like Japanese), ensuring they see at least some content rather than an empty screen.

Best Practices for Text Elements

  • It’s recommended to always use text elements in customer programs. However, during testing or prototyping phases, it's acceptable not to focus on them as they are primarily for internal use.

Formatting Output in SAP

Enhancing Screen Output

  • The speaker discusses formatting options like changing background colors and creating horizontal lines for better visual separation of topics.
  • A skip statement can be used to add line breaks between outputs, enhancing readability.

Changing Background Colors

  • To change background colors behind text headers, format color constants are utilized before writing statements.
  • The speaker provides a list of eight defined colors available for background changes and explains two methods: using constants or numerical values associated with specific colors.

Additional Write Options in SAP

Utilizing Write Statement Features

  • Additional write options include specifying positions or lengths when displaying strings. This allows more control over how data appears on the screen.
  • The speaker emphasizes that while many options exist within the write statement, not all are available across different versions of SAP; backward-compatible options should be prioritized.

How to Display Strings and Use System Variables in Programming

Displaying Strings with Positioning

  • The speaker discusses displaying the "Hello World" string, emphasizing the importance of positioning. Initially, they mention starting from a fixed position (20), but later express the need for dynamic positioning based on where the string starts.
  • A solution is proposed using an "under" statement that allows text to be displayed beneath another data object, which simplifies adjustments when customer requirements change.
  • Instead of hardcoding strings, the speaker suggests using a string variable for flexibility. This way, if changes are needed, only the variable's value needs to be updated.
  • The process of declaring a string variable is explained. By assigning "Hello World" to this variable, it becomes easier to manage and modify as needed.

Advanced String Manipulation

  • The speaker introduces displaying a substring by specifying both a starting position (20) and length (16 characters). They demonstrate how to implement this in code effectively.
  • An example is provided where part of a string variable is displayed starting from position 14 and showing 10 characters. This showcases versatility in handling strings dynamically.
  • The same logic applies when working with character variables; thus demonstrating consistency across different data types in output formatting.

Utilizing Icons for Status Indication

  • The discussion shifts towards displaying icons within text outputs. Three common icons are introduced: green light (success), yellow light (warning), and red light (error).
  • Icons can enhance user feedback by visually indicating program status alongside textual messages.
  • The speaker reassures viewers that memorizing icon codes isn't necessary; they can access available icons through specific program commands.

Understanding System Variables

  • System variables are highlighted as automatically filled by the runtime environment and accessible across programs. These variables provide insights into system states during execution.
  • To find specific system values like language or username, users can navigate through transaction SE11 and search for relevant keys within system structures.
  • For instance, retrieving the current system language involves writing specific statements that reference component names found in system structures.

This structured approach provides clarity on how to manipulate strings dynamically while also utilizing visual indicators and understanding essential system variables within programming contexts.

Understanding System Variables and Language Settings

Overview of System Configuration

  • The term for "date" is derived from German, indicating a multilingual aspect in system settings.
  • The program being discussed is named "Opti Brooke," with the system identified as "Why I Sit" and the client referred to as "Sy Man."
  • All system variables are stored within a structure called sys T, emphasizing the importance of structured data management.
  • The output confirms that the system language is set to English, with user credentials logged under "BC User."
  • Current date and time are noted as May 10, 2016, at 14:28, providing context for when this configuration was made.

Key Learning Outcomes

  • Participants have learned how to create hard-coded text for rapid testing of programs aimed at prototyping.
  • Techniques for creating translatable text were covered, preparing code for localization into various languages.
  • Instructions on changing background colors of texts were provided, enhancing visual customization options.
  • Additional writing options such as position length and parameters were introduced, expanding formatting capabilities.