quinta-feira, outubro 22, 2015

Como determinar o comprimento de um registro de ADABAS

O dblog (nome antigo ADALOG) é um utilitário que pode ser usado para mostrar as chamadas Adabas Natural de um programa. Usaremos dblog no que se segue para olhar para conteúdo de formato e Record Buffers. Isto é essencial para a compreensão de como este trecho de código funciona.

Iniciando

A primeira coisa que temos a fazer é invocar dblog. Isto é mostrado abaixo. O asterisco indica queremos ver todas as opções dblog.
 > test dblog *                          > +  Program     CLAUD005 Lib NAT2CUR
 Top    ....+....1....+....2....+....3....+....4....+....5....+....6....+....7..
   0010 DEFINE DATA
   0020 LOCAL
   0030       1 CARROS VIEW OF VEHICLES-FILE
   0040             2 REG-NUM
   0050             2 MAKE
   0060             2 MODEL
   0070             2 COLOR
   0080             2 YEAR
   0090             2 PERSONNEL-ID
   0100             2 CHASSIS-NUM
   0110       1 CLIENTES VIEW OF EMPLOYEES
   0120             2 PERSONNEL-ID
   0130             2 FIRST-NAME
   0140 *
   0150 *   DECLARACAO DE VARIAVEIS DE TRABALHO
   0160 *
   0170       1 #REG-NUM(A15)
   0180       1 #MAKE(A20)
   0190       1 #CHASSIS-NUM(I4)
   0200       1 #MODEL(A20)
   0210       1 #COLOR(A10)
   0220       1 #YEAR(N2)
   0230       1 #PERSONNED-ID(A8)
   0240       1 #FIRST-NAME(A20)
   0250 END-DEFINE
   0260 *
   0270 *
   0280 READ (10) CARROS BY MAKE STARTING FROM #MAKE
   0290 DISPLAY NOTITLE
   0300 (CD=GR)       'TESTE' *COUNTER
   0310 (CD=PI)       'MARCA' 'MARCA' MAKE
   0320 (CD=RE)       'MODELO' MODEL
   0330 (CD=TU)       'ANO' YEAR
   0340 (IC=19 CD=BL) 'COR' COLOR
   0350 END-READ
   0360 END
        ....+....1....+....2....+....3....+....4....+....5....+... S 36   L 17
Como você pode ver, o código coloquei (B) para indicar que eu queria começar a registrar as chamadas Adabas, e marquei com X embaixo no FB (Formato Buffer) e RB (Record Buffer).
 15:27:56             ***** NATURAL TEST UTILITIES *****              22/10/2015
 User AA01055                   - DBLOG Menu -                  Library NAT2CUR


                  Code  Function

                   B    Begin Logging of Adabas Commands
                   E    End and Display Log Records
                   S    Snapshot of Specific Adabas Commands
                   .    Exit

           Code .. b

        Command .. __       Skip ....... _____    Program .... ________
        DBID ..... _____    FNR ........ _____    Line from .. 0000
        Low Resp . _____    High Resp .. 9999_    Line to .... 0000

        Optional Buffers for Code B
          FB .. x RB .. x SB .. _ VB .. _ IB .. _


 Command ===>
 Enter-PF1---PF2---PF3---PF4---PF5---PF6---PF7---PF8---PF9---PF10--PF11--PF12---
       Help  Print Exit  Begin End   Snap                                Canc
Iniciado o DBLOG;
 MORE
 DBLOG started now.
Rodando

Rodando o programa;
 > r                                     > +  Program     CLAUD005 Lib NAT2CUR
 Top    ....+....1....+....2....+....3....+....4....+....5....+....6....+....7..
   0010 DEFINE DATA
   0020 LOCAL
   0030       1 CARROS VIEW OF VEHICLES-FILE
   0040             2 REG-NUM
   0050             2 MAKE
   0060             2 MODEL
   0070             2 COLOR
   0080             2 YEAR
   0090             2 PERSONNEL-ID
   0100             2 CHASSIS-NUM
   0110       1 CLIENTES VIEW OF EMPLOYEES
   0120             2 PERSONNEL-ID
   0130             2 FIRST-NAME
   0140 *
   0150 *   DECLARACAO DE VARIAVEIS DE TRABALHO
   0160 *
   0170       1 #REG-NUM(A15)
   0180       1 #MAKE(A20)
   0190       1 #CHASSIS-NUM(I4)
   0200       1 #MODEL(A20)
        ....+....1....+....2....+....3....+....4....+....5....+... S 36   L 1
