View previous topic :: View next topic
|
Author |
Message |
santohsks1987 Warnings : 1 New User
Joined: 29 Dec 2010 Posts: 31 Location: Mumbai
|
|
|
|
I have to sort an array with 3 fields i.e Name, date and code. Then i have to compare the records in the array with a table and put the records which are not present in the table into another table.
Please help me how to sort it and how to compare it also.
How to compare the date field? |
|
Back to top |
|
|
santohsks1987 Warnings : 1 New User
Joined: 29 Dec 2010 Posts: 31 Location: Mumbai
|
|
|
|
Hi everyone,
I have to read a VSAM file and populate an array. This has three elements in it. Please give me the code how this can be achieved. |
|
Back to top |
|
|
PeterHolland
Global Moderator
Joined: 27 Oct 2009 Posts: 2481 Location: Netherlands, Amstelveen
|
|
|
|
Now thats a bad start for 2011 for a software engineer (sic), asking for code without offering something. |
|
Back to top |
|
|
santohsks1987 Warnings : 1 New User
Joined: 29 Dec 2010 Posts: 31 Location: Mumbai
|
|
|
|
i have a vsam file with many fields. but i have to read only the first name, DOB and relationship code and put in an array.
what other information is required |
|
Back to top |
|
|
Akatsukami
Global Moderator
Joined: 03 Oct 2009 Posts: 1787 Location: Bloomington, IL
|
|
|
|
santohsks1987 wrote: |
i have a vsam file with many fields. but i have to read only the first name, DOB and relationship code and put in an array.
what other information is required |
The amount that you will be paying one of us to produce code for which you will take credit. |
|
Back to top |
|
|
Dsingh29
Active User
Joined: 16 Dec 2008 Posts: 132 Location: IBM
|
|
|
|
there is ascending/descending clause available while working with cobol tables....google more for it..and u can use it in ur code. |
|
Back to top |
|
|
santohsks1987 Warnings : 1 New User
Joined: 29 Dec 2010 Posts: 31 Location: Mumbai
|
|
|
|
no. I have a vsam file and put the contents into an array in a sorted order. give me sample code for this. take an example of 3 fields that i have to consider while sorting. that is i have to sort that based on all the three keys
|
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8700 Location: Dubuque, Iowa, USA
|
|
|
|
Quote: |
Please help me how to sort it and how to compare it also. |
There is a link to manuals at the top of the page. Click it, find the COBOL Language Reference manual, and read up on the SORT verb -- follow up with reading in the COBOL Programming Guide manual. Then, research the IF statement and how to use it. |
|
Back to top |
|
|
Dsingh29
Active User
Joined: 16 Dec 2008 Posts: 132 Location: IBM
|
|
|
|
did u googled for it....????
I think it doesnot matter to cobol tables from where the data is coming...when u r populating the cobol table....so the asc/desc clause will work just fine....
And please stop asking for sample codes....you have to build your own code... |
|
Back to top |
|
|
Kjeld
Active User
Joined: 15 Dec 2009 Posts: 365 Location: Denmark
|
|
|
|
santohsks1987 wrote: |
I have to sort an array with 3 fields i.e Name, date and code. Then i have to compare the records in the array with a table and put the records which are not present in the table into another table.
Please help me how to sort it and how to compare it also.
How to compare the date field? |
As you have put the requirement, you don't have to sort. I would suggest this approach:
1. Read input record
2. If EOF, you are done.
3. Look up the key in the compare table (you even don't have to fetch any data - use EXISTS in DB2)
4. If you got a row not found result from the lookup, perform logic to insert the infile information into table.
5. Read input record
6. Proceed from step 2
This assumes that you can select unique observations on all keys; if not, you will have to retrieve the not used key variables and compare them in the lookup code to establish if a match has been found. |
|
Back to top |
|
|
Phrzby Phil
Senior Member
Joined: 31 Oct 2006 Posts: 1050 Location: Richmond, Virginia
|
|
|
|
gimme gimme gimme gimme gimme gimme gimme gimme gimme gimme gimme gimme gimme gimme gimme gimme gimme gimme gimme gimme gimme gimme gimme gimme gimme gimme gimme gimme gimme gimme gimme gimme gimme gimme gimme gimme gimme gimme gimme gimme gimme gimme gimme gimme gimme gimme gimme
Oh yeah - thanks. |
|
Back to top |
|
|
Kjeld
Active User
Joined: 15 Dec 2009 Posts: 365 Location: Denmark
|
|
|
|
santohsks1987 wrote: |
i have a vsam file with many fields. but i have to read only the first name, DOB and relationship code and put in an array.
what other information is required |
Is this information enough to make a unique match? |
|
Back to top |
|
|
santohsks1987 Warnings : 1 New User
Joined: 29 Dec 2010 Posts: 31 Location: Mumbai
|
|
|
|
I have to sort an array based on three key fields. Is it possible using bubble sort.... |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10889 Location: italy
|
|
|
|
Quote: |
I have to sort an array based on three key fields. Is it possible using bubble sort.... |
YES!
or any other algorithm You feel comfortable with
there are quite a few examples that can be found by GOOGLING! |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
you can even pass the COBOL Internal Table via linkage to a sub-module,
which would be a COBOL Sort program (one that uses SD's, SORT Procedure statements, etc....)
which would RELEASE each item of the COBOL Internal Table to SORT
and then repopulate the COBOL Internal Table with the RETURN statement results.
That you even have to ask about sorting,
means you are probably incapable of a timely implementation of a routine to perform a bubble sort. |
|
Back to top |
|
|
Kjeld
Active User
Joined: 15 Dec 2009 Posts: 365 Location: Denmark
|
|
|
|
Santosh,
If you are that unfamiliar with comparing values and how to structure a fairly simple requirement as you revealed in your original posting, I will advice against implementing your own sorting algoritm.
It makes your program harder to maintain, and can probably only be justified if you have a simple sort key, and a limited number (<100?) of rows to sort.
Check the Cobol manual for how to code an internal sorting. Internal sorting will call a utility sort, IBM's DFHSORT or other, depending on your installation. Sort utilities will choose a suitable and efficient sort method for you, and use internal or external temporary storage as needed. |
|
Back to top |
|
|
santohsks1987 Warnings : 1 New User
Joined: 29 Dec 2010 Posts: 31 Location: Mumbai
|
|
|
|
ya that is fine but i am actually working in online mode. will this work even in the online mode???? |
|
Back to top |
|
|
Kjeld
Active User
Joined: 15 Dec 2009 Posts: 365 Location: Denmark
|
|
|
|
Ahh, a requirement you didn't tell us about!
What on earth are you doing with sequential unsorted data in a real-time environment?
Is there any possibility to convert this task into a asynchroneous (offline) one? |
|
Back to top |
|
|
santohsks1987 Warnings : 1 New User
Joined: 29 Dec 2010 Posts: 31 Location: Mumbai
|
|
|
|
Thank you all for your replies...... It really helped me a lot in thinking in different views. |
|
Back to top |
|
|
|