Skip to Content

Let’s imagine this simple scenario…

   body

   #login

 

   body

   #login

 

FUNCTION ZRPY_TRANSACTION_DELETE.

*”—-


“Local interface:

*”  IMPORTING

*”     VALUE(TRANSACTION) LIKE  TSTC-TCODE

*”     VALUE(TRANSPORT_NUMBER) LIKE  RGLIF-TRKORR

*”  EXCEPTIONS

*”      NOT_EXCECUTED

*”      OBJECT_NOT_FOUND

*”—-


  TABLES: TSTC,RSSTCD.

  DATA: RCODE(5),

        CLASS(4),

        ACTION LIKE RSTC_NAVI-MODE,

        HEX_MEN TYPE X VALUE ’01’,

        O_LANGU LIKE SY-LANGU,

        M_LANGU LIKE SY-LANGU,

        TRANSPKEY LIKE TRKEY,

        L_OBJ_KEY TYPE SEU_OBJKEY,

        L_BADI_CHECK TYPE REF TO IF_EX_S_TOOL_ACCESS.

  CONSTANTS: C_FALSE VALUE SPACE.

  SELECT SINGLE * FROM TSTC WHERE TCODE = TRANSACTION.

  IF SY-SUBRC NE 0.

    MESSAGE E074 WITH TRANSACTION RAISING OBJECT_NOT_FOUND.

    EXIT.

  ENDIF.

  ACTION = ‘EDIT’.

  IF TSTC-CINFO O HEX_MEN.

    MESSAGE E297 WITH TSTC-TCODE RAISING NOT_EXCECUTED.

  ELSE.

    CLASS = ‘TRAN’.

  ENDIF.

  PERFORM CHECK_PERMISSION USING TSTC-TCODE CLASS C_FALSE

                           CHANGING O_LANGU M_LANGU RCODE.

  IF RCODE = ‘EXIT’. EXIT. ENDIF.

  • BAdI

  L_OBJ_KEY = TRANSACTION.

  CALL METHOD CL_EXITHANDLER=>GET_INSTANCE

              CHANGING INSTANCE = L_BADI_CHECK.

  CALL METHOD L_BADI_CHECK->CHECK_ACCESS_PERMISSION

              EXPORTING FLT_VAL = SWBM_C_TYPE_TRANSACTION

                        P_OBJECT_NAME = L_OBJ_KEY

                        P_OPERATION   = SWBM_C_OP_DELETE

              EXCEPTIONS PERMISSION_FAILURE = 4.

  IF SY-SUBRC NE 0.

    PERFORM FREE USING TRANSACTION ‘TRAN’.

    MESSAGE ID     SY-MSGID

            TYPE   ‘E’

            NUMBER SY-MSGNO

            WITH   SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4

    RAISING NOT_EXCECUTED.

  ENDIF.

  IF ACTION = ‘EDIT’.

  •    Korrektureintrag

    CALL FUNCTION ‘RS_CORR_INSERT’

         EXPORTING

              GLOBAL_LOCK         = ‘X’

              OBJECT              = TSTC-TCODE

              OBJECT_CLASS        = ‘TRAN’

              KORRNUM             = TRANSPORT_NUMBER

         IMPORTING

              TRANSPORT_KEY       = TRANSPKEY

         EXCEPTIONS

              CANCELLED           = 01

              PERMISSION_FAILURE  = 02

              UNKNOWN_OBJECTCLASS = 03.

    IF SY-SUBRC NE 0.

  •              Entsperren und Abbruch der Aktion

      PERFORM FREE USING TSTC-TCODE ‘TRAN’.

      MESSAGE ID     SY-MSGID

              TYPE   ‘E’

              NUMBER SY-MSGNO

              WITH   SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4

      RAISING NOT_EXCECUTED.

      EXIT.

    ENDIF.

  •           Löschen

    DELETE FROM TSTCT WHERE TCODE = TRANSACTION.

    DELETE FROM TSTCP WHERE TCODE = TRANSACTION.

    DELETE FROM TSTCA WHERE TCODE = TRANSACTION.

    DELETE FROM TSTC  WHERE TCODE = TRANSACTION.

    DELETE FROM TSTCC WHERE TCODE = RSSTCD-S_TCODE.

    PERFORM MODIFY_TEXTLOG USING ‘DELETE’.

