Assigning Tcodes to new roles from a text file

Assigning Tcodes to new roles from a text file

Creating a new role from scratch can be tedious and SAP hasn't provided a user friendly way of assigning a large number of Tcodes to a new role. This program allows you to take a text file (converted from Excel) and insert the Tcodes directly into the role menu. It is then a simple matter of creating the authorization profile from the new Tcodes.
The code was written in R/3 4.6C.
REPORT z_role_tcode_addition .
************************************************************************
* Program to write tcodes from text file to a Role
*
************************************************************************
* 10.07.03 CWC Created
************************************************************************
TABLES: cus_actobj, agr_tcodes.

DATA: iagrtc LIKE agr_tcodes OCCURS 1000 WITH HEADER LINE.


* Table to store the uploaded file.
DATA : BEGIN OF itab OCCURS 0,
         tcode LIKE agr_tcodes-tcode,
       END OF itab.


*  Input file parameter.
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME.
PARAMETERS: role LIKE agr_tcodes-agr_name OBLIGATORY.
PARAMETERS: ifile LIKE rlgrap-filename OBLIGATORY .
SELECTION-SCREEN END OF BLOCK b1.


**** Drop down for the file search
AT SELECTION-SCREEN ON VALUE-REQUEST FOR ifile.
  CALL FUNCTION 'WS_FILENAME_GET'
       EXPORTING
            def_path         = '*.txt'  " ifile
            mask             = ',*.*,*.*.'
            mode             = '0'
            title            = 'Select The Input File'
       IMPORTING
            filename

    Requires Free Membership to View

    When you register, you will start receiving targeted emails from my award-winning team of editorial writers. Our goal is to keep you informed on the hottest topics and biggest challenges faced by SAP professionals today.

    Hannah Smalltree, Editorial Director

    By submitting your registration information to SearchSAP.com you agree to receive email communications from TechTarget and TechTarget partners. We encourage you to read our Privacy Policy which contains important disclosures about how we collect and use your registration and other information. If you reside outside of the United States, by submitting this registration information you consent to having your personal data transferred to and processed in the United States. Your use of SearchSAP.com is governed by our Terms of Use. You may contact us at webmaster@TechTarget.com.

= ifile EXCEPTIONS inv_winsys = 1 no_batch = 2 selection_cancel = 3 selection_error = 4 OTHERS = 5. IF sy-subrc <:> 0. STOP. ENDIF. START-OF-SELECTION. PERFORM up_load. PERFORM process_itab. *&---------------------------------------------------------------------* *& Form up_load *&---------------------------------------------------------------------* FORM up_load. CALL FUNCTION 'WS_UPLOAD' EXPORTING filename = ifile filetype = 'DAT' TABLES data_tab = itab. IF sy-subrc NE 0. MESSAGE e368(00) WITH 'Error in uploading the file ' . ENDIF. ENDFORM. " up_load *&---------------------------------------------------------------------* *& Form process_itab *&---------------------------------------------------------------------* FORM process_itab. iagrtc-agr_name = role. iagrtc-type = 'TR'. iagrtc-direct = 'X'. LOOP AT itab. iagrtc-tcode = itab-tcode. APPEND iagrtc. write: / iagrtc-agr_name, iagrtc-tcode. ENDLOOP. MODIFY agr_tcodes FROM TABLE iagrtc. ENDFORM. " process_itab

This was first published in October 2003

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.