Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Unstring

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
srini24

New User


Joined: 14 Feb 2017
Posts: 12
Location: India

PostPosted: Sat Dec 22, 2018 12:18 am    Post subject: Unstring
Reply with quote

My input string is 'WRITE IN COBOL LANGUAGE'.
Output should be in 'RITE N OBOL ANGUAGE'.
which is first character of every string from input to be removed and then to be captured into output string.

I tried to unstring the message into 4 delimited by spaces and then splitted into 4 strings with countin(length).Using reference modification,i moved each string from its second position to its length specified in COUNTIN.

Is there any other way to do it?



Code:

05  WS-STRING1             PIC X(20)  VALUE 'WRITE IN COBOL LANGUAGE'.
UNSTRING WS-STRING1 DELIMITED BY SPACES INTO
         WS-OUTPUT1 COUNT IN WS-COUNT1       
         WS-OUTPUT2 COUNT IN WS-COUNT2       
         WS-OUTPUT3 COUNT IN WS-COUNT3.
END-UNSTRING.     
MOVE WS-OUTPUT1(2:WS-COUNT1)    TO WS-FIN1
MOVE WS-OUTPUT2(2:WS-COUNT2)    TO WS-FIN2
MOVE WS-OUTPUT3(2:WS-COUNT3)    TO WS-FIN3
Back to top
View user's profile Send private message

Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8449
Location: Dubuque, Iowa, USA

PostPosted: Sat Dec 22, 2018 12:46 am    Post subject: Reply to: Unstring
Reply with quote

Quote:
Is there any other way to do it?
It would be rare indeed for there only one way to do something in COBOL. You could also use reference modification to accomplish what you want.
Back to top
View user's profile Send private message
srini24

New User


Joined: 14 Feb 2017
Posts: 12
Location: India

PostPosted: Sat Dec 22, 2018 6:59 pm    Post subject: Reply to: Unstring
Reply with quote

What logic can be applied using reference modification alone?
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1315
Location: Israel

PostPosted: Sun Dec 23, 2018 8:14 pm    Post subject: Reply to: Unstring
Reply with quote

Is that an exercise ?
Are there always 4 words in the sentence ?
Back to top
View user's profile Send private message
Rohit Umarjikar

Senior Member


Joined: 21 Sep 2010
Posts: 2165
Location: NY,USA

PostPosted: Thu Dec 27, 2018 12:54 am    Post subject:
Reply with quote

1.See if you can twist INSPECT the way you want.
2.If you are allowed to use SQLs then use scalar functions.
3. As suggested by Robert , Use Ref modifications. loop thru the whole string to skip first letter and when you encountered SPACE then set a flag and skip the first letter of the next word and unset that same flag and move remaining letters until you hot next SPACE and repeat this till end of the string.
4. If these are record from the data set then use DFSORT to create a new Data Set the way you want and then run Cobol Program. I would not prefer this when COBOL is simpler.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts UNSTRING problem Apurva Ghogale COBOL Programming 3 Tue Oct 09, 2018 8:01 pm
No new posts UNSTRING a big string Apurva Ghogale COBOL Programming 16 Thu Sep 20, 2018 12:12 pm
No new posts Unstring list of values into an array. Roshnii COBOL Programming 8 Mon Jun 27, 2016 6:25 pm
No new posts Problem with UNSTRING of CSV data Bill Woodger COBOL Programming 14 Tue Dec 15, 2015 5:32 pm
No new posts Unstring in Cobol Govardhana krishna COBOL Programming 7 Thu Oct 17, 2013 8:52 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us