*

    CALL FUNCTION ‘RS_TREE_OBJECT_PLACEMENT’

         EXPORTING

              OBJECT    = TRANSACTION

              OPERATION = ‘DELETE’

              TYPE      = ‘OT’

              PROGRAM   = TSTC-PGMNA.

    MESSAGE S075 WITH TRANSACTION.

    PERFORM TRANSACTION_AUTHORITIES_DELETE USING TRANSACTION.

  ENDIF.

  • Entsperren

  PERFORM FREE USING TSTC-TCODE CLASS.

ENDFUNCTION.

—-


  •       FORM check_permission                                         *

—-

FORM CHECK_PERMISSION USING OBJECT CLASS NO_ERROR_MESS

                      CHANGING O_LANGU M_LANGU RCODE.

  DATA: MODE(6),

        EXIT_FUNCTION(30),

        MESS_TYPE LIKE SY-MSGTY,

        ACTION LIKE RSTC_NAVI-MODE,

        TRANSPKEY LIKE TRKEY.

  CONSTANTS: C_TRUE VALUE ‘X’.

  CLEAR RCODE.

  IF ACTION = ‘ADD’.

    MODE = ‘INSERT’.

  ELSEIF ACTION = ‘SHOW’ OR ACTION = ‘CHECK’.

    MODE = ‘SHOW’.

  ELSE.

    MODE = ‘MODIFY’.

  ENDIF.

  IF CLASS     = ‘PARA’.

    EXIT_FUNCTION = ‘RS_PARAMETER_LANGUAGE_EXIT’.

  ELSEIF CLASS = ‘TRAN’.

    EXIT_FUNCTION = ‘RS_TRANSACTION_LANGUAGE_EXIT’.

  ELSEIF CLASS = ‘MENU’.

    EXIT_FUNCTION = ‘RS_PROG_CHANGE_LANGUAGE_UPD’.

  ENDIF.

  CALL FUNCTION ‘RS_ACCESS_PERMISSION’

       EXPORTING

            GLOBAL_LOCK             = ‘X’

            OBJECT                  = OBJECT

            OBJECT_CLASS            = CLASS

            MODE                    = MODE

            MASTER_LANGUAGE         = ‘D’

            LANGUAGE_UPD_EXIT       = EXIT_FUNCTION

            SUPPRESS_LANGUAGE_CHECK = SPACE

       IMPORTING

            NEW_MASTER_LANGUAGE     = O_LANGU

            MODIFICATION_LANGUAGE   = M_LANGU

            TRANSPORT_KEY           = TRANSPKEY

            DEVCLASS                = RSSTCD-DEVCLASS

       EXCEPTIONS

            CANCELED_IN_CORR        = 1

            OTHERS                  = 2.

  IF SY-SUBRC NE 0 AND ACTION = ‘DELE’.

    RCODE = ‘EXIT’.

    MESSAGE ID     SY-MSGID

                 TYPE   ‘I’

                 NUMBER SY-MSGNO

                 WITH   SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

    RCODE = ‘EXIT’.

  ELSEIF SY-SUBRC = 1.

    RCODE = ‘EXIT’.

  ELSEIF SY-SUBRC NE 0 AND ACTION = ‘ADD’.

    MESSAGE ID     SY-MSGID

             TYPE   ‘I’

             NUMBER SY-MSGNO

             WITH   SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

    RCODE = ‘EXIT’.

  ELSEIF SY-SUBRC NE 0.

    PERFORM FREE USING OBJECT CLASS.

    ACTION = ‘SHOW’.

    IF NO_ERROR_MESS = C_TRUE.

      MESS_TYPE = ‘S’.

    ELSE.

      MESS_TYPE = ‘E’.

    ENDIF.

    MESSAGE ID     SY-MSGID

            TYPE   MESS_TYPE

            NUMBER SY-MSGNO

            WITH   SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

  ENDIF.

ENDFORM.

—-


  •       FORM free                                                     *

—-


