Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CPYFRMQRY

Status
Not open for further replies.

loonybin

Programmer
Dec 12, 2002
38
US
I have a header and detail files that are multi member. I am trying this approach:

to process the main member first qry it and copy it to same filename but different library and different member. Then I process the archive member and do the same thing but adding it to the same member/file/library where I copy the records from the first opnqry(for the main member).

Problem is it is not doing it. When I look at the file in qtemp that the cpyfrm qry had CREATED(not updated), It contains the main and the archive member. Why is the 2nd cpyfrmqry not adding the records to the member specified? why is it creating a new member? Actually even the first cpyfrmqry is not putting it to member TEST01 but rather putting it to the same member as the from member name.

Please help. Thanks.

* Process Main Member
OVRDBF FILE(HDRFILE) MBR(HDRFILE)
OVRDBF FILE(DTLFILE) MBR(DTLFILE)
OPNQRYF FILE((DTLFILE) (HDRFILE)) FORMAT(DTLFILE)+
QRYSLT(&QRYSLT) KEYFLD((SIONO) (SISEQ) +
(SICLS) (SIVEN) (SISTY) (SICLR)) +
JFLD((SIONO SHONO)) MAPFLD((S1SDTE 'SHNBDT'))

CPYFRMQRYF FROMOPNID(DTLFILE) TOFILE(QTEMP/DTLFILE) +
TOMBR(TEST01) MBROPT(*REPLACE) CRTFILE(*NO)
DLTOVR FILE(HDRFILE)
DLTOVR FILE(DTLFILE)
CLOF OPNID(DTLFILE)

/* Archive Member */
OVRDBF FILE(HDRFILE) MBR(ARCHIVE)
OVRDBF FILE(DTLFILE) MBR(ARCHIVE)

OPNQRYF FILE((DTLFILE) (HDRFILE)) +
FORMAT(DTLFILE) QRYSLT(&QRYSLT) +
JFLD((SIONO SHONO)) MAPFLD((S1SDTE 'SHNBDT'))
CPYFRMQRYF FROMOPNID(DTLFILE) TOFILE(QTEMP/DTLFILE) +
TOMBR(TEST01) MBROPT(*ADD) CRTFILE(*NO)
 
loonybin,

I believe you need a SHARE( *YES ) on your OVRDBF statements just before the OPNQRYF. Try that out and see if that helps.

HTH,
MdnghtPgmr
 
Share(*yes) first, yes, then this is what I'd do. At least it's worth giving a try:
Code:
OVRDBF FILE(HDRFILE) MBR(HDRFILE) [b]SHARE(*YES)                            [/b]
OVRDBF FILE(DTLFILE) MBR(DTLFILE)[b] SHARE(*YES)                            [/b]
OPNQRYF FILE((DTLFILE) (HDRFILE)) FORMAT(DTLFILE)+              
QRYSLT(&QRYSLT) KEYFLD((SIONO) (SISEQ) + 
(SICLS)(SIVEN) (SISTY) (SICLR)) +
JFLD((SIONO SHONO)) MAPFLD((S1SDTE 'SHNBDT'))
                                                                            CPYFRMQRYF FROMOPNID(DTLFILE) TOFILE(QTEMP/DTLFILE) +           
  TOMBR(TEST01) MBROPT(*REPLACE) CRTFILE(*NO)           
DLTOVR FILE(HDRFILE)                                           
DLTOVR FILE(DTLFILE)                                           
CLOF   OPNID(DTLFILE)                     

/* Archive Member */
OVRDBF FILE(HDRFILE) MBR(ARCHIVE) [b]SHARE(*YES)                            [/b] 
OVRDBF FILE(DTLFILE) MBR(ARCHIVE) [b]SHARE(*YES)                            [/b]
OPNQRYF FILE((DTLFILE [b]ARCHIVE[/b]) (HDRFILE [b]ARCHIVE[/b]))  +  
  FORMAT(DTLFILE) QRYSLT(&QRYSLT) + 
JFLD((SIONO SHONO)) MAPFLD((S1SDTE 'SHNBDT'))
CPYFRMQRYF FROMOPNID(DTLFILE) TOFILE(QTEMP/DTLFILE) +  
  TOMBR(TEST01) MBROPT(*ADD) CRTFILE(*NO) 
...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top