Error using CPYFRMIMPF

5 pts.
Tags:
AS/400
AS/400 administration
CPYFRMIMPF
CSV file format
I have a .CSV file that contains a header record and then several detail records (random number as it is the EDI invoices). I use the CPYFRMIMPF to copy the first record to the header file and then I do it again for record 2 to *end. The problem is that it will copy the header fine but then it will only copy a few random in the detail detail. So if the file has: Header record 1 Detail record 2 Detail record 3 Detail record 4 Detail record 5 I will get the header fine but then I get record 2, 4 and 5 in the detail and it skips record 3. I do not get any errors. If I go into the .csv file with EXCEL and tab down all the lines and then run the program I get all the data copied correctly. I really want to automate this process. commandString = 'cpyfrmimpf fromstmf(''' + %trim(filePath) + %trim(fileName) + ''') tofile(qtemp/S4B03_temh) mbropt(*replace) rcddlm(*crlf) 'fromrcd(*first 1) rplnullval(*flddft)'; I have tried *CR, *LF and *LFCR with no better results.

Software/Hardware used:
AS/400, RPG

Answer Wiki

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

The problem is with the raw data, something isn’t formated correctly. When you bring it into Excel and then save it, that error is corrected by Excel.

Before you’ve used excel to “Fix” the record, inspect it with notepad (not wordpad)
You will find something different at the end of the third record or in the fourth record. I would suspect the the Cr and/or LF is/are missing between the third and fourth records.

Try backing out this return and adding it back using notepad and resave it. it should now work…keep replacing characters until it does.

Once you’ve found the error, you will need to change the program that is generating the file.
Phil

Discuss This Question: 1  Reply

 
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
  • TomLiotta
    You only show us one example of a CPYFRMIMPF command. Is that for the header or the detail records? Is that the part that works or the part that fails? Do any messages appear in the joblog? Are the headers and details all in the same format? What does the record format look like for "qtemp/S4B03_temh"? If the example CPYFRMIMPF is for the details, why do you have both "fromrcd(*first 1)" and "mbropt(*replace)"? Are you using the same .CSV as input for both headers and details? Tom
    125,585 pointsBadges:
    report

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