MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Help with STRING

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming
View previous topic :: View next topic  
Author Message
sakreg
Beginner


Joined: 28 Feb 2005
Posts: 80
Topics: 26

PostPosted: Wed Jul 05, 2006 3:07 am    Post subject: Help with STRING Reply with quote

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 (,)?
Back to top
View user's profile Send private message
shekar123
Advanced


Joined: 22 Jul 2005
Posts: 528
Topics: 90
Location: Bangalore India

PostPosted: Wed Jul 05, 2006 4:08 am    Post subject: Reply with quote

Sasreg,

Can you please specify what exactly would be your input and expected output to give more clear understanding ?
_________________
Shekar
Grow Technically
Back to top
View user's profile Send private message
sakreg
Beginner


Joined: 28 Feb 2005
Posts: 80
Topics: 26

PostPosted: Wed Jul 05, 2006 5:01 am    Post subject: Reply with quote

shekar123

Either Some or all of the variable
Quote:
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

would be populated with the value from
Quote:
L1 Or L2 Or L3 Or L4Or L5Or L6 Or L7Or L8Or L9Or L10 Or L10

For Example, let me say
Quote:
WS-MM-L1,WS-MM-L5 and WS-MM-L9 are populated with values from L1, L5 and L9

Which means I would have moved
Quote:
L1 to WS-MM-L1, L5 to WS-MM-L5, L9 to WS-MM-L9.

So I now have to MOVE what I have in WS-MM-L1, WS-MM-L5, WS-MM-L9 the values of which are Column 1, Column 5 and Column 9 TO COMMENTS-OUT-C as
Quote:
Mismatch On Column 1, Column 2, Column 5.

Basically looking for a way to String the Literals and format that with ',' in between and prefixing with the Literal 'Mismatch On'

I believe I have made a clear understanding of what I expect, any questions please let me know which would make you to help me better
Back to top
View user's profile Send private message
shekar123
Advanced


Joined: 22 Jul 2005
Posts: 528
Topics: 90
Location: Bangalore India

PostPosted: Wed Jul 05, 2006 6:48 am    Post subject: Reply with quote

Sasreg,

Try this code if you are looking for this output:
Code:

       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                                                                                                           

_________________
Shekar
Grow Technically
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12376
Topics: 75
Location: San Jose

PostPosted: Wed Jul 05, 2006 7:34 am    Post subject: Reply with quote

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.

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
sakreg
Beginner


Joined: 28 Feb 2005
Posts: 80
Topics: 26

PostPosted: Wed Jul 05, 2006 7:49 am    Post subject: Reply with quote

shekar123,

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. Rolling Eyes

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
Back to top
View user's profile Send private message
sakreg
Beginner


Joined: 28 Feb 2005
Posts: 80
Topics: 26

PostPosted: Wed Jul 05, 2006 7:55 am    Post subject: Reply with quote

kolusu,

You got me. Other than STRING verb are there any thoughts with COBOL structures this can be accomplished.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12376
Topics: 75
Location: San Jose

PostPosted: Wed Jul 05, 2006 8:08 am    Post subject: Reply with quote

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 '. '
                                                 
DISPLAY COMMENTS-OUT-C                           



Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
sakreg
Beginner


Joined: 28 Feb 2005
Posts: 80
Topics: 26

PostPosted: Thu Jul 06, 2006 12:41 am    Post subject: Reply with quote

That is a Brilliant thought kolusu, Thankyou. It worked as required Very Happy
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
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


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group