Replace use of USR03 table
SELECT * FROM usr03.
CLEAR w_usr03.
MOVE-CORRESPONDING usr03 TO w_usr03.
I start with that, and then I have the this requirement
"Due usr03 table is considered obsolete, but we can use it already, we have to change this select sentence and replace it for a non-obsolete table, I dont want none reference to usr03."
what do I do if the 28 fields of usr03 table are used in a specific task?
where do I find that 28 fields now?
How do I prepare the information to use it in the new specification?
So I start to investigate and I only find some references but the information was dispersed, with the suggestion for using ADRC, ADCP, ADCR , USR02, and so on of options, after several discussions I could try this:
I learned I could use the CALL FUNCTION 'BAPI_USER_GET_DETAIL' and using returned tables with that Call function, I could specify fields that I need to my processes.
the substitution was this way:
this is the CALL FUNCTION 'BAPI_USER_GET_DETAIL' definition
CALL FUNCTION 'BAPI_USER_GET_DETAIL'
EXPORTING
USERNAME =
* CACHE_RESULTS = 'X'
* IMPORTING
* LOGONDATA =
* DEFAULTS =
* ADDRESS =
* COMPANY =
* SNC =
* REF_USER =
* ALIAS =
* UCLASS =
* LASTMODIFIED =
* ISLOCKED =
* IDENTITY =
* ADMINDATA =
TABLES
* PARAMETER =
* PROFILES =
* ACTIVITYGROUPS =
RETURN =
* ADDTEL =
* ADDFAX =
* ADDTTX =
* ADDTLX =
* ADDSMTP =
* ADDRML =
* ADDX400 =
* ADDRFC =
* ADDPRT =
* ADDSSF =
* ADDURI =
* ADDPAG =
* ADDCOMREM =
* PARAMETER1 =
* GROUPS =
* UCLASSSYS =
* EXTIDHEAD =
* EXTIDPART =
* SYSTEMS =
.
So I need an username value, I going to use selveral of the return tables listed above
First I did the next declarations:
DATA: F_USERNAME TYPE BAPIBNAME-BAPIBNAME, " this value will be used as call function parameter
USRMANDT TYPE USR21-MANDT, " usr03 used mandt as a field
USRBNAME TYPE USR21-BNAME, " we need this field as part of 28 fields of usr03
USRKOSTL TYPE USR21-KOSTL, " we need this field as part of 28 fields of usr03
S_ADDRESS TYPE BAPIADDR3, " we need this type of structure to retain importing address values
S_LOGON TYPE BAPILOGOND, " we need this type of structure to retain importing logon values
S_DEFFAULT TYPE BAPIDEFAUL, " we need this type of structure to retain importing deffault values
TAB_RETURN TYPE BAPIRET2 OCCURS 1. " we need this type of structure to retain table return values
DATA: BEGIN OF WT_BNAME, " to manipulate into a usr21 table loop
F_BNAME TYPE USR21-BNAME,
END OF WT_BNAME.
DATA: BEGIN OF TAB_TELEFS OCCURS 0. " to use several values for this bapiadtel structure
INCLUDE STRUCTURE bapiadtel.
DATA: END OF TAB_TELEFS.
DATA: BEGIN OF TAB_TELTEX OCCURS 0. " to use several values for this bapiadttx structure
INCLUDE STRUCTURE bapiadttx.
DATA: END OF TAB_TELTEX.
DATA: BEGIN OF TAB_TELEX OCCURS 0. " to use several values for this bapiadtlx structure
INCLUDE STRUCTURE bapiadtlx.
DATA: END OF TAB_TELEX.
SELECT * FROM usr21. " we do the select into usr21
MOVE-CORRESPONDING USR21 TO WT_BNAME.
F_USERNAME = USR21-BNAME. " we assign bname to be used into call function 'BAPI_USER_GET_DETAIL'
CALL FUNCTION 'BAPI_USER_GET_DETAIL'
EXPORTING
USERNAME = F_USERNAME
IMPORTING
DEFAULTS = S_DEFFAULT " We assign this "work structure" for the imported tables
ADDRESS = S_ADDRESS " We assign this "work structure" for the imported tables
LOGONDATA = S_LOGON " We assign this "work structure" for the imported tables
TABLES
RETURN = TAB_RETURN " We assign this "work structure" for the imported tables
ADDTEL = TAB_TELEFS " We assign this "work structure" for the imported tables
ADDTTX = TAB_TELTEX " We assign this "work structure" for the imported tables
ADDTLX = TAB_TELEX. " We assign this "work structure" for the imported tables
*------------------------- we need declare fields for the values with the data type specific we want to use.
data: begin of w_usr21,
USRMANDT TYPE usr21-mandt,
*...,
*...,
*... and so on,
HUSHOR TYPE BAPIADDR3-TIME_ZONE,
end of w_usr21.
* total: 28 field declarations
*-------------------------after that we asigned the next values located inside structures declared above. ( any name can be declared)
W_USR21-USRMANDT = USR21-MANDT.
W_USR21-USRBNAME = USR21-BNAME.
W_USR21-FIRSTNAME = S_ADDRESS-FIRSTNAME.
W_USR21-LASTNAME = S_ADDRESS-LASTNAME.
W_USR21-MIDDLENAME = S_ADDRESS-MIDDLENAME.
W_USR21-SECONDNAME = S_ADDRESS-SECONDNAME.
W_USR21-TITLEP = S_ADDRESS-TITLE_P.
W_USR21-DEPARTMT = S_ADDRESS-DEPARTMENT.
W_USR21-USRKOSTL = USR21-KOSTL.
W_USR21-BUILDING = S_ADDRESS-BUILDING_P.
W_USR21-FLOOR = S_ADDRESS-FLOOR_P.
CONCATENATE S_ADDRESS-STREET S_ADDRESS-ROOM_NO_P INTO W_USR21-S_STRNUM SEPARATED BY SPACE.
W_USR21-APPOSTAL = S_ADDRESS-POSTL_COD2.
W_USR21-CODPOSTAL = S_ADDRESS-POSTL_COD1.
W_USR21-CITY = S_ADDRESS-CITY.
W_USR21-REGION = S_ADDRESS-REGION.
W_USR21-COUNTRY = S_ADDRESS-COUNTRY.
W_USR21-LANG = S_ADDRESS-LANGU.
W_USR21-NTELEF = S_ADDRESS-TEL1_NUMBR.
W_USR21-TELNR = '--'. " there is no value for that field
W_USR21-TEL01 = '--'. " there is no value for that field
W_USR21-TEL02 = '--'. " there is no value for that field
W_USR21-NTELEX = TAB_TELEX-TELEX_NO.
W_USR21-NFAX = S_ADDRESS-FAX_NUMBER.
W_USR21-NTELTEX = TAB_TELTEX-TELETEX.
W_USR21-POBOXCIT = S_ADDRESS-PO_BOX_CIT.
W_USR21-POBOXBARR = S_ADDRESS-PBOXCIT_NO.
W_USR21-HUSHOR = S_ADDRESS-TIME_ZONE.
*- so we have 28 assigned values.
*-------------------------then we do several operations with the fields
do.
*---
*----
*---
*---
*------------------------- and finally.
ENDSELECT.
*------------
*- Then we can migrate or forget of the use of usr03.
*- I´am working to find out and solve the 3 fields phone problem, because I did'nt find this fields,but this code help me with the problem.