* Si se añade a pelo en la UST04 tambin cuela!!!
form ins_or_del_profile_in_user using user profile action ret.
data: fill type i.
*
call function 'ENQUEUE_E_USR04'
exporting
bname = user
exceptions
foreign_lock = 1
system_failure = 2.
if sy-subrc <> 0.
ret = 1.
exit.
endif.
* Benutzerstammsatz lesen und aktualisieren
perform read_usr04
using user rc fill.
if action = 'I'. "Aktion Hinzufuegen
perform add_prof_in_tabusr using profile.
elseif action1 = 'D'. "Aktion Loeschen
delete tabusr where profile = profile.
endif.
perform upd_usr04
using user.
call function 'DEQUEUE_E_USR04'
exporting
bname = user.
endform.
*---------------------------------------------------------------------*
* FORM read_usr04 *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
* --> VALUE(USER) *
* --> RC *
* --> USRFILL *
*---------------------------------------------------------------------*
form read_usr04 using value(user) rc usrfill.
clear usr04.
rc = 0.
select single * from usr04 "Einen Rec. lesen
where bname = user.
if sy-subrc = 0. "Den variablen Teil des Rec. auf-
"schluesseln u. in int. Tab.
"tabusr schreiben
perform fill_tabusr using usrfill.
loop at tabusr.
clear usr10.
select single * from usr10
where profn = tabusr-profile
and aktps = aktivated.
if usr10-typ = colectprof.
tabusr-samprof = 'X'.
elseif usr10-typ = generprof.
tabusr-samprof = 'G'.
else.
clear tabusr-samprof.
endif.
modify tabusr.
endloop.
else.
refresh tabusr.
clear tabusr.
usrfill = 0.
rc = 4.
endif.
endform.
*---------------------------------------------------------------------*
* FORM fill_tabusr *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
* --> USRFILL *
*---------------------------------------------------------------------*
form fill_tabusr using usrfill.
data: nrpro type i,
off type i.
*
refresh tabusr.
clear tabusr.
usrfill = 0.
off = 2.
nrpro = usr04-nrpro / 12. "MBK0001
if nrpro > maxusr. nrpro = 0. endif.
do nrpro times.
assign usr04-profs+off(proflng) to <text>.
write <text> to tabusr-profile.
append tabusr.
usrfill = usrfill + 1.
off = off + proflng.
enddo.
endform.
*---------------------------------------------------------------------*
* FORM add_prof_in_tabusr *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
* --> PROFILE *
*---------------------------------------------------------------------*
form add_prof_in_tabusr using profile.
read table tabusr with key profile = profile.
if sy-subrc = 0.
call function 'DEQUEUE_E_USR04'
exporting
bname = user.
raise profile_already_in_user.
endif.
tabusr-profile = profile.
append tabusr.
endform. " ADD_PROF_IN_USER
*---------------------------------------------------------------------*
* FORM upd_usr04 *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
* --> VALUE(USER) *
*---------------------------------------------------------------------*
form upd_usr04 using value(user).
data: off type i,
z type i value 0,
max type i,
longstring(3750),
longstring1(3750).
data: begin of intust04 occurs 50.
include structure ust04.
data: end of intust04.
*
select single * from usr04
where bname = user.
if sy-subrc = 0.
longstring1 = usr04-profs.
endif.
rc = sy-subrc.
move-corresponding usr04 to *usr04.
clear usr04.
clear longstring.
usr04-bname = user. "Festteil des Userrec beschreiben
off = 2.
z = 0.
max = maxrec - proflng.
sort tabusr.
loop at tabusr. "Den var. Teil beschreiben
write tabusr-profile to longstring+off(proflng).
off = off + proflng.
z = z + 1.
if off > max.
* message w263 with user.
exit.
endif.
endloop.
usr04-nrpro = off.
usr04-profs = longstring.
if rc = 0.
* Aenderungsbeleg wegschreiben
if *usr04-profs(1) <> rec_type_create and "MBK0002
*usr04-profs(1) <> rec_type_modify. "MBK0002
select * from ush04 "MBK0002
where bname = user. "MBK0002
exit. "MBK0002
endselect. "MBK0002
if sy-subrc <> 0. "MBK0002
write rec_type_create to *usr04-profs(1). "MBK0002
else. "MBK0002
move-corresponding *usr04 to ush04. "MBK0002
clear ush04-profs. "MBK0002
insert ush04. "Originaldatum wegschreiben "MBK0002
*usr04-modda = sy-datum. "MBK0002
*usr04-modti = sy-uzeit - 1. "MBK0002
*usr04-modbe = sy-uname. "MBK0002
endif. "MBK0002
endif. "MBK0002
move-corresponding *usr04 to ush04.
modify ush04. "MS160398
usr04-modbe = sy-uname. "MBK0002
usr04-modda = sy-datum. "MBK0002
usr04-modti = sy-uzeit. "MBK0002
write rec_type_modify to usr04-profs(1). "MBK0002
update usr04.
insertflag = 0.
else.
usr04-modbe = sy-uname. "MBK0002
usr04-modda = sy-datum. "MBK0002
usr04-modti = sy-uzeit. "MBK0002
write rec_type_create to usr04-profs(1). "MBK0002
insert usr04.
insertflag = 1.
endif.
select * from ust04 into intust04
where bname = user.
append intust04.
endselect.
sort intust04.
loop at intust04.
read table tabusr with key profile = intust04-profile.
if sy-subrc <> 0.
delete from ust04
where bname = intust04-bname
and profile = intust04-profile.
endif.
endloop.
ust04-bname = user.
loop at tabusr.
read table intust04 with key profile = tabusr-profile.
if sy-subrc <> 0.
ust04-profile = tabusr-profile.
insert ust04.
endif.
endloop.
call function 'SUSR_USER_BUFFER_AFTER_CHANGE'
exporting
username = user.
endform.