I need to find the total number of records for a particular id in a huge PS file variable length. The issure here is the the field location for that ID is not fixed. There are 50 occurances of the defined field and a particualr id say 45 can be in any of the occurences.
Your description of the input records is too vague for anyone to give you a general solution. You need to do a better job of describing what you're trying to do exactly.
Please show an example of the records in your input file (relevant fields only) and what you expect for output. Explain the "rules" for getting from input to output. Give the starting position, length and format of each relevant field. Give the RECFM and LRECL of the input files. Cover all relevant variations in your example.