One way to assign a value to a data item is to read the value from a screen or a file.
To enter data from the screen, first associate the monitor with a mnemonic-name in the SPECIAL-NAMES paragraph. Then use ACCEPT to assign the line of input entered at the screen to a data item. For example:
Environment Division.
Configuration Section.
Special-Names.
Console is Names-Input.
. . .
Accept Customer-Name From Names-Input
To read from a file instead of the screen, make either of the following changes:
SYSIN is Names-Input
SET CONSOLE=\myfiles\myinput.rpt
The environment-variable name must be the same as the system device name used. In the example above, the system device is Console, but the method of assigning an environment variable to the system device name is supported for all valid system devices. For example, if the system device is SYSIN, the environment variable that must be assigned a file specification is also SYSIN.
The ACCEPT statement assigns the input line to the data item. If the input line is shorter than the data item, the data item is padded with spaces of the appropriate representation. When you read from a screen and the input line is longer than the data item, the remaining characters are discarded. When you read from a file and the input line is longer than the data item, the remaining characters are retained as the next input line for the file.
When you use the ACCEPT statement, you can assign a value to an alphanumeric or national group item, or to an elementary data item that has USAGE DISPLAY, USAGE DISPLAY-1, or USAGE NATIONAL.
When you assign a value to a USAGE NATIONAL data item, the input data is converted from the code page associated with the current runtime locale to national (Unicode UTF-16) representation only if the input is from the terminal.
To have conversion done when the input data is from any other device, use the NATIONAL-OF intrinsic function.
related concepts
Unicode and the encoding of language characters
related tasks
Setting environment variables
Converting alphanumeric and DBCS data to national data (NATIONAL-OF)
Getting the system date under CICS
related references
ACCEPT statement
(COBOL for Windows Language Reference)
SPECIAL-NAMES paragraph
(COBOL for Windows Language Reference)