Giter Site home page Giter Site logo

gos_attachments's Introduction

Get all attachmetns of business objects

This example show how you can retrieve all attachments of any business object and then use CRUD.

Source code here.

How use.

  1. Run method SET_OBJECT. This method define what kind of attachmetns do you want to retrieve.
  • ATTACHMENTS - retrieve all attachmetns of BO.
  • NOTES - retrieve all notes of BO.
  • URLS - retrieve all urls of BO.

Want to get all urls of BO FMBU

  DATA: lo_attachments TYPE REF TO lcl_gos_attachments,
        ls_object      TYPE lcl_gos_attachments=>mty_s_borid,
        lt_attachmetns TYPE lcl_gos_attachments=>mty_t_borid,
        lo_witem       TYPE REF TO cl_browser_item,
	lo_msg_item    TYPE REF TO cl_msg_al_item,
	lv_typid       TYPE swo_typeid,
	lv_url         TYPE string,
	lv_docid       TYPE so_entryid,
	ls_borident    TYPE borident.
		
  CREATE OBJECT lo_attachments.	
  
  ls_object-objkey  = '0400000004'.
  ls_object-objtype = 'FMBU'.
  ls_object-urls    = 'X'.

  lo_attachments->set_object(
   EXPORTING
     is_object = ls_object
   ).   

Method SET_OBJECT allow to set list of objects, see interface of method.

  1. Run method GET_ATTACHMENTS to retrieve all uploaded data for BO for those attachments which you selected in step 1.

Get requested attachments

  lt_attachmetns = lo_attachments->get_attachments( ).

This is what method returned

alt text

Table has field with table type where store all attachments which are represented like instance of class CL_MSG_AL_ITEM.

alt text

This is how you can get attachments data

  LOOP AT lt_attachmetns ASSIGNING <ls_boitem>.
    LOOP AT <ls_boitem>-t_bitem INTO lo_witem.
      TRY.
          lo_msg_item ?= lo_witem.
        CATCH cx_sy_move_cast_error.
          CONTINUE.
      ENDTRY.

      CONCATENATE lo_msg_item->gs_folder lo_msg_item->gs_document INTO lv_docid.
      lv_url = lo_attachments->get_object_content( lv_docid ).
    ENDLOOP.
  ENDLOOP.

This is how you can display and edit attachments

  LOOP AT lt_attachmetns ASSIGNING <ls_boitem>.
    LOOP AT <ls_boitem>-t_bitem INTO lo_witem.
      TRY.
          lo_msg_item ?= lo_witem.
        CATCH cx_sy_move_cast_error.
          CONTINUE.
      ENDTRY.

      "Edit trigger commit work even if you cancel changed data
      lo_msg_item->execute( cl_gos_attachments=>gc_cmd_edit ).

      "Just display
      lo_msg_item->execute( cl_gos_attachments=>gc_cmd_display ).

    ENDLOOP.
  ENDLOOP.

Another way display, edit, create and export attachments

  MOVE-CORRESPONDING ls_object TO ls_borident.  

  "Allow to create attachemtns, note, urls. Need to use commit after creation.
  "See more variants in class CL_GOS_DOCUMENT_SERVICE
  lo_attachments->mo_services->create( EXPORTING is_object = ls_borident  ).

  LOOP AT lt_attachmetns ASSIGNING <ls_boitem>.
    LOOP AT <ls_boitem>-t_bitem INTO lo_witem.
      TRY.
          lo_msg_item ?= lo_witem.
        CATCH cx_sy_move_cast_error.
          CONTINUE.
      ENDTRY.

      "Display single row
      CONCATENATE lo_msg_item->gs_folder lo_msg_item->gs_document INTO lv_typid.
      lo_attachments->mo_services->display_attachment( EXPORTING ip_attachment = lv_typid  ).

      "Edit single row
      lo_attachments->mo_services->edit_attachment( EXPORTING ip_attachment = lv_typid  ).
      
      "Just export attachments
      lo_attachments->mo_services->export_attachment( EXPORTING ip_attachment = lv_typid ).
      
    ENDLOOP.
  ENDLOOP.
 

This is how you can display all attachments in ALV

Need to call go_attachments->display_all( '0400000004' ). in PBO Popup screen with ALV will be created

CLASS: lcl_gos_attachments DEFINITION DEFERRED.

DATA go_attachments TYPE REF TO lcl_gos_attachments.


MODULE status_0900 OUTPUT.
*  SET PF-STATUS 'xxxxxxxx'.
*  SET TITLEBAR 'xxx'.

  go_attachments->display_all( '0400000000' ).

ENDMODULE.                 " STATUS_0900  OUTPUT

gos_attachments's People

Contributors

sgudkov avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.