Posted: Sun Nov 25, 2007 12:31 pm Post subject: Central user maintenance from one SAP for a set of systems
Central user maintenance from one SAP system for a set of systems
Code:
REPORT ZRDCATF NO STANDARD PAGE HEADING.
************************************************************************
* Central user maintenance from one SAP system for a set of systems.
* (Like in UNIX: NIS, TIVOLI or OMNIGUARD)
*
* The program first calls SU01 to create, delete or modify an SAP user
* in the local system. Everything looks normal, but in the background
* it captures the entered data using RS_CATT_MAINTAIN.
* Then it converts the CATF table to a regular BDC table.
* As a third step it reads the type 3 RFC destinations from the table
* RFCDES with the format: SID_user_CLIENT (where SID and CLIENT are
* variables), and displays a selection screen (interactive list) with
* checkboxes.
* Then runs SU01 in the selected remote systems, with the captured
* parameters.
* The catf/bdf conversion is somewhat simplifyed, uses only the varf1,
* but it can do the job.
************************************************************************
TABLES: CATF, CATR, CATG, CATV, CATU, CATP, CATX, CATA.
TABLES: BDCDATA, RFCDES.
DATA: FIRST(2), SECOND(2), FNAM(30), FVAL(50).
DATA: TRNAM LIKE CATF-TCODE.
DATA: ABLNR LIKE CATF-ABLNR.
DATA: BEGIN OF BDC_TAB OCCURS 5.
INCLUDE STRUCTURE BDCDATA.
DATA: END OF BDC_TAB.
DATA: MARK, GOMB(13).
DATA: BEGIN OF MESSG.
INCLUDE STRUCTURE MESSAGEINF.
DATA: END OF MESSG.
* Call SU01 and capture the input data in the CATT tables
CALL FUNCTION 'RS_CATT_MAINTAIN'
EXPORTING
AKTION = 'GENR'
CONFIRMATION = ' '
TCODE = 'SU01'
IMPORTING
ABLNR = ABLNR.
* Create a BDC table based upon the data in catf
CLEAR BDC_TAB.
REFRESH BDC_TAB.
SELECT * FROM CATF WHERE ABLNR = ABLNR.
IF NOT CATF-TCODE IS INITIAL.
TRNAM = CATF-TCODE.
ENDIF.
BDC_TAB-PROGRAM = CATF-MPOOL.
BDC_TAB-DYNPRO = CATF-DYNNR.
BDC_TAB-DYNBEGIN = 'X'.
APPEND BDC_TAB.
CLEAR BDC_TAB.
DO.
FIRST = CATF-VARF1.
SHIFT CATF-VARF1 LEFT BY 2 PLACES.
SECOND = CATF-VARF1.
SHIFT CATF-VARF1 LEFT BY 2 PLACES.
IF FIRST IS INITIAL.EXIT. ENDIF.
FNAM = CATF-VARF1(FIRST).
SHIFT CATF-VARF1 LEFT BY FIRST PLACES.
FVAL = CATF-VARF1(SECOND).
SHIFT CATF-VARF1 LEFT BY SECOND PLACES.
BDC_TAB-FNAM = FNAM.
BDC_TAB-FVAL = FVAL.
APPEND BDC_TAB.
CLEAR BDC_TAB.
ENDDO.
ENDSELECT.
* Clean the CATT tables
DELETE FROM CATF WHERE ABLNR = ABLNR.
DELETE FROM CATR WHERE ABLNR = ABLNR.
DELETE FROM CATG WHERE ABLNR = ABLNR.
DELETE FROM CATV WHERE ABLNR = ABLNR.
DELETE FROM CATU WHERE ABLNR = ABLNR.
DELETE FROM CATP WHERE ABLNR = ABLNR.
DELETE FROM CATX WHERE ABLNR = ABLNR.
DELETE FROM CATA WHERE ABLNR = ABLNR.
COMMIT WORK.
* Display the list of systems and clients defined with SM59
WRITE: / 'SELECT ONE OR MORE SYSTEMS AND CLIENTS ' COLOR 4.
WRITE: / 'DOUBLECLICK ON PROCEED TO MIGRATE THE CHANGES ' COLOR 4.
WRITE: / 'DOUBLECLICK ON EXIT TO LEAVE WITHOUT MIGRATION' COLOR 4.
SKIP.
SELECT * FROM RFCDES WHERE RFCTYPE = '3' AND RFCDEST LIKE '%user%'.
WRITE:/1(3) RFCDES-RFCDEST, 9 RFCDES-RFCDEST+9(3), MARK AS CHECKBOX.
HIDE: RFCDES-RFCDEST, MARK.
ENDSELECT.
SKIP.
GOMB = 'PROCEED'.
WRITE: / GOMB COLOR 6. HIDE GOMB.
SKIP.
GOMB = 'EXIT'.
WRITE: / GOMB COLOR 6. HIDE GOMB.
CLEAR GOMB.
* When EXIT or PROCEED is choosed
AT LINE-SELECTION.
IF GOMB = 'EXIT'.
LEAVE PROGRAM.
ELSEIF GOMB = 'PROCEED'.
DO.
CLEAR MARK.CLEAR RFCDES-RFCDEST.
READ LINE SY-INDEX FIELD VALUE MARK.
IF SY-SUBRC NE 0. EXIT. ENDIF.
IF RFCDES-RFCDEST IS INITIAL.CONTINUE.ENDIF.
* For all the marked entries: run su01 in the remote system
IF MARK = 'X'.
CALL FUNCTION 'RFC_CALL_TRANSACTION' DESTINATION RFCDES-RFCDEST
EXPORTING
TRANCODE = TRNAM
IMPORTING
MESSG = MESSG
TABLES
BDCTABLE = BDC_TAB.
* Write the log
WRITE: / RFCDES-RFCDEST, MESSG-MSGTX.
ENDIF.
ENDDO.
ENDIF.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG. SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG. Every effort is made to ensure content integrity. Use information on this site at your own risk.