Welcome, you seems to be new here. Get Connected: Become a Fan on Facebook Join ABAP Help on Google+ Subscribe to email X

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

By | February 9, 2009 | Generic Object Services (GOS) | 4,783 views
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.

Advertisement

Get your Social On!

Stay Tuned with ABAP Help

11 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.

    Reply

  • 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

    Reply

  • Anonymous |

    Hi Namesh,

    Wonderfull Blog .

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

    Thanks,
    Jaya

    Reply

  • Anonymous |

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

    Reply

  • 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

    Reply

  • 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?

    Reply

  • 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.

    Reply

  • 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.

    Reply

    Naimesh Patel |

    Can you please post your code?

    Regards,
    Naimesh Patel

    Reply

    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.”

    Reply

    Naimesh Patel |

    Sam,

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

    Regards,
    Naimesh Patel

    Reply

Wanna say something?





=

To post ABAP code use shortcode [abap_code slider="X" title=""][/abap_code]