Why doesn’t the substring of a large field in CLLE program work correctly?

110 pts.
Tags:
CLLE
CPF errors
Substring
I have a CLLE program in which I pass two parameters, the first is a one character field, the second is a 600 character field. When run, the parameters come in correctly. But when I substring the second parameter into 40 fifteen character pieces it gives me a CPF0804 error half way through the string. I got around this problem by defining another field as 1200 characters and setting the value the same as the 600 character field. Then I use half of the 2400 character field in the substring to get my 40 values. Why does this not work correctly - or is my solution the only way out?

Answer Wiki

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

<i>Why does this not work correctly…</i>

There’s no way for us to know because you don’t show us the code that fails. Most likely it’s because the coding is incorrect.

My first guess would be that one or more variables is DCLed incorrectly. My second guess would be that the parms are sent incorrectly.

Tom

Discuss This Question: 5  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
  • Rick53
    0008.00 PGM 0009.00 DCL VAR(&ERROR) TYPE(*CHAR) LEN(1) VALUE(' ') 0010.00 DCL VAR(&ITEMS) TYPE(*CHAR) LEN(600) VALUE(' ') 0011.00 DCL VAR(&XXXXXX) TYPE(*CHAR) LEN(1200) VALUE(' ') 0012.00 DCL VAR(&ITEMX) TYPE(*CHAR) LEN(15) VALUE(' ') 0013.00 DCL VAR(&CNTR) TYPE(*DEC) LEN(2 0) VALUE(01) 0014.00 DCL VAR(&A) TYPE(*DEC) LEN(4 0) VALUE(0001) 0015.00 DCL VAR(&B) TYPE(*DEC) LEN(4 0) VALUE(0001) 0016.00 0017.00 CALL PGM(FLTDPRR) PARM(&ERROR &EMAILS) 0018.00 0019.00 IF (&ERROR = '1') THEN(DO) 0020.00 CHGVAR VAR(&XXXXXX) VALUE(&ITEMS) 0021.00 RUNQRY QRY(DBLPRS1CI) 0022.00 0023.00 LOOP: CHGVAR VAR(&A) VALUE((&CNTR * 15) - 14) 0024.00 CHGVAR VAR(&B) VALUE(&CNTR * 15) 0025.00 0026.00 If COND(%sst(&XXXXXX &a &b) *NE ' ') THEN(DO) 0027.00 CHGVAR VAR(&ITEMX) VALUE(%SST(&XXXXXX &A &B)) 0028.00 0029.00 CALL PGMA PARM(&ITEMX) 0030.00 0031.00 ENDDO 0032.00 0033.00 CHGVAR VAR(&CNTR) VALUE(&CNTR + 1) 0034.00 0035.00 IF COND(&CNTR *GT 40) THEN(GOTO CMDLBL(ENDPGM)) 0036.00 GOTO CMDLBL(LOOP) 0037.00 ENDDO 0038.00 0039.00 ENDPGM: ENDPGM in above CLLE program, XXXXXX is used because I get: CPF0804 - "Built-in function operands not valid. Reason code 4." I originally had EMAILS. This field is 15 characters times 40
    110 pointsBadges:
    report
  • Rick53
    Resent corrected listing: 0008.00 PGM 0009.00 DCL VAR(&ERROR) TYPE(*CHAR) LEN(1) VALUE(’ ‘) 0010.00 DCL VAR(&ITEMS) TYPE(*CHAR) LEN(600) VALUE(’ ‘) 0011.00 DCL VAR(&XXXXXX) TYPE(*CHAR) LEN(1200) VALUE(’ ‘) 0012.00 DCL VAR(&ITEMX) TYPE(*CHAR) LEN(15) VALUE(’ ‘) 0013.00 DCL VAR(&CNTR) TYPE(*DEC) LEN(2 0) VALUE(01) 0014.00 DCL VAR(&A) TYPE(*DEC) LEN(4 0) VALUE(0001) 0015.00 DCL VAR(&B) TYPE(*DEC) LEN(4 0) VALUE(0001) 0016.00 0017.00 CALL PGM(FLTDPRR) PARM(&ERROR &ITEMS) 0018.00 0019.00 IF (&ERROR = ‘1′) THEN(DO) 0020.00 CHGVAR VAR(&XXXXXX) VALUE(&ITEMS) 0021.00 RUNQRY QRY(DBLPRS1CI) 0022.00 0023.00 LOOP: CHGVAR VAR(&A) VALUE((&CNTR * 15) - 14) 0024.00 CHGVAR VAR(&B) VALUE(&CNTR * 15) 0025.00 0026.00 If COND(%sst(&XXXXXX &a &b) *NE ‘ ‘) THEN(DO) 0027.00 CHGVAR VAR(&ITEMX) VALUE(%SST(&XXXXXX &A &B)) 0028.00 0029.00 CALL PGMA PARM(&ITEMX) 0030.00 0031.00 ENDDO 0032.00 0033.00 CHGVAR VAR(&CNTR) VALUE(&CNTR + 1) 0034.00 0035.00 IF COND(&CNTR *GT 40) THEN(GOTO CMDLBL(ENDPGM)) 0036.00 GOTO CMDLBL(LOOP) 0037.00 ENDDO 0038.00 0039.00 ENDPGM: ENDPGM in above CLLE program, XXXXXX is used because I get: CPF0804 - “Built-in function operands not valid. Reason code 4.” I originally had EMAILS. This field is 15 characters times 40
    110 pointsBadges:
    report
  • philpl1jb
    It's the pesky &b %SST(&XXXXXX &A &B) &XXXXXX is the string &A is the starting position in the string &B is the number of characters to extract (40) not the ending position! Phil
    51,365 pointsBadges:
    report
  • TomLiotta
    the number of characters to extract (40) 15? A constant would be better than {&B}. Or a better name such as &Len15 with a value initialized to 15 and never changed. Tom
    125,585 pointsBadges:
    report
  • philpl1jb
    You're right Tom - 15 not 40. Effectively %SST(&XXXXXX 1 15) %SST(&XXXXXX 16 15) etc
    51,365 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