Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Insert a record in a variable at particular position

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

New User


Joined: 14 Nov 2007
Posts: 70
Location: mumbai

PostPosted: Tue Mar 23, 2010 1:19 pm    Post subject: Insert a record in a variable at particular position
Reply with quote

Hi Guys,

I need to scan a variable ( Pic X 20000) for a keyword '{108' and then insert 'HI' in the 7th position from '{108'.Also its not necessar that #VAR (pic X 20000) will have all 20000 chars occupied.

Now here is the code which i had applied for this.

Code:
MOVE 'N' TO WS-108-FOUND                     
PERFORM VARYING WS-108-POS FROM 1 BY 1       
                     UNTIL WS-108-POS > 19980 OR           
                              WS-108-FOUND-YES               
IF #VAR(WS-108-POS : 4) = '{108'           
MOVE 'Y' TO WS-108-FOUND                               
MOVE #VAR(WS-108-POS + 11 :19980 )   
TO #VAR(WS-108-POS + 13 :19980 )   
MOVE 'HI' TO #VAR(WS-108-POS + 11 :2)
end-if
end-perform


Now the issue is,Until population of U2,its coming fine but whatever variable is appearing after that is reapeating till the end instead of the orignal data.

For example

INPUT IS
{ASBDASDSDKJAKSDJKASJDKASD{108:12345}ABCDEFGHIJKLMNOPQRST}

OUTPUT
{ASBDASDSDKJAKSDJKASJDKASD{108:12345HI}}}}}}}}}}}}}}}}}}


Thanks in advane guys.
Back to top
View user's profile Send private message

GuyC

Senior Member


Joined: 11 Aug 2009
Posts: 1278
Location: Belgium

PostPosted: Tue Mar 23, 2010 4:11 pm    Post subject:
Reply with quote

old school assembler initialisation icon_wink.gif
I guess you have to work with a temp field.
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2150
Location: At my coffee table

PostPosted: Wed Mar 24, 2010 12:18 am    Post subject:
Reply with quote

As GuyC stated (sort of), an overlapping move is a basic assembler initialization technique.
the COBOL MOVE is an assembler MVC which is processed from left to right.
I am suprised that with the two byte displacement you are not getting something like:
Code:
{ASBDASDSDKJAKSDJKASJDKASD{108:12345HI}A}A}A}A}A}A}A}A}A}A...
Back to top
View user's profile Send private message
UmeySan

Active Member


Joined: 22 Aug 2006
Posts: 743
Location: Germany

PostPosted: Wed Mar 24, 2010 2:30 pm    Post subject:
Reply with quote

Morning Sir !

I'm just thinking about using Unstring/String command with the Pointer option ...
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 How to update a portion of text in a ... Bill Woodger DFSORT/ICETOOL 25 Wed Nov 09, 2016 9:41 pm
No new posts sort with previous record anatol DFSORT/ICETOOL 9 Thu Oct 06, 2016 2:36 am
No new posts Get Record count in summary record fo... Atul Banke DFSORT/ICETOOL 21 Fri Sep 23, 2016 4:17 pm
No new posts Format to pipe delimited with variabl... pshongal SYNCSORT 6 Wed Sep 14, 2016 2:48 pm
No new posts Change date (DD/MM/YY) in 2nd record ... uday kiran DFSORT/ICETOOL 12 Wed Sep 07, 2016 10:57 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us