hi, i am having a pf in that pf contain many members, using display file i have to search a perticular string in all the members if it is found these matching records want to write into another file this is my requirement. in CL grogram how to do this? using FNDSTRPDM can we do that, please replay me if any other solution please send me with example.
Unconfigured Ad Widget
Collapse
Announcement
Collapse
No announcement yet.
w to write all the matching records in to antoher
Collapse
X
-
Re:w to write all the matching records in to antoh
FndStrPDM could be used to find the string but I don't think you can use it to output a single record to another file; it wants to perform the option on the whole member. SQL would be your better choice, but it doesn't handle multiple member files easily. You'd have to cycle through each member performing your search. If this sounds like something you'd rather do, I can give you an example of the SQL you would need. Bill
-
Re:w to write all the matching records in to antoher
If you dont want to mess around with API calls to get a MbrList...You need one anyway. Simply DSPFD MBRLIST to an outfile. Read it and feed it to an OVRDBF in CL and I would suggest making a QM Query out of your SQL statement using CRTQMQRY cmd on a member like: [SELECT * FROM &LibFile where field like &Like_valu] Call it with STRQMQRY using the keywords LibFile and Like_valu in the SETVAR parameters. where LibFile gets passed as LibFile(&CL_Pgm_Var1) containing your 'Libr/File' and Like_valu(&CL_Pgm_Var2) would contain your like predicate value: Such as '%SomeText%'. Beware when calling from within a CL program to supply the quotes because (one pair) I believe are stripped from these variables automatically. The like predicate requires a quoted value. I suggest setting up a CL Var as "E ('''') and concatenating the "E to the front and back of your "search" string. "E || &LIKE_VALU || "E. You specify an OUTFILE on the STRQMQRY cmd and MBROPT(*REPLACE or *ADD). Hope this isnt too cryptic.
Comment
Comment