Reading VB input file ,all the records at same time



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

Re: Reading VB input file ,all the records at same time

Postby rekhamf » Tue Apr 10, 2012 8:24 pm

Thanks Gokul .I'm trying the same logic.
rekhamf
 
Posts: 33
Joined: Mon Nov 28, 2011 5:09 am
Has thanked: 0 time
Been thanked: 0 time

Re: Re: Reading VB input file ,all the records at same time

 

Re: Reading VB input file ,all the records at same time

Postby rekhamf » Tue Apr 10, 2012 9:45 pm

Hi ,

I was trying this logic,,

But i could not able to append the record at the end of first line . i cannot use compute ,is there any function to append ?
rekhamf
 
Posts: 33
Joined: Mon Nov 28, 2011 5:09 am
Has thanked: 0 time
Been thanked: 0 time

Re: Reading VB input file ,all the records at same time

Postby rekhamf » Tue Apr 10, 2012 10:12 pm

Hi Gokul ,
How i can append the current record with the previous record ?output record = output record + current_record ,is there any function that i can use ?
rekhamf
 
Posts: 33
Joined: Mon Nov 28, 2011 5:09 am
Has thanked: 0 time
Been thanked: 0 time

Re: Reading VB input file ,all the records at same time

Postby dick scherrer » Tue Apr 10, 2012 11:16 pm

Hello,

Why do you believe COMPUTE might be used?

You do not need some "function". If you define the working storage properly, all you should need is the MOVE with reference modification. . . And a way to make sure your output record meets the length criteria and spans multiple records if needed.

Possibly i misunderstand.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6304
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 91 times

Re: Reading VB input file ,all the records at same time

Postby BillyBoyo » Wed Apr 11, 2012 3:33 am

rekhamf wrote:[...]

if first time
move input-data to output-data(1:ws-length ) ,, ws-length is length of each field
if curr-field = prev-field
and not first time
compute ws-length1 = ws-length1 + ws-length
move input-data to output-data(ws-length1)
else
continue ( read the next record)

like this ...


I thought from the pseudo code that you had some idea of where you were going with that.

This is a normal MOVE:

MOVE the-source-field TO the-target-field


The whole of the-source-field will be move to the whole of the-target-field. If the-target-field is bigger than the-source-field, it will be "padded" with trailing blanks. If it is shorter, the data will be truncated, from the right.

This is a MOVE with reference-modification:

MOVE the-source-field ( start-position : length-required ) TO the-target-field ( another-start-position : another-length-required )


This allows you to move any part of the-source-field to any part of the-target-field, depending on the values for the start positions and the lengths.

Whether you need reference-modification for your source field depends on how you have defined your data, but:

MOVE the-source-field ( 1 : length-of-input-record ) TO the-target-field


Will do for the move for the first record of a group, as it will initialise the unused part of the-target-field, by the padding to trailing blanks.

For your subsequent MOVEs, the-source-field stays the same, but the-target-field has to now be modified:

MOVE the-source-field ( 1 : length-of-input-record ) TO the-target-field ( length-so-far +1 : length-of-input-record )


If you use reference-modification, try to give everything good names. Don't use a literal 1, but define a value in working-storage with a descriptive name. Do the calculation "outside" of the reference modification (the +1).

Although this is the "modern" way to do it, that does not mean you have to make it more unclear/difficult to follow later.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times

Re: Reading VB input file ,all the records at same time

Postby gokulNmf » Wed Apr 11, 2012 8:11 am

BillyBoyo has detailed the move with reference modification..you can try that. That is the simple method used for string movement with modifications. You also learn abt the string and unstring verbs.
Cheers,
Gokul
User avatar
gokulNmf
 
Posts: 114
Joined: Sat Mar 28, 2009 6:41 pm
Location: India
Has thanked: 0 time
Been thanked: 0 time

Previous

Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post