ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Converting Character field (flat registration) to Zoned

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

  • Converting Character field (flat registration) to Zoned

    I explain my problem: Create a process that automatically compares fields from two files that have the same number of fields, but the numeric fields changed length. This comparison process was carried out by REGISTERING FLAT FROM FILE ONE vs PLOT REGISTRATION FROM FILE TWO, and by means of a DSPFFD saved in an OUTFILE I take the structure and go through the flat register doing a SUBSTR .... For now all good, I have no problem with the Character fields (Type A), nor with the Packaged ones (Type P), however with the S type I have a problem .... As I mentioned earlier the numerical fields changed length, and there are fields that went from 13,2 => 19,3?.
    When the value field of the field is equal to Zero, and I do the SUBSTR of the field, it reflects me as a difference: VALUE ONE FILE:000 VALUE ONE FILE: 0000

    However, it is not a real difference, since the absolute value is zero, to avoid that, I made a game and only took the whole value of the field .... The problem I have when the value of the field is NEGATIVE, when the value of the field is negative: 00000000079Q Being the real value: 798- How can I do to extract the real value of the negative field read from the flat register (00000000079Q)? I have done the conversion to hexadecimal but I do not know how to extract the real value of the hexadecimal field, someone will know how ?? F0F0F0F0F0F0F0F0F0F0F7F9D8

    ----
    Español:
    Explico mi problema:
    Cree un proceso que automáticamente compara campos de dos archivos que tienen la misma cantidad de campos, pero los campos numéricos cambiaron de longitud. Este proceso de comparación lo realizo REGISTRO PLANO DEL ARCHIVO UNO vs REGISTRO PLANO DEL ARCHIVO DOS, y mediante un DSPFFD guardado en un OUTFILE tomo la estructura y voy recorriendo el registro plano haciendo un SUBSTR?. Por ahora todo bien, no tengo problema con los campos Carácter (Tipo A), ni con los Empaquetados (Tipo P), sin embargo con los tipo S tengo un inconveniente?.
    Como mencione anteriormente los campos numéricos cambiaron de longitud, y hay campos que pasaron de 13,2 => 19,3?.
    Cuando el campo valor del campo es igual a Zero, y hago el SUBSTR del campo, me refleja como una diferencia:
    VALOR ARCHIVO UNO: 000
    VALOR ARCHIVO DOS: 0000
    Sin embargo, no es una diferencia real, ya que el valor absoluto es cero, para evitar eso, hice un juego y solo tomo el valor entero del campo?.
    El problema lo tengo cuando el valor del campo es NEGATIVO, cuando el valor del campo es negativo: 00000000079Q
    Siendo el valor real: 798-
    ¿Como puedo hacer para extraer el valor real del campo negativo leído desde el registro plano (00000000079Q)?
    He hecho la conversión a hexadecimal pero no se como extraer el valor real del campo hexadecimal, alguien sabra como??
    F0F0F0F0F0F0F0F0F0F0F7F9D8

    Convirtiendo campo Carácter (registro plano) a Zoned

  • #2
    Create a data structure with a zoned(63) subfield, and overlay the zoned subfield with a character(63) subfield. Move your zoned data to the end of the character subfield, ensuring that the digits on the left are all '0'. The zoned subfield will have the numeric value of your zoned data.

    Cree una estructura de datos con un subcampo tipo S con longitud 63, y superponga el subcampo tipo S con un subcampo tipo A con longitud 63. Mueva sus datos tipo S al final del subcampo tipo A, asegurándose de que los dígitos de la izquierda son todos '0'. El subcampo tipo S tendrá el valor numérico de tus datos de tipo S.

    dcl-ds cvtZoned qualified;
    z zoned(63) inz;
    a char(63) overlay(z);
    end-ds;
    dcl-s zeros63 zoned(63) inz;

    EVALR cvtZoned.a = zeros63 + zoneddata1;
    numval = cvtZoned.z;

    Comment


    • #3
      Originally posted by Barbara Morris View Post
      Create a data structure with a zoned(63) subfield, and overlay the zoned subfield with a character(63) subfield. Move your zoned data to the end of the character subfield, ensuring that the digits on the left are all '0'. The zoned subfield will have the numeric value of your zoned data.

      Cree una estructura de datos con un subcampo tipo S con longitud 63, y superponga el subcampo tipo S con un subcampo tipo A con longitud 63. Mueva sus datos tipo S al final del subcampo tipo A, asegurándose de que los dígitos de la izquierda son todos '0'. El subcampo tipo S tendrá el valor numérico de tus datos de tipo S.

      dcl-ds cvtZoned qualified;
      z zoned(63) inz;
      a char(63) overlay(z);
      end-ds;
      dcl-s zeros63 zoned(63) inz;

      EVALR cvtZoned.a = zeros63 + zoneddata1;
      numval = cvtZoned.z;
      Thanks Barbara, the process worked perfectly :*

      Comment

      Working...
      X