Workshop - Template Programming

Embed Size (px)

Citation preview

  • 7/28/2019 Workshop - Template Programming

    1/7

    WORKSHOP ON TEMPLATE PROGRAMMING

    EXERCISE I

    1) Create a template for the following

    Requirements -

    Field No. Field Name Type Details

    0 ID Order No. 16,A Standard Globus format

    1 Customer No 10, CUS Mandatory

    2 Order Date 11, D Mandatory

    3 XXconfirmed Only Yes or No

    6 Local 10,A No input

    Solution :

    Define the field names along with the characteristics using the template routineXX.FIELD.DEFINITIONS

    >ED BP XX.FIELD.DEFINITIONS

    Then save the routine in BP by replacing XX with ORDZZ where ZZ is your initials.

    ----: Save BP ORDZZ.FIELD.DEFINITIONS.Quit.----:Q

    Now open the new routine copied and make the necessary changes for the above template.

    >ED BP ORDZZ.FIELD.DEFINITIONS

    Here define parameters for the field as under.

    DEFINE.FIELDS:0020:0021: ID.F = "ORDER.NO" ; ID.N = "16" ; ID.T = "A" ; ID.T =

    "#####/#####/#####"0022: *0023: Z=00024: *0025: Z+=1 ; F(Z) = "CUSTOMER.NO" ; N(Z) = "10.1" ; T(Z) = "CUS"0026:0027: Z+=1 ; F(Z) = "ORDER.DATE" ; N(Z) = "11" ; T(Z) = "D"0028: Z+=1 ; F(Z) = "XXCONFIRMED" ; N(Z) = "3" ; T(Z) = "YES_NO"0031: Z+=1 ; F(Z) = "LOCAL" ; N(Z) = "10" ; T(Z) = "A" ; T(Z) = "NOIN PUT"

    Compile the routine.

    STEP 2

    >ED BP TEMPLATEPage 1 of 7

  • 7/28/2019 Workshop - Template Programming

    2/7

    ----:SAVE BP ORDERS.ZZ----:Q

    ED BP ORDERS.ZZ

    In the para GOSUB Define.parameters remove the REM statement, and insert the name of the

    field definitions as ORDZZ.FIELD.DEFINITIONS

    DEFINE.PARAMETERS:* SEE 'I_RULES' FOR DESCRIPTIONS *0393:0394: CALL ORDZZ.FIELD.DEFINITIONS0395:0396: RETURN

    Next for the purpose of standard Globus format for ID, we call the subroutineEB.FORMAT.ID in the paragraph GOSUB CHECK.ID

    CHECK.ID:Validation and changes of the ID entered. Set ERROR to 1 if in error.

    CALL EB.FORMAT.ID ("ORDZZ")

    IF E THENERROR = 1CALL ERR

    END

    RETURN

    Compile the routine.

    STEP 3

    In Globus create a record in PGM.FILE with the name ORDERS.ZZ as under. Authorise therecord.

    ORDERS.TR--------------------------------------------------------------------------

    1 TYPE.............. H2.1 GB SCREEN.TITLE ORDERS TRAINING TEMPLATE3 ADDITIONAL.INFO...4.1 BATCH.JOB......

    5 PRODUCT........... EB6 SUB.PRODUCT.......

    H type indicates the inclusion of all 3 files namely LIVE/UNAUTH/HIS

    STEP 4

    To create a file control, we will open an existing file.control as under -

    >ED F.FILE.CONTROL ACCOUNT

    21 lines long.

    ----: SAVE F.FILE.CONTROL ORDERS.TR"ORDERS.TR" filed in file "F.FILE.CONTROL".

    Page 2 of 7

  • 7/28/2019 Workshop - Template Programming

    3/7

    ----: Q

    Now open the file control file and make the following changes.

    >ED F.FILE.CONTROL ORDERS.TR21 lines long.----:0001: THE ACCOUNT FILE----: C/ACCOUNT/ORDERS.TR0001: THE ORDERS.TR FILE0002: AC

    ----: C/AC/EB ------------ As mentioned in PGM.FILE0002: EB

    0003: $HIS$NAU --------For a H type file in PGM.FILE0004: 20005: 170006: FIN0007:

    ----: FI"ORDERS.TR" filed in file "F.FILE.CONTROL".

    STEP 5

    Run the FILE.LAYOUT to create the I_ as under

    >FILE.LAYOUT

    FILE LAYOUT - CREATING I_F FILE

    NAME OF THE FILE (E.g. BP, BANK.BP):

    ?At this system prompt, mention the file as BP

    At the next prompt Enter Program/File(s) :Give the program name ORDERS.ZZ

    The system prompts as underBuild Insert from File (D)ictionarys or (P)rograms or (Q)uit :Mention P

    At the next promptEnter output Name - = I_F.Entryname:

    Enter return

    Next prompt by the system isEnter PREFIX or = NONE :Mention an appropriate prefix ORDTR

    The system then Processes the matrix entries for ORDERS.ZZ program

    STEP 6

    In Globus run the application CREATE.FILES at the command prompt. The system prompts

    for

    COMPANY NAME

    Page 3 of 7

  • 7/28/2019 Workshop - Template Programming

    4/7

    Mention the Bank name (by its Mnemonic)

    CREATE FILES FOR Globus Demo Account

    It next prompts forLIST NAMEGive returnIt prompts forFILE NAME ORDERS.ZZ

    USING FILE NAME(S) INPUT

    CONTINUE (Y/N) Y

    The following message will be flashed stating that the dict & data files are being created asper the file control details regarding modulo/separation given therein and also files for $NAU

    & $HIS types.Creating dictionary for F.ORDERS.TRCreating file "D_F.ORDERS.TR" as Type 3, Modulo 1, Separation 2.Added "@ID", the default record for RetrieVe, to "D_F.ORDERS.TR".Copying to ../demo.dict/D_F.ORDERS.TRDeleting local dictionary D_F.ORDERS.TR

    Creating file FBNK.ORDERS.TRWARNING: An operating system file will be created with a truncated name.Creating file "FBNK.ORDE000" as Type 2, Modulo 17, Separation 4.Copying to ../demo.data/eb/FBNK.ORDE000Deleting local file FBNK.ORDE000

    Creating file FBNK.ORDERS.TR$HISWARNING: An operating system file will be created with a truncated name.Creating file "FBNK.ORDE000" as Type 2, Modulo 17, Separation 4.Copying to ../demo.data/eb/FBNK.ORDE001Deleting local file FBNK.ORDE000

    Creating file FBNK.ORDERS.TR$NAUWARNING: An operating system file will be created with a truncated name.Creating file "FBNK.ORDE000" as Type 2, Modulo 17, Separation 4.Copying to ../demo.data/eb/FBNK.ORDE002Deleting local file FBNK.ORDE000

    STEP 7

    In GLOBUS open the application STANDARD SELECTION in the name ORDERS.ZZ andset FIELD.NO.28 to Y. The system automatically generates the DICT file for the fieldswhich can be referenced later on.

    ORDERS.ZZ application is now ready for input.

    EXERCISE 2

    Introduce a CHECKFILE for the input of the customer ID and enrichment displayed for thesame. Also we will introduce automatic ID generation.

    Page 4 of 7

  • 7/28/2019 Workshop - Template Programming

    5/7

    Solution :

    Open the routine ORDZZ.FIELD.DEFINITIONS and include the following CHECKFILE

    0027: Z += 1 ; F(Z) = "CUSTOMER.NO" ; N(Z) = 10.1."; T(Z) = "CUS0028: CHECKFILE(Z) = CHK.CUSTOMER

    Insert the following line after the field.definitions

    CHK.CUSTOMER = "CUSTOMER":FM:EB.CUS.SHORT.NAME:FM:'.A'Compile the routine.

    Now while inputting a record into the ORDERS.ZZ application in Globus the system checksthe input made into the customer field for the existence in the CUSTOMER application andthereupon display the enrichment of the short name.

    For ID generation in Globus open the application AUTO.ID.START

    Auto ID Start INPUT

    KEY............... ORDERS.TR--------------------------------------------------------------

    1. 1 DESCRIPTION.... ORDERS TRAINING TEMPLATE2. 1 APPLICATION.... ORDERS.TR3. 1 ID.START....... ORDTR00053000014 RECORD.STATUS.....

    Open the COMPANY record and include the template under PGM.AUTO.ID field.

    COMPANY.CODE...... GB-001-0001 Great Britain ----------------13.29 PGM.AUTOM.ID... ORDERS.ZZ

    Now the template can be run with an automatic ID generation

    EXERCISE 3

    Add a routine using CHECKFIELD to populate the order date with the current date.

    Solution :

    >ED BP XX.CHECK.FIELDS113 lines long.

    ----: SAVE BP ORDZZ.CHECK.FIELDS"ORDZZ.CHECK.FIELDS" filed in file "BP".----: Q

    In ORDZZ.CHECK.FIELDS make the following changes

    Include $INSERT I_F.ORDERS.ZZ

    Page 5 of 7

  • 7/28/2019 Workshop - Template Programming

    6/7

    Include the condition for populating the field with current day by using the condition COMI= TODAY as under

    DEFAULT.FIELDS:

    0072: *0073: BEGIN CASE0074: CASE AF = ORDTR.ORDER.DATE0075: COMI = TODAY0076:0077: END CASE0078:0079: CALL REFRESH.FIELD(AF,'')0080:0081: RETURN

    Compile the routine.

    Open the routine ORDZZ.FIELD.DEFINITIONS and include the following in the Nparameter and compile it.

    0028: Z += 1 ; F(Z) = ORDER.DATE ; N(Z) = 10.1.C ; T(Z) = D

    Open ORDERS.ZZ and remove the REM statement in GOSUB CHECK.FIELDS and callORDZZ.CHECK.FIELDS.

    CHECK.FIELDS:

    CALL ORDZZ.CHECK.FIELDS

    IF E THENT.SEQU = "IFLD"CALL ERR

    END

    RETURN

    Compile the routine.

    Now the routine can execute the requirement.

    EXERCISE 4

    Include a routine to cross validate that the input of quantity above 1000 needs to beconfirmed.

    Solution :

    >ED BP XX.CROSSVAL127 lines long.

    ----: SAVE BP ORDZZ.CROSSVAL"ORDZZ.CROSSVAL" filed in file "BP".----: Q>ED BP ORDZZR.CROSSVAL

    Page 6 of 7

  • 7/28/2019 Workshop - Template Programming

    7/7

    0030:REAL.CROSSVAL:0031: *0032: * Real cross validation goes here....0033: *0034: AF = ORDTR.QUANTITY

    0035: NO.OF.AV = DCOUNT(R.NEW(AF),VM)0036: FOR AV = 1 TO NO.OF.AV0037: IF R.NEW(ORDTR.QUANTITY) > 1000 ANDR.NEW(ORDTR.CONFIRMED) = "NO" THEN0038: AF = ORDTR.QUANTITY0039:0040: ETEXT = "QNTY ABOVE 1000 NEEDS CONFIRMATION"0041: CALL STORE.END.ERROR0042: END0043: NEXT AV0044: RETURN0045: *

    Compile the routine.

    Reopen the template ORDERS.ZZ and remove the REM statement in the GOSUB CROSSVALIDATION.

    In the paragraph CROSS.VALIDATION call ORDZZ.CROSSVAL.

    Compile the template.

    Now the application will meet the requirement.

    Page 7 of 7