Applying Other Techniques to Dynamic Form Elements

Objective

After completing this lesson, you will be able to implement display patterns for forms

Display Patterns

The options for formatting output fields are as follows:

  • With patterns, for example, date formats and omission of leading zeros.
  • Through checking the Limit Length on the Field tab page of the Object palette (output length).
  • In the form data provider, through offsets and compression of blanks.

The display pattern describes how the data is displayed at runtime in the document.

There is a set of rule-based specifications to govern the formatting and parsing of the following fields:

  • Dates
  • Times
  • Numeric Data
  • Text Data

For example, the current date (which technically has the format YYYYMMDD, for example, 20241219) can be displayed as 2024-12-19, or Thursday, December 19, 2024.

In some parts of the documentation, you also find the term "picture clauses" instead of the display pattern.

Display patterns are optional and you should use them only when necessary. If you do not use them, a standard format is used based on the locale (the combination of language and country). You specify a display pattern on the Field tab page of the Object palette. The drop-down list lets you choose from some typical display patterns, but you are also free to type in your own.

Edit Pattern on the Field tab page and Validation Pattern on the Value tab page are irrelevant.

Data Pattern on the Binding tab page defines how a data field should be read. As all date/time fields coming from the context are automatically parsed correctly, you should not manually set the Data Pattern.

Display patterns consist of the following:

  • Special Symbols

    Symbols are dependent on the type of the field. For example, MMMM stands for the full month name. These symbols are resolved at runtime, according to the appropriate locale. For instance, MMMM could result in January.

  • Literals

    To include a phrase in a pattern, delimit the text string with single quotation marks ('...'). For example, 'Your payment is due no later than' MM-DD-YY.

  • The comma (,), the dash (-), the colon (:), the slash (/), the period (.), and the space ( )

    These are treated as literal values and can be included anywhere in a pattern.

Be aware that display patterns cannot be translated. All patterns are case-sensitive.

After you type the desired display pattern, ensure that you press ENTER. Adobe LiveCycle Designer then checks whether the pattern is syntactically correct.

If you use a long display pattern, ensure that the field for which you define the pattern has enough space. To find out if enough space has been provided, activate the form and run a test.

Sometimes, data can come in various forms; in this case, a single simple pattern would not work. For example, number plates vary a lot from state to state. You can write the pattern several different ways. At runtime, the system uses the pattern that matches the data.

The syntax for defining a number of acceptable patterns is:

<category_name>{<pattern>}|<category_name>{<pattern>}

You can specify an unlimited number of patterns. <category_name> can be date, time, num, or text, for example, text {AA-99}|text{AAA-999} text{AA-99}|text{AAA-999}.

Date Pattern Symbols

Date Pattern Symbols

The table shows the date pattern symbols and offers a description for each instance:

PatternDescription
DOne- or two-digit (1-31) day of the month
DDZero-padded two-digit (01-31) day of the month
MOne or two-digit (1-12) month of the year
MMZero-padded two-digit (01-12) month of the year
MMMAbbreviated month name
MMMMFull month name
EEAbbreviated weekday name
EEEEFull weekday name
YYTwo-digit year
YYYYFour-digit year

For a full list of date pattern symbols, consult the Adobe LiveCycle Designer online manual.

Time Pattern Symbols

Time Pattern Symbols

The table shows the time pattern symbols and offers a description for each instance:

PatternDescription
hOne- or two-digit (1-12) hour of the meridian (AM/PM)
hhZero-padded two-digit (01-12) hour of the meridian (AM/PM)
HOne- or two-digit (0-23) hour of the day
HHZero-padded two-digit (0-23) hour of the day
MOne- or two-digit (0-59) minute of the hour
MMZero-padded two-digit (00-59) minute of the hour
SOne- or two-digit (0-59) second of the minute
SSZero-padded two-digit (00-59) second of the minute
AMeridian (AM or PM)
ZAbbreviated time-zone name, for example, GMT, GMT+05:00, GMT-00:30, EST, and PDT

For a full list of time pattern symbols, consult the Adobe LiveCycle Designer online manual.

Pattern Examples (Date or Time Fields)

Patterns for Date and Time Fields

The table shows examples of patterns for date and time fields:

Custom PatternInput Value (ABAP)Resulting Formatted Value
N/AN/ALocale en_USLocale de_DE
MMM DD, YYYY20211219Dec 19, 2024Dez 19, 2024
EEEE, 'the' D. MMMMYYYY20211219

