View previous topic :: View next topic |
Author |
Message |
coolguy2005 Beginner
Joined: 22 Mar 2005 Posts: 22 Topics: 16
|
Posted: Wed Apr 27, 2005 6:37 pm Post subject: Read from a file record by record only 1st 6 characters |
|
|
Hai,
I am new to PL/1 & I am working on a new requirement where in i have to read from a file passed in RUNJCL which has many records one by one till the end of the file and only i should be reading only 6 characters of the record & store the 6 characters read individually of the record one by one & store them individually into an array of 20,000 elements.
After doing that i have to compare values obtaining from a DB2 table which is again 6 bytes with the elements individually in the array ,if found matching ,then i have to display the 6 bytes otherwise do not display.
Can anyone please assist me in this requirement. |
|
Back to top |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
|
Posted: Thu Apr 28, 2005 7:29 am Post subject: |
|
|
Coolguy2005,
Please do not expect others to do your work. If you get a code from here, you will never learn anything. Try out and if you have any questions regarding the code, please feel free to ask. The most important thing is you need to TRY.
btw you do not have to store the values in an array.
psuedo code
Code: |
OPEN THE FILE
READ THE FILE INTO FILE-LAYOUT
PERFROM MAIN-PROCESS UNTIL END-OF-FILE = 'Y'
MAIN-PROCESS.
PERFORM SELECT-6-BYTE-FROM TABLE
IF TABLE-6-BYTES = FILE-LAYOUT-6-BYTES
DISPLAY 'THE 6 BYTES IS FOUND ON THE DB2 TABLE'
END-IF
READ THE FILE INTO FILE-LAYOUT
|
It is as simple as that. Remember you always learn when you do it on your own.
Hope this helps...
Cheers
kolusu _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
 |
coolguy2005 Beginner
Joined: 22 Mar 2005 Posts: 22 Topics: 16
|
Posted: Thu Apr 28, 2005 9:20 am Post subject: FIND AN ELEMENT IN A ARRAY & STORE ELEMENTS IN A ARRAY |
|
|
Kolusu,
Thanks for an early response .I need some clarifcation if i want to find a particlur value in a array of elements how can i do that in PLI.
For example : say i want to find the number '123456' in a array of 1000 elements just we have search / search all in cobol ,how can we do that in PLI.Morever if we are reading from the file,how can we store individual record in a array of elements. |
|
Back to top |
|
 |
Mervyn Moderator

Joined: 02 Dec 2002 Posts: 415 Topics: 6 Location: Hove, England
|
Posted: Thu Apr 28, 2005 10:02 am Post subject: |
|
|
coolguy2005,
With an array of 2000 elements, and not too many values to find, you'd use the ANY builtin function:
Code: |
IF ANY(MY_ARRAY = '123456') THEN
BLAH BLAH BLAH
ELSE
BLAH_BLAH BLAH
|
_________________ The day you stop learning the dinosaur becomes extinct |
|
Back to top |
|
 |
coolguy2005 Beginner
Joined: 22 Mar 2005 Posts: 22 Topics: 16
|
Posted: Thu Apr 28, 2005 10:29 am Post subject: ASSIGN VALUES TO INDIVIDUAL ELEMENTS OF ARRAY READ FROM FILE |
|
|
Thanks Mervyn,
I have a concern here how can i assign values to an array of elements individually after reading from a file record one by one with 10 bytes till end of file .
The code which i am using is
DCL ARRAY(2000) FIXED CHAR(10,0);
DCL INFILE FILE INPUT RECORD ENV(F RECSIZE(10));
DCL DATA_AREA CHAR(10);
DCL MORE_RECORDS BIT(1);
DCL NO BIT(1) INITIAL ('0'B);
DCL YES BIT(1) INITIAL ('1'B);
ON ENDFILE(INFILE) MORE_RECORDS = NO;
MORE_RECORDS = YES;
READ FILE(INFILE) INTO(DATA_AREA);
DO WHILE(MORE_RECORDS);
WRITE ARRAY FROM(DATA_AREA);
READ FILE(INFILE) INTO(DATA_AREA);
END;
After assigning the values to individial elements ,i have to get the values from db2 table,compare the db2 table value with the individual element value,if found process further otherwise do not process further |
|
Back to top |
|
 |
Mervyn Moderator

Joined: 02 Dec 2002 Posts: 415 Topics: 6 Location: Hove, England
|
Posted: Thu Apr 28, 2005 3:33 pm Post subject: |
|
|
I'm with Kolusu, on more than one level (he's not infallible, but he's almost always right ).
Your program appears to be a two file match. It's pretty straightforward, and you don't actually need an array, provided the two files are in the same sequence..
You can ensure that the DB2 table rows are in the correct sequence simply by using ORDER BY. Your other input file can be sorted, if necessary, before you read it.
I really think you've got all the information you need. Go for it! _________________ The day you stop learning the dinosaur becomes extinct |
|
Back to top |
|
 |
|
|