Sunday, November 22, 2009

SAPscript Control Commands- Part 2


Formatting Time Fields: SET TIME MASK


You can use the SET TIME MASK control command to format time fields as you require. Executing this command causes all subsequent time fields to be output using the specified format.

Syntax:

/: SET TIME MASK = 'time_mask'

The following codes can be used in the time mask:



• HH hours (two digits)

• MM minutes (two digits)

• SS seconds (two digits)



All other characters found in a time mask are interpreted as simple text and are copied straight into the output.



Assuming the current time is 10:08:12,

/: SET TIME MASK = 'HH:MM'

&TIME& -> 10:08

/: SET TIME MASK = 'HH hours MM minutes'

&TIME& -> 10 hours 08 minutes

The time mask may be reset to the default setting by using an empty string:

/: SET TIME MASK = ' '





Country-Dependent Formatting: SET COUNTRY




The formatting for certain field types depends on the country settings. These field types include, for example, date fields and number fields that include either a decimal point or the 'thousands' separator character. The formatting options defined in the user master record are usually the ones used here. The SET COUNTRY control command can be used to select a formatting option other than that specified in the user master record. The country-dependent formatting options are stored in the T005X table.

Syntax:

/: SET COUNTRY country_key

The country key can be specified either as a literal value enclosed in quotes or as a symbol.



/: SET COUNTRY 'CAN'

/: SET COUNTRY &country_key&

A blank country name can be used to revert to the setting found in the user master record:

/: SET COUNTRY ' '

This SAPscript command actually calls the corresponding ABAP command internally. Therefore the effect of the SAPscript command is guaranteed to be identical with that of the ABAP command.



If the formatting turns out not to be as required, then you should check the settings in the T005X table.









Position of the Leading Sign: SET SIGN



The usual convention in business applications is to show the leading sign to the right of the figure to which it applies. However, it is sometimes necessary to show the leading sign to the left of the figure. The SET SIGN control command can be used to specify this globally. Executing this command affects the formatting of all subsequent program symbols that possess a leading sign.

Syntax:

/: SET SIGN LEFT

The leading sign is output to the left of the number.

/: SET SIGN RIGHT

The leading sign is output to the right of the number.





Initializing Numbered Paragraphs: RESET

The RESET control command is used to reset the numbering of an outline paragraph to its initial value. If the RESET command is not used, then the numbering of all outline paragraphs in a text will be continuous. If the name of an outline paragraph is specified in the RESET command, then its paragraph numbering and that of subordinate paragraphs will be reinitialized.

Syntax:

/: RESET paragraph_format

The paragraph format specifies the outline paragraph to be reset.



Assume that the paragraph N1 is defined in the style you are using. This kind of paragraph is intended for enumerated lists and causes a sequential number to be output.

* Proceed as follows if you want to work with the SAP R/3

system:

N1 Ensure that you have a PC

N1 Switch the PC on

N1 Click on the SAP icon using the mouse.

* You will then enter the SAP logon screen. In order to log

on here, you must carry out the following actions:

/: RESET N1

N1 Enter your user name

N1 Enter your password

N1 Select the application you want to use



This text specification would be output as follows:

Proceed as follows if you want to work with the SAP R/3



system:

1. Ensure that you have a PC

2. Switch the PC on

3. Click on the SAP icon using the mouse.



You will then enter the SAP logon screen. In order to log on here, you must carry out the following actions:

1. Enter your user name

2. Enter your password

3. Select the application you want to use



If there were no RESET command between the two sections, then the two lists would be numbered in a single sequence:



Proceed as follows if you want to work with the SAP R/3

system:

1. Ensure that you have a PC

2. Switch the PC on

3. Click on the SAP icon using the mouse.

You will then enter the SAP logon screen. In order to log on here, you must carry out the following actions:

4. Enter your user name

5. Enter your password

6. Select the application you want to use


Including Other Texts: INCLUDE

You can use the INCLUDE control command to include the contents of another text into the current text. The text to be included continues to be treated as a separate text and is copied over only at the point at which the output is formatted.

Thus the use of the INCLUDE command always ensures that the most current version of a text is included into the output, since the text is not read and inserted until the output is formatted.

Syntax:

/: INCLUDE name [OBJECT o] [ID i] [LANGUAGE l] [PARAGRAPH p]

[NEW-PARAGRAPH np]

The name of the text to be inserted must be specified and can be up to 70 characters long. If the name of the text contains spaces, then it must be enclosed in quotes as a literal value. The name may alternatively be specified via a symbol. All remaining parameters in the INCLUDE command are optional. If an optional parameter is not specified, then SAPscript uses default values as applicable for the calling environment.



