W Pub: ABAP Prog Propios MIGCMP

  1. report znadar_downthis line-size 255.
  2.  
  3. tables: dd03l.
  4. * Tabla obligatoria para comparar
  5. tables: anla.
  6.  
  7. data: aux_tab like anla,
  8.       d03 like dd03l occurs 0 with header line.
  9.  
  10. field-symbols: <f>, <k>.
  11.  
  12. parameters: tabname like dd02l-tabname,
  13.             down as checkbox default 'X',
  14.             upl  as checkbox default ' '.
  15. data: itab(65534) occurs 0 with header line,
  16.       tabread(65534),
  17.       di(30), si(30).
  18.  
  19. end-of-selection.
  20.    if down = 'X'.
  21.       perform load_data.
  22.       perform download_filez.
  23.    elseif upl = 'X'.
  24.       select * from dd03l into table d03 where tabname = tabname.
  25.       perform upload_filez.
  26.       loop at itab.
  27.          aux_tab = itab.
  28.          perform compara_tab.
  29.          if sy-subrc ne 0.
  30.             write: / 'No econtrado:', aux_tab.
  31.          else.
  32.             if aux_tab ne tabread.
  33.                write: / 'Campos diferentes:', aux_tab.
  34.                loop at d03.
  35.                   concatenate 'aux_tab-' d03-fieldname into si.
  36.                   concatenate tabname '-' d03-fieldname into di.
  37.                   assign (si) to <f>.
  38.                   assign (di) to <k>.
  39.                   if <f> ne <k>.
  40.                      write: / 'Campo diferente:', d03-fieldname,
  41.                               'Fichero:', <f>,
  42.                               'BBDD:', <k>.
  43.                   endif.
  44.                endloop.
  45.             endif.
  46.          endif.
  47.       endloop.
  48.    endif.
  49.  
  50. form compara_tab.
  51.    select single * from anla into tabread
  52.      where bukrs = aux_tab-bukrs and
  53.            anln1 = aux_tab-anln1 and
  54.            anln2 = aux_tab-anln2.
  55.  
  56. *    where belnr = aux_tab-belnr
  57. *      and blpos = aux_tab-blpos.
  58.  
  59.  
  60. *          where  bukrs  = aux_tab-bukrs
  61. *          and    hbkid  = aux_tab-hbkid.
  62.    if tabread is initial.
  63.       sy-subrc = 4.
  64.    else.
  65.       anla = tabread.
  66.    endif.
  67. endform.
  68.  
  69. form load_data.
  70.    select * up to 5000 rows
  71.     from (tabname) into table itab.
  72. endform.
  73.  
  74. form upload_filez.
  75.    call function 'UPLOAD'
  76.     exporting
  77.       filetype                = 'ASC'
  78.      tables
  79.        data_tab               = itab
  80.     exceptions
  81.       conversion_error        = 1
  82.       invalid_table_width     = 2
  83.       invalid_type            = 3
  84.       no_batch                = 4
  85.       unknown_error           = 5
  86.       gui_refuse_filetransfer = 6
  87.       others                  = 7
  88.              .
  89. endform.
  90.  
  91. form download_filez.
  92.   call function 'DOWNLOAD'
  93.   exporting
  94.     filetype                      = 'ASC'
  95.   tables
  96.     data_tab                      = itab.
  97. endform.