Page 1 of 1

concatenation of all table elements in a variable

PostPosted: Wed Jun 23, 2010 11:28 am
by anchal
I want to Concatenate all elements of a table elements are mon,tue,wed till sun.i want to display them in a single line with appropriate spaces but not able to do.please help me out it's urgent for me.

I have written the following code:-


01 WS-WEEKS.
05 DAY1 PIC X(3) VALUE 'MON'.
05 DAY2 PIC X(3) VALUE 'TUE'.
05 DAY3 PIC X(3) VALUE 'WED'.
05 DAY4 PIC X(3) VALUE 'THR'.
05 DAY5 PIC X(3) VALUE 'FRI'.
05 DAY6 PIC X(3) VALUE 'SAT'.
05 DAY7 PIC X(3) VALUE 'SUN'.
01 WS-WEEKS-TABLE REDEFINES WS-WEEKS.
05 WS-DAYS PIC X(03) OCCURS 7 TIMES.

01 I PIC 9(2) VALUE ZEROS.
01 STR PIC X(35) VALUE SPACES.
01 SPC PIC X(3) VALUE SPACES.


then i m doing this:-

PERFORM VARYING I FROM 1 BY 1 UNTIL I > 7
STRING WS-DAYS(I)
SPC
STR DELIMITED BY SPC
INTO STR

output desired is:-

mon tue wed thr fri sat sun

Re: concatenation of all table elements in a variable

PostPosted: Wed Jun 23, 2010 5:32 pm
by Robert Sample
Why not use something like
01 WS-WEEKS.
05 DAY1 PIC X(4) VALUE 'MON'.
05 DAY2 PIC X(4) VALUE 'TUE'.
05 DAY3 PIC X(4) VALUE 'WED'.
05 DAY4 PIC X(4) VALUE 'THR'.
05 DAY5 PIC X(4) VALUE 'FRI'.
05 DAY6 PIC X(4) VALUE 'SAT'.
05 DAY7 PIC X(4) VALUE 'SUN'.
.
.
.
MOVE WS-WEEKS TO <output area>.

Re: concatenation of all table elements in a variable

PostPosted: Thu Jun 24, 2010 9:59 am
by anchal
Thanks Robert.