0% found this document useful (0 votes)
92 views

Programa de Subfile Usando Cursor de SQL

This document contains code for an RPGLE program that displays transaction records from a database. It declares data structures and indicators, connects to the database, defines procedures to read and display records, and contains a loop to fetch records and display them in a subfile. The program allows navigating records, searching by criteria, and drilling down on a record to view details.

Uploaded by

Jimmy Acosta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
92 views

Programa de Subfile Usando Cursor de SQL

This document contains code for an RPGLE program that displays transaction records from a database. It declares data structures and indicators, connects to the database, defines procedures to read and display records, and contains a loop to fetch records and display them in a subfile. The program allows navigating records, searching by criteria, and drilling down on a record to view details.

Uploaded by

Jimmy Acosta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 8

**************************************************************************

*** SFLC01 SQLRPGLE CONSULTA DE TRANSACCIONES ***


**************************************************************************

ctl-opt datfmt(*iso) option(*nodebugio:*srcstmt);

dcl-f SFLC01FM workstn sfile(subf:rrn) infds(dsinf);


dcl-f WEBCAB disk keyed usage(*input) usropn;

dcl-ds *N PSDS;
Pgm char(10) pos(1);
wstn char(10) pos(244);
user char(10) pos(254);
end-ds;

dcl-ds dsinf;
Curs0 zoned(2:0) pos(376);
Curs01 zoned(3:0) pos(380);
Fkey char(1) pos(369);
end-ds;

dcl-ds FDAT;
Fazo zoned(4:0) inz(0);
Fmes zoned(2:0) inz(0);
Fdia zoned(2:0) inz(0);
end-ds;

dcl-ds FECFIL;
@AZO char(4) inz('0000');
Gui1 char(1) inz('-');
@MES char(2) inz('00');
Gui2 char(1) inz('-');
@DIA char(2) inz('00');
end-ds;

dcl-ds Wdatos ;
FECHOR char(26) inz(*blanks);
TIPOES char(1) inz(*blanks);
CODPGM char(10) inz(*blanks);
CODUSU char(10) inz(*blanks);
BODY char(4000) inz(*blanks);
end-ds;

dcl-s apagado ind inz(*off);


