Here, if I use MOVE BY POSITION, it will move the whole structure 1 to structure 2.
I do not want to keep the identical varialbles in both the structure and use MOVE BY NAME.
How can I make a move of only first 3 variables from structure 1 to first 3 variables in structure 2?
"Steve, just curious, did you ever compare the performance of MOVE BY NAME vs MOVE BY POSITION ?
I will have to dig it out. Probably re-run the code too, since it would be at least one (and possibly two) Natural versions ago.
HOWEVER, one point I should have made in my earlier response.
I really am annoyed when I see a MOVE BY NAME being used improperly (from a performance viewpoint).
I often see two Groups with identical fields (over twenty in one case I saw). There were two MOVE BY NAME’s for the Groups.
Instead, I had the programmer REDEFINE the Group as a single alpha field, then do a simple MOVE of the single field from within one Group to the other Group. The performance difference was quite astounding; okay, not really astounding since Natural was doing one move operation rather than twenty plus moves. I will post such a comparison later today.
To be fair, you would have to synchronize any changes to the two Groups. A miniscule price to pay (a tiny edit chore versus lots of extra MOVE’s every time the code was executed).
In Mishra’s case, instead of ST1-FIRST-THREE and ST2-FIRST-THREE being Groups, they could each be fields formatted as A13.
PAGE # 1 DATE: 02/19/12
PROGRAM: MOVNM04X LIBRARY: BOST-PER
MOVE BY NAME TIME: 30 301
MOVE TIME: 13 129
FOR LOOP ONLY: 12 116
I tend to use CPU time as a better indicator of performance than elapsed time (although on my PC, they are pretty much in lockstep).
After subtracting out the FOR loop CPU time, the single MOVE CPU time is 13, whereas the MOVE BY NAME CPU time is 185, which is a ratio of about fifteen to one. NOTE, this is only ten fields in the group. Performance should be somewhat linear with the number of fields.
Are there things I can do with MOVE BY NAME that I cannot do with a REDEFINE? Of course. However, when the two Groups are identical (same field names, same formats), I NEVER use the MOVE BY NAME.