Skip to Content
-1
Sep 15, 2020 at 03:22 AM

How to add log to an enhancement

111 Views

I want to record log to an enhancement. So I wrote below code.

 ENHANCEMENT 1  ZBP01.    "active version
     DATA(dset) = 'ZBP01'&& sy-datum.
    IF SY-tcode = 'BP'.
    OPEN DATASET dset FOR APPENDING IN TEXT MODE ENCODING DEFAULT.
   TRANSFER 'user' to dset.
   TRANSFER sy-uname TO dset.
   SELECT COUNT(*) FROM ztuserexit WHERE id = 'ZBP01' AND zt = 'X'.
     IF sy-subrc <> 0.
    "    SELECT SINGLE NAME_ORG1 INTO @DATA(l_org1) FROM but000 where but000~partner_gui      d = @gv_partner_guid.
     SELECT SINGLE LFA1~LIFNR INTO @DATA(LV_LIFNR) FROM LFA1 JOIN but000 ON LFA1~LIFNR = but000~partner WHERE but000~partner_guid = @gv_partner_guid.

  IF SY-subrc = 0.
    TRANSFER 'query result exist' TO dset.
  ELSE.
    TRANSFER 'query result error' TO dset.
  ENDIF.
 ENDIF.
CLOSE DATASET dset.
ENDIF.
ENDENHANCEMENT.

I want to know :1. Is using OPEN DATASET the correct way to archive it? 2. It runs OK for me but when user use it, missing authorization error occurred. So how to fix it? If I add authorzation to user, is there some security issue need to concern? Thx.