Generic Object Services (GOS) Toolbar Part 5 : Get Note attachment contents

By | February 9, 2009 | Generic Object Services (GOS) | 20,392 | 12

Shows how to get the contents of the NOTE attachements

You can find all of these discussions at Tutorials > Generic Object Services (GOS).

Today, we will see how to get the contents of the NOTE attachements.

Sometimes, we need to give the options for the attachement List when we design the some application with GOS toolbar. We will use the static method READ_LINKS from the class CL_BINARY_RELATION.

Code Snippet to Read the GOS attachments content

*&---------------------------------------------------------------------*
*& Report  ZTEST_NP_GOS_ATT
*&
*&---------------------------------------------------------------------*
*& Read the GOS attachments
*&
*&---------------------------------------------------------------------*
*
REPORT  ztest_np_gos_note.
*
* Selection Screen
PARAMETERSp_matnr TYPE mara-matnr.
*
*
START-OF-SELECTION.
*
*---------
* Get all the NOTE attached to Business object
*---------
*
* buseinss object key
  DATAgs_lpor TYPE sibflporb.
*
  gs_lpor-instid p_matnr.
  gs_lpor-typeid 'BUS1001006'.
  gs_lpor-catid  'BO'.
*
* attachment type selection
  DATAlt_relat TYPE obl_t_relt,
        la_relat LIKE LINE OF lt_relat.
*
  la_relat-sign 'I'.
  la_relat-option 'EQ'.
  la_relat-low 'NOTE'.
  APPEND la_relat TO lt_relat.
*
* Read the links
  DATAt_links TYPE obl_t_link,
        la_links LIKE LINE OF t_links.
*
  DATAlo_root TYPE REF TO cx_root.
*
  TRY.
      CALL METHOD cl_binary_relation=>read_links
        EXPORTING
          is_object           gs_lpor
          it_relation_options lt_relat
        IMPORTING
          et_links            t_links.
    CATCH cx_root INTO lo_root.
  ENDTRY.
*
*---------
* Read NOTE contents
*---------
  DATA l_folder_id TYPE soodk.
  DATA l_object_id TYPE soodk.
  DATA document_id       TYPE sofmk.
*
* Get document id
  READ TABLE t_links INTO la_links INDEX 1.
*
  document_id la_links-instid_b.
*
* Set folder
  l_folder_id-objtp document_id-foltp.
  l_folder_id-objyr document_id-folyr.
  l_folder_id-objno document_id-folno.
*
* Set Object
  l_object_id-objtp document_id-doctp.
  l_object_id-objyr document_id-docyr.
  l_object_id-objno document_id-docno.
*
* Read the document content
  DATA document_content  TYPE STANDARD TABLE OF soli.
*
  CALL FUNCTION 'SO_OBJECT_READ'
    EXPORTING
      folder_id                  l_folder_id
      object_id                  l_object_id
    TABLES
      objcont                    document_content
    EXCEPTIONS
      active_user_not_exist      1
      communication_failure      2
      component_not_available    3
      folder_not_exist           4
      folder_no_authorization    5
      object_not_exist           6
      object_no_authorization    7
      operation_no_authorization 8
      owner_not_exist            9
      parameter_error            10
      substitute_not_active      11
      substitute_not_defined     12
      system_failure             13
      x_error                    14
      OTHERS                     15.
  IF sy-subrc NE 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.

To test this program:
Go to MM02
Enter Material and go to Basic data view 1
In GOS toolbar, Create > Note

Now, run the above program to get the attached NOTE contents.

Like It? Share!!

Don't miss an Update

Get notified of the new post, right into your inbox

Naimesh Patel{274 articles}

I'm SAP ABAP Consultant for more than a decade. I like to experiment with ABAP especially OO. I have been SDN Top Contributor.
Follow :

Explore all of his 274 articles.

Load comments

12 Comments

  • Anonymous

    hi namesh..hats off to you man.you did a really wonderful job.Could you please post some programs related to events in inheritence and with in a class.

  • Anonymous

    Hi namesh,
    Thanks for ur wonderful blog.
    I have a requirement to retrieve excel file records from GOS,for this i am using CL_BINARY_RELATION=>READ_LINKS AND FM'SO_DOCUMENT_READ_API1', but it is working fine to retrieve for .ext,note.when i am attaching excel or pdf into the attachment , it is not able to retrieve the attached records .
    Please help me .
    Thanks ,
    Ajit

  • Anonymous

    Hi Namesh,

    Wonderfull Blog .

    Question : Can we save GOS in a purchase requisition at the line item level?

    Thanks,
    Jaya

  • Anonymous

    how will i make the attachment uneditable/delete/not create new ..if pr is released i.e. banpr is 05

  • Anonymous

    Hi Naimesh,

    The above code helped me a lot. Now I am able to display all the notes in a customer as report output. But I have to display the NOTE TITLE, CREATOR NAME & CREATED ON.

    Could you please where to look for this information.

    Thakns
    Abhii

  • Anonymous

    Hy all,
    I tried this example but it does not work. The linktable is always empty and I get an internal error, something like: No Interface for Assignment Please, can someone help me?

  • Sam

    Hi Namesh,

    i read your blog and it’s very interesseting.
    I try to get the Attachmentlist like in Equipment-View of MM.

    Now i have the Information of the Attachments in the Programm but how con i bring it to the user.

    Greatings Sam.

  • Anonymous

    Hi!
    I tried this example but it does not work.I keep getting this error “Object ZPROG of class RE and language EN does not exist” when I run my program.

    Thanks.

  • Naimesh Patel

    Can you please post your code?

    Regards,
    Naimesh Patel

  • Sam

    Hi,

    do you made these steps?

    ” To test this program:
    Go to MM02
    Enter Material and go to Basic data view 1
    In GOS toolbar, Create > Note

    Now, run the above program to get the attached NOTE contents.”

  • Naimesh Patel

    Sam,

    You asked:
    > do you made these steps?
    I Didn’t get your question.

    Regards,
    Naimesh Patel

  • Hervé

    Hi,
    Thank you for your code.
    It works great with my notes on MM02. So I’ve tried to get a note on a piece displayed from FBL5N.
    The link is stored in table SRGBTBREL (as for MM02 notes) :
    CATID_A = BO
    TYPEID_A = BSEG
    INSTID_A = 003300900005582011001
    RELTYPE = NOTE

    I made the change in your code above, but can’t manage to retrieve the note.

    What’s wrong ? Notes linked to BSEG can’t be retrieved this way ? How to get them ?

    Thanks

    Hervé

Comments on this Post are now closed. If you have something important to share, you can always contact me.

You seem to be new here. Subscribe to stay connected.