Resultado;
 MORE
    TESTE              MARCA                   MODELO         ANO     COR
 ----------- -------------------------- -------------------- ----- ----------

           1 MARCA AUDI                 QUATTRO TURBO         1983 PRETO
           2 MARCA AUDI                 QUATTRO TURBO         1986 BRANCO
           3 MARCA AUDI                 100 CD                1982 VINHO
           4 MARCA AUDI                 80 S                  1980 VERDE
           5 MARCA AUDI                 100 CC                1984 PRETO
           6 MARCA AUDI                 80 LS                 1985 BRANCO
           7 MARCA AUDI                 100 CD                1984 VERDE
           8 MARCA AUDI                 100 CC                1985 BRANCO
           9 MARCA AUDI                 100 CD 5E             1984 CINZA
          10 MARCA AUDI                 80 CL                 1985 VERMELHO
Desabilitando o DBLOG

Chamado de novo o dblog - agora vamos desabilitar;
 test dblog *                          +  Program     CLAUD005 Lib NAT2CUR
 Top    ....+....1....+....2....+....3....+....4....+....5....+....6....+....7..
   0010 DEFINE DATA
   0020 LOCAL
   0030       1 CARROS VIEW OF VEHICLES-FILE
   0040             2 REG-NUM
   0050             2 MAKE
   0060             2 MODEL
   0070             2 COLOR
   0080             2 YEAR
   0090             2 PERSONNEL-ID
   0100             2 CHASSIS-NUM
   0110       1 CLIENTES VIEW OF EMPLOYEES
   0120             2 PERSONNEL-ID
   0130             2 FIRST-NAME
   0140 *
   0150 *   DECLARACAO DE VARIAVEIS DE TRABALHO
   0160 *
   0170       1 #REG-NUM(A15)
   0180       1 #MAKE(A20)
   0190       1 #CHASSIS-NUM(I4)
   0200       1 #MODEL(A20)
        ....+....1....+....2....+....3....+....4....+....5....+... S 36   L 1
Código E (Finalizar);
 15:43:45             ***** NATURAL TEST UTILITIES *****              22/10/2015
 User AA01055                   - DBLOG Menu -                  Library NAT2CUR


                  Code  Function

                   B    Begin Logging of Adabas Commands
                   E    End and Display Log Records
                   S    Snapshot of Specific Adabas Commands
                   .    Exit

           Code .. e

        Command .. __       Skip ....... _____    Program .... ________
        DBID ..... _____    FNR ........ _____    Line from .. 0000
        Low Resp . _____    High Resp .. 9999_    Line to .... 0000

        Optional Buffers for Code B
          FB .. _ RB .. _ SB .. _ VB .. _ IB .. _


 Command ===>
 Enter-PF1---PF2---PF3---PF4---PF5---PF6---PF7---PF8---PF9---PF10--PF11--PF12---
       Help  Print Exit  Begin End   Snap                                Canc
Observação dos Comandos

Antes de prosseguir vou colocar o que faz cada comando Adabas;
CR - Codigos de retorno                   BA - Buffer areas
CB - Control-block                        L1 - Read por Isn sem Hold
FB - Format-buffer                        L2 - Read fisico sem Hold
RB - Record-buffer                        L3 - Read sequencial sem Hold
SB - Search-buffer                        L4 - Read por Isn com Hold
VB - Value-buffer                         L5 - Read fisico com Hold
IB - Isn-buffer                           L6 - Read sequencial com Hold
A1 - Update                               L9 - Histogram por descritor
A4 - Update                               N1 - Store
BT - Backout                              N2 - Store
CL - Close                                OP - Open
C1 - Checkpoint nao sincronizado          RC - Release Command-id
C2 - Checkpoint sincronizado              RE - Read dados gravados por ET
C3 - Ready Checkpoint sincronizado        RI - Release Isn
C5 - Write Data Protection Log            S1 - Find sem Hold
ET - End transaction                      S2 - Find com Sorted by
E1 - Delete                               S4 - Find com Hold
E4 - Delete                               S5 - Find Coupled
HI - Hold                                 S8 - Read listas pre-selecionadas
LF - List file                            S9 - Sort de listas pre-selecionadas
Checando o Format Buffer