/: INCLUDE MYTEXT

The text MYTEXT is included in the language of the calling text.

/: INCLUDE MYTEXT LANGUAGE 'E' PARAGRAPH 'A1'

The text with the name MYTEXT and the language E is included, regardless of the language of the calling text. The paragraph format A1 will be used as the standard paragraph type for this call.



Optional parameters:



• LANGUAGE



If this parameter is not specified, then the language of the calling text or the layout set language are used for the text to be included. If the language is specified, then the text will be fetched in this language, regardless of the language of the calling text.



• PARAGRAPH



The text to be included is formatted using the style allocated. The PARAGRAPH parameter can be used to redefine the standard paragraph for this style for the current call. All *-paragraphs in the included text will then be formatted using the paragraph specified here.



• NEW-PARAGRAPH



The first line of the text to be included will be given this format indicator, as long as it is not a comment or command line. If the optional PARAGRAPH parameter (see above) is not specified, then all *-paragraphs of the included text will also be formatted using the paragraph np specified in the NEW-PARAGRAPH command.



• OBJECT



In order to completely specify a text, information about the text object is also required. There are a number of restrictions and other rules that depend on the object type of the calling text:



- Any kind of text can be included in a layout set. If no object is specified, then TEXT will be used (standard texts).

- In the case of a document text (DOKU object), you can include only document texts. This object type will also be assumed if no object is specified in this environment.

- Only hypertexts and document texts can be included in a hypertext (DSYS object). If the OBJECT parameter is missing, then DSYS is used as the default value.

- In the other kinds of text you can include only standard texts (TEXT object), document texts or hypertexts. If there is no specification, then the default object is TEXT.



• ID



The text-ID is a part of the text key which permits further text objects within a given object. If no ID is specified, then the default include ID is used from the TTXID table for the calling text. If there is no entry in this table, then the text-ID of the calling text is used.



The following consistency check is applied both to the ID and the object:



• All text-IDs are allowed in a layout set.

• In document texts only document texts may be included which have text-IDs TX (general texts) or UO (authorization objects) and also other document texts which have the same text-ID as the calling document text.

• In DSYS texts all DSYS texts can be included, whatever ID they have. Document texts to be included must have one of the IDs TX and UO.

• Standard texts with any allowable text-ID, DSYS texts with all IDs and document texts with the IDs TX and UO can be included into the other texts.



The INCLUDE command returns a status code in the SAPSCRIPT-SUBRC symbol:



• 0: the text include was successful.

• 1: the command could not be executed because it contained syntax errors.

• 2: the rules governing the text to be included were not followed (see above).



This value cannot occur if the command is used in a SAPscript layout set.



• 4: the specified text could not be found.



Changing the Style: STYLE



The STYLE control command allows you to change the style within a text. The new style is in force until another STYLE command is issued. If * is specified as the name of style, then the system reverts to the original style.

Syntax:

/: STYLE style

/: STYLE *

The STYLE command is automatically set in the text editor if another text module is inserted and immediately expanded using the menu option Include ® Text. The same thing happens if the contents of texts that have been included using INCLUDE are copied into the text via Edit ® Selected area ® Expand INCLUDE.





Formatting Addresses: ADDRESS

The ADDRESS - ENDADDRESS control command formats an address according to the postal convention of the recipient country defined in the COUNTRY parameter. The reference fields are described in the structures ADRS1, ADRS2, or ADRS3, depending upon the type of address. Either direct values or symbols may be assigned to the parameters.

Syntax:

/: ADDRESS [DELIVERY] [TYPE t] [PARAGRAPH a] [PRIORITY p] [LINES l]

/: TITLE title

/: NAME name1[,name2[,name3[,name4]]]

/: PERSON name of natural person [TITLE form of address]

/: DEPARTMENT department

/: STREET street name

/: LOCATION additional location information

/: POBOX po box [CODE post code / zip code] [CITY city]

/: POSTCODE post code / zip_code

/: CITY city1[,city2]

/: REGION county / state

/: COUNTRY recipient country [LANGUAGE language code]

/: FROMCOUNTRY sender country

/: ADDRESSNUMBER address number

/: ENDADDRESS



The parameter values contain both formatting and address information. The address data are formatted for output according to the data in the following parameters:



• TYPE

• FROMCOUNTRY

• COUNTRY

• LANGUAGE

• PRIORITY

• DELIVERY; and

• LINES



For more information, please also see the on-line documentation for the SAP function module ADDRESS_INTO_PRINTFORM (transaction SE37).

If DELIVERY is not specified and if a POBOX is specified, then it is used in an address instead of a STREET.



Parameters



• DELIVERY

