Page 2 of 2

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

PostPosted: Tue Apr 10, 2012 8:24 pm
by rekhamf
Thanks Gokul .I'm trying the same logic.

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

PostPosted: Tue Apr 10, 2012 9:45 pm
by rekhamf
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 ?

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

PostPosted: Tue Apr 10, 2012 10:12 pm
by rekhamf
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 ?

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

PostPosted: Tue Apr 10, 2012 11:16 pm
by dick scherrer
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.

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

PostPosted: Wed Apr 11, 2012 3:33 am
by BillyBoyo
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.

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

PostPosted: Wed Apr 11, 2012 8:11 am
by gokulNmf
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.