Ver Mensaje Individual
  #3
Antiguo 17 de enero de 2019, 19:31
JCantero
El Foro es mi casa
Activista del Foro: Activista del Foro - Issue reason: Por participación activa Agradecimientos: Por muchos agradecimientos de parte de los Foreros - Issue reason: Por muchos agradecimientos de parte de los Foreros 
Última Actividad 02.09.2026 00:15
Posts Posts: 442
Likes enviados Enviados: 167
Likes recibidos Recibidos: 269

Si quieres tener en cuenta los nombre y apellidos compuestos tienes que analizar cada cada campo y montar despues como indica Roger.

Código COBOL:
  1. WORKING STORAGE.
  2. 01 Nombres Pic x(25).
  3. 01 Paterno Pic x(15).
  4. 01 Materno Pic x(15).
  5. 01 NOMBRE PIC X(60).
  6. 01 ipaterno pic 99.
  7. 01 imaterno pic 99.
  8. 01 inombres pic 99.
  9.  
  10. PROCEDURE DIVISION.
  11.      perform varying inombres from 1 by 1 until inombres = 25 or nombres(inombres:) = '  '
  12.          continue
  13.      end-perform
  14.      perform varying ipaterno from 1 by 1 until ipaterno = 15 or paterno(ipaterno:) = '  '
  15.          continue
  16.      end-perform
  17.      perform varying imaterno from 1 by 1 until imaterno = 15 or materno(imaterno:) = '  '
  18.          continue
  19.      end-perform
  20.  
  21.  ****** montar dependiendo del tamaño de cada uno.
  22. ****** pero tienes que ver si el campo esta en blanco o totalmente ocupado.
  23. ****** ¡¡ un lio ¡¡

Creo que lo mejor es ir montandolo sobre la marcha y evitar un monton de condiciones.
Quedaria asi:

Código COBOL:
  1. WORKING STORAGE.
  2. 01 Nombres Pic x(25).
  3. 01 Paterno Pic x(15).
  4. 01 Materno Pic x(15).
  5. 01 NOMBRE PIC X(60).
  6. 01 indice pic 99.
  7. 01 indicex pic 99.
  8.  
  9. PROCEDURE DIVISION.
  10.      move 1 to indice
  11.      initialize nombre
  12.      perform varying indicex from 1 by 1 until indicex > 15 or paterno(indicex:) = '  '
  13.          move paterno(indicex:1) to nombre(indice:1)
  14.          add 1 to indice
  15.      end-perform
  16.      add 1 to indice
  17.      perform varying indicex from 1 by 1 until indicex > 15 or materno(indicex:) = '  '
  18.          move materno(indicex:1) to nombre(indice:1)
  19.          add 1 to indice
  20.      end-perform
  21.      add 1 to indice
  22.      perform varying indicex from 1 by 1 until indicex > 25 or nombres(indicex:) = '  '
  23.          move nombres(indicex:1) to nombre(indice:1)
  24.          add 1 to indice
  25.      end-perform.
  26.  
  27. ***** en nombre lo tienes perfectamente montado.    


---------- Post añadido : 19:31 ---------- Post anterior : 19:21 ----------

Si quieres dejarlo asi (con una coma antes del nombre): Meza Moya, Juan Martin


Código COBOL:
  1. WORKING STORAGE.
  2. 01 Nombres Pic x(25).
  3. 01 Paterno Pic x(15).
  4. 01 Materno Pic x(15).
  5. 01 NOMBRE PIC X(60).
  6. 01 indice pic 99.
  7. 01 indicex pic 99.
  8.  
  9. PROCEDURE DIVISION.
  10.      move 1 to indice
  11.      initialize nombre
  12.      perform varying indicex from 1 by 1 until indicex > 15 or paterno(indicex:) = '  '
  13.          move paterno(indicex:1) to nombre(indice:1)
  14.          add 1 to indice
  15.      end-perform
  16.      add 1 to indice
  17.      perform varying indicex from 1 by 1 until indicex > 15 or materno(indicex:) = '  '
  18.          move materno(indicex:1) to nombre(indice:1)
  19.          add 1 to indice
  20.      end-perform
  21.      move ',' to nombre(indice:1)
  22.      add 2 to indice
  23.      perform varying indicex from 1 by 1 until indicex > 25 or nombres(indicex:) = '  '
  24.          move nombres(indicex:1) to nombre(indice:1)
  25.          add 1 to indice
  26.      end-perform.
  27.  
  28. ***** en nombre lo tienes perfectamente montado.    
JCantero is offline   Responder Con Cita