Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Natural Query to read adabas file

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> Java & MQSeries
View previous topic :: :: View next topic  
Author Message
Shivendu

New User


Joined: 20 Feb 2009
Posts: 14
Location: Workstation

PostPosted: Wed Apr 01, 2009 3:03 pm    Post subject: Natural Query to read adabas file
Reply with quote

I want to write a Natural query through which all the data present in a particular adabas file is read and written to a flat file. I know the copybook of the adabas file and the key field (policy number) which will be used to search for the particular record in the adabas file.

Please help as I am new to Natural.
Back to top
View user's profile Send private message

ofer71

Global Moderator


Joined: 27 Dec 2005
Posts: 2360
Location: Israel

PostPosted: Wed Apr 01, 2009 3:08 pm    Post subject:
Reply with quote

1. There are many many examples in Software AG's fine manuals.
2. What do you mean by "copybook of the adabas file"? Copybook is a COBOL term. In Natural, only DDM may describe the structure of a database file.
3. If you want to read "all the data present in a particular adabas file" - Why do you need a key? You can read it physically, which would be much faster.

O.
Back to top
View user's profile Send private message
Shivendu

New User


Joined: 20 Feb 2009
Posts: 14
Location: Workstation

PostPosted: Wed Apr 01, 2009 3:20 pm    Post subject:
Reply with quote

Sorry, I meant DDM only. icon_smile.gif

Suppose, there are 1000 policies in the adabas file (1000 records). I have a flat file which contains 100 policy numbers. By reading this flat file, I want to query adabas and extract all the data (i.e. all the fields in the DDM) for all these 100 policies. Hope I am clear this time.
Back to top
View user's profile Send private message
ofer71

Global Moderator


Joined: 27 Dec 2005
Posts: 2360
Location: Israel

PostPosted: Wed Apr 01, 2009 3:23 pm    Post subject:
Reply with quote

Take a look at the READ statement, with the BY operand. If you want to read 1 record at a time, use the limit notation.

O.
Back to top
View user's profile Send private message
Shivendu

New User


Joined: 20 Feb 2009
Posts: 14
Location: Workstation

PostPosted: Mon Apr 06, 2009 8:05 pm    Post subject:
Reply with quote

My adabas file has 200 variables (in DDM). I want to write values contained in ALL of these variables to a flat file. Do I need to explicitly code all these (all 200) in DEFINE DATA LOCAL?
Right now what all variables I am coding in definition are getting written to the output file correctly (policy number in below case) using below code.

Code:
DEFINE DATA LOCAL               
1 NGI-POLICY VIEW OF NGI-POLICY
  2 POLICY-NUMBER               


Code:
READ WORK FILE 1 #POLICY-NUMBER                       
   FIND NGI-POLICY WITH POLICY-NUMBER = #POLICY-NUMBER
                    WRITE WORK FILE 2                 
                             NGI-POLICY   


Policy number is getting written to output file, rest all is blanks.

Is there a way to have all the DB fields written to output file WORK FILE 2?
Back to top
View user's profile Send private message
Shivendu

New User


Joined: 20 Feb 2009
Posts: 14
Location: Workstation

PostPosted: Mon Apr 06, 2009 8:18 pm    Post subject:
Reply with quote

Please refer to next post...not able to delete this one. Sorry!
Back to top
View user's profile Send private message
purushottam

New User


Joined: 26 Feb 2007
Posts: 34
Location: pune

PostPosted: Mon Apr 06, 2009 9:16 pm    Post subject:
Reply with quote

Yes, you will need to code all these (all 200) in VIEW Definition then move those values to corresponding variables of WORK FILE 2.

I dont think there is any other way out.

Regards,

Puru
Back to top
View user's profile Send private message
ofer71

Global Moderator


Joined: 27 Dec 2005
Posts: 2360
Location: Israel

PostPosted: Tue Apr 07, 2009 10:36 am    Post subject:
Reply with quote

1. You can use pure Reporting mode to avoid the VIEW definition; However, you still have to specify each field in your WRITE statement.
2. There are tools for writing a whole record (Take a look at TreeHouse, for example).

O.
Back to top
View user's profile Send private message
Ralph Zbrog

New User


Joined: 21 Nov 2009
Posts: 58
Location: California

PostPosted: Sat Dec 12, 2009 1:39 am    Post subject: Reply to: Natural Query to read adabas file
Reply with quote

All 200 field names must exist in your view, but that does not mean that you have to type all of them manually. Natural can generate the field list for you.
    . invoke the data editor
    . use .V line command to insert the view: .v(viewname)
    . select the 200 field names from the list
    . use the GEN command, which places you in the program editor
    . change the module type to Program: SET TYPE P
    . use this module as the basis of your query, or save it temporarily as a separate module for inclusion in the DEFINE DATA portion of your query

You do not need to move the field values from the view to a temporary structure to be used in the WRITE WORK, as suggested by Purushottam. For performance reasons, this is frowned upon. Your example
Code:
WRITE WORK FILE 2 NGI-POLICY

will work.
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 -> Java & MQSeries All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts SORTJOIN - Copy Matched and Unmatched... Steve Ironmonger DFSORT/ICETOOL 5 Tue Jan 17, 2017 4:26 pm
No new posts Join in SQL Query vickey_dw DB2 2 Tue Jan 17, 2017 12:15 am
This topic is locked: you cannot edit posts or make replies. MQ setup query mohitsaini Java & MQSeries 4 Sun Jan 08, 2017 1:53 am
No new posts DB2 query Using Recursion, Converting... smilewithashu2 DB2 1 Tue Jan 03, 2017 12:50 pm
No new posts Copy RECFM =VB TO FB file with RECL =... sahil41352 DFSORT/ICETOOL 3 Wed Dec 28, 2016 11:29 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us