ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Using decimal data areas on /free

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Using decimal data areas on /free

    Hi, i was reading thread 3682 about using data areas in free, but they are type char and i have a decimal (6, 0) one:

    Type . . . . . . . . . : *DEC
    Length . . . . . . . : 6 0

    When i read it, i get an error that i am trying to redefine it as a char instead of a decimal. Here's the code:

    Code:
    DNUMTRA           DS                  DTAARA('NUMTRAA')
         DNUMERO                   1      6  0                  
    
    /free
    IN *LOCK NUMTRA;
               NUMERO=NUMERO+1;
               OUT NUMTRA;       
    /end-free
    This is the error i get:

    The type or length of the data area PRODUCTEST/NUMTRAA
    does not match with the defined data area in the program.

    Cause . . . . . : You have defined the data area as type char and length 1. The real data area
    PRODUCTEST/NUMTRAA is of type *DEC and legth (6 0).

    What i am doing wrong? I don't want to use C style DEFINE codes and such.

  • #2
    Re: Using decimal data areas on /free

    PHP Code:
    DNumTra           DS                  DTAARA('NUMTRAA'
    D DNumero                 1      6S 0 
    Hunting down the future ms. Ex DeadManWalks. *certain restrictions apply

    Comment


    • #3
      Re: Using decimal data areas on /free

      Originally posted by DeadManWalks View Post
      PHP Code:
      DNumTra           DS                  DTAARA('NUMTRAA'
      D DNumero                 1      6S 0 
      yet another example of why it's ALWAYS a good idea to specify the data type...
      I'm not anti-social, I just don't like people -Tommy Holden

      Comment


      • #4
        Re: Using decimal data areas on /free

        Doesn't work... it still thinks i am defining the data area as char instead of decimal

        Full code:
        Code:
        DNUMTRA           DS                  DTAARA('NUMTRAA')
        DNUMERO                   1      6S 0
              /FREE
        
                   IN *LOCK NUMTRA;
                   NUMERO=NUMERO+1;
                   OUT NUMTRA;
        Last edited by fjleon; July 22, 2008, 10:23 AM. Reason: example

        Comment


        • #5
          Re: Using decimal data areas on /free

          try this:
          Code:
          dnumtra           s              6s 0 dtaara('NUMTRAA') 
           /free                                                  
              in *lock numtra;                                    
              numtra += 1;                                        
              out numtra;                                         
              *inlr=*on;                                          
              return;
          I'm not anti-social, I just don't like people -Tommy Holden

          Comment


          • #6
            Re: Using decimal data areas on /free

            Hi fjleon:

            To determine if your data area is numeric on a command line key in:dspdtaara mydtaara

            Data area . . . . . . . : GLSTEST
            Library . . . . . . . : QTEMP
            Type . . . . . . . . . : *DEC
            Length . . . . . . . . : 10 0
            Text . . . . . . . . . :
            Value . . . . . . . . . : 123456789
            You cannot change from char to dec you will have to delete the data area and recreate it. When you create the data area prompt and ensure *dec is used as the type.

            Best of Luck
            GLS
            The problem with quotes on the internet is that it is hard to verify their authenticity.....Abraham Lincoln

            Comment


            • #7
              Re: Using decimal data areas on /free

              Originally posted by tomholden View Post
              try this:
              Code:
              dnumtra           s              6s 0 dtaara('NUMTRAA') 
               /free                                                  
                  in *lock numtra;                                    
                  numtra += 1;                                        
                  out numtra;                                         
                  *inlr=*on;                                          
                  return;
              Now it says that it cannot find the data area;

              Can't find the data area numtraa on *LIBL.

              I am pretty sure it exists:
              DSPDTAARA DTAARA(*libl/NUMTRAA)

              Área datos . . . . . . : NUMTRAA
              Biblioteca . . . . . : PRODUCTEST
              Tipo . . . . . . . . . : *DEC
              Longitud . . . . . . . : 6 0
              Texto . . . . . . . . . : Nro.de Transacción para el Ramo Auto-FLOTAS.
              Valor . . . . . . . . . : 157

              Comment


              • #8
                Re: Using decimal data areas on /free

                Hi fjleon:

                Code:
                DNUMTRAA         UDS                 
                DNUMERO                   1      6S 0
                      /FREE
                
                            NUMERO=NUMERO+1;
                           *inlr=*on;
                I beleive this works

                Best of Luck
                GLS
                The problem with quotes on the internet is that it is hard to verify their authenticity.....Abraham Lincoln

                Comment


                • #9
                  Re: Using decimal data areas on /free

                  The only way i can make this work is to use the old DEFINE function:

                  D NUMTRAA DS INZ
                  D NUMTRA S 6 0 INZ(0)
                  C *DTAARA DEFINE NUMTRAA NUMTRA

                  IN *LOCK NUMTRA;
                  NUMTRA+=1;
                  OUT NUMTRA;

                  Comment


                  • #10
                    Re: Using decimal data areas on /free

                    Originally posted by fjleon View Post
                    Now it says that it cannot find the data area;

                    Can't find the data area numtraa on *LIBL.

                    I am pretty sure it exists:
                    DSPDTAARA DTAARA(*libl/NUMTRAA)

                    Área datos . . . . . . : NUMTRAA
                    Biblioteca . . . . . : PRODUCTEST
                    Tipo . . . . . . . . . : *DEC
                    Longitud . . . . . . . : 6 0
                    Texto . . . . . . . . . : Nro.de Transacción para el Ramo Auto-FLOTAS.
                    Valor . . . . . . . . . : 157
                    worked perfect on my system. this is not a code error as it is...it's an environment error.
                    I'm not anti-social, I just don't like people -Tommy Holden

                    Comment

                    Working...
                    X