ContentsIndexPreviousNext

Code Examples

Assume the following data items:

01  CLAIM-CODE   PIC X(20).  |destination data item,
                             |initialize before use
01  CUSTOMER-ID  PIC X(8).   |source data item
01  ORDER-NO     PIC X(10).  |source data item
01  ORDER-DATE   PIC 9(6).   |source data item
01  STRING-PTR   PIC 99.     |concatenation pointer,
                             |initialize before use

Assume the program assigns the following values before the STRING statement executes:

CLAIM-CODE  = SPACES
(destination item gets space filled)
CUSTOMER-ID = C077/W12
(customer number "/" region code)
ORDER-NO    = W12-A00234
(region code "-" order number)
ORDER-DATE  = 060199
(mmddyy)

Code example 1:

STRING ORDER-DATE DELIMITED BY SIZE
       ORDER-NO   DELIMITED BY SIZE
       INTO CLAIM-CODE
END-STRING.
*CLAIM-CODE = "060199W12-A00234    "
*spaces appear at the end of concatenated string
*because CLAIM-CODE was assigned SPACES before the
*STRING concatenation statement executed

Code example 2:

Use POINTER to coordinate multiple STRING statements into a common concatenation object.

SET STRING-PTR TO 1.
MOVE SPACES TO CLAIM-CODE.
STRING ORDER-DATE DELIMITED BY SIZE
    INTO CLAIM-CODE
    POINTER STRING-PTR
END-STRING.
*CLAIM-CODE now contains: "060199"

*Reassign the value of STRING-PTR so as to
*eliminate the year digits by overwriting
*positions 5 & 6 in the destination string
SUBTRACT 2 FROM STRING-PTR.
...
*build the remainder of the string
*start by adding a hyphen delimiter,
*add all characters before "/" in CUSTOMER-ID
*add another hyphen delimiter
*add all of ORDER-NO
STRING "-",
       CUSTOMER-ID DELIMITED BY "/",
       "-",
       ORDER-NO    DELIMITED BY SIZE
   INTO CLAIM-CODE
   POINTER STRING-PTR
   ON OVERFLOW
      DISPLAY "Claim-Code OVERFLOW"
   NOT ON OVERFLOW
      PERFORM PROCESS-CLAIM-CODE
END-STRING.
*CLAIM-CODE = "0601-C077-W12-A00234"