9.78 GET_CHAR_AREA

Note: Built-In Function Rules     Usage Options

Gets a character string from a character data area.

Arguments

No

Type

Req/ Opt

Description

Min Len

Max Len

Min Dec

Max Dec

1

A

Req

Data area name

1

10

 

 

2

A

Opt

Library name

Default: *LIBL When data area is *LDA or *GDA this argument must be *LIBL

1

10

 

 

3

A

Opt

Lock data area

Y - lock data area

N - do not lock data area

Default: N When data area is *LDA or *GDA this argument is ignored.

1

1

 

 

4

N

Opt

Start pos. to retrieve from Default: position 1

1

5

0

0

Req

If *LDA or *GDA is the data area

 

 

 

 

5

N

Opt

Length to retrieve

Default: full length

1

4

0

0

Req

If *LDA or *GDA is the data area

 

 

 

 

 

Note: Start position and length, if specified, must BOTH be provided as argument values.

Return Values

No

Type

Req/ Opt

Description

Min Len

Max Len

Min Dec

Max Dec

1

A

Opt

Returned value

1

2000

 

 

 

Examples

Retrieve a company name from a data area named COMPID. Use the job's current library list to locate the data area:

USE    BUILTIN(GET_CHAR_AREA) WITH_ARGS(COMPID) TO_GET(#COMPANY)

Retrieve bytes 101 - 110 of data area called USERINFO in library QTEMP and place the result into a field called #OUTQ:

USE    BUILTIN(GET_CHAR_AREA)

       WITH_ARGS(USERINFO QTEMP N 101 10) TO_GET(#OUTQ)

Warning: When processing *LDA or *GDA, a start position and a length must be specified. If these arguments are not specified the program will terminate abnormally. * Retrieve the first 30 bytes of information from the Local Data Area (*LDA). Note: The *LDA data area will not be locked even if it is specified in the functions arguments.

DEFINE    FIELD(#RETVAL) TYPE(*CHAR) LENGTH(30)

USE       BUILTIN(GET_CHAR_AREA) WITH_ARGS('''*LDA''' '''*LIBL''' N 1 30) TO_GET(#RETVAL)

Retrieve some information passed by one of my group jobs into the Group Data Area (*GDA). The information is in positions 20 to 50 of the *GDA:

DEFINE    FIELD(#RETVAL) TYPE(*CHAR) LENGTH(30)

USE       BUILTIN(GET_CHAR_AREA) WITH_ARGS('''*GDA''' '''*LIBL''' N 20 30) TO_GET(#RETVAL)