Skip to Content
Technical Articles
Author's profile photo Kallol Chakraborty

Easy way to disable creation, modification & deletion of sales order item text ids in VA02

Introduction

In certain cases, you need to disable text ids of the Sales order item in VA02 under the Texts tab to restrict the user from deleting, changing, or creating texts.

This can be complex based on your approach. So, for the easy solution, I am writing this blog post.

This solution is to convert the type( V -> A ) of the transaction in the include: MV45AF0C_CUA_SETZEN by doing an explicit enhancement.

Table T180 contains the type of transaction codes. Please check the screenshot below for reference.

T180

Solution

To solve the issue, please follow the below steps.

  1. Go to SE38 and open the include: MV45AF0C_CUA_SETZEN.
  2. Go to the enhancement point: enhancementpoint cua_setzen_10 spots es_sapmv45a & create an explicit enhancement.Enhancement%20Point Here, I am blocking 2 standard Text Ids: TX02(Sales Note for Customer) & TX05(Billing Instruction).
  3. Insert the below block of code & manipulate it based on your need.
    * Local Constants
    DATA(lc_screen_4152) = '4152'.
    DATA(lc_tcode_va02)  = 'VA02'.
    DATA(lc_v)           = 'V'.    "Edit
    
    * Checking of the TCODE
    IF sy-tcode = lc_tcode_va02.
    * Checking Screen for limiting the number of executions of the below code
      IF taxi_body_subscreen = lc_screen_4152.
    
        TYPES lty_textid_type TYPE RANGE OF char4.
        DATA : lr_textids  TYPE lty_textid_type,
               lv_temp     TYPE int8.
    
        lr_textids = VALUE lty_textid_type(
                          LET s = 'I'
                              o = 'EQ'
                          IN sign   = s
                             option = o
                             ( low = 'TX02' ) "Sales Note for Customer
                             ( low = 'TX05' ) "Billing Instruction
                            ).
    
    * Local Constants
        DATA(lc_vbbp) = 'VBBP'.     "Sales Item Texts
        DATA(lc_item) = 'ITEM'.
        DATA(lc_a) = 'A'.
        DATA(lc_0) = '0'.
        DATA(lc_1) = '1'.
        DATA(lc_pos_add) = 'POS+'.  "Sideways movement: Right
        DATA(lc_pos_sub) = 'POS-'.  "Sideways movement: Left
    
        FIELD-SYMBOLS : <lfs_tdid>      TYPE any,
                        <lfs_vbeln>     TYPE any,
                        <lfs_posnr>     TYPE any,
                        <lfs_tdlinetab> TYPE ANY TABLE,
                        <lfs_xthead>    TYPE ANY TABLE.
    
    * Fetching of the values from different places
    * Text Type ID
        ASSIGN ('(SAPLV70T)LV70T-TDID') TO <lfs_tdid>.
    * Sales and Distribution Document Number
        ASSIGN ('(SAPMV45A)XVBAP-VBELN') TO <lfs_vbeln>.
    * Item number of the SD document
        ASSIGN ('(SAPMV45A)XVBAP-POSNR') TO <lfs_posnr>.
    * TDLINE table
        ASSIGN ('(SAPLV70T)TLINETAB[]') TO <lfs_tdlinetab>.
    * XTHEAD: Contains the Text Ids
        ASSIGN ('(SAPMV45A)XTHEAD[]') TO <lfs_xthead>.
    
    * Corner Cases:
    * If the previous/next button is pressed of the last/first item
        DATA(lv_tabix) = VALUE i( ivbap[ posnr = <lfs_posnr> ]-tabix OPTIONAL ).
        IF lv_tabix IS NOT INITIAL.
          IF sy-ucomm = lc_pos_add.
            ADD 1 TO lv_tabix.
          ELSEIF sy-ucomm = lc_pos_sub.
            SUBTRACT 1 FROM lv_tabix.
          ENDIF.
        ENDIF.
    
    * For entering 2nd time the same screen(Item Detail)
        IF <lfs_tdid> IS NOT ASSIGNED OR <lfs_tdid> = space
    * For sideways movements of items
           OR ( ( sy-ucomm = lc_pos_add OR sy-ucomm = lc_pos_sub )
    * Restricting the first/last item to change its existing text id
           AND ( lv_tabix GE lc_1 AND lv_tabix LE lines( ivbap ) ) ).
    * Assigning the first text id available
          ASSIGN xthead[ 1 ]-tdid TO <lfs_tdid>.
        ENDIF.
    
    * For entering 2nd time the same screen(Item Detail)
        IF sy-ucomm = lc_item AND <lfs_tdid> IN lr_textids.
    * Assigning the first text id available
          <lfs_tdid> = VALUE char4( xthead[ 1 ]-tdid OPTIONAL ).
        ENDIF.
    
        IF <lfs_tdid> IS ASSIGNED AND <lfs_tdid> IN lr_textids.
    * Changing the screen to display mode
          t180-trtyp = lc_a.     "Display
          lv_temp = <lfs_vbeln> && <lfs_posnr>.
    * Screen Refresh: If the text id does not have text maintained
          SELECT COUNT( * )
          FROM stxh               "STXD SAPscript text file header
          INTO lv_temp
          WHERE tdobject = lc_vbbp AND
          tdname = lv_temp AND
          tdid = <lfs_tdid>.
          IF sy-subrc = 0 AND lv_temp = lc_0.
            CLEAR <lfs_tdlinetab>.
          ENDIF.
    * For not displaying in case of sideways movements
          IF sy-ucomm NE lc_pos_sub AND sy-ucomm NE lc_pos_add.
    * Message: The text id is disabled
            MESSAGE TEXT-e01 TYPE 'I' DISPLAY LIKE 'E'.
          ENDIF.
        ELSE.
    * Change mode
          t180-trtyp = lc_v. "Change
        ENDIF.
    
        CLEAR : lv_temp,
                lv_tabix,
                lr_textids.
      ELSE.
    * Change mode
        t180-trtyp = lc_v. "Change
      ENDIF.
    ENDIF.​
  4. Output

That’s it. 🙂

For populating the range tables in other ways, please check this link for further details.

Assigned Tags

      Be the first to leave a comment
      You must be Logged on to comment or reply to a post.