View previous topic :: View next topic |
Author |
Message |
rakshith Beginner
Joined: 26 Jul 2005 Posts: 32 Topics: 16 Location: bangalore
|
Posted: Thu Dec 15, 2005 9:45 am Post subject: move statement doubt |
|
|
hi all
I have two group items like,
1 01 A .
02 a1 OCCURS 3 TIMES PIC X(2).
02 a2 OCCURS 3 TIMES PIC 9(1)V9(2)
02 a3 OCCURS 3 TIMES PIC X(2).
2 02 B
02 b1 OCCURS 10 TIMES PIC X(2).
02 b2 OCCURS 10 TIMES PIC 9(1)V9(2).
02 b3 OCCURS 10 TIMES PIC X(2).
I have move A to B , A occurs 3 times and B occurs 10 times
I am using PERFORM statement to move all the variables from 1 by 1 until n times
move a1 to b1
.....
....
can any suggest value of n and why,
thanks in advance,
rakshith |
|
Back to top |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
|
Posted: Thu Dec 15, 2005 10:32 am Post subject: |
|
|
rakshith,
What exactly is your question?
Kolusu _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
 |
Crox Beginner
Joined: 29 May 2004 Posts: 52 Topics: 9
|
Posted: Sat Dec 17, 2005 7:03 am Post subject: |
|
|
you can just move one by one, no perform necessary:
MOVE A1(1) TO B(1)
MOVE A1(2) TO B(2)
...
etc.
When you use a perform varying for this, you can do something like:
PERFORM VARYING TALLY FROM 1 BY 1 UNTIL TALLY > 3
MOVE A1(TALLY) TO B1(TALLY)
END-PERFORM
But now you are coding the same amount of lines of code. And the performance is less. So this is also not a good way.
If you create a group above the A1, you can transfer a1(1 to 3) in one move to b1 (1 to 3). For example:
01 A .
02 A1-GROUP.
03 a1 OCCURS 3 TIMES PIC X(2).
..
01 B.
02 B1-GROUP.
03 B1 OCCURS 10 TIMES PIC X(2).
IF you move A1-GROUP TO B1-GROEP (1:6), you transfer those 6 bytes in one move into the right place of B.
I guess youi do a study?
1 01 A.
is no COBOL.
01 A.
is.
Regards,
Crox |
|
Back to top |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
|
Posted: Sat Dec 17, 2005 9:31 am Post subject: |
|
|
Quote: |
you can just move one by one, no perform necessary:
MOVE A1(1) TO B(1)
MOVE A1(2) TO B(2)
...
etc.
|
Crox,
Why not a simple Move A to B?
Kolusu _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
 |
Crox Beginner
Joined: 29 May 2004 Posts: 52 Topics: 9
|
Posted: Sat Dec 17, 2005 10:47 am Post subject: |
|
|
I am afraid you ignore the occurs and the field types. In A there are 3 occurs, in B 10. So expressing the bytes in memory by a string, you have the following situation:
Code: | 01 A .
02 a1 OCCURS 3 TIMES PIC X(2).
02 a2 OCCURS 3 TIMES PIC 9(1)V9(2)
02 a3 OCCURS 3 TIMES PIC X(2).
2 02 B
02 b1 OCCURS 10 TIMES PIC X(2).
02 b2 OCCURS 10 TIMES PIC 9(1)V9(2).
02 b3 OCCURS 10 TIMES PIC X(2).
in memory,
a1 represented by a,
a2 represented by b,
a3 represented by c,
b1 represented by a,
b2 represented by b,
b3 represented by c.
01 LEVEL A IN MEMORY looks like:
aaaaaabbbbbbbbbcccccc
01 LEVEL B in MEMORY looks like:
aaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbcccccccccccccccccccc
|
A is 21 bytes long. B is 70 bytes long. Moving A to B means that the 21 bytes of A will be transferred to the first 21 bytes of B and the rest will be filled with spaces, which also does not fit with the picture of those fields. So that is probably not what is meant to do!
NB. COBOL is not like PL/I |
|
Back to top |
|
 |
|
|