Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Organizing

Status
Not open for further replies.

SMAlvarez

Programmer
Dec 4, 2005
27
US
Hey Again,

How would I go about doing this?
Lets say I have data like this:

0000abcd123
0001efgh123
0002ijkl123
0003mnop123

And I want to lay it out like:


Code Letters Numbers
0000 abcd 123
0001 efgh 123
0002 ijkl 123
0003 mnop 123

I know how to get the headings, but how do I separate the data like that? Thanks Again!
 
Please be specific. Is your data always of the same size?
Is this on one field or sveral field? Where do you want to lay the output is it printer, a file or whatever? Are the values always in consistent format?

The simplest solution would be to do
a MOVE fieldname (position:lenght) to something.
 
Lets say the length is just like that 12 characters.
For example I want to seperate 0000abcd123 and print out to the printer 0000 abcd 1234 under those headings.

Get what Im trying to say??
 
So you define your printer layout like
01 PRT01.
02 P1 Pic x(4).
02 P2 Pic x(4).
02 P3 Pic x(4).

Then just do

MOVE Fieldname TO PRT01.

or

MOVE Fieldname(1:4) to P1.
MOVE Fieldname(5:4) to P2.
MOVE Fieldname(9:4) to P3.

 
jmanj, you didn't address the spacing between the collumns implicitly specified in the original request. So
Code:
01 PRT01.
  02  P1    Pic x(4).
  [COLOR=red]02        Pic x.[/color]
  02  P2    Pic x(4).
  [COLOR=red]02        Pic x.[/color]
  02  P3    Pic x(4).
Then just do
Code:
  [COLOR=red]MOVE Space               to PRT01.[/color]
  MOVE Fieldname(1:4)      to P1.
  MOVE Fieldname(5:4)      to P2.
  MOVE Fieldname(9:4)      to P3.
 
Thanks guys, what does the 1 and the 4 stand for in
MOVE Fieldname(1:4) to P1.

?

Thanks again. I haven't seen a move like this until now.
 
Then (n:m) following a field name is called Referance Modification. It is COBOL's answer to substrings. n is the beginning position of the substring, and m is the length. n or m can be a constant, a variable, or in the form [variable +/- constant]. With many compilers, neither n nor m are restricted by the specified length of the Referance Modified field. Although dangerous, this can simplify some very complex dynamic string manimulation.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top