midrange.com code scratchpad
Name:
OCCURSDEP
Scriptlanguage:
Plain Text
Tabwidth:
4
Date:
06/11/2009 07:50:13 pm
IP:
Logged
Description:
Example combining OCCURS DEPENDING with LINKAGE SECTION "based" definitions.
Code:
  1.        PROCESS APOST
  2.        Identification Division.
  3.        Program-ID.  OCCURSDEP.
  4.  
  5.        Environment Division.
  6.        Configuration Section.
  7.        Source-computer.  IBM-AS400.
  8.        Object-computer.  IBM-AS400.
  9.       /
  10.        Data Division.
  11.  
  12.        Working-storage Section.
  13.  
  14.        77  subtext  PIC x(1200).
  15.        77  SQL-TEXT PIC x(1024)
  16.                value 'Here is enough text to play with.'.
  17.        77  pSQL     pointer.
  18.  
  19.        01  SQL-struct.
  20.            05  SQL-STATEMENT-TEXT-LEN2             PIC S9(00009) BINARY.
  21.  
  22.        Linkage Section.
  23.  
  24.        01  SQL-STATEMENT-TEXT2-struct.
  25.            05  SQL-STATEMENT-TEXT2     PIC X
  26.                                        OCCURS 1 TO 1024 TIMES
  27.                                          DEPENDING ON
  28.                                              SQL-STATEMENT-TEXT-LEN2.
  29.        Procedure Division.
  30.  
  31.        0000-Main Section.
  32.        0010-MainLine.
  33.  
  34.            set pSQL    to  address of SQL-TEXT
  35.            set address of SQL-STATEMENT-TEXT2-struct   to  pSQL
  36.  
  37.            compute SQL-STATEMENT-TEXT-LEN2 =  19
  38.  
  39.            string SQL-STATEMENT-TEXT2-struct  delimited SIZE
  40.                   '<end'                      delimited SIZE
  41.                into
  42.                   subtext
  43.            end-string
  44.  
  45.            display subtext
  46.  
  47.            GOBACK
  48.            .
  49.  
© 2004-2019 by midrange.com generated in 0.005s valid xhtml & css