Hi,, M25 is one of my flat file which is 34 char length. I want to write data from flat file to normal pf. Pf contains 3 char field which is equally devide.
Now generaly to read file we have to requre key field but flat file doesn't have any key field then how i will write this pf?
Software/Hardware used:
ASKED:
August 27, 2010 4:12 AM
UPDATED:
August 30, 2010 8:52 AM
Several options are vailale to do what you want. Tom mentiond two of them. I’ll supply you with 2 other options:
1. Use Query/400 over your flat file, and define result fields within the query using the fieldnames and field attributes from the target pf (SUBSTR from flat file). Then select Output type as ’3′ (‘Database file’), whereafter you will be prompted for the name and lib of the outputfile ; – use ’4′ or ’5′ to replace/add to member. Having created the query, use RUNQRY command in your application-CL. That’s it..
2. Use RPG cycle.
Using Tom’s RPG code as model, here is my version, which uses the RPG-cycle for automatic reading a file from start till end (‘ip’ (input primary)). Thus there is no need for any more RPG-code to readthe file and end the program – the ‘cycle’ does just that.
fM25 ip f 34 disk foutfile o a e disk iM25 aa 01 i 1 34 Rec /free F1 = %subst(Rec: 1:11); . . Fn = %subst(Rec:12:11); Write OutFileR;Since you’l propably need to move data to fields, I inserted some lines assuming fieldnmes in targetfile to be F1, F2 etc.
It is often claimed that this method is executing faster tha doing your on read. Well, – I did some tests (timestamp added to outputrec) on this and must report that on a 10+ mio recs inputfile, the IP-model used 82 secs whereas Tom’s READ-model used 80 secs.
I recommend you to use the READ-model, since this code is propably more clear to maintain for the future, even though I (being an oldtimer) is still fascinated by the fact that the IP-model reduces needed coding.
DanF
To clarify, CharlieBrowne responded first with the RPG suggestion. I only added the CPYF comments.
Tom
Sorry CharlieBrowne, I overlooked that you were the source. Thanks to Tom for the info
DanF