Copy data from flat file to a flat file

165 pts.
Tags:
AS/400 import/export
COBOL
COBOL/400
Flat files
PF
Physical File
RPG
My requirement is : I need to copy data from 1 big flat file to a flat file,but size of this flat file must not > 3MB, if size increases then new members will be created and remaining data will be copied there ….so on..hence this small files will only contain records with size upto 3mb. Can you provide me with a code in cobol or rpg.
ASKED: November 3, 2008  6:37 AM
UPDATED: November 3, 2008  2:39 PM

Answer Wiki

Thanks. We'll let you know when a new response is added.

This can be done in a cl using ADDPFM and CPYF

— here is a rough draft of the prog
it assumes that 1. you have created the NewFile and that it allows sufficient members
to accomodiate this job.

Pgm

DCL &MaxRecPerMem *DEC 10 0
DCL &NumRec *DEC 10 0
DCL &StartRec *DEC 10 0
DCL &EndRec *DEC 10 0
DCL &MemCnt *DEC 4 0
DCL &MemCntChar *CHAR 4
DCL &MemberName *CHAR 10

/* 1. Compute number of rec */
chgvar &MaxRecPerMem = 3000000/132

/* 2. Get number of rec in first file where NumRec is numeric 10 0 */
RtvMbrD OrigLib/OrigFile NBRCURRCD(&NumRec)

/* 3. compute startrec and end rec */

chgvar &StartRec 1
chgvar &MemCnt 0

/* 4. Loop computes and creates member(s) computes endRec and copies data to member(s) */

loop:
chgvar &MemCnt (&MemCnt + 1)
chgvar &MemCntChar &MemCnt
chgvar &EndRec (&StartRec + &MaxRecPerMem)
chgvar &MemberName (‘M’ *cat &MemCntChar)
if (&EndRec > &NumRec) then chgvar &EndRec &NumRec
AddPFM NewLib/NewFile &MemberName
CPYF OrigLib/OrigFile NewLib/NewFile ToMember(&MemberName) MBROPT(*Replace) +
FROMRCD(&StartRec ) toRcd(&EndRec)
if (&EndRec >= &NumRec) goto End
chgvar &StartRec (&StartRec + &MaxRecPerMem)
goto loop

end: endpgm

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following