IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Unstring


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
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
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: 8700
Location: Dubuque, Iowa, USA

PostPosted: Sat Dec 22, 2018 12:46 am
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
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: 1353
Location: Israel

PostPosted: Sun Dec 23, 2018 8:14 pm
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

Global Moderator


Joined: 21 Sep 2010
Posts: 3076
Location: NYC,USA

PostPosted: Thu Dec 27, 2018 12:54 am
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Handling the numeric data in unstring... COBOL Programming 18
No new posts UNSTRING problem COBOL Programming 3
No new posts UNSTRING a big string COBOL Programming 16
No new posts Unstring list of values into an array. COBOL Programming 8
No new posts Problem with UNSTRING of CSV data COBOL Programming 14
Search our Forums:

Back to Top