SAP ABAP: Smartforms/SAPscript formatting

SAP Smartforms/SAPscript



SAP ABAP Smartforms

Smartforms Formatting
Following are the few useful formatting options:
Offset:
N left-most characters of the symbol value will not be displayed.
If symbol has the value 123456789, the following will be displayed:
&symbol& -> 123456789
&symbol+3& -> 456789
&symbol+7& -> 89
&symbol+12& ->
&symbol+0& -> 123456789


 Output Length
To define how many character positions should be copied from the value.
If symbol has the value 123456789.
&symbol(3)& -> 123
&symbol(7)& -> 1234567

 The SYST-UNAME field contains the logon name of a user called Einstein. The
Dictionary entry for this field contains an output length of 12.
&SYST-UNAME&… -> Einstein…
&SYST-UNAME(9)&… -> Einstein …
&SYST-UNAME(*)&… -> Einstein …

Omitting the Leading Sign
The S option can be used to ensure that the value is formatted without the sign.
The ITCDP-TDULPOS field contains the value -100.00. The ABAP/4 Dictionary
definition for this field includes a leading sign.
&ITCDP-TDULPOS& -> 100.00-
&ITCDP-TDULPOS(S)& -> 100.00

Leading Sign to the Left
This option enables you to specify that the leading sign should be placed to the left of the number.
&ITCDP-TDULPOS& -> 100.00-
&ITCDP-TDULPOS(<)& -> -100.00

Leading Sign to the Right
If you used the SET SIGN LEFT control command to specify that the leading sign should be output before the value, this specification can be overridden for individual symbols to enable these to be output with the leading sign to the right.
Syntax:
&symbol(>)&

Omitting Leading Zeros
Certain symbol values are output with leading zeros. If you wish to suppress these, you may do so with the Z option.
Assuming the current date is 1.1.1994, &DAY& -> 01
&DAY(Z)& -> 1

Space Compression
The C option has the effect of replacing each string of space characters with a single space and shifting the ’words’ to the left as necessary to close up the gaps.
Assuming ‘ Albert Einstein ‘ is the symbol value,
&symbol& -> Albert Einstein
&symbol(C)& -> Albert Einstein

Number of Decimal Places
A program symbol of one of the data types DEC, QUAN and FLTP can contain decimal place data. This option is used to override the Dictionary definition for the number of decimal places for the formatting of this symbol value.
The EKPO-MENGE field contains the value 1234.56. The Dictionary definition specifies 3 decimal places and an output length of 17.
&EKPO-MENGE& -> 1,234.560
&EKPO-MENGE(.1) -> 1,234.6
&EKPO-MENGE&(.4) -> 1,234.5600
&EKPO-MENGE&(.0) -> 1,235

Specifying an Exponent for Floating Point Numbers
The way that a floating point number is formatted depends on whether an exponent is specified.
PLMK-SOLLWERT field is assumed to have the value
123456.78 and to be of data type FLTP.
&PLMK-SOLLWERT& -> +1.23456780000000E+05
&PLMK-SOLLWERT(E3)& -> +123.456780000000E+03
&PLMK-SOLLWERT(E6)& -> +0.12345678000000E+06
&PLMK-SOLLWERT(E0)& -> +123456.780000000
&PLMK-SOLLWERT(E)& -> +123456.780000000

Right-Justified Output
Right-justified formatting can be specified with the R option. This option has to be used in conjunction with an output length specification. If symbol has the value 1234.
&symbol& -> 1234
&symbol(8R) -> 1234

Fill Characters
Leading spaces in a value can be replaced with a fill character.
The figure for customer sales in the KNA1-UMSAT field is $700. The Dictionary description of the field specifies an output length 8.
&KNA1-UMSAT& -> 700.00
&KNA1-UMSAT(F*)& -> **700.00
&KNA1-UMSAT(F0)& -> 00700.00

Suppress Output of Initial Value
The I option can be used to suppress the output of symbols which still contain their initial value.
Assuming KNA1-UMSAT contains the value 0 and the currency is DEM.
&KNA1-UMSAT& -> 0,00
&KNA1-UMSAT(I)& ->
If the field contains an amount other than 0, this value will be output in the normal way.
&KNA1-UMSAT& -> 700,00
&KNA1-UMSAT(I)& -> 700,00

Ignore Conversion Routines
SAPscript conversion routines specified in the Dictionary are automatically recognized and used when program symbols are being formatted. Using the K option can prevent these conversions.

Date Mask
The formatting for date fields can be defined with the SAPscript SET DATE MASK command. Executing this command causes all subsequent date fields to be output using the specified formatting.
/: SET DATE MASK = ‘date_mask’
The following templates may be used in the date mask:
DD day (two digits)
DDD name of day (abbreviated)
DDDD name of day (written out in full)
MM month (two digits)
MMM name of month (abbreviated)
MMMM name of month (written out in full)
YY year (two digits)
YYYY year (four digits)
LD day (formatted as for the L option)
LM month (formatted as for the L option)
LY year (formatted as for the L option)

Time Mask
You can use the SAPscript SET TIME MASK command to format time fields in a way that differs from the standard setting.
Assuming the current time is 10:08:12.
&TIME& -> 10:08:12
/: SET TIME MASK = ‘HH:MM’
&TIME& -> 10:08
/: SET TIME MASK = ‘HH hours MM minutes’
&TIME& -> 10 hours 08 minutes
&TIME(Z)& -> 10 hours 8 minutes

 Other Standard Outputs:
&DAY&, &MONTH&, &YEAR&, &HOURS&, &MINUTES&, &SECONDS&, &DATE&,
&TIME&, &PAGE&, &NEXTPAGE&.


Happy Abaping!

Comments

Post a Comment

Popular posts from this blog

SAP ABAP: Capturing CHECK BOX event in FM REUSE_ALV_GRID_DISPLAY / Cell Editing

SAP ABAP: Adding leading zero to char or string.