Are all of these input records in the same file, or are the EX1, EX2 and EX3 records in different files?
The rules you give are quite vague. It would help if you showed the expected output records.
For EX1, does the word you want to extract always start in the same position as shown in your example records, or is it more complicated than that? Is the pattern of the records always a number followed by a word, or can it be some other pattern?
For EX2, what is the pattern? Is the single character always an E or can it be any character? Is the single character always the second "word"?
You really need to do a better job of explaining the rules, and the pattern of the records before anyone can help you. Also, show better examples of input and output.
All the examples are there in the same input file. Basically what I require is for EX1 ,I need the word that follows the number and space which is not fixed.
For Ex2: I need the word that follows the number, space, single caharacter,space and the postion and value are not fixed.
Sigh. The patterns still aren't clear. Do you want to handle the records differently depending on their relative record number, that is, handle records 1 and 2 as EX1, handle record 3 as EX2 and handle record 4 as EX3, or are there some other rules for the pattern that indicates how a record should be handled?
Think of this in programming terms. You need a set of IF/THEN conditions to identify how each record should be handled, e.g.
IF (pattern1) THEN ...
IF (pattern2) THEN ...
and you need to describe the patterns. Is the pattern for EX1 a number followed by a word, or two words, or something else? Is the pattern for EX2 a number followed by a single character followed by a word, or something else?
What about EX3 ... you said "For Ex3: I need to write as inthe input" but you don't show the last input record in the output. Why? And if you do want it in the output, what is the pattern for EX3 ... is it a non-numeric followed by a word or something else?
You can't just throw out some vague requirement and expect somebody to tell you how to do it. You have to give clear requirements to get the correct result. That's a basic skill of programming. If you can't give clear requirements, then nobody can help you.
I suspect you can use DFSORT's PARSE function to do the kind of thing you want to do. You can read about DFSORT's PARSE function here: