110 pts.
 Why doesn’t the substring of a large field in CLLE program work correctly?
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?

Software/Hardware used:
ASKED: June 17, 2010  8:43 PM
UPDATED: June 19, 2010  9:38 AM

Answer Wiki:
<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
Last Wiki Answer Submitted:  June 18, 2010  12:42 am  by  TomLiotta   108,260 pts.
All Answer Wiki Contributors:  TomLiotta   108,260 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

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 pts.

 

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 pts.

 

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

 44,190 pts.

 

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

 108,260 pts.

 

You’re right Tom – 15 not 40. Effectively
%SST(&XXXXXX 1 15)
%SST(&XXXXXX 16 15)
etc

 44,190 pts.