CLLE program

105 pts.
Tags:
CLLE
RPGLE
I am new to AS400.I just learnt CLLE and i am facing the problem with the parameter that send from a RPGLE pgm to a CLLE pgm. The first pgm is to prompt the user to key in the date which is a numeic field. The coding for the first pgm is : FWKCFFM CF E WORKSTN * Parameter List Definition C WKCFEL2PR PLIST C PARM SSPDT6 * To execute format prompt the Maintenance Date C EXFMT MAINDT C *IN03 DOWEQ '0' C CALL 'WKCELC2T' WKCFEL2PR C IF *IN03 ='1' C LEAVE C ENDIF C ENDDO C SETON LR The 2nd pgm is : PGM PARM(&DATE6) DCLF FILE(CFMNTT) RCDFMT(RSSMNTT) DCL VAR(&DATE6) TYPE(*CHAR) LEN(6) CHGVAR VAR(&DATE6) VALUE(&SSPDT6) /* select cfmntt */ (CFMNTT is PF and SSPDT6 is the file field,numeric and have 6 digits for the date) OVRDBF FILE(CFMNTT) SHARE (*YES) /*SELECT ALL FILE NAME = 'DDSTOP' AND DATE = SSPDT6(the date that user key in)*/ OPNQRYF FILE((CFMNTT)) QRYSLT('SSPFIL *EQ "DDSTOP" + *And SSPDT6 *eq ' *cat &date6 *cat ' ') + KEYFLD(*FILE) /* call processing */ (WKCFEL3 is the third pgm that read the record of CFMNTT to get the result of the selection) CALL PGM(WKCFEL3) PARM(&DATE6) /* close file */ DLTOVR FILE(CFMNTT) CLOF OPNID(CFMNTT) ENDPGM The 3rd pgm is: FCFMNTT IF E K DISK FWKCFMNTT UF A E K DISK * Parameter List Definition *ENTRY PLIST PARM MDATE 6 0 C *like define sspdt6 mdate *Get the Maintenance Date and Update file C READ RSSMNTT 40 C *IN40 DOWEQ *OFF C WRITE RWKCFMNTT C READ RSSMNTT 40 C ENDDO C SETON LR The problem is i can't pass in the date.why the value of the date always equal to zero after i pass in? i don't know what is the mistake..

Answer Wiki

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

Cev

In your CL you receive DATE6 which should be the passed value from your first RPG program

PGM PARM(&DATE6)

DCLF FILE(CFMNTT) RCDFMT(RSSMNTT)
– issue 1 do not declare this file in this program .. you aren’t going to use it that way

DCL VAR(&DATE6) TYPE(*CHAR) LEN(6)

CHGVAR VAR(&DATE6) VALUE(&SSPDT6)
— issue 2 without the DCLF this command will fail (&SSPDT6) isn’t known
but that’s ok you don’t need it. You don’t acutally want to change the value
of &DATE6 here, it was passed in on the PGM command.

This part of the override
*cat ‘ ‘) + should be *cat ””) +
.. why ??? your final string should look like

‘SSPFIL *EQ “DDSTOP” *And SSPDT6 *eq 081103 ‘
the four quotes ”” work like this quote #1 start a string
quotes 2 & 3 don’t think of me as a string end thrink of me as a quote
quote 4 sting end

