UNABLE TO WRITE TO A FLAT FILE FROM DS

pts.
Tags:
AS/400 Subfiles
Data Structure to Flat File
RPG debugging
Hi Am trying to move a data structure to a flat file.The flat file field name is SASAM. The error is The Result-Field operand SASAM is not valid for the specified operation. The data to be written is CCODE and then the value in HCMPYV. Please find code snippet for ur reference FSASAM IF A E DISK F RENAME(SASAM:SA100) D*HDR DS D*HCMPY 1 11 INZ('CCode') D*HCMPYV 12 13 SRHEAD BEGSR MOVE HDR SASAM WRITE SA100 ENDSR

Answer Wiki

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

Hi,

Firstly you have your file declared as input with add – the compiler will expect you to do some sort of input operation on the file, unless you declare the file as output.

Your file name is SASAM, you have renamed the record format name from SASAM to SA100.

It looks like your D-specs are commented out (with the *s).

You move HDR to SASAM (which is the file name, not a field name).

I think your biggest problem is the confusion between the file name and the field name.

Regards,

Martin Gilbert.

Discuss This Question: 3  Replies

 
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
  • The * is in there by mistake...As regards the flat file when i use the crtpf to create the flat file by default the file gets created with the same name SASAM for file ,rcdfmt and the field name.Do i need to create a pf with dds that has only one field in whic case i may be able to give diffrerent names. Can you please clarify if i need to move the data struct hdr to the file name or field name.
    0 pointsBadges:
    report
  • a sample may be of good help
    0 pointsBadges:
    report
  • philpl1jb
    For flat files 1. Create the file -- CRTPF name library and record length 2. The F statement is Fixed not external length must match the data structure 3. write to the file result field = datastructure. Here is example: FSASAM O f 13 disk Dhdr ds D HCMPY 11 inz('CCode') D HCMPYV 2 inz('YV') C write SASAM hdr C Eval *inlr = *on C return
    51,355 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