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 = 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