FORM FREE USING OBJECT CLASS.

  CALL FUNCTION ‘RS_ACCESS_PERMISSION’

       EXPORTING

            MODE         = ‘FREE’

            OBJECT       = OBJECT

            OBJECT_CLASS = CLASS.

ENDFORM.

—-


  •       FORM MODIFY_TEXTLOG                                           *

—-


FORM MODIFY_TEXTLOG USING TACTION.

  DATA: BEGIN OF TEXTLOG_TEXT OCCURS 20.

          INCLUDE STRUCTURE TEXTSTRU.

  DATA: END OF TEXTLOG_TEXT.

  DATA: TRANSPKEY LIKE TRKEY.

  CLEAR TEXTLOG_TEXT.

  TEXTLOG_TEXT-PRIORITY = ‘2’.

  CASE TACTION.

    WHEN ‘DELETE’. TEXTLOG_TEXT-OPERATION = ‘D’.

    WHEN ‘INSERT’. TEXTLOG_TEXT-OPERATION = ‘I’.

    WHEN ‘MODIFY’. TEXTLOG_TEXT-OPERATION = ‘M’.

  ENDCASE.

  APPEND TEXTLOG_TEXT.

  CALL FUNCTION ‘RS_TEXTLOG_CHANGE’

       EXPORTING

            LANGUAGE      = SY-LANGU

            TRANSPORT_KEY = TRANSPKEY

       TABLES

            TEXT          = TEXTLOG_TEXT.

  REFRESH TEXTLOG_TEXT.

ENDFORM.                    ” MODIFY_TEXTLOG

—-


  •       FORM transaction_authorities_delete                           *

—-


FORM TRANSACTION_AUTHORITIES_DELETE USING TCODE.

  DATA: NAME LIKE USOBT-NAME.

  NAME = TCODE.

  CALL FUNCTION ‘SUSP_DELETE_USOBX_AND_USOBT’

       EXPORTING

            NAME                     = NAME

            EU_TYPE                  = ‘TR’

       EXCEPTIONS

            NOT_AUTHORIZED           = 1

            LOCKED_ENTRY             = 2

            ERROR_IN_LOCK_MANAGEMENT = 3

            OTHERS                   = 4.

ENDFORM.

ZTRANSACTION_SHOW

This function is used to read transaction info.

FUNCTION ZTRANSACTION_SHOW.

*”—-


“Local interface:

*”  IMPORTING

*”     VALUE(TRANSACTION) LIKE  TSTC-TCODE

*”  EXPORTING

*”     VALUE(PROGRAM) LIKE  TRDIR-NAME

*”     VALUE(DYNPRO) LIKE  D020S-DNUM

*”     VALUE(DEVELOPMENT_CLASS) LIKE  RGLIF-DEVCLASS

*”     VALUE(TRANSPORT_NUMBER) LIKE  RGLIF-TRKORR

*”     VALUE(SHORTTEXT) LIKE  TSTCT-TTEXT

*”—-


  SELECT SINGLE PGMNA DYPNO TTEXT

  INTO (PROGRAM,DYNPRO,SHORTTEXT)

  FROM ( TSTC INNER JOIN TSTCT

        ON TSTCTCODE EQ TSTCTTCODE )

  WHERE TSTC~TCODE EQ TRANSACTION.

  IF SY-SUBRC EQ 0.

    SELECT SINGLE KORRNUM DEVCLASS

    INTO (TRANSPORT_NUMBER,DEVELOPMENT_CLASS)

    FROM TADIR

    WHERE OBJ_NAME EQ TRANSACTION.

  ENDIF.

ENDFUNCTION.

Now…We’re ready for some pictures…

Login Page.

!https://weblogs.sdn.sap.com/weblogs/images/48024/SE93_Login.png|height=234|alt=image|width=375|src=https://weblogs.sdn.sap.com/weblogs/images/48024/SE93_Login.png|border=0!

Main page to decide actions to perform.

image

Create a new transaction.

image

Display a transaction.

image

Delete a transaction.

image

Before you ask me this -:) I didn’t include a “Change” picture…Because “Change” works by deleting and creating the Transaction again…

To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply