COPYS2R

Note:
This is an authorized command.
Read syntax diagramSkip visual syntax diagram>>-COPYS2R------------------------------------------------------>
 
>--stor_anchor--+-vname-+--+-offset--length----------+---------><
                '-*-----'  +-struct_vname--fieldname-+
                           '-struct_name--fieldname--'
 

COPYS2R copies data from GETMAINed storage to a REXX variable.

Operands

stor_anchor
specifies the REXX variable containing the anchor for the target storage area that was GETMAINed earlier. This anchor consists of four bytes, containing the address of the earlier GETMAINed storage. specifies that all the REXX variables are copied. If you specify an asterisk (*) you cannot specify fieldname.
vname
specifies the REXX variable containing the value to be copied from the previously GETMAINed area.
Note:
This value should be in quotes so that substitution does not occur.
offset
specifies the displacement into the previously GETMAINed storage area, that the contents of the REXX variable is copied to. The first byte of the area is indicated by a displacement of zero.
length
specifies the length in decimal bytes of the copy performed. If this length is specified, then the contents of the source REXX variable is truncated, or padded with blanks to match this length, and then copied. However, the source REXX variable is not altered in this process. If this length is omitted, then the current length of the source REXX variable, is used.
struct_vname
specifies a REXX variable containing a structure definition (or mapping) of the fields in the GETMAINed storage area. The format of the data in this variable is: field1_name length ... fieldn_name length. This capability is provided so that field displacements are easily calculated and changed, from a central location.
struct_name
specifies the structure file ID containing a structure definition (or mapping) of the fields in the GETMAINed storage area.

Structures are made up of records in the following format: fieldname location length type, where:

fieldname
specifies a 1 to 12 character symbolic name of the field.
location
specifies the position in structure that this field starts (the first position is 1).
length
specifies decimal length of this field in bytes.
type
specifies the field data type: C (character), F (fullword), or H (halfword).
fieldname
is a 1 to 12 character symbolic name associated with the destination field for this copy. This name must exist in the above specified REXX variable or structure definition file. The fieldname must be specified when struct_vname or struct_name is specified.

Return Codes

0
Normal return
2102
Invalid operand
2121
Invalid structure definition
2122
Invalid variable structure definition
2123
Field name not found
2125
Failure processing GETVAR request
2126
Invalid numeric input
2127
RFS read error
2128
Invalid offset
2129
Invalid length value

Example

var1 = '' /* set REXX variable VAR1 to null */
struct1 = 'flda 4 fldb 2 fldc 3 fldd 8 flde 5'
'COPYS2R WORKANC VAR1 STRUCT1 FLDC'

This example copies three bytes of data from positions 7 through 9 of the earlier GETMAINed storage area anchored by the fullword address in REXX variable WORKANC, and copies it to REXX variable VAR1.

Notes

  1. Anchor addresses are not limited to being set by the GETMAIN command. For example, a COPYS2R can be used to copy a fullword address of a GETMAINed area to a REXX variable that is used as the anchor for a subsequent COPYS2R or COPYR2S.
  2. There can be multiple structure (field) definitions for a GETMAINed area; they can overlap, be nested, and used to redefine fields.
  3. Anchor addresses do not need to point to the beginning of a GETMAINed area. It is important, however, that anchor addresses are within a GETMAINed area that you own, and that any operation on them does not exceed their boundaries.