Skip to Content
avatar image
-1
Former Member

check whether the attachment exist or not when save a document

Hi,everyone,

I'm going to add an enhancement based on the Transaction ME51N/ME52N.

The needs has told it's going to check whether the attachment is exist when the save command is excute.

Can anyone help me!

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    avatar image
    Former Member
    Oct 13, 2017 at 09:06 AM
    -1

    Hi,everyone,

    I've got the answer,when i change the attachmens i'll export the information list to a memory id,during command execution i'll got the list from the memory id and check whether the data exist or not.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Oct 13, 2017 at 06:44 AM

    Hi,

    I think you can't add an attachment in ME51N for this functionality requires a reference number, in this case, a purchase requisition number, which does not exist yet.

    As for ME52N, you need to find a user-exit (that will be triggered on the save command) wherein the purchase requisition number is accessible.

    Next, inside the user-exit, select data from table SRGBTBREL with the following conditions:

    • RELTYPE = 'ATTA' (attachment)
    • INSTID_A = (purchase requisition number)
    • TYPEID_A = 'BUS2105' (purchase requisition object id)
    • CATID_A = 'BO' (instances of BOR object types)

    The code should look something like this:

    data: lt_srgbtbrel type standard table of srgbtbrel.
    
        select *
          from srgbtbrel
    into table lt_srgbtbrel
         where reltype  eq 'ATTA'
           and instid_a eq us_banfn  " (suppose that variable us_banfn holds the purchase requisition number)
           and typeid_a eq 'BUS2105'
           and catid_a eq 'BO'.
    
    if sy-subrc ne 0.
      " (means no attachment is found, display relevant error message)
    endif.
    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi,

      During command execution,the data of table SRGBTBREL is not the latest.For tha case, in the user-exit i cannot get the latest data.

      On the other hand, If the purchase requisition had attached a attachment already,now I delete it.The attachment's information still exists in table SRGBTBREL.So it won't display any error.