CDS234

Copy common template fields

Last Revised: 09/07/16

This routine is used to copy fields with the same name from one string template to another.  It is used by CDS034 and can also be used in custom data conversion programs, Dynaweb applications to map fields from CGI$ to another templated string, or other application programs.

CDS234 also supports changes in template field type including conversion from C to any numeric template type, and from a numeric template type to C, from one numeric template type to another, and from MM/DD/YY dates to julian.  See field conversion notes below.

Calling Format:

CALL "CDS234", ERR=XXXX, RECIN$, RECOUT$ {, S234$ }

CDS234 Arguments
Argument Passed To/From Description
ERR=XXXX N/A Error branch taken if:
  • there is no template associated with RECIN$ or RECOUT$.  Operator will be prompted in this case regardless of S234.ERRMSG$ value.
  • S234.ERRMSG$<>"N" and a field mapping error occurred, and operator selected option A to Abort application
RECIN$ to Input templated string
RECOUT$ to Output templated string.  Note that that RECOUT$ is not initialized by CDS234, so any fields with data will not be changed unless the same field name is found in RECIN$.
S234$ to/from
ERRMSG$ Pass to CDS234 as "N" to ignore all field mapping errors.  No operator prompt will occur. Data for non-printable fields will not be copied from RECIN$ to RECOUT$.

Any other value will prompt user with field mapping error message.  If field mapping error does occur, and user selected option "I" to Ignore error messages, then CDS234 will change ERRMSG$ to "N" so that subsequent field mapping problems are ignored.

NONPRINT$

Pass as "Y" to copy all non-printable characters from RECIN$ to RECOUT$ and not notify operator.
PCK$ Pass as "Y" if the data includes fields packed using the PCK() function. The PCK() function does include non-printable characters $7F$ thru $83$. Any fields containing these characters will be copied without notification.
ERRCNT Set by CDS234 to the number of field mapping errors encountered.  ERRCNT is updated regardless of ERRMSG$ value.

CDS234 will display an Error Message unless S234.ERRMSG$="N".  The operator can touch F5 to display the input and output data, I to ignore subsequent error messages, and A to abort which will cause CDS234 to EXIT 99.

Fields contained in RECIN$ but not RECOUT$ are ignored without an error message.

Error Messages
Message Description
RECIN$ must be templated The RECIN$ argument requires a template.
RECOUT$ must be templated The RECOUT$ argument requires a template.
Data does not match template at Field Name XXXX The program is encountering an error 47 at the Field Name specified.  This indicates that the template does not accurately describe the data in RECIN$.  Correct the data or template.
Input field contains non-printable character(s) at Field Name XXXX The input field contains a non-printable character, typically a line feed field terminator.  This usually indicates that the template does not accurately describe the data in RECIN$.  Correct the data or template.
Non-numeric data of XXXX at Field Name XXXX The program is encountering an error 26 at the Field Name specified.  This indicates that numeric field in RECIN$ contains non-numeric characters.  The field value is displayed in 'string' or $hexadecimal$ format.  Correct the data or template.
Field Name with value of 'XXXX' changed to 'XXXXX' This usually indicates that the field size in RECOUT$ is not large enough to hold the value from RECIN$.
Field Conversion Notes
Rule# Description
1 When converting a C(8) field to a numeric field and the data contains a "/" in the 3rd and 6th position, the C(8) field is assumed to be a date, and stored in julian format in the numeric field, typically a U(3) or N(7) field.  This enables conversion of dates in MM/DD/YY format to julian without needing to write custom code.
2 When converting from C(x) to U(y) where x=y is the same, i.e., C(3) to U(3), it is assumed that the C(x) field contains binary data and simple string conversion takes place, i.e., RECOUT.FLD$=RECIN.FLD$.  This enables conversion of ID fields such as AP12.VOUCHERNO$ from C(3) to U(3).
3 When converting from C(x) to U(y) where x <> y, or from C() to I() or B, then the numeric value of the string will be used, i.e., RECOUT.FLD=NUM(RECIN.FLD$).
4 When converting to an N() type field and an output mask is provided, and the mask does not contain a comma, a % (date & time masks), nor an R (CR/DR), then the data will be stored using the mask provided, i.e., RECOUT.FLD$=STR(VAL:OMASK$).  This is consistent with how CDS039 stores masked N type fields which is useful when a numeric field is used as a key segment.
5 When converting from N(x) to C(y), or C(x) to N(y), or N(x) to N(y) and x=y, then simple string assignment is used, i.e., RECOUT.FLD$=RECIN.FLD$.  This will retain any leading zero's when a mask is not provided.
6 When converting from N(x) to C(y), or C(x) to N(y), or N(x) to N(y) and x<>y, and the output field is a fixed length, then the data will be right justified to retain any numerical sorting sequence.  This is useful when the field is used as a key segment.
7 In all other cases where a numeric field is converted to a string field, the STR() function is used, i.e., RECOUT.FLD$=STR(VAL).
8 Repeating fields are supported.  Input, Output or both can be repeating fields.  No error message is created when the maximum repeat of the output field is less than the input field.  For example if the input data includes SALES[12] and the output includes SALES[10], SALES[1] through SALES[10] will be copied to the output, and SALES[11] and [12] will be ignored.
Example (Copy and paste code to execute test)
2000 TEST:
2010 DIM RECIN$:"STR1:C(1),STR2:C(2),STR3:C(1*),STR4:C(1*),STR5:C(1),STR6:C(2),NUM1:N(1),NUM2:N(2),NUM3:N(1*),NUM4:N(1*),NUM5:N(1),NUM6:N(2),SN1:C(1),SN2:C(2),SN3:C(1*),SN4:C(1*),SN5:C(1),SN6:C(2),SN7:C(3),NS1:N(5),NS2:N(3),IDNO1:C(3),DATE1:C(8)"
2020 LET RECIN.STR1$="X",RECIN.STR2$="XX",RECIN.STR3$="X",RECIN.STR4$="XX",RECIN.STR5$="X",RECIN.STR6$="XX"
2030 LET RECIN.NUM1=1,RECIN.NUM2=12,RECIN.NUM3=1,RECIN.NUM4=12,RECIN.NUM5=1,RECIN.NUM6=12
2040 LET RECIN.SN1$="1",RECIN.SN2$="12",RECIN.SN3$="1",RECIN.SN4$="12",RECIN.SN5$="1",RECIN.SN6$="12",RECIN.SN7$="012"
2050 LET RECIN.NS1$="00123",RECIN.NS2$="012",RECIN.IDNO1$=BIN(12345678,3),RECIN.DATE1$=DATE(0)
2060 DIM RECOUT$:"STR1:C(2),STR2:C(1),STR3:C(1),STR4:C(1),STR5:C(1*),STR6:C(1*),NUM1:N(2),NUM2:N(1),NUM3:N(1),NUM4:N(1),NUM5:N(1*),NUM6:N(1*),SN1:N(2),SN2:N(1),SN3:N(1),SN4:N(1),SN5:N(1*),SN6:N(1*),SN7:N(5):omask=00000:,NS1:C(5),NS2:C(5),IDNO1:U(3),DATE1:U(3)"
2070 CALL "CDS234",RECIN$,RECOUT$
2080 CALL "CDS279",RECOUT$,"","DOutput Data"