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

Natural Query to read adabas file


IBM Mainframe Forums -> Java & MQSeries
Post new topic   Reply to topic
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
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: 2358
Location: Israel

PostPosted: Wed Apr 01, 2009 3:08 pm
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
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: 2358
Location: Israel

PostPosted: Wed Apr 01, 2009 3:23 pm
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
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
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: 37
Location: pune

PostPosted: Mon Apr 06, 2009 9:16 pm
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: 2358
Location: Israel

PostPosted: Tue Apr 07, 2009 10:36 am
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> Java & MQSeries

 


Similar Topics
Topic Forum Replies
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 8
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Error to read log with rexx CLIST & REXX 11
Search our Forums:

Back to Top