The first thing is to introduce myself, my name is Carlos, an RPG developer for many years from Barcelone, Spain.
I've been following Scott for a long time although I don't usually use these forums but today I'm launching my first post here.
THEME
Following Scott's information about publishing RPG programs for SOAP or REST consumption
1. I have set up an IWS server on the I-Series and have developed a small test program
2. Consumers (SOAPUI) work perfectly with a GET operation and achieving a single record.
THE CHALLENGE
I don't quite understand how to return a group of records through the *ENTRY PARM
I need to return a JSON (which is already transformed by IWS) but with multiple records.
I'm not able to do it.
Here, attached code of the RPG service and SoapUI Results as a file
Code: Select all
//========================================================================
//WSCUSTOMER
//Webservice en RPG para exposición y uso
//Carlos Del Valle
//16/03/2022
//========================================================================
ctl-opt OPTION(*NODEBUGIO:*SRCSTMT) DFTACTGRP(*NO) THREAD(*SERIALIZE)
ACTGRP('CDVREST') PGMINFO(*PCML: *MODULE);
ctl-opt decedit('0,');
//========================================================================
//Database definition
//========================================================================
dcl-f COCLIN disk keyed usage(*INPUT) usropn ExtFile(file_coclin)
prefix('CUST.');
//========================================================================
//General Definitions
//========================================================================
dcl-ds pgm_stat psds;
sdsPgmID char(10) pos(1);
PgmID char(10) pos(1);
sdsWrkstn char(10) pos(244);
sdsJobUser char(10) pos(254);
sdsCurUser char(10) pos(358);
UsrId char(10) pos(358);
sdsJobnbr char(6) pos(264);
sdsJobDate char(6) pos(270);
sdsMsg char(7) pos(40);
sdsMsgd char(80) pos(91);
sdsDate char(8) pos(191);
end-ds;
dcl-ds err qualified;
bytesProv int(10) inz(0);
bytesAvail int(10) inz(0);
end-ds;
dcl-s MsgDta varchar(1000);
dcl-s MsgKey char(4);
dcl-s file_coclin char(21) inz('/COCLIN');
dcl-s zxcias packed(3:0);
dcl-s zxlist packed(1:0);
//========================================================================
//Back Error control
//========================================================================
dcl-pr QMHSNDPM ExtPgm;
MessageID char(7) Const;
QualMsgF char(20) Const;
MsgData char(32767) Const options(*varsize);
MsgDtaLen int(10) Const;
MsgType char(10) Const;
CallStkEnt char(10) Const;
CallStkCnt int(10) Const;
MessageKey char(4);
ErrorCode char(32767) options(*varsize);
end-pr;
//========================================================================
//Customer Record Estructure
//========================================================================
dcl-ds CUST ext qualified extname('COCLIN') end-ds;
//========================================================================
//*Entry Params
//========================================================================
dcl-pi *n;
@ptran char(25); // IN Transacción
@pcias char(3); // IN Compañía
@pcust like(Cust.s0cust); // IN Código Cliente (Not mandatory)
@pCunm like(Cust.s0des1); // OUT Nombre de Cliente
@pVrno like(Cust.s0nifi); // OUT Id Fiscal
@pChai like(Cust.s0grp2); // OUT Cadena Comercial
@pPais like(Cust.s0pais); // OUT Código de País
@pZopa like(Cust.s0zopa); // OUT Zona Comercial
@pSupa like(Cust.s0supa); // OUT SubZona Comercial
@presu char(3); // OUT Resultado OK/NOK
@pidms char(10); // OUT ID Mensaje
@ptxms char(150); // OUT Texto Mensaje
end-pi;
//========================================================================
//Program Structure
//========================================================================
file_coclin = 'PURLIBF' + @pcias + file_coclin;
open(e) coclin;
zxcias=%dec(@pcias:3:0);
select;
when @ptran='GetCust';
exsr cs_GetCust;
when @ptran='ListCust';
exsr cs_ListCust;
endsl;
//========================================================================
//End
//========================================================================
close(e) *all;
*inLR = *on;
//========================================================================
begsr cs_GetCust;
//========================================================================
chain (zxcias:@pcust) coclin;
if %found(coclin);
exsr cs_MoveData;
@presu='OK';
@pidms=*Blanks;
@ptxms=*blanks;
else;
@presu='NOK';
@pidms='CPF9897';
@ptxms='Customer not found.';
//msgdta='Customer not found.';
//QMHSNDPM( 'CPF9897' : 'QCPFMSG *LIBL' : msgdta : %len(msgdta)
//: '*ESCAPE' : '*PGMBDY' : 1 : MsgKey : err );
endif;
endsr;
//========================================================================
begsr cs_ListCust;
//========================================================================
zxlist=0;
setll (zxcias) coclin;
reade (zxcias) coclin;
dow not %eof(coclin);
zxlist=1;
exsr cs_MoveData;
@presu='OK';
@pidms=*Blanks;
@ptxms=*blanks;
reade (zxcias) coclin;
enddo;
if zxlist=0;
@presu='NOK';
@pidms='CPF9897';
@ptxms='Customer not found.';
//msgdta='Customer not found.';
//QMHSNDPM( 'CPF9897' : 'QCPFMSG *LIBL' : msgdta : %len(msgdta)
//: '*ESCAPE' : '*PGMBDY' : 1 : MsgKey : err );
endif;
endsr;
//========================================================================
begsr cs_MoveData;
//========================================================================
@pcust=Cust.s0cust;
@pCunm=Cust.s0des1;
@pVrno=Cust.s0nifi;
@pChai=Cust.s0grp2;
@pPais=Cust.s0pais;
@pZopa=Cust.s0zopa;
@pSupa=Cust.s0supa;
endsr;