Posted: Mon Dec 24, 2007 11:53 am Post subject: Запрет на изменение части строк в table maintaince
Доброе утро!
Стоит задача, в транзакцию ведения пользовательской таблицы sm30 вставить авторизационную проверку, чтобы пользовать мог добавлять, изменять, удалять только записи, в которые он авторизован по полю Company Code. Это возможно?
Age: 46 Joined: 05 Nov 2007 Posts: 725 Location: КраснАдар
Posted: Mon Dec 24, 2007 11:59 am Post subject:
Можно все эти проверки вписать в PAI-логику сгенерированного экрана. Но нужно понимать, что в случае изменения структуры таблицы и перегенерации ракурса ведения все Ваши "добавления" исчезнут.
*"----------------------------------------------------------------------
* Event 1 handler for table ZTABLE
*"----------------------------------------------------------------------
FORM TABLE_EVENT_1.
CONSTANTS: TEXT1(12) VALUE 'Company Code'.
DATA: l_tmp(200).
DATA: BEGIN OF lt_bukrs OCCURS 0,
bukrs TYPE t001-bukrs,
END OF lt_bukrs.
TYPES: BEGIN OF tt.
INCLUDE STRUCTURE ZTABLE.
TYPES: ACTION TYPE C,
MARK TYPE C,
END OF tt.
DATA: LINE(48).
DATA: F_INDEX LIKE SY-TABIX. "Index to note the lines found
DATA: l_er TYPE C.
field-symbols: <fs> TYPE tt.
LOOP AT TOTAL INTO LINE.
ASSIGN LINE TO <fs> CASTING.
CHECK sy-subrc IS INITIAL.
CHECK NOT <fs>-ACTION IS INITIAL.
lt_bukrs-bukrs = <fs>-bukrs.
AUTHORITY-CHECK OBJECT 'Z_BUKRS'
ID 'BUKRS' FIELD lt_bukrs-bukrs
ID 'TCODE' FIELD sy-tcode.
IF NOT sy-subrc IS INITIAL.
COLLECT lt_bukrs.
l_er = 'X'.
CLEAR <fs>-ACTION.
MODIFY TOTAL FROM <fs>.
READ TABLE EXTRACT WITH KEY TOTAL.
IF SY-SUBRC EQ 0.
F_INDEX = SY-TABIX.
MODIFY EXTRACT FROM <fs> INDEX F_INDEX.
ENDIF.
ENDIF.
ENDLOOP.
IF NOT l_er IS INITIAL.
LOOP AT lt_bukrs.
CONCATENATE l_tmp lt_bukrs-bukrs INTO l_tmp SEPARATED BY SPACE.
ENDLOOP.
MESSAGE I003(zxxx) WITH TEXT1 l_tmp. "You do not have authorization to & & & &.
SY-SUBRC = 4.
ENDIF.
ENDFORM.
*"----------------------------------------------------------------------
* Event 3 handler for table ZTABLE
*"----------------------------------------------------------------------
FORM TABLE_EVENT_3.
CONSTANTS: TEXT1(12) VALUE 'Company Code'.
TYPES: BEGIN OF tt.
INCLUDE STRUCTURE ZTABLE.
TYPES: ACTION TYPE C,
MARK TYPE C,
END OF tt.
DATA: LINE(48).
field-symbols: <fs> TYPE tt.
LOOP AT TOTAL INTO LINE.
ASSIGN LINE TO <fs> CASTING.
CHECK sy-subrc IS INITIAL.
CHECK NOT <fs>-MARK IS INITIAL.
AUTHORITY-CHECK OBJECT 'Z_BUKRS'
ID 'BUKRS' FIELD <fs>-bukrs
ID 'TCODE' FIELD sy-tcode.
IF NOT sy-subrc IS INITIAL.
MESSAGE E003(zxxx) WITH TEXT1 <fs>-bukrs.
ENDIF.
ENDLOOP.
ENDFORM.
*"----------------------------------------------------------------------
* Event 5 handler for table ZTABLE
*"----------------------------------------------------------------------
FORM TABLE_EVENT_5.
CONSTANTS: TEXT1(12) VALUE 'Company code'.
field-symbols: <fs> TYPE ZTABLE.
ASSIGN <TABLE1> TO <fs>.
IF sy-subrc IS INITIAL.
IF <fs>-bukrs IS INITIAL.
SY-SUBRC = 4.
MESSAGE E043(zxxx) WITH TEXT1. "Empty & field is forbidden.
ELSE.
AUTHORITY-CHECK OBJECT 'Z_BUKRS'
ID 'BUKRS' FIELD <fs>-bukrs
ID 'TCODE' FIELD SY-TCODE.
IF NOT sy-subrc IS INITIAL.
MESSAGE E003(zxxx) WITH TEXT1 <fs>-bukrs. "You do not have authorization to & & & &.
ENDIF.
ENDIF.
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.