Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
write record in DB2 table from input files

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: write record in DB2 table from input files
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

Moderator


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

PostPosted: Tue Jan 24, 2012 12:54 pm    Post subject:
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10326
Location: italy

PostPosted: Tue Jan 24, 2012 1:01 pm    Post subject: Reply to: write record in DB2 table from input files
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7315

PostPosted: Tue Jan 24, 2012 1:09 pm    Post subject: Re: write record in DB2 table from input files
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

Moderator


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

PostPosted: Tue Jan 24, 2012 1:18 pm    Post subject:
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10326
Location: italy

PostPosted: Tue Jan 24, 2012 1:28 pm    Post subject: Reply to: write record in DB2 table from input files
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: 757
Location: Germany

PostPosted: Tue Jan 24, 2012 7:11 pm    Post subject:
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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts How to write Rexx program to size and... sreejeshcs CLIST & REXX 14 Thu Oct 12, 2017 7:26 am
No new posts Update table without cursor Ron Klop DB2 3 Wed Oct 11, 2017 1:06 pm
No new posts Copy 4 byte of data from the last rec... arunsoods DFSORT/ICETOOL 9 Fri Oct 06, 2017 12:15 pm
No new posts Table(Unicode(Graphic) table) loading... muralikrishnan_new DB2 0 Thu Oct 05, 2017 5:10 pm
No new posts FTP Skip or ignore error and process ... AJAYREDDY All Other Mainframe Topics 3 Wed Sep 27, 2017 8:12 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us