Writers

Information about how write are structured and how to build new program writers.

Writers are developed usign IBM 5722WDS ILE-RPG V5R1 or newer and source code are included to create new writers or modify it to your own requirements.

For example, SABXML can process this SQL Select

SELECT CUSTNA, CADDR, CCITY, CPHONE FROM adtslab.customer ORDER BY CUSTNA
and build this XML file

<resultset>
<row>
<custna>
Alex Martinez</custna>
<caddr>Mi </caddr>
<ccity>Valencia</ccity>
<cphone>111-222-3333</cphone>
</row>
:
:
:
</resutset>

Writer skeleton program tipically contains 100 or less code lines (more efficient code maintenance).
Main procedure usually only contains a call SABRunRQS originator procedure , like:

SABRunRQS( Id :  // Id request called
                    Values : // filter variables
                    %paddr( Header ) : // Header procedure pointer
                    %paddr( StartRow ) : // Start row procedure pointer
                    %paddr( StartCol ) : // Start column procedure pointer
                    %paddr( EndRow ) : // End row procedure pointer
                    %paddr( End ) ) ;  // End data/file procedure pointer


To complete writer code you must code five procedures to format information on different steps.
This procedure are called-back form SABRunRQS on different moments (like a RPG logic cicle 1P, detail, totals and LR phases)
  • Header procedure:
    On this step its defined root XML element, for example <resultset>
  • Start row
    On this step its defined first child element, for example <row>
  • Start column
    On this step its defined columns elements, for example <ccity>Valencia</ccity>
  • End row
    On this step its defined first child element, for example </row>
  • End data/file
    On this step its defined root XML element, for example </resutset>

For example, EndRow procedure source code tipically are defined as:

     p EndRow          b
     d                 pi            10i 0
      /Free
           SAB_wl ( '</row>' ) ; // SAB_wl procedure to write data
           return    1 ;
      /End-free
     p                 e

License


The writers source code is provided under a Creative Commons license 2.5 Attribution-ShareAlike 2.5

Comercial license are available too.

Comments