Called program entry:
dcl-pi PGM1;
choice uns(3) const;
returnCode likeds(returnCodeTpl);
parameterPtr pointer const options(*nopass);
parameterPtr2 pointer const options(*nopass);
parameterPtr3 pointer const options(*nopass);
end-pi;
Caller program:
document.field1 = 'EL';
document.field2 = 'T';
document.field3 = 2780;
PGM1(1:returnCode:%addr(document));
document
definition (on called):
dcl-ds document_ qualified based(parameterPtr);
field1 char(2);
field2 char(1);
field3 packed(7:0);
end-ds;
document
definition (on caller):
dcl-ds document qualified inz;
field1 char(2);
field2 char(1);
field3 packed(7:0);
end-ds;
Called program then process the document
DS, calling an exported procedure:
select;
...
when (1 = choice);
myProc(document_);
...
endsl;
myProc
definition:
dcl-proc myProc export;
dcl-pi *n ind;
document likeds(document_) const;
end-pi;
dcl-s i int(5) inz;
exec sql <--- Error appears there
select count(field1) into :i from myFile
where
field1 = :document.field1 and
field2 = :document.field2 and
field3 = :document.field3;
...
return i > 0;
end-proc;
myFile
fields equal in types document
fields.
The error a keep getting is MCH5003 - scalar error. The length of the invalid scalar operand is 128. Debug stop over the exec sql
clause.
I really can't figure out what it is!
In the end it was a parameter passing error.
Before the call to PGM1, another call to PGM2 was passing the second out of eight parameters as char(91) instead of char(500).
I didn't see it because it was defined as likeds(), and that DS was supposed to be 500 bytes long.
Thanks anyways @Charles.