Thank’s you very much at all members for your response
Sorry but i make a mistake when i showed the example
I have more and more fields in the structure, not just level1 and i have need to move all structure
-1- Move by name all structure except the periodic group and multiple field
-2- Move multiple fields (no pb for this because move a to b compil correctly)
-3- Move periodic group
If i want compil the first move by name, i must change the group’s name and it’s no possible to make
'move by name ’ for periodic group after
At first, I did not understand the problem you were trying to address. Your second post clarified the problem (I think).
Suppose you have a FROM group and a TO group which are identical, and have many named fields and arrays.
What you could do (perhaps) is something like the following:
Suppose I want to move the FROM group to the TO group, except for an array #ARRAY (1:10).
You could have a small third group, say the SAVE group, which has just #ARRAY (1:10)
Do a MOVE BY NAME (or just a MOVE) of FROM.#ARRAY(1:10) to #SAVE.#ARRAY(1:10)
Now do the big MOVE BY NAME of FROM to TO.
Next, do a move of #SAVE.#ARRAY(1:10) to TO.#ARRAY (1:10)
This will clearly not be as efficient as individual moves, and, you would need separate SAVE arrays for different exclusions, but it will work, and will avoid the “messiness” of working with the large groups (possibly using separate MOVEs for each field/array).
Ok but it’s no work because th perodifc group can’t move (Compil error)
To clarify the problem, i write the entire code below
DEFINE DATA
LOCAL
1 £IN
2 £TAB01 (/1:191)
3 £TAB02 (A4)
3 £TAB03 (A3)
2 £TAB11 (A5/1:191)
2 £CH01 (A6)
1 £OUT
2 £HTAB01 (/1:*)
3 £HTAB02 (A4)
3 £HTAB03 (A3)
2 £HTAB11 (A5/1:*)
2 £CH01 (A6)
1 £SAVE
2 £TAB01 (/1:191)
3 £TAB02 (A4)
3 £TAB03(A4)
1 £I (N3)
END-DEFINE
£IN.£TAB02(1) := 'A'
£IN.£TAB03(1) := '1'
£IN.£TAB02(2) := 'B'
£IN.£TAB03(2) := '2'
£IN.£TAB02(3) := 'C'
£IN.£TAB03(3) := '3'
RESIZE ARRAY £OUT.£HTAB01 TO (1:3)
MOVE BY NAME £IN TO £OUT
MOVE BY NAME £IN.£TAB01(1:3) TO £SAVE.£TAB01(1:3)
MOVE £SAVE.£TAB01(1:3) TO £OUT.£HTAB01(1:3)
FOR £I := 1 TO 8
WRITE £OUT.£HTAB01(£I)
END-FOR
* WRITE WORK FILE 1 VARIABLE £OUT
END
In fact, the X-ARRAY is the problem but i have no other solution because the real program must write a file like a “decompress” method
field field nb occurence oc1 oc2 … ocn f3 f4 …
with nb occurence variable
MOVE BY NAME #IN TO #OUT
COMPRESS #IN.#TAB01(1:3) inTO #STRING with delimiter ‘,’
**
SEPARATE #STRING into #OUT.#TAB01 (1:3) with delimiter ‘,’
FOR #I := 1 TO 3
WRITE #OUT.#TAB01(#I)
END-FOR
write // ‘=’ #string
END
Page 1 16-01-21 14:32:57
A 1
B 2
C 3
#STRING: A,B,C,1,2,3
The use of COMPRESS and SEPARATE may do what you require.
If the above does not solve your problem, please post a specific example and the output you require
In fact, with MOVE BY POSITION you can eliminate the intermediate group called #SAVE and just do:
MOVE BY NAME #IN TO #OUT
MOVE BY POSITION #IN.#TAB01(1:#U) TO #OUT.#HTAB01(1:#U) /* <== :-()
Writing a variable number of occurrences of an MU or PE is simple. You don’t need the CPU overhead of X-arrays nor the complexity of multiple structures (#IN & #OUT) and MOVE BY NAME/POSITION. All you need is a verbose WRITE WORK statement.