Thursday, the 19.

December 2024

Donnerstag, the 19.

Dezember 2024

h:MM A0910309:10 AM9:10 AM 

The table shows some custom patterns that you can define for formatting date and time values using a display pattern. Note that only special symbols (for example, DD and EEEE) are locale-dependent. The sequence of the individual parts of the patterns remains unchanged in all languages, and everything you include in single quotation marks remains unchanged as well.

Predefined Formatting of Date Fields

Patterns cannot be adjusted when a form is translated. As a consequence, setting a fixed pattern results in extra effort. On the other hand, in some cases, you would like to set some features of the date. In a table, for example, you might want to make sure a date field fits into a cell. To combine the flexibility of a localized date format with a specific date length, a script is needed. This is why Adobe LiveCycle Designer for SAP, comes with four predefined date objects, which are assembled in the Library palette on the Form Builder tab page.

You insert a predefined date object just as you would insert a standard object or one of your own custom objects, by dragging it to its position on any page.

The FormCalc scripting that is executed at event initialize is as follows:

$.format.picture = DateFmt(1, $.locale); // for display

$.ui.picture = DateFmt(1, $.locale); // for user input

Instead of digit 1 for a short format, you would have 2 for a medium format, 3 for a long format, and 4 for a full format.

Hint

A pattern that you might use in addition to the coding is overridden by the scripting.

Country-Specific Formatting with No Patterns

Default settings for country-specific formatting with no patterns is as follows:

  • If you do not use display patterns or coding, a medium format is used for dates.
  • If there are no pattern entries, data is formatted according to the specified locale.
  • A prerequisite: is that the locale is specified for the form data provider.

A locale is a combination of a country and a language.

Numeric Pattern Symbols

Numeric Pattern Symbols

The table shows the numeric pattern symbols and offers a description for each instance:

PatternDescription
9A single digit, or a zero digit if empty or a space
8A single digit, or a zero digit if empty or a space
zA single digit, or nothing if empty, a space, or the zero digit
ZA single digit, or nothing if empty, a space, or the zero digit
sA minus sign if the number is negative and nothing otherwise
SA minus sign if the number is negative and a space otherwise
$The currency symbol of the ambient locale
,The grouping separator of the ambient locale
.The decimal radix of the ambient locale 

For a full list of numeric pattern symbols, consult the Adobe LiveCycle Designer online manual.

To evaluate currency-specific or unit-specific information on decimal places, you must explicitly use display pattern 8 (the backend system distinguishes between internal and external representations of currencies and quantities). For example, the internal digit of 1000 might be USD 10.00 or JPY 1000 when printed).

ABAP dictionary information about decimal places and output lengths is evaluated automatically. It is represented by the options Limit Leading Digits and Limit Trailing Digits. Make sure that you deselect these options if you want your own display pattern to work.

You must allow for the maximum number of decimals that you expect. If you have a field type decimal field that at runtime can have amounts with, say, USD and JPY, a suitable display pattern could be zzz,zzz,zz9.88.

Pattern Examples (Numeric Fields)

Patterns for Numerical Fields

The table shows examples of patterns for numerical fields:

Custom PatternInput ValueFormatted Value
en_USde_DE
S999.9

1.55

155

"001.6"

"155.0"

"001,6"

"155,0"

SZZ9.99

15.5

-1.55

"15.50"

"-1.55"

"15,50"

"-1,55"

SZZ9.99

155

-155

"155.00"

"-155.00"

"155,00"

"-155,00"

The table shows some custom patterns that you can define for formatting numeric values. The formatted results are delimited by double quotation marks so that you can see where spaces would appear in the result. The quotation marks are not actually part of the result.

Text Pattern Symbols

Text Pattern Symbols

The table shows text pattern symbols and offers a description for each instance:

PatternDescription
ASingle alphabetical character
XSingle character
O or 0Single alphanumeric character
9Single digit 

How to Create Dynamic Form Elements

Business Example

A travel agency wants to use SAP Forms service by Adobe to print invoices for its customers' flight bookings. The form has been set up, but it lacks all relevant data for the business process. The form designer now needs to integrate dynamic content, such as the customers’ addresses.

Follow the simulation to learn how to create dynamic form elements.

Log in to track your progress & complete quizzes