Discuss This Question: 11  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
  • TLT
    Sorry,i am not very understand what you explain for the cat This part of the override *cat ' ') + should be *cat '''') + .. why ??? your final string should look like 'SSPFIL *EQ "DDSTOP" *And SSPDT6 *eq 081103 ' the four quotes '''' work like this quote #1 start a string quotes 2 & 3 don't think of me as a string end thrink of me as a quote quote 4 sting end can you explain? expecially the quotes 2 &3. Thank you.
    15 pointsBadges:
    report
  • philpl1jb
    Yes, the double quote is used when you want a quote added to the string.
    49,730 pointsBadges:
    report
  • philpl1jb
    In cases like this I usually create a string var DCL &QRYSLT *CHAR 120 chgvar &QRYSLT ('SSPFIL *EQ "DDSTOP" *And SSPDT6 *eq ' *cat &date6 *cat '''') Then send the variable in a message to myself as part of the test and use it in the OVRDBF command. Seing what is actually sent to the QueryEngine usually makes the debugging much easier.
    49,730 pointsBadges:
    report
  • Gilly400
    Hi, I think you have a problem with your first program - you have your EXFMT operation before your DO loop and then your DO loop is checking for *IN03 (which I guess is F3=Exit from your display file). With your current logic, your program should get stuck in a loop after running your second program. You say the date field is numeric, then you should move it to a character field to pass to your CL program, because you have defined it as character in the CL. Your second program (the CL program) should be much simpler - you don't need the file declared at all, but you will need to get the OPNQRYF parameters correct (as already mentioned). In your third program it looks like you are writing a record to WKCFMNTT for every record that you find in your OPNQRYF statement. Do these two files have the same format by any chance? If so, you could use a CPYF or CPYFRMQRYF statement instead of this program. You also have the date field as a *ENTRY parameter, but I don't see it being used anywhere (unless it's defined in your WKCFMNTT file - in which case you shouldn't need to define it again on your PARM statement or your *LIKE DEFINE. Regards, Martin Gilbert.
    23,730 pointsBadges:
    report
  • Cev
    may i know is it necessary that we have to declare the numeric field (date6) to char in CL?can i remain using the numeric field and declare it as dec in CL?if yes,how to do the coding for the qryslt if i want to compare a numeric field to a numeric variable? i know that if we want to compare a field with a variable,we have to use *cat,but how to do the coding ? in the 3rd pgm, is it the type of entry parm list wrong defined (*ENTRY PLIST PARM MDATE 6 0) ?because i already changed date6 to char type in CL.when i pass the parm to the 3rd pgm,is it the parm type supposed to be like *ENTRY PLIST PARM MDATE 6 ?when i put like this,compilation error.when i remark the DCLF and CHGVAR stament in the CL pgm, the pg has this error 2100 - OVRDBF FILE(CFMNTT) SHARE(*YES) 2700 - OPNQRYF FILE((CFMNTT)) QRYSLT (X'4DE2E2D7C6C9D3405CC5D8407FC4C4E2E3D6D77F40405CC1D5C4404DE2E2D7C 4E3F6405CC5D8400041098F0100405D') KEYFLD(*FILE) Character in string ' ± ) ' in expression on parameter QRYSLT not valid . CPF9899 unmonitored by WKCELC2T at statement 0000002700, instruction X'0000'. CPF9899 received by procedure WKCELC2T. (C D I R)
    105 pointsBadges:
    report
  • Cev
    Hi Gilly400, i put *ENTRY PARM in 3rd pgm so that the date frm CL can pass in to the 3rd pgm to get the result of the search.as u say,is it mean that after calling the 3rd pgm,i do not need to use *ENTRY parm and the CL pgm will straight away pass in the parm without using *ENTRY in 3rd pgm?besides that, the two files have the same format..how to use CPYF or CPYFRMQRYF ?
    105 pointsBadges:
    report
  • Cev
    i already changed the CL pgm to PGM PARM(&DATE6) DCL VAR(&DATE6) TYPE(*CHAR) LEN(6) DCL VAR(&QRYSLT) TYPE(*CHAR) LEN(120) /* rtv CFMNTT */ CHGVAR VAR(&QRYSLT) VALUE('SSPFIL *EQ "DDSTOP" *AND + SSPDT6 *EQ ' *CAT &DATE6 *CAT ' ') /* select cfmntt */ OVRDBF FILE(CFMNTT) SHARE(*YES) /*SELECT ALL FILE NAME = 'DDSTOP' AND DATE = SSPDT6*/ OPNQRYF FILE((CFMNTT)) QRYSLT(&QRYSLT) +KEYFLD(*FILE) /* call processing */ CALL PGM(WKCFEL3) PARM(&DATE6) /* close file */ DLTOVR FILE(CFMNTT) CLOF OPNID(CFMNTT) ENDPGM Eventhough there's no compilation error but afer i key in the date,it shows Character in string ' ± ' in expression on parameter QRYSLT not valid. Function check. CPF9899 unmonitored by WKCELC2T at statement 0000003700, instruction X'0000'. what's wrong with the qryslt statement. why have to put the two double quotation at the end of the code?isn't it is not valid.... chgvar &QRYSLT (’SSPFIL *EQ “DDSTOP” *And SSPDT6 *eq ‘ *cat &date6 *cat ” ” )
    105 pointsBadges:
    report
  • Gilly400
    Hi, I think the error you're getting now is because you're passing a decimal value from your RPG to a character value in your CL. If you take a D to dump the CL program when it gives the error message, you will see the values in your variables. I suggest you pass the parameter as character (decimals can give problems between RPG and CL and character fields are easier to read, decimals are often packed), so define a character field in your RPG program and use that as the parameter for the call. Regards, Martin Gilbert.
    23,730 pointsBadges:
    report
  • Cev
    how to define a character field in the RPG program and use that as the parameter for the call?SSPDT6 is a numeric field and the user will key in the date which is a numeric field.can i declare the variable date6 as dec in the CL pgm?i am not sure which is the best way to solve the problem.
    105 pointsBadges:
    report
  • Gg1
    I usually pass parameters as a DS for 2 reasons, 1 - to avoid the problem of packed/zoned numeric fields being passed between RPG and CL programs, 2 - if you make the DS longer than you need at the moment, you can always add more fields to the DS without causing any harm or the need to compile all programs using the same DS. The RPG program looks like this: parm_ds ds 50 p_f1 5 p_f2 9 0 etc. You can translate this to a prototype: parm_pr pr ('MYPROG') parm_x 50 myprog(parm_ds) ; In the CL you extract the field according to the position in the parameter: dcl &parm *char 50 dcl &f2 *char 9 chgvar &f2 %sst(&parm 6 9) Then you can change it to numeric if necessary or use it as it is.
    45 pointsBadges:
    report
  • TomLiotta
    how to define a character field in the RPG program and use that as the parameter for the call? If it isn't a character field, don't pass it as a character field. Pass it as the type that it is. Declare it correctly in any program that uses it. If one of the programs needs to change the data type for some particular operation, then do the conversion only within that program in a temporary variable. Regardless, why do you have three programs when you seem to only need one? A simple CL to present the display file and get the date from the user could then run a basic QM query that INSERTs the records. Unless, of course, the programs are much more complex than you show. But if that's the case, then any problems that you have with variable values and parameters might come from missing parts of the programs. why have to put the two double quotation at the end of the code? They are not "two double quotation" marks. They are four single-quotation marks. There are two single-quote marks on the outside because you need to enclose character constants in quotes. And there are two single-quotes inside because you always have to use two quotes inside a string in order to get one. For example, you might have a string like:
    We are at John's house.
    When you make that into a quoted string, it must be created like this:
    'We are at John''s house.'
    The one quote in the string has to made into two quotes. That tells the compiler that it has not reached the end of the literal constant yet. 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