dcl-s encendido ind inz(*on);
dcl-s rrn zoned(5:0) inz(*zeros);
dcl-s nReg zoned(2:0) inz(*zeros);
dcl-s tReg zoned(2:0) inz(0);
dcl-s Reg zoned(5:0) inz(0);
dcl-s trrn zoned(2:0) inz(23);
dcl-s llenar char(1) inz('S');
dcl-s ctrlPag packed(1:0) inz(*zeros);
dcl-s V1 char(450) inz(*blanks);
dcl-s SITUA char(26) inz('0001-01-01-00.00.00.000000');
dcl-s SITUA2 char(26) inz(*blanks);
dcl-s SITUAz timestamp;
dcl-s Parm_FH char(26) inz(*blanks);
dcl-s PtrIndicators pointer inz(%addr(*in));
dcl-s NomBanco char(35) inz(*blanks);
dcl-c Enter Const(X'F1');
dcl-s Flag char(1) inz(*blank);
dcl-s Incluir char(100) inz(*blanks);
dcl-s @ char(1) inz('''');

dcl-ds Indicators based(PtrIndicators);


Output ind pos(91);
Azul ind pos(92);
Blanco ind pos(93);
Salir ind pos(03);
Cancela ind pos(12);
F5 ind pos(05);
Lista ind pos(10);
IndiError ind pos(13);
SflClr ind pos(61);
SflDspCtl ind pos(61);
SflDsp ind pos(62);
AvPag ind pos(63);
RePag ind pos(64);
SflStart ind pos(65);
Sflerr ind pos(96);
SflEnd ind pos(99);
IndArr ind pos(01) dim(99);
end-ds;

dcl-pr Ver_Detalle extpgm('WEBC02');


dcl-parm Parm_FH char(26);
dcl-parm Program char(10);
dcl-parm USUAR char(10);
dcl-parm Date1 char(8);
dcl-parm TiES char(1);
end-pr;

EXEC SQL Select cntnme into :nomBanco from cntrlcnt


fetch first row only;

if user='ANDRES';
Azul=*off;
Blanco=*on;
else;
Azul=*on;
Blanco=*off;
endif;
Dow Salir=Apagado and Cancela=Apagado;
if llenar='S';
exsr LecturaInicial;
clear SITUA;
llenar='N';
endif;
write foot;
exfmt ctl;
Select;
When F5=encendido;
exfmt FILTRO;
EXEC SQL close RRN;
SITUA='0001-01-01-00.00.00.000000';
llenar='S';
When salir=Encendido or Cancela=Encendido;
EXEC SQL close RRN;
leave;
When RePag=Encendido;
exsr Regresar;
When AvPag=Encendido;
exsr Avanzar;
When AvPag=Apagado and RePag=Apagado and
FKey=Enter and RRN>*Zeros;
if SITUA>*blanks;
EXEC SQL close RRN;
llenar='S';
else ;
exsr LeeSubfile;
if salir=encendido;
leave;
Endif;
endif;
endSl;
enddo;
*inlr=Encendido;

begsr Display;
CtrlPag=*zeros;
rrn=*zeros;
%subArr(IndArr:61:01)=Encendido;
%subArr(IndArr:62:01)=Apagado;
write ctl;
%subArr(IndArr:61:02)=Apagado;
endsr;

begSr LecturaInicial;
exsr ScriptSQL;
exsr Display;
EXEC SQL prepare C1 from :V1;
EXEC SQL declare RRN Scroll Cursor For C1;
EXEC SQL open RRN using :SITUA;
EXEC SQL fetch From RRN InTo :Wdatos ;
dow SQLCode=*Zeros;
Reg=Reg+1;
exsr WriteSfl;
if rrn=Trrn;
leave;
endif;
EXEC SQL fetch next From RRN InTo :Wdatos ;
enddo;
if sqlcode<>*zeros;
SflEnd=Encendido;
endif;
endSr;

begsr Avanzar;
if (SQLCOD<>0 and Flag='A') or sflend;
SflStart=*on;
else;
Flag='A';
SflStart=*off;
exsr Display;
EXEC SQL fetch next From RRN InTo :Wdatos ;
dow SQLCode=*Zeros;
Reg=Reg+1;
exsr WriteSfl;
if rrn = Trrn;
leave;
endif;
Exec SQL Fetch next From RRN InTo :Wdatos ;
enddo;
if sqlcode<>*zeros;
SflEnd=Encendido;
Exec SQL Fetch prior From RRN InTo :Wdatos;
endif;
endif;
endSr;

begsr Regresar;
if sqlcod<>0 and Flag='R';
SflStart=encendido;
else;
Sflend=apagado;
Flag='R';
SflStart=*off;
if Reg>23;
tReg=RRN+23;
else;
tReg=RRN;
endif;
for Nreg=1 to TReg;
EXEC SQL fetch prior from RRN InTo :Wdatos ;
if sqlCod<>0;
leave;
else;
Reg=Reg-1;
endif;
endfor;
if sqlCod=0 or sqlCod=100;
exsr Avanzar;
endif;
endif;
endSr;

begsr WriteSfl;
SflEnd=Apagado;
rrn+=1;
SITUA2=FECHOR;
open WEBCAB;
chain CODPGM WEBCAB;
if %found(WEBCAB);
NOMTRN=MAPDES;
else;
NOMTRN='*Error';
endif;
close WEBCAB;
COD7=CODPGM;
FEC23=%subst(FECHOR:1:23);
if TIPOES='S';
Output=encendido;
ES='Salida ';
CERR=%subst(BODY:71:4);
DERR=%subst(BODY:75:37);
TIPOES='R';
else;
Output=apagado;
ES='Entrada';
CERR=*blanks;
DERR=*blanks;
endif;
write subf;
sfldsp=Encendido;
endSr;

begsr LeeSubfile;
Sflerr=Apagado;
readc subf;
dow not %eof;
Select;
When Sel='5';
Ver_Detalle(FECHOR:FPGM:FUSU:FDAT:TIPOES);
other;
Sflerr=Encendido;
Endsl;
clear sel;
if TIPOES='R';
Output=encendido;
else;
Output=apagado;
endif;
update subf;
readc subf;
enddo;
endSr;

begsr ScriptSQl;
clear Incluir;
if FPGM<>*blanks;
Incluir=' and LOGPGM='+@+%trim(FPGM)+@;
endif;
if FUSU<>*blanks;
Incluir=%trimr(Incluir)+' and LOGUSU='+@+%trim(FUSU)+@;
endif;
if FDAT<>'00000000';
@AZO=%editc(FAZO:'X');
@MES=%editc(FMES:'X');
@DIA=%editc(FDIA:'X');
Incluir=%trimr(Incluir)+
' and substr(char(LOGHOR),1,10)='+@+FECFIL+@;
else;
Incluir=%trimr(Incluir)+' and LOGHOR >= ? ';
endif;
clear V1;
V1='Select LOGHOR, LOGTIP, LOGPGM, LOGUSU, LOGDAT '+
'from WEBLOGPF a where LOGSEC=1 '+%trim(Incluir)+
' order by LOGHOR desc';
endSr;

**************************************************************************
*** SFLC01FM ***
**************************************************************************

A*%%TS SD 20210203 132028 UIFOUT11 REL-V7R3M0 5770-WDS


A*0IGC 0DS4 890421
A*%%EC
A DSPSIZ(27 132 *DS4)
A CHGINPDFT
A R FILTRO
A*%%TS SD 20210203 132028 UIFOUT11 REL-V7R3M0 5770-WDS
A RTNCSRLOC(&REGCUR &CAMCUR)
A CSRLOC(FILA COLU)
A OVERLAY
A CA03(03 'Salir')
A FILA 3S 0H
A COLU 3S 0H
A REGCUR 10A H
A CAMCUR 10A H
A 1124TIME
A 27 2' Intro=Continuar -
A -
A -
A '
A DSPATR(HI)
A 11 52'Programa......'
A 15 49' '
A DSPATR(RI)
A 11 49' '
A DSPATR(RI)
A 12 49' '
A DSPATR(RI)
A 13 49' '
A DSPATR(RI)
A 11 80' '
A DSPATR(RI)
A 12 80' '
A DSPATR(RI)
A 13 80' '
A DSPATR(RI)
A 9 49' '
A DSPATR(RI)
A 14 49' '
A DSPATR(RI)
A 14 80' '
A DSPATR(RI)
A 10 49' '
A DSPATR(RI)
A 10 80' '
A DSPATR(RI)
A 2 2' -
A -
A -
A '
A DSPATR(UL)
A FPGM 10A B 11 67DSPATR(HI)
A 12 52'Usuario.......'
A FUSU 10A B 12 67DSPATR(HI)
A 13 52'Fecha.........'
A FDIA 2Y 0B 13 67EDTCDE(Z)
A DSPATR(HI)
A FMES 2Y 0B 13 70EDTCDE(Z)
A DSPATR(HI)
A FAZO 4Y 0B 13 73EDTCDE(Z)
A DSPATR(HI)
A 1 2'WEBC01'
A 1 54'Consulta Web-Regional'
A DSPATR(UL)
A DSPATR(HI)
A 26 2' -
A -
A -
A '
A DSPATR(UL)
A R SUBF SFL
A*%%TS SD 20200205 090156 UIFOUT11 REL-V7R3M0 5770-WDS
A SEL 1A B 3 3DSPATR(UL)
A TIPOES 1A O 3 7
A 91 92 COLOR(BLU)
A 91 93 COLOR(WHT)
A FEC23 23A O 3 10
A 91 92 COLOR(BLU)
A 91 93 COLOR(WHT)
A COD7 7A O 3 34
A 91 92 COLOR(BLU)
A 91 93 COLOR(WHT)
A CODUSU 10A O 3 79
A 91 92 COLOR(BLU)
A 91 93 COLOR(WHT)
A NOMTRN 35A O 3 42
A 91 92 COLOR(BLU)
A 91 93 COLOR(WHT)
A CERR 4A O 3 90
A 91 92 COLOR(BLU)
A 91 93 COLOR(WHT)
A DERR 37A O 3 95
A 91 92 COLOR(BLU)
A 91 93 COLOR(WHT)
A CODPGM 10A H
A ES 7A H
A FECHOR 26A H
A R CTL SFLCTL(SUBF)
A*%%TS SD 20200205 090156 UIFOUT11 REL-V7R3M0 5770-WDS
A CA03(03 'Salir')
A CA05(05 'Filtro')
A CF12(12 'Regresar')
A ROLLUP(63 'AVPAG')
A ROLLDOWN(64 'REPAG')
A OVERLAY
A N61 62 SFLDSP
A N61 SFLDSPCTL
A 61 SFLCLR
A SFLSIZ(0023)
A SFLPAG(0023)
A 65 SFLMSG('Giro hacia arriba o hacia a-
A bajo m s all del primer � �ltimo r-
A egistro en el Archivo.' 65)
A 96 SFLMSG('Error.- Selecci�n no permit-
A ida' 96)
A 1124TIME
A 2 2'Opc Fecha/Hora Se-
A rvicio -
A Usuario Respuesta -
A '
A DSPATR(UL)
A 1 2'WEBC01'
A 1 54'Consulta Web-Regional'
A DSPATR(UL)
A DSPATR(HI)
A 1 11'5=Consultar'
A DSPATR(HI)
A R FOOT
A 27 2' F3=Salir F5=Filtros F12=Re-
A gresar -
A -
A '
A DSPATR(HI)
A 26 2' -
A -
A -
A '
A DSPATR(UL)

You might also like