Code: Alles auswählen.
*&---------------------------------------------------------------------*
*& Report ZCOPY_USER
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT zcopy_user2.
TABLES: sscrfields,usr02.
TYPE-POOLS: icon.
* Info Destinationen
DATA: des1_info TYPE rfcsi,
des2_info TYPE rfcsi.
SELECTION-SCREEN FUNCTION KEY 1.
SELECTION-SCREEN BEGIN OF BLOCK b WITH FRAME TITLE text-001.
PARAMETERS p_des1 TYPE rfcdes-rfcdest OBLIGATORY DEFAULT 'NONE'.
SELECTION-SCREEN END OF BLOCK b.
SELECTION-SCREEN BEGIN OF BLOCK a WITH FRAME TITLE text-002.
PARAMETERS p_des2 TYPE rfcdes-rfcdest OBLIGATORY DEFAULT 'NONE'.
SELECTION-SCREEN END OF BLOCK a.
SELECTION-SCREEN BEGIN OF BLOCK c WITH FRAME TITLE text-003.
PARAMETERS password TYPE bapipwd OBLIGATORY LOWER CASE DEFAULT 'Berlin4$'.
SELECT-OPTIONS bname FOR usr02-bname NO INTERVALS.
SELECTION-SCREEN END OF BLOCK c.
LOOP AT bname.
PERFORM copy_user USING bname-low.
ENDLOOP.
EXIT.
*&---------------------------------------------------------------------*
*& Form write_for_display
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM write_for_display.
DATA: t1(80),t2(80).
DATA: info LIKE rfcsi,
msg_text(80) TYPE c. "Message text
FORMAT COLOR COL_HEADING.
WRITE: / '*** STATUS RFC-Erreichbarkeit ***' , AT sy-linsz space.
ULINE.
FORMAT COLOR OFF.
CLEAR msg_text.
CALL FUNCTION 'RFC_PING'
DESTINATION p_des2
EXCEPTIONS
communication_failure = 1 MESSAGE msg_text
system_failure = 2 MESSAGE msg_text.
t1 = p_des2.
CONDENSE t1.
IF msg_text IS INITIAL.
CONCATENATE 'Destination :' t1 'erreichbar.' INTO t2 SEPARATED BY space.
FORMAT INTENSIFIED OFF.
WRITE: / icon_led_green AS ICON,
t2 COLOR COL_POSITIVE.
ELSE.
CONCATENATE 'Destination :' t1 'nicht erreichbar.' INTO t2 SEPARATED BY space.
FORMAT INTENSIFIED OFF.
WRITE: / icon_led_red AS ICON,
t2 COLOR COL_NEGATIVE.
ENDIF.
CLEAR msg_text.
CALL FUNCTION 'RFC_PING'
DESTINATION p_des1
EXCEPTIONS
communication_failure = 1 MESSAGE msg_text
system_failure = 2 MESSAGE msg_text.
t1 = p_des1.
CONDENSE t1.
IF msg_text IS INITIAL.
CONCATENATE 'Destination :' t1 'erreichbar.' INTO t2 SEPARATED BY space.
FORMAT INTENSIFIED OFF.
WRITE: / icon_led_green AS ICON,
t2 COLOR COL_POSITIVE.
ELSE.
CONCATENATE 'Destination :' t1 'nicht erreichbar.' INTO t2 SEPARATED BY space.
FORMAT INTENSIFIED OFF.
WRITE: / icon_led_red AS ICON,
t2 COLOR COL_NEGATIVE.
ENDIF.
ENDFORM. "write_for_display
INITIALIZATION.
sscrfields-functxt_01 = '@38@ Check RFC-Desitinations'.
AT SELECTION-SCREEN.
IF sy-ucomm = 'FC01'." n = 1 up to 5
* Teste Erreichbarkeit
PERFORM write_for_display.
CALL FUNCTION 'C14A_POPUP_LIST_DISPLAY'
EXPORTING
i_callback = 'WRITE_FOR_DISPLAY'
i_callback_program = sy-repid
i_title = 'RFC-Verbindungen'
i_col = 4
i_row = 4
i_width = 84
i_height = 10
* I_TEXT_WIDTH =
* I_FLG_SHOW_PRINT_BUTTON = ESP1_FALSE
EXCEPTIONS
no_callback_specified = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDIF.
*&---------------------------------------------------------------------*
*& Form copy_user
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM copy_user USING uname TYPE usr02-bname.
DATA msg_text(80) TYPE c. "Message text
DATA dummy(80) TYPE c. "Message text
* Input
DATA username TYPE bapibname-bapibname.
* Output
DATA:
logondata LIKE bapilogond,
defaults LIKE bapidefaul,
address LIKE bapiaddr3,
company LIKE bapiuscomp,
snc LIKE bapisncu,
ref_user LIKE bapirefus,
alias LIKE bapialias,
uclass TYPE bapiuclass,
lastmodified TYPE bapimoddat,
islocked TYPE bapislockd.
*Tables
DATA:
parameter TYPE TABLE OF bapiparam,
profiles TYPE TABLE OF bapiprof,
activitygroups TYPE TABLE OF bapiagr,
return TYPE TABLE OF bapiret2,
addtel TYPE TABLE OF bapiadtel,
addfax TYPE TABLE OF bapiadfax,
addttx TYPE TABLE OF bapiadttx,
addtlx TYPE TABLE OF bapiadtlx,
addsmtp TYPE TABLE OF bapiadsmtp,
addrml TYPE TABLE OF bapiadrml,
addx400 TYPE TABLE OF bapiadx400,
addrfc TYPE TABLE OF bapiadrfc,
addprt TYPE TABLE OF bapiadprt,
addssf TYPE TABLE OF bapiadssf,
adduri TYPE TABLE OF bapiaduri,
addpag TYPE TABLE OF bapiadpag,
addcomrem TYPE TABLE OF bapicomrem,
parameter1 TYPE TABLE OF bapiparam1,
groups TYPE TABLE OF bapigroups,
uclasssys TYPE TABLE OF bapiuclasssys,
extidhead TYPE TABLE OF bapiusextidhead,
extidpart TYPE TABLE OF bapiusextidpart,
systems TYPE TABLE OF bapircvsys.
* RC
DATA lret1 TYPE bapiret2.
username = uname.
CALL FUNCTION 'BAPI_USER_GET_DETAIL' DESTINATION p_des2
EXPORTING
username = username
* CACHE_RESULTS = 'X'
IMPORTING
logondata = logondata
defaults = defaults
address = address
company = company
snc = snc
ref_user = ref_user
alias = alias
uclass = uclass
lastmodified = lastmodified
islocked = islocked
TABLES
parameter = parameter
profiles = profiles
activitygroups = activitygroups
return = return
addtel = addtel
addfax = addfax
addttx = addttx
addtlx = addtlx
addsmtp = addsmtp
addrml = addrml
addx400 = addx400
addrfc = addrfc
addprt = addprt
addssf = addssf
adduri = adduri
addpag = addpag
addcomrem = addcomrem
parameter1 = parameter1
groups = groups
uclasssys = uclasssys
extidhead = extidhead
extidpart = extidpart
systems = systems
EXCEPTIONS
communication_failure = 1 MESSAGE msg_text
system_failure = 2 MESSAGE msg_text.
IF sy-subrc NE 0.
EXIT.
ENDIF.
LOOP AT return INTO lret1.
message i398(00) into dummy with lret1-MESSAGE ' ' ' ' ' ' .
ENDLOOP.
CLEAR lret1.
LOOP AT return INTO lret1 WHERE type = 'E'.
EXIT.
ENDLOOP.
CHECK lret1 IS INITIAL.
CLEAR logondata-class.
DELETE parameter WHERE parid(1) = 'Z' OR parid(1) = 'Y'.
DELETE parameter1 WHERE parid(1) = 'Z' OR parid(1) = 'Y'.
CALL FUNCTION 'BAPI_USER_CREATE1' DESTINATION p_des1
EXPORTING
username = username
* NAME_IN =
logondata = logondata
password = password
defaults = defaults
address = address
company = company
snc = snc
ref_user = ref_user
alias = alias
* EX_ADDRESS =
uclass = uclass
force_system_assignment = 'X'
* SELF_REGISTER = ' '
TABLES
parameter = parameter
return = return
addtel = addtel
addfax = addfax
addttx = addttx
addtlx = addtlx
addsmtp = addsmtp
addrml = addrml
addx400 = addx400
addrfc = addrfc
addprt = addprt
addssf = addssf
adduri = adduri
addpag = addpag
addcomrem = addcomrem
* groups = groups
parameter1 = parameter1
extidhead = extidhead
extidpart = extidpart
EXCEPTIONS
communication_failure = 1 MESSAGE msg_text
system_failure = 2 MESSAGE msg_text.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
LOOP AT return INTO lret1.
message i398(00) into dummy with lret1-MESSAGE ' ' ' ' ' ' .
ENDLOOP.
ENDFORM.