W Pub: ABAP Prog Propios RPT Puntua

  1. .report znadar1
  2.  
  3. .parameters: prog(32)
  4.            ,save as checkbox default ' '
  5.            ,prin radiobutton group r01 default 'X'
  6.            ,fina radiobutton group r01
  7.  
  8. * El sorce de entrada tiene que ser abap-strict
  9. .data src(72) occurs 0 with header line
  10. .data di(72)
  11.  
  12. .end-of-selection
  13. .data: ax(2)
  14.      ,bx(2) type n
  15.      ,al(1)
  16.  .break-point
  17.  .read report prog into src
  18.  .al = '.'
  19.  .if prin = 'X'
  20.    .loop at src
  21.      .perform punt_al_principio
  22.      .write: / src
  23.    .endloop
  24.    .if sy-subrc eq 0
  25.       .src = al
  26.       .append src
  27.       .write: / src
  28.    .endif
  29.  .else
  30.    .loop at src
  31.      .perform punto_al_final
  32.      .write: / src
  33.    .endloop
  34.  .endif
  35.  .if not save is initial
  36.     .insert report prog from src
  37.  .endif
  38.  
  39. .form punt_al_principio
  40. *Pone el punto al principio
  41. *
  42. * Bugs conocidos:
  43. *   * Cuando hay comentarios en la misma lnea habra que truncarlos
  44. *     y comprobar en que acaba
  45. *
  46. *   * Los comandos multilineas fallan al colocar el punto final.
  47. *
  48.  .check src+0(1) ne '*'
  49.  .check src+0(1) ne '"'
  50.  .check src      ne '*'
  51.  .check not src is initial
  52.  .if src cp '*.'
  53.     .ax = strlen( src )
  54.     .if ax <= 71
  55.       .ax = ax - 1
  56.       .bx = '01'
  57.       .src+ax(bx) = ' '
  58.       .di = src
  59.       .while di+0(1) = ' '
  60.          .shift di left
  61.          .if di is initial. exit. endif
  62.       .endwhile
  63.       .ax = strlen( src ) - strlen( di ) - 1
  64.       .if ax < 0
  65.          .concatenate al src into src
  66.       .else
  67.          .src+ax(bx) = al
  68.       .endif
  69.       .al = '.'
  70.       .modify src index sy-tabix
  71.     .else
  72.       .src = al
  73.       .insert src index sy-tabix
  74.     .endif
  75.  .endif
  76.  .if src cp '*,'
  77.     .ax = strlen( src )
  78.     .if ax <= 71
  79.       .ax = ax - 1
  80.       .bx = '01'
  81.       .src+ax(bx) = ' '
  82.       .di = src
  83.       .while di+0(1) = ' '
  84.          .shift di left
  85.          .if di is initial. exit. endif
  86.       .endwhile
  87.       .ax = strlen( src ) - strlen( di ) - 1
  88.       .if ax < 0
  89.          .concatenate al src into src
  90.       .else
  91.          .src+ax(bx) = al
  92.       .endif
  93.       .al = ','
  94.       .modify src index sy-tabix
  95.     .else
  96.       .src = al
  97.       .insert src index sy-tabix
  98.     .endif
  99.  .endif
  100. .endform
  101.  
  102. .form punto_al_final
  103. *Pone el punto al final, en la columna 72
  104.     .check src+0(1) ne '*'
  105.     .if src cp '*.'
  106.        .ax = strlen( src )
  107.        .check ax <= 71
  108.        .ax = ax - 1
  109.        .bx = '01'
  110.        .src+ax(bx) = ' '
  111.        .src+71(1)  = '.'
  112.        .modify src index sy-tabix
  113.     .endif
  114.     .if src cp '*,'
  115.        .ax = strlen( src )
  116.        .check ax <= 71
  117.        .ax = ax - 1
  118.        .bx = '01'
  119.        .src+ax(bx) = ' '
  120.        .src+71(1)  = ','
  121.        .modify src index sy-tabix
  122.     .endif
  123. .endform
  124. .