Means that the address should be formatted as a complete delivery address, i.e. using the street name and number rather than the P. O. Box.



• TYPE

Specifies the type of address. The following types are possible:



- 1 normal address (ADRS1). This is the address of a company or organization. It corresponds to the address structure that is expected in most SAP applications.

- 2 private or personal address (ADRS2). This is the address of a natural person, a private or home address.

- 3 company address (ADRS3) with contact person. This is the address of a colleague or contact within a company or organization. The company name should be specified in the TITLE and NAME fields; the ATTN: contact person should be named in PERSON and TITLE.



Should you enter another address type or leave the field blank, then type 1 is used for formatting.



• PARAGRAPH

Specifies the paragraph format to be used for outputting the address. If this parameter is not given, the address will be output using the default paragraph format.



• PRIORITY

Specifies which of the address lines may be omitted should this be necessary. Any combination of the following codes may be specified. The order in which you list the codes determines the order in which address lines are left out.

The codes are as follows:



- A title

- P mandatory empty line

- 4 name4

- 3 name3

- R region

- T neighborhood, administrative section of a city (CITY2)

- D department

- L country name

- C post code or zip code

- 2 name2

- B P.O. Box (Japan only)

- S street name and number or P.O. Box, depending upon DELIVERY parameter

- N name and form of address of natural person (PERSON and TITLE)

- I Location information in LOCATION

- O city



• LINES



This specifies how many lines may be used for formatting the address. If there are too few lines available to allow all the address data to be formatted, then the data specified in the PRIORITY parameter are omitted. If there is no LINES parameter and if this command is in a layout set window of a type other than MAIN, then the number of lines available for formatting the address are automatically calculated based on the current output position and the size of the window.



• TITLE

Title or form of address. Used only with addresses of types 1 and 3.



• NAME

Up to four names may be given, separated by commas. Used only with addresses of types 1 and 3.



• PERSON

Name of the addressee. Used only for addresses of type 2 (private or personal address) or type 3 (company contact address). In type 3 addresses, use PERSON for the name of your contact person: 'Attn: Mr. Jeffries'. The name fields should be used for the company address.



• TITLE (with PERSON)

Title of the addressee. Used only for addresses of type 2 or type 3 (private or personal address).



• DEPARTMENT

Department of the addressee. Used only for addresses of type 3 (company address).



• STREET

Street name, including the street number(s).



• LOCATION

Additional location information, such as the building, "Upstairs Apartment" and so on. Appears on its own line in the address.



• POBOX

P. O. Box.



• CODE

The post code / zip code of the P. O. Box if this is different than the post code / zip code of the recipient.



• CITY

The city in which the destination P.O. Box is located if this is different than the city of the recipient.



• POSTCODE

Post code / zip code of the recipient.



• CITY

Addressee's city. city1 is expected to be the city; city2 is the neighborhood or administrative section, if required.



• REGION

This allows an administrative region, county, province, or state etc. to be specified.



• COUNTRY

Specifies the recipient country, i.e. the country according to whose postal conventions the address is to be formatted.



• LANGUAGE

Language code of the language of the recipient country, if different than that of the recipient COUNTRY. Example: addresses in Switzerland. Standard SAP language codes are used; you can display these in the initial SAPscript text processing screen or in table T002.



• FROMCOUNTRY

Specifies the language to be used for formatting the name of the recipient country. For most European countries, the recipient country is specified by placing the international car registration letters in front of the post code and separating them from the post code with a hyphen.



• ADDRESSNUMBER

An address number for use in special cases, such as addressing in Japan. The number is used to index a central address file, from which the desired address is read. You can find more information on this facility in the documentation for the function module ADDRESS_INTO_PRINTFORM (transaction SE37).





/: ADDRESS

/: TITLE 'Firma'

/: NAME 'Schneider & Co', 'Finanzberatung'

/: STREET 'Kapitalgasse 33'

/: POBOX '12345' CODE '68499'

/: POSTCODE '68309'

/: CITY 'Mannheim'

/: COUNTRY 'DE'

/: FROMCOUNTRY 'DE'

/: ENDADDRESS

produces the following output address:

Firma

Schneider & Co

Finanzberatung

Postfach 12345



68499 Mannheim

If the DELIVERY parameter is specified on the ADDRESS command, then the street name and number will appear in the address in place of the P. O. Box number.

Firma

Schneider & Co

Finanzberatung

Kapitalgasse 33



68309 Mannheim



SAPscript makes an internal call to the ADDRESS_INTO_PRINTFORM function module for formatting the address. If the result is not as expected, you should check the settings for this function module (see the function module documentation (transaction SE37)).

No comments:

Post a Comment