Posted: Wed Jul 05, 2006 3:07 am Post subject: Help with STRING
I am trying to format few literals using STRING verb
This is my Working Storage definition
Code:
77 WS-MM-L1 PIC X(08) VALUE SPACES.
77 WS-MM-L2 PIC X(08) VALUE SPACES.
77 WS-MM-L3 PIC X(08) VALUE SPACES.
77 WS-MM-L4 PIC X(08) VALUE SPACES.
77 WS-MM-L5 PIC X(08) VALUE SPACES.
77 WS-MM-L6 PIC X(08) VALUE SPACES.
77 WS-MM-L7 PIC X(08) VALUE SPACES.
77 WS-MM-L8 PIC X(08) VALUE SPACES.
77 WS-MM-L9 PIC X(08) VALUE SPACES.
77 WS-MM-L10 PIC X(09) VALUE SPACES.
77 WS-MM-L11 PIC X(09) VALUE SPACES.
77 L1 PIC X(08) VALUE 'Column 1'.
77 L2 PIC X(08) VALUE 'Column 2'.
77 L3 PIC X(08) VALUE 'Column 3'.
77 L4 PIC X(08) VALUE 'Column 4'.
77 L5 PIC X(08) VALUE 'Column 5'.
77 L6 PIC X(08) VALUE 'Column 6'.
77 L7 PIC X(08) VALUE 'Column 7'.
77 L8 PIC X(08) VALUE 'Column 8'.
77 L9 PIC X(08) VALUE 'Column 9'.
77 L11 PIC X(09) VALUE 'Column 10'.
77 L11 PIC X(09) VALUE 'Column 11'.
77 COMMENTS-OUT-C PIC X(100) VALUE SPACES.
Based on some rules I populate some or all with L1 OR L2 OR L3 .....L11
Code:
77 WS-MM-L1 PIC X(08) VALUE SPACES.
77 WS-MM-L2 PIC X(08) VALUE SPACES.
77 WS-MM-L3 PIC X(08) VALUE SPACES.
77 WS-MM-L4 PIC X(08) VALUE SPACES.
77 WS-MM-L5 PIC X(08) VALUE SPACES.
77 WS-MM-L6 PIC X(08) VALUE SPACES.
77 WS-MM-L7 PIC X(08) VALUE SPACES.
77 WS-MM-L8 PIC X(08) VALUE SPACES.
77 WS-MM-L9 PIC X(08) VALUE SPACES.
77 WS-MM-L10 PIC X(09) VALUE SPACES.
77 WS-MM-L11 PIC X(09) VALUE SPACES.
After populating I have to MOVE the above values to COMMENTS-OUT-C
And What I see in COMMENTS-OUT-C should be like
Quote:
Mismatch on Column 1, Column2, Column 10
or
Quote:
Mismatch on Column 2, Column 5
or
Quote:
Mismatch on Column 10
or
Quote:
Mismatch on Column 1, Column 2, Column 9, Column 10
based on what values are populated among those.
Can this be achieved used STRING verb making sure you elimnate spaces and concatenate ONLY those variable NOT EQUAL TO SPACES and using a seperator (,)?
Can you please specify what exactly would be your input and expected output to give more clear understanding ? _________________ Shekar
Grow Technically
WORKING-STORAGE SECTION.
77 WS-MM-L1 PIC X(08) VALUE SPACES.
77 WS-MM-L2 PIC X(08) VALUE SPACES.
77 WS-MM-L3 PIC X(08) VALUE SPACES.
77 WS-MM-L4 PIC X(08) VALUE SPACES.
77 WS-MM-L5 PIC X(08) VALUE SPACES.
77 WS-MM-L6 PIC X(08) VALUE SPACES.
77 WS-MM-L7 PIC X(08) VALUE SPACES.
77 WS-MM-L8 PIC X(08) VALUE SPACES.
77 WS-MM-L9 PIC X(08) VALUE SPACES.
77 WS-MM-L10 PIC X(09) VALUE SPACES.
77 WS-MM-L11 PIC X(09) VALUE SPACES.
77 L1 PIC X(08) VALUE 'COLUMN 1'.
77 L2 PIC X(08) VALUE 'COLUMN 2'.
77 L3 PIC X(08) VALUE 'COLUMN 3'.
77 L4 PIC X(08) VALUE 'COLUMN 4'.
77 L5 PIC X(08) VALUE 'COLUMN 5'.
77 L6 PIC X(08) VALUE 'COLUMN 6'.
77 L7 PIC X(08) VALUE 'COLUMN 7'.
77 L8 PIC X(08) VALUE 'COLUMN 8'.
77 L9 PIC X(08) VALUE 'COLUMN 9'.
77 L11 PIC X(09) VALUE 'COLUMN 10'.
77 L11 PIC X(09) VALUE 'COLUMN 11'.
77 COMMENTS-OUT-C PIC X(100) VALUE SPACES.
77 PUTCOMMA PIC X(01) VALUE ','.
77 MISMATCH PIC X(12) VALUE 'MISMATCH ON '.
77 FULLSTOP PIC X(01) VALUE '.'.
PROCEDURE DIVISION.
0000-MAIN.
D DISPLAY "ENTRY INTO SASPGM".
MOVE L1 TO WS-MM-L1.
MOVE L5 TO WS-MM-L5.
MOVE L9 TO WS-MM-L9.
STRING MISMATCH WS-MM-L1 PUTCOMMA
WS-MM-L5 PUTCOMMA
WS-MM-L9 FULLSTOP DELIMITED BY SIZE
INTO COMMENTS-OUT-C.
DISPLAY 'COMMENTS-OUT-C:' COMMENTS-OUT-C.
DISPLAY "EXIT FROM SASPGM".
0000-MAIN-EXIT.
EXIT.
GOBACK.
OUTPUT
Code:
ENTRY INTO SASPGM
COMMENTS-OUT-C : MISMATCH ON COLUMN 1,COLUMN 5,COLUMN 9.
EXIT FROM SASPGM
Joined: 26 Nov 2002 Posts: 12376 Topics: 75 Location: San Jose
Posted: Wed Jul 05, 2006 7:34 am Post subject:
shekar123,
Please understand the question before you answer. The poster does not know which fields will be in the string list. You need to determine based on the move. So at any time he may have a min of 1 field or 10 fields in the string list.
I accept your Solution. The complex part I think here is,
The STRING Should be qualified with all the
WS-MM-L1 ,WS-MM-L2.WS-MM-L3,WS-MM-L4,WS-MM-L5, WS-MM-L6, WS-MM-L7, WS-MM-L8, WS-MM-L9, WS-MM-L10, WS-MM-L11
and it should then get formatted acordingly.
There can be many possibilites (any combination of mismatch is possible) and obviously it is NOT possible to check for NOT EQUAL TO SPACES and then STRING the variables by trimming any space between and including comma.
There are altogther 11 columns and any combination of Mismatch can come. So Can a Single STRING verb do the Wonder? May be the thoughts are like first String all the variable whether are not those are populated. Then care shd be taken to strip out any leading, trailing and embedded spaces. Also making sure the Comma are inserted.
I am open for any ideas. Not just want to stick to STRING verb
Sounds interseting? If there are any questions plz let me know
Joined: 26 Nov 2002 Posts: 12376 Topics: 75 Location: San Jose
Posted: Wed Jul 05, 2006 8:08 am Post subject:
sakreg,
Try this
Code:
01 WS-MM-L1 PIC X(09) VALUE SPACES.
01 WS-MM-L2 PIC X(09) VALUE SPACES.
01 WS-MM-L3 PIC X(09) VALUE SPACES.
01 WS-MM-L4 PIC X(09) VALUE SPACES.
01 WS-MM-L5 PIC X(09) VALUE SPACES.
01 WS-MM-L6 PIC X(09) VALUE SPACES.
01 WS-MM-L7 PIC X(09) VALUE SPACES.
01 WS-MM-L8 PIC X(09) VALUE SPACES.
01 WS-MM-L9 PIC X(09) VALUE SPACES.
01 WS-MM-L10 PIC X(10) VALUE SPACES.
01 WS-MM-L11 PIC X(10) VALUE SPACES.
01 L1 PIC X(09) VALUE 'COLUMN_1,'.
01 L2 PIC X(09) VALUE 'COLUMN_2,'.
01 L3 PIC X(09) VALUE 'COLUMN_3,'.
01 L4 PIC X(09) VALUE 'COLUMN_4,'.
01 L5 PIC X(09) VALUE 'COLUMN_5,'.
01 L6 PIC X(09) VALUE 'COLUMN_6,'.
01 L7 PIC X(09) VALUE 'COLUMN_7,'.
01 L8 PIC X(09) VALUE 'COLUMN_8,'.
01 L9 PIC X(09) VALUE 'COLUMN_9,'.
01 L10 PIC X(10) VALUE 'COLUMN_10,'.
01 L11 PIC X(10) VALUE 'COLUMN_11,'.
MOVE L5 TO WS-MM-L5
MOVE L8 TO WS-MM-L8
STRING 'MISMATCH ON ' DELIMITED BY SIZE
WS-MM-L1 DELIMITED BY SPACE
WS-MM-L2 DELIMITED BY SPACE
WS-MM-L3 DELIMITED BY SPACE
WS-MM-L4 DELIMITED BY SPACE
WS-MM-L5 DELIMITED BY SPACE
WS-MM-L6 DELIMITED BY SPACE
WS-MM-L7 DELIMITED BY SPACE
WS-MM-L8 DELIMITED BY SPACE
WS-MM-L9 DELIMITED BY SPACE
WS-MM-L10 DELIMITED BY SPACE
WS-MM-L11 DELIMITED BY SPACE
INTO COMMENTS-OUT-C
END-STRING
INSPECT COMMENTS-OUT-C REPLACING ALL '_' BY ' '
INSPECT COMMENTS-OUT-C REPLACING ALL ', ' BY '. '
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum