My IPeople

Community discussion for IPeople products and services
Welcome to My IPeople Sign in | Help
Home Blogs Forums

What are the benefits of using a macro instead of a fragment and how do I do this with the NPR Report Writer?

  •  08-14-2006, 1:48 AM

    What are the benefits of using a macro instead of a fragment and how do I do this with the NPR Report Writer?

    Why use a macro instead of a fragment?

    For querying information from another application, macros will typically run faster than fragments. Also, this could save the developer time for report creation. Now the developer can create one report instead of two.

     

    How do I call a macro?

    There are several ways in which a macro can be called by a report. The most common method for calling a macro is to place the call in the footnote of the report using the AL footnote attribute. To incorporate a macro into the report object code, enter the following AL footnote in the report's footnote editor.

    AL where.to.put.macro macro.name

    For example: AL START macro.name

     

    A macro can also be called from line attributes and field attributes.  When macros are called from a field or line attribute, the code is not placed directly into the report's object code; only the call to the macro is inserted. As a result, the macro is treated as a program.  For this reason, the last line of the macro must end with a semi-colon. When called as a program the macro call takes a form like %DPM.report.name.M.macro("").

    Example: %ADM.PAT.zcus.status.M.get.info("")

      

    Where does the code get inserted when using the AL footnote attribute?

     

    Keyword                                 Macro Code Inserted

    START                                   Beginning of program

    SKn                                         After sort key acquired

    AFTER.GET.MAIN                After details are processed and before any multiples

    BEFORE.PRINT                   After detail process and multiples

    region.name                         Just before lines in regions are printed

    AFTER.region.name            After lines in regions are printed

    CLOSE.UP                            Report has printed but prefixes are still open

     

    How do I open a prefix to a specified application through a macro?

    MEDITECH provides standard Z program calls for both Magic and Client Server platforms that allow you to open prefixes to a specified application. As a result, you can have a report from Admissions (ADM.PAT) call the Z program in order to open a prefix to BAR (BAR.PAT). Once the prefix is open, the report can access fields from the database for the application. It is important to remember that before you can access any field values from the application, the subscripts (or primary key) of that segment must be defined.

     

    For Magic platforms, utilize the program Z.link to open a prefix to the specified application.

    %Z.link(A,B,C,D,E)

    A = Prefix to open

    B = Application Name

    C = Physical File Name

    D = Database Name

    E = Argument to logical file name (optional)

    Example: %Z.link("*","BAR","%.BAR.data","BAR.XXX")

     

    For Client Server platforms, utilize the program Z.link.db to open a prefix to the specified application.

    %Z.link.db(Q(“application database”),Q(A,B,C))

    A = O for Open the database  or C for Close the database

    B = “B” for bypass database checks – we skip this logic because we don’t care to see msgs

    C = 1 for suppress messages – like argument B – we don’t want to see any messages

    Example: %Z.link.db({“PHA.XXX”}, {“O”})

     

    Sample Code:

    The code below can be used to access B/AR data (BAR.PAT) from an Admissions report (ADM.PAT:

    A^BAR.PAT.number,

    @OPEN.BAR,

    @GET.BAR.INFO,

    @CLOSE.BAR,

    /TOT.CHG;

     

    OPEN.BAR

    C(*S),

    @Chg.prefix(BAR.PAT,:,*),

    @Chg.prefix(BAR.PAT,?,*),

    %Z.link("*","BAR","%.BAR.data","BAR.XXX")

     

    GET.BAR.INFO

    @Next(BAR.PAT.account,@BAR.PAT.number.x),

    @BAR.PAT.chg.total^/TOT.CHG

     

    CLOSE.BAR

    C(*U)

     

    Let’s Take a Look at the Code for Magic Platforms:

              The account number is passed to the macro as argument A

              A Prefix is a pointer to a data structure

              C(*S) - Stores the * prefix in case this prefix is already in use

              @Chg.prefix(BAR.PAT,:,*) - Tells the report to translate all fields with : as the prefix to *

              Z.Link - Opens a pointer (*) to the BAR data

              @BAR.PAT.chg.total^/TOT.CHG Stores the value from the charge total field into a global variable

              C(*U) - Closes the pointer to BAR and restored the * prefix

     

    Note: For Client Server platforms, you do not need to close and restore prefixes before and after making the call to Z.link.db. The prefixes for Client Server are already managed by MEDITECH.
    Filed under: , ,
View Complete Thread
Powered by Community Server, by Telligent Systems