Abaixo estão as chamados para o Adabas para os dados que o nosso programa fez, como a consulta foi limitada em 10 registros READ temos 10 L3, para ver Format Buffer digite no primeiro L3 (ou em qualquer um) para checar.
 15:44:06             ***** NATURAL TEST UTILITIES *****              22/10/2015
 User AA01055                  - DBLOG Trace -                  Library NAT2CUR
 M   No Cmd   DB   FNR  Rsp        ISN        ISQ  CID CID(Hex) OP Pgm      Line
 _    1 RC   230                                       00000000 F  ATEST    0220
 F    2 L3   230     5              94            ?Ø?? 02800101  A CLAUD005 0280
 _    3 L3   230     5              95            ?Ø?? 02800101  A CLAUD005 0280
 _    4 L3   230     5              98            ?Ø?? 02800101  A CLAUD005 0280
 _    5 L3   230     5              99            ?Ø?? 02800101  A CLAUD005 0280
 _    6 L3   230     5             103            ?Ø?? 02800101  A CLAUD005 0280
 _    7 L3   230     5             104            ?Ø?? 02800101  A CLAUD005 0280
 _    8 L3   230     5             108            ?Ø?? 02800101  A CLAUD005 0280
 _    9 L3   230     5             113            ?Ø?? 02800101  A CLAUD005 0280
 _   10 L3   230     5             115            ?Ø?? 02800101  A CLAUD005 0280
 _   11 L3   230     5             129            ?Ø?? 02800101  A CLAUD005 0280
 _   12 RC   230     5                            ?Ø?? 02800101 SI CLAUD005 0280
 _   13 RC   230                                       00000000 F  CLAUD005 0360
 _
 _
 _
 _

 Command ===>
 Enter-PF1---PF2---PF3---PF4---PF5---PF6---PF7---PF8---PF9---PF10--PF11--PF12---
       Help  Print Exit  Top   Posi  Bot    -     +                      Canc
Repare na tela abaixo (AA,015,A) o AA refere-se ao nome Adabas do campo, o 015 é o tamanho já o (A) é o formato do campo (alfa);
 15:44:06             ***** NATURAL TEST UTILITIES *****              22/10/2015
 User AA01055                  - DBLOG Trace -                  Library NAT2CUR
 M   No Cmd   DB   FNR  Rsp        ISN        ISQ  CID CID(Hex) OP Pgm      Line
 _    1 RC   230                                       00000000 F  ATEST    0220
 f    2 L3   230     5              94            ?Ø?? 02800101  A CLAUD005 0280
 _    +----------------------------------------------------------------------+ 0
 _    |  _     Seq No ..     2   Format Buffer                               | 0
 _    | 0000 * C1C16BF0 F1F56BC1 6BC1C46B F0F2F06B * AA,015,A,AD,020, * 0000 | 0
 _    | 0010 * C16BC1C5 6BF0F2F0 6BC16BC1 C66BF0F1 * A,AE,020,A,AF,01 * 0010 | 0
 _    |                                                                      | 0
 _    | 0020 * F06BC16B C1C76BF0 F0F26BE4 6BC1C36B * 0,A,AG,002,U,AC, * 0020 | 0
 _    | 0030 * F0F0F86B C16BC1C2 6BF0F0F4 6BC64B00 * 008,A,AB,004,F.  * 0030 | 0
 _    | 0040 * 00000000 00000000 00000000 00000000 *                  * 0040 | 0
 _    +----------------------------------------------------------------------+ 0
 _   12 RC   230     5                            ?Ø?? 02800101 SI CLAUD005 0280
 _   13 RC   230                                       00000000 F  CLAUD005 0360
 _
 _
 _
 _

 Command ===>
 Enter-PF1---PF2---PF3---PF4---PF5---PF6---PF7---PF8---PF9---PF10--PF11--PF12---
       Help  Print Exit  Top   Posi  Bot    -     +                      Canc
