IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

write record in DB2 table from input files


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
preethi sajjan

New User


Joined: 27 Oct 2011
Posts: 4
Location: india

PostPosted: Tue Jan 24, 2012 11:50 am
Reply with quote

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
View user's profile Send private message
Pandora-Box

Global Moderator


Joined: 07 Sep 2006
Posts: 1592
Location: Andromeda Galaxy

PostPosted: Tue Jan 24, 2012 12:54 pm
Reply with quote

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 icon_biggrin.gif
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Tue Jan 24, 2012 1:01 pm
Reply with quote

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 icon_cool.gif


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
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Tue Jan 24, 2012 1:09 pm
Reply with quote

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
View user's profile Send private message
Pandora-Box

Global Moderator


Joined: 07 Sep 2006
Posts: 1592
Location: Andromeda Galaxy

PostPosted: Tue Jan 24, 2012 1:18 pm
Reply with quote

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
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Tue Jan 24, 2012 1:28 pm
Reply with quote

/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
View user's profile Send private message
UmeySan

Active Member


Joined: 22 Aug 2006
Posts: 771
Location: Germany

PostPosted: Tue Jan 24, 2012 7:11 pm
Reply with quote

@ 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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 3
No new posts TRIM everything from input, output co... DFSORT/ICETOOL 1
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts Load new table with Old unload - DB2 DB2 6
Search our Forums:

Back to Top