Loading

Equivalent functionality for REDEFINES in Easytrieve

have you already read Easytrieve Variable declaration?

In COBOL, REDEFINES verb can be used to declare variables that share a same memory location.
In Easytrieve also, there is a similar functionality.
For example, the ALPHA and NUMERIC variables given below share the same 5 bytes.

 WS-ALPHA   W        5 A
 WS-NUMERIC WS-ALPHA 5 N

Since the starting position for WS-NUMERIC is given as WS-ALPHA, both of them start from the same memory location.

In case, if you want the same functionality in a File variable,

 FILE INFILE
 IN-REC   1 80 A
 IN-ALPHA     1  5 A
 IN-NUMERIC   1  5 N
 FILLER       6 75 A

Related Posts




blog comments powered by Disqus

There's 6 Comments So Far

  •   louie
    February 14th, 2012 at 6:36 pm

    Example of taking a Numeric field in WS of 6 bytes and breaking it down into 6 seperate alpha bytes please

  •   Karthik
    February 19th, 2012 at 11:54 am

    Hi Louie,

    WS-NUMERIC W 6 N
    WS-DIGIT-1 WS-NUMERIC 1 N
    WS-DIGIT-2 WS-NUMERIC +1 1 N
    WS-DIGIT-3 WS-NUMERIC +2 1 N
    WS-DIGIT-4 WS-NUMERIC +3 1 N
    WS-DIGIT-5 WS-NUMERIC +4 1 N
    WS-DIGIT-6 WS-NUMERIC +5 1 N

    Hope this helps. You can also read http://code.xmlgadgets.com/2009/10/07/easytrieve-variable-declaration/

  •   Prerna
    May 8th, 2012 at 5:54 am

    How can i move a Packed datatype to unpacked datatype?

  •   Prerna
    May 8th, 2012 at 5:55 am

    I want to perform this manipulation in Easytrieve

  •   Karthik
    May 8th, 2012 at 6:28 am

    Hi Prerna,

    You can move a packed number to unpacked variable by using assign statements like
    WS-UNPK = WS-PACK

    Please read “Moving Numeric values between variables in Easytrieve”
    http://code.xmlgadgets.com/2010/09/16/moving-numeric-values-between-variables-in-easytrieve/

  •   Senthil
    May 9th, 2012 at 1:23 pm

    Hi Prerna,

    WS-AMOUNT-PKD W 4 P 2
    WS-AMOUNT-UNPKD W 6 N 2

    If you want to move the above mentioned packed to unpacked (numeric) data type variable, plz code it as below
    WS-AMOUNT-UNPKD = WS-AMOUNT-PKD * 1

    In EZTV packed format, the size of the field must be declared same as the total memory bytes that is stored. For example, above unpacked variable will be stored in memory as 4 bytes using the formula n/2+1. While converting packed into unpacked, care should be taken to declare a correct size with appropriate dec point.

Share your thoughts, leave a comment!