Ajuntando e somando os tamanhos dos campos dá para descobrir o tamanho record buffer (abaixo dá 79)
* AA,015,A,AD,020,A,AE,020,A,AF,010,A,AG,002,U,AC,008,A,AB,004,F.
     015   +  020   +  020   +  010   +  002   +  008   +  004 = 79 record buffer
Checando o Record Buffer

Abaixo, vamos usar a opção R (Record Buffer) para a mesma chamada Adabas.
 16:07:15             ***** NATURAL TEST UTILITIES *****              22/10/2015
 User AA01055                  - DBLOG Trace -                  Library NAT2CUR
 M   No Cmd   DB   FNR  Rsp        ISN        ISQ  CID CID(Hex) OP Pgm      Line
 _    1 RC   230                                       00000000 F  ATEST    0220
 r    2 L3   230     5              94            ?Ø?? 02800101  A CLAUD005 0280
 _    3 L3   230     5              95            ?Ø?? 02800101  A CLAUD005 0280
 _    4 L3   230     5              98            ?Ø?? 02800101  A CLAUD005 0280
 _    5 L3   230     5              99            ?Ø?? 02800101  A CLAUD005 0280
 _    6 L3   230     5             103            ?Ø?? 02800101  A CLAUD005 0280
 _    7 L3   230     5             104            ?Ø?? 02800101  A CLAUD005 0280
 _    8 L3   230     5             108            ?Ø?? 02800101  A CLAUD005 0280
 _    9 L3   230     5             113            ?Ø?? 02800101  A CLAUD005 0280
 _   10 L3   230     5             115            ?Ø?? 02800101  A CLAUD005 0280
 _   11 L3   230     5             129            ?Ø?? 02800101  A CLAUD005 0280
 _   12 RC   230     5                            ?Ø?? 02800101 SI CLAUD005 0280
 _   13 RC   230                                       00000000 F  CLAUD005 0360
 _
 _
 _
 _

 Command ===>
 Enter-PF1---PF2---PF3---PF4---PF5---PF6---PF7---PF8---PF9---PF10--PF11--PF12---
       Help  Print Exit  Top   Posi  Bot    -     +                      Canc
Aqui esta o Record Buffer - o registro em si.
 16:04:28             ***** NATURAL TEST UTILITIES *****              22/10/2015
 User AA01055                  - DBLOG Trace -                  Library NAT2CUR
 M   No Cmd   DB   FNR  Rsp        ISN        ISQ  CID CID(Hex) OP Pgm      Line
 _    1 RC   230                                       00000000 F  ATEST    0220
 r    2 L3   230     5              94            ?Ø?? 02800101  A CLAUD005 0280
 _    +----------------------------------------------------------------------+ 0
 _    |  _     Seq No ..     2   Record Buffer                               | 0
 _    | 0000 * C2E7E960 C1F0F0F3 F1F2F4F2 F0F9F3C1 * BXZ-A0031242093A * 0000 | 0
 _    | 0010 * E4C4C940 40404040 40404040 40404040 * UDI              * 0010 | 0
 _    |                                                                      | 0
 _    | 0020 * 404040D8 E4C1E3E3 D9D640E3 E4D9C2D6 *    QUATTRO TURBO * 0020 | 0
 _    | 0030 * 40404040 404040D7 D9C5E3D6 40404040 *        PRETO     * 0030 | 0
 _    | 0040 * 40F8F3F5 F0F0F2F2 F5F0F000 345DC900 *  8350022500 ?)I  * 0040 | 0
 _    +----------------------------------------------------------------------+ 0
 _   12 RC   230     5                            ?Ø?? 02800101 SI CLAUD005 0280
 _   13 RC   230                                       00000000 F  CLAUD005 0360
 _
 _
 _
 _

 Command ===>
 Enter-PF1---PF2---PF3---PF4---PF5---PF6---PF7---PF8---PF9---PF10--PF11--PF12---
       Help  Print Exit  Top   Posi  Bot    -     +                      Canc
