report programa.
define e_create_data. "Declaration of vars only 1 Call!
types: begin of e_db,
tab(30),
field(30),
value(30),
end of e_db.
data: begin of t_error occurs 0,
prg(30), "Cdigo de programa
src(30), "Rutina de error
db type e_db occurs 0,
txt(255),
end of t_error,
my_db type e_db,
_syst like syst,
_my_txt(25).
end-of-definition.
define e_adderror. "Add header of errors
t_error-Prg = &1.
t_error-src = &2.
t_error-txt = &3.
append t_error.
clear t_error.
refresh t_error-db.
end-of-definition.
define e_addfield. "Add TAB error
my_db-tab = &1.
my_db-field = &2.
my_db-value = &3.
translate my_db-tab to upper case.
translate my_db-field to upper case.
append my_db to t_error-db.
end-of-definition.
define e_addsyst. "ADD most used syst vars
_syst = syst.
e_addfield: 'SYST' 'TCODE' _syst-TCODE,
'SYST' 'cprog' _syst-cprog,
'SYST' 'REPID' _syst-REPID,
'SYST' 'XFORM' _syst-XFORM,
'SYST' 'UNAME' sy-UNAME,
'SYST' 'datum' _syst-datum,
'SYST' 'uzeit' _syst-uzeit,
'SYST' 'subrc' _syst-subrc,
'SYST' 'tabix' _syst-tabix,
'SYST' 'index' _syst-index,
'SYST' 'UCOMM' _syst-UCOMM,
'SYST' 'MSGV1' sy-MSGV1,
'SYST' 'MSGV2' sy-MSGV2,
'SYST' 'MSGV3' sy-MSGV3,
'SYST' 'MSGV4' sy-MSGV4.
end-of-definition.
define e_listdata.
loop at t_error.
at first.
write: / 'Listado de errores'.
uline /1(18).
endat.
if not t_error-prg is initial. write: / t_error-prg. endif.
if t_error-prg is initial. write: /001 ''. endif.
write: t_error-src.
loop at t_error-db into my_db.
if not my_db-tab is initial and not my_db-field is initial.
concatenate my_db-tab '-' my_db-field into _my_txt.
elseif not my_db-tab is initial.
_my_txt = my_db-tab.
elseif not my_db-field is initial.
_my_txt = my_db-field.
endif.
condense _my_txt no-gaps.
if not _my_txt is initial.
write: /010 _my_txt+0(25).
else.
write: /010 ''.
endif.
write: my_db-value.
endloop.
endloop.
end-of-definition.
* Ejemplo
end-of-selection.
e_create_data.
e_addsyst.
e_adderror '' 'end-of-selection' 'Error de sistema'.
e_listdata.