Retrive Field Value from Database File in CL

pts.
Tags:
CLP
My first attempt at reading a database file in CL. Have the following: DCLF FILE(*LIBL/DVACKWLV) RCDFMT(SCWACK) OPNID(WRK) DCL VAR(&WRK_SCADTE) TYPE(*DEC) LEN(6) DCL VAR(&FILEDATE) TYPE(*CHAR) LEN(6) RCVF OPNID(WRK) MONMSG CPF0864 EXEC(DO) /* End of file */ CHGVAR &FILEDATE (&WRK_SCDATE) Program dump shows that &WRK_SCADTE has the proper value from the first record in the file. The CHGVAR command, however, leaves &FILEDATE at blanks instead of filling with the same value as &WRK_SCDATE. Am I missing a step? Thanks!

Answer Wiki

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

Hi

Not sure if it’s a typo in your email or in the program, but you mention field &WRK_SCADTE as having the correct value, but use field &WRK_SCDATE in the CHGVAR operation.

One thing, though, is that when you use a DCLF all of the fields from the record layout are automatically defined by default, so you don’t need to define them separately.

All the best

Jonathan

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
  • TimRac
    I did not think a CL could update a file (table) using a CHGVAR command. If you get this working, let us know about it. Tim Raczek
    25 pointsBadges:
    report
  • BigKat
    your chgvar will only run after the last recordhas been read. you want something like below to loop through file PGM DCLF FILE(*LIBL/DVACKWLV) RCDFMT(SCWACK) OPNID(WRK) DCL VAR(&FILEDATE) TYPE(*CHAR) LEN(6) READ: RCVF OPNID(WRK) MONMSG CPF0864 EXEC(GOTO DONE) /* End of file */ CHGVAR &FILEDATE (&WRK_SCDATE) do something with &FILEDATE GOTO READ DONE: CLOF WRK ENDPGM
    8,350 pointsBadges:
    report
  • Suzuki9380
    Thanks everyone. My problem was the end of record check . . . when I wasn't looping through the file to actually get there!
    0 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