Comprimento do Record Buffer

Para descobrir o comprimento do record buffer digite C;
 15:45:50             ***** NATURAL TEST UTILITIES *****              22/10/2015
 User AA01055                  - DBLOG Trace -                  Library NAT2CUR
 M   No Cmd   DB   FNR  Rsp        ISN        ISQ  CID CID(Hex) OP Pgm      Line
 _    1 RC   230                                       00000000 F  ATEST    0220
 c    2 L3   230     5              94            ?Ø?? 02800101  A CLAUD005 0280
 _    3 L3   230     5              95            ?Ø?? 02800101  A CLAUD005 0280
 _    4 L3   230     5              98            ?Ø?? 02800101  A CLAUD005 0280
 _    5 L3   230     5              99            ?Ø?? 02800101  A CLAUD005 0280
 _    6 L3   230     5             103            ?Ø?? 02800101  A CLAUD005 0280
 _    7 L3   230     5             104            ?Ø?? 02800101  A CLAUD005 0280
 _    8 L3   230     5             108            ?Ø?? 02800101  A CLAUD005 0280
 _    9 L3   230     5             113            ?Ø?? 02800101  A CLAUD005 0280
 _   10 L3   230     5             115            ?Ø?? 02800101  A CLAUD005 0280
 _   11 L3   230     5             129            ?Ø?? 02800101  A CLAUD005 0280
 _   12 RC   230     5                            ?Ø?? 02800101 SI CLAUD005 0280
 _   13 RC   230                                       00000000 F  CLAUD005 0360
 _
 _
 _
 _

 Command ===>
 Enter-PF1---PF2---PF3---PF4---PF5---PF6---PF7---PF8---PF9---PF10--PF11--PF12---
       Help  Print Exit  Top   Posi  Bot    -     +                      Canc
Converter o valor (RB Length) hexadecimal para Decimal via a calculadora do Windows;
 15:46:06             ***** NATURAL TEST UTILITIES *****              22/10/2015
 User AA01055                  - DBLOG Trace -                  Library NAT2CUR
 M   No Cmd   DB   FNR  Rsp        ISN        ISQ  CID CID(Hex) OP Pgm      Line
 _    1 RC   230                                       00000000 F  ATEST    0220
 _    2 RC   230                                       00000000 F  AEDIT    5250
 c +-----------------------------------------------------------------------------+
 _ |  _  SEQ NO ..     3  PROGRAM .. CLAUD005  LINE .. 0280                      |
 _ | Command Code .. L3         Command ID ... ?Ø?? 02800101 CB Start ... 00D5   |
 _ | Response Code . 0000       ISN ..........         94    FNR first .. 00     |
 _ | ISN Low Limit .            ISN Quantity .               FNR last ... 05     |
 _ | FB Length ..... 003F       RB Length .... 004F          SB Length .. 0008   |
 _ | VB Length ..... 0014       IB Length .... 0000                              |
 _ | Command Opts ..   A      00C1                                               |
 _ | Additions 1 ... AD¨­     C1C4BBCA40404040    Command Time .. 00000009        |
 _ | Additions 2 ...  | |     004F004F            User Area ..... 00000000       |
 _ |                                                                             |
 _ | Additions 3 ...          0000000000000000                                   |
 _ | Additions 4 ...      È W 40404040407400E6                                   |
 _ | Global FID .... 0000000000000000                                            |
 _ +-----------------------------------------------------------------------------+

 Command ===>
 Enter-PF1---PF2---PF3---PF4---PF5---PF6---PF7---PF8---PF9---PF10--PF11--PF12---
       Help  Print Exit  Top   Posi  Bot    -     +                      Canc
Valor do record buffer é de 79


Site Calculadora - Clique Aqui
Sites Referentes - Clique Aqui - Clique Aqui

0 comentários:

Enviar um comentário