View previous topic :: View next topic
|
Author |
Message |
preethi sajjan
New User
Joined: 27 Oct 2011 Posts: 4 Location: india
|
|
|
|
Hi all,
The requirement is as follows,
The program should write the Message field in to the table from input file.
Input file is as follows
RECORD ID PIC X(3).
MSG PIC X(20).
Code: |
AB RRRRRR
AB YYYYYY
CD ZZZZZZ
AB RRRRRR
|
Messages that are writing to table are as follows
MSG CHAR(20) NOTNULL.
Code: |
RRRRRR
YYYYYYZZZZZZ
RRRRRR
|
I.e.. If any AB record follows CD record i should combine both record message and write it into the table.
Thanks in advance. |
|
Back to top |
|
|
Pandora-Box
Global Moderator
Joined: 07 Sep 2006 Posts: 1592 Location: Andromeda Galaxy
|
|
|
|
Small correction
1.We insert or Update records in DB2 Table not write
2. Its just a logic you need to incorporate what have you tried so far?
Not sure if you want us to write it for you and you get the salary |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
|
|
just checked the profile, it says
Quote: |
Occupation: software engineer
Mainframe Skills: cobol,jcl,db2,cics,vsam
|
I guess that both job description and skill set are overrated
where is the problem? the logic or the coding...
reading a file and <stacking> records <waiting> for a trigger is part of the basic programming ( any language ) training
which , training, seems missing here |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
preethi sajjan wrote: |
[...]
Code: |
RRRRRR
YYYYYYZZZZZZ
RRRRRR
|
I.e.. If any AB record follows CD record i should combine both record message and write it into the table.
[...] |
Not only is it unclear what you are asking of us, but your sample output does not match how you describe it should be built.
The R and Y values are from AB records. So in the about, the CD is appended to the previous AB, not AB following the CD appended to that CD.
Also, if you make examples like that for a 20-byte field, you have to be explicit to us whether they are to be treated as 20-bytes, or whether you need the trailing spaces removed, if any of that is involved in the answer, if there is a question. |
|
Back to top |
|
|
Pandora-Box
Global Moderator
Joined: 07 Sep 2006 Posts: 1592 Location: Andromeda Galaxy
|
|
|
|
preethi sajjan
I would suggest you to check out in beginners forum but again you might need to answer similar questions there too but may be you got to do some quiet practice to do some programming ( Please dont get offended)
Enrico,
Double Like!! |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
|
|
/chat on
this kind of problem has generally two logic approaches
1) process the stacked data on the <terminating> <trigger> ( CD in this case
2) the same, but on the <starting> <trigger> ( AB in this case )
my preference goes to option 2 ,
the <looping> logic will not change if more <stackable> records are added
the <trigger> is compared against a single value ( the starting one )
/chat off |
|
Back to top |
|
|
UmeySan
Active Member
Joined: 22 Aug 2006 Posts: 771 Location: Germany
|
|
|
|
@ preethi sajjan
Just without any structure and supervisory control routine.
Not taking care of exceptions.
Read In-Rec into In-Area-1
Read In-Rec into In-Area-2
If In-Area-1-Key = XX and In-Area-2-Key = YY
...String In-Area-1-Txt, In-Area-2-Txt
......delimited by size into Out-Area
...End-String
...Exec SQL insert ...
Else
...move In-Area-1-Txt to ...
...Exec SQL insert ...
...move In-Area-1-Txt to ...
...Exec SQL insert ...
End-If |
|
Back to top |
|
|
|