View previous topic :: View next topic
|
Author |
Message |
sudhirk63
New User
Joined: 08 Oct 2006 Posts: 19 Location: Bangalore
|
|
|
|
Hello All,
Any clues as how can I achive to concatenate records into same variable.
My requirement is to read from a file and concatenate several records into one output record based on certain conditions.
The input can be as :
001AAAA
001BBBBBBB
002CCCCCCCCCC
003DDDDDDDDDDDDD
003EEEEEEEEEE
003FFFFFFFFFF
The output I want to achieve is as, assuming that for a record if first three bytes are same, they merge together into one record. The number of records with same key values are not fixed nor the maximum number of occurence of the same value of the key is know.
001AAAA001BBBBBBB
002CCCCCCCCCC
003DDDDDDDDDDDDD003EEEEEEEEEE003FFFFFFFFFF
In the code, performing in a loop and writing to the same output varaibe does not concatenate the string together.
STRING MOD77IN-FILE-I
DELIMITED BY SIZE
INTO OUT-DATA
This snippet wipes out the previously written data to the OUT-DATA varaible.
Can any one help me as how can I use the STRING function or any other technique to get the desired result.
Thanks in advance for your help.
Sudhir |
|
Back to top |
|
|
CICS Guy
Senior Member
Joined: 18 Jul 2007 Posts: 2146 Location: At my coffee table
|
|
|
|
sudhirk63 wrote: |
In the code, performing in a loop and writing to the same output varaibe does not concatenate the string together. |
Have you thought of using the POINTER phrase of the STRING statement |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
You may have added difficulty that is not needed. . .
What is the maximum lrecl of an output record?
Seems ike you could read the records and compare the "key". If thi key is the same, simply append "this" record to the "output area" using reference modification and keeping track of where you are in the output area. If the record just read would exceed maximum lrecl, write the record already in the output area, clear the area, and move in the first entry of the next output record.
Unless i've misunderstood, there is no need for a loop or string, just reference-modified moves.
If i've misunderstood, please advise |
|
Back to top |
|
|
hemanth.nandas
Active User
Joined: 18 Aug 2007 Posts: 120 Location: India
|
|
|
|
Hi All,
Use Like this,
Code: |
01 WS-NEW-FIELD.
05 WS-NEW-FIELD-1 PIC X(UR 1ST VARIABLE LENGHT)
05 WS-NEW-FIELD-1 PIC X(UR 2ND VARIABLE LENGHT)
EVALUATE TRUE
WHEN
WS-FIELD-1(WS-INDEXED-1)(1:3) =
WS-FIELD-2(WS-INDEXED-2)(1:3)
MOVE WS-FIELD-1(WS-INDEXED-1) TO WS-NEW-FIELD-1
MOVE WS-FIELD-2(WS-INDEXED-2) TO WS-NEW-FIELD-2
DISPLAY 'COMBINED RECORD' WS-NEW-FIELD
WRITE OUT-REC FROM WS-NEW-FIELD |
No need to declare index but performance ways, it is better to declare and do it in loop. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Please re-read the requirement.
I believe the posted code will not handle the requirement. . . |
|
Back to top |
|
|
hemanth.nandas
Active User
Joined: 18 Aug 2007 Posts: 120 Location: India
|
|
|
|
Hi Dick,
Quote: |
Please re-read the requirement |
Quote: |
MOVE WS-FIELD-1(WS-INDEXED-1) TO WS-NEW-FIELD-1
MOVE WS-FIELD-2(WS-INDEXED-2) TO WS-NEW-FIELD-2 |
You are right Dick, But before this need to code some logic I mean For lenght.
Let us know if you got answer.
Thanks DICK. |
|
Back to top |
|
|
sudhirk63
New User
Joined: 08 Oct 2006 Posts: 19 Location: Bangalore
|
|
|
|
Thanks Cics_guy and Dick. Both pointer and reference modification worked for me.
I have used reference modification as it seemed easier.
Sudhir |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello Sudhir,
Thank you for posting your progress
Hemanth,
Is there something in my earlier reply that is not clear to you?
If you have a question, please explain what is not clear and i will try to clarify. |
|
Back to top |
|
|
hemanth.nandas
Active User
Joined: 18 Aug 2007 Posts: 120 Location: India
|
|
|
|
Hi Dick,
I got It.. Thanks.. |
|
Back to top |
|
|
hemanth.nandas
Active User
Joined: 18 Aug 2007 Posts: 120 Location: India
|
|
|
|
Hi Sudhir,
Quote: |
Thanks Cics_guy and Dick. Both pointer and reference modification worked for me.
I have used reference modification as it seemed easier. |
Post your answer so that other can also refer the same.. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
You're welcome |
|
Back to top |
|
|
|