Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


How to MOVE A TO B with specs

How to MOVE A TO B with specs

How to MOVE A TO B with specs

Excuse the subject as I was trying to be brief w/o being too cryptic.

I would like to find a way to move field A to field B specifying the offset into field B for the length of A.

The application needs to construct a signature line where the person's name concatenated with a known job title in field A needs to be moved so it fills the rightmost portion of field B.

Something like:
MOVE FIELD-A TO FIELD-B (offset into FIELD-B:length-of-FIELD-A)

Any ideas?
I'm using Micro Focus Server Express COBOL if it makes any difference.


RE: How to MOVE A TO B with specs

Look in your reference manual for "reference modification".  The syntax is almost identical to what you have coded.

Tom Morrison
Micro Focus

RE: How to MOVE A TO B with specs

I assume when you want to use the length of field A you actually mean how many characters of field A are being used - not the length as defined in the PIC clause.

You need to set up a loop to calculate the number of characters being used in field A.  You could start at pos 1 of field A and add 1 to a counter as long as Field A from that position to the end is not equal to all spaces.
   ADD 1 to counter
   ADD 1 to pos

Now that you know how many characters long field A is, you can subtract that from LENGTH OF field B to see what column to start moving into field B.  

If field B is defined as 20 bytes long and you have determined that field A uses 6 bytes, you want to begin moving Field A to Field B starting at position 15 of field B (so you fill that rightmost 6 bytes of field B).

MOVE SPACES TO FIELD-B.  Get rid of any old data in first 14 bytes
MOVE FIELD-A TO FIELD-B(calculated-first-byte:).
you don't need a length value on the reference modification because you are filling all of the remaining characters of FIELD-B.

Another way would be to define FIELD-B with the JUSTIFIED clause so when you do a move into that field it will be right justified rather than left justified.  Now after you have calculated the length of FIELD-A use:

You don't need the initial move spaces as previously because when you move a shorter field to a longer, spaces are padded in unused characters.

RE: How to MOVE A TO B with specs

Thank you very much coboldeke, I really appreciate the assistance.  You were correct, by length of field A, I intended the positions being used, not the PIC length.

Using JUSTIFIED on the receiving field occurred to me, but I immediately dumped that idea since it is being used for just about every line of the output which is a legal document.  The original author (back in 1990) used the approach of stringing text together using a subroutine for that purpose.  It appends text to the line and avoids splitting words.  It also keeps track of how much of the line is filled.

I came up with a solution at the last minute Friday...
I knew how much space was in the line (field B), and was able to determine the length of text in field A) as you did above, so I then computed the amount of offset needed to right justify the line then called the stringing routine giving it the required info.  This seemed the best approach under the circumstances, since I could find what I was looking for in the documentation online.  I think I'll go back and implement your suggestion since it was really my preferred method.

k5tm Thanks for the input.  Unfortunately we have no manuals these days and I couldn't think of "reference modification" because of time pressures.  Being an old timer (today begins week 2 in year 44 of this fun) I much prefer real manuals... you can't keep track of several places in a web "manual" by sticking your fingers between pages.  Reference materials on the web are great, but give me a hardcopy manual, please!

Thanks for the responses, and especially for a solution.


RE: How to MOVE A TO B with specs


Our manuals are always available at:

Yes, I also bemoan the loss of 'real' manuals, fought the battle several years ago at Liant, and lost.  The stark reality is that no one wants to pay the extra cost for a 'real manual' these days.  And, since I am a developer, the lead time for getting manuals printed is enormous in today's compressed development schedules.  Keeping the docs aligned with the actual product was a nightmare when we were actually printing books.

Finally, there are products, both free and at some cost, to add bookmarks to PDF documents.  Not sure it is worth the time, though, since you probably only want the marks for one session.

Tom Morrison
Micro Focus

RE: How to MOVE A TO B with specs

Move A (1:1) to B (1:1)

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close