Skip to Content
Author's profile photo HIMANSHU GUPTA

FILES AND NOTE ATTACHMENTS CREATION, DISPLAY AND DELETION USING GOS SERVICES

STEP 1:- Use transaction SWO1 to create an generic object services.

STEP 2:- A popup appears. Fill fields Object type, Object name, Name, Description and Program. Choose Application = ‘*’. Leave Supertype blank.

STEP 3:- In the main page position the mouse pointer on “Interfaces” and press F5 (add object). In the popup choose interface IFGOSASERV for SAP ECC 4.7 and IFGOSXSERV for SAP ECC 6.0.

STEP 4:- Add key fields by position on “Key Fields” and press F5. Give table name TRDIR and press ok.

STEP 6:- Position on method GOSAddObjects under methods tab and press F6 (Redefine). Insert the following code:

DATA:

SERVICE(255),

BUSIDENTIFS LIKE BORIDENT OCCURS 0,

LS_BORIDENT type BORIDENT.

CLEAR LS_BORIDENT.

LS_BORIDENT-LOGSYS = SPACE.

LS_BORIDENT-OBJTYPE = ‘ZGOS’.

LS_BORIDENT-OBJKEY = OBJECT-KEY.

APPEND LS_BORIDENT to BUSIDENTIFS.

SWC_GET_ELEMENT CONTAINER ‘Service’ SERVICE.

SWC_SET_TABLE CONTAINER ‘BusIdentifs’ BUSIDENTIFS.

Add highlighted code here

STEP 7:- Save and generate Business Object. Set release status to “released”

If it is causing problem then put cursor on business object then follow the path EDIT->CHANGE RELEASE STATUS->OBJECT TYPE COMPONENET->TO IMPLEMENTED.

Then save and again generate then release.

STEP 8:- In data decleration put the code below:

CONSTANTS : objtype TYPE borident-objtype VALUE ‘ZGOS’.

DATA: manager TYPE REF TO cl_gos_manager,
obj
TYPE borident.

Now in program add the below code in PBO where you want to use it.

  1. Examples.

IF manager IS INITIAL.
obj-objtype = objtype.
DATA : goskey(70) TYPE c.

IF zcapex-capex_no IS NOT INITIAL.

“key creation according to your requirement
CONCATENATE sy-repid ‘/’ zcapex-capex_no INTO goskey.

      obj-objkey = goskey.

ENDIF.

IF zcapex-capex_no IS NOT INITIAL.
CREATE OBJECT manager
EXPORTING
is_object    = obj
ip_no_commit =
‘R’
EXCEPTIONS
OTHERS       = 1.
ENDIF.

Here, goskey is the key to find the document in corresponding of particular number.

Many Thanks / Himanshu Gupta

Assigned Tags

      9 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo HIMANSHU GUPTA
      HIMANSHU GUPTA
      Blog Post Author

      Dear KS,

      As per your mail that I got, you made the object in local element package, that's why it is showing an error while creating. Must assign a package to make this GOS object.

      Many Thanks / Himanshu Gupta

      Author's profile photo Former Member
      Former Member

      Hi Himanshu!

      Sorry for deleting my previous comment.

      Yes i followed your blog along with some other blogs to create ZGOS. But im not able to efficiently implement it for file attachment in custom screen (via module pool).

      In addition to your blog, i followed http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/0e6b0d95-0a01-0010-4696-ca0a48de5fb3?overridelayout=true

      My doubt is:

      -> I have some other field in this custom transactions as well, i need this attachment  feature in addition to it.

      -> On SAVE, along with the inputs given by user, this file should also get saved - and this attachment should correspond to this record.

      -> And additionally - if possible - i need multiple attachments.

      (and yes - ive saved all in same package)

      Thanks a ton,

      KS

      Author's profile photo HIMANSHU GUPTA
      HIMANSHU GUPTA
      Blog Post Author

      Dear K S,

      Define the objects in top of module which are defined below:

      CONSTANTS : objtype TYPE borident-objtype VALUE 'ZGOS'.

      DATA: manager TYPE REF TO cl_gos_manager,

            obj TYPE borident.

      Then, add the following code in PBO of the module pool dynpro on which you want to add this feature:

      IF manager IS INITIAL.
      obj-objtype = objtype.
      DATA : goskey(70) TYPE c.

      IF <key> IS NOT INITIAL.

      “key creation according to your requirement

      goskey = <key>

      obj-objkey = goskey.

      ENDIF.

      IF <key> IS NOT INITIAL.
      CREATE    OBJECT manager
      EXPORTING
      is_object    = obj
      ip_no_commit =
      'R'
      EXCEPTIONS
      OTHERS       = 1.
      ENDIF.

      here <key> is use to uniquely define the attachments for particular document.

      Note: when the manager object initiates it automatically saves the attached document in correspond to the <key> which uniquely define the attachments in correspond to particular document no.

      On save at last use this method below:

      CLEAR obj.

        CALL METHOD manager->unpublish

          .

        FREE manager.

      This clears the gos object and gos manager. So, the tool is ready to make attachments for new generation of key.

      Yes, with the help of this object you can made multiple attachments.

      Many Thanks / Himanshu Gupta

      Author's profile photo Former Member
      Former Member

      Hi Himanshu,

      I tried everything you said.

      In context to what you explained, i will show you how i coded by following what you said:

      INCLUDE ZISSUESTOP                              .    " global Data

      CONSTANTS : objtype TYPE borident-objtype VALUE 'ZGOS'.

      DATA: manager TYPE REF TO cl_gos_manager,

             obj TYPE borident,

             WA_YISSUES_LOG_USER TYPE YISSUES_LOG_USER.

      MODULE STATUS_0100 OUTPUT.

         SET PF-STATUS 'ZSTATUS1'.   "icon SAVE is enabled

      IF manager IS INITIAL.

      obj-objtype = objtype.

      DATA : goskey(70) TYPE c.

      IF WA_YISSUES_LOG_USER-ZCALL_LOG_NO IS NOT INITIAL. "(my  <KEY>)

      goskey = WA_YISSUES_LOG_USER-ZCALL_LOG_NO.

      obj-objkey = goskey.

      ENDIF.

      IF WA_YISSUES_LOG_USER-ZCALL_LOG_NO IS NOT INITIAL.

      CREATE    OBJECT manager

      EXPORTING

      is_object    = obj

      ip_no_commit = 'R'

      EXCEPTIONS

      OTHERS       = 1.

      ENDIF.

        ENDIF.

      ENDMODULE.                 " STATUS_0100  OUTPUT

      MODULE USER_COMMAND_0100 INPUT.

      CASE SY-UCOMM.

         WHEN 'SAVE'.

           MODIFY YISSUES_LOG_USER FROM WA_YISSUES_LOG_USER.

            IF SY-SUBRC = 0.

                  MESSAGE i001(zissues_details). "Data Saved.

                ELSE.

                  MESSAGE e002(zissues_details). "Data not saved! Please check the entries.

                endif.

               CLEAR obj.

         CALL METHOD manager->unpublish    .

         FREE manager.

        ENDCASE.

      ENDMODULE.                 " USER_COMMAND_0100  INPUT


      ****************************************************************************

      Yet, i do not  get a tool-bar for attachment.

      Also, my program type is 'Module Pool'.

      Is there anything else i'm supposed to do or somewhere i'm terribly wrong, maybe?

      Regards & Thanks,

      KS


      Author's profile photo HIMANSHU GUPTA
      HIMANSHU GUPTA
      Blog Post Author

      Dear K S,

      First you check that have you made GOS object correctly as name of 'ZGOS'.

      Here, the scenario is when the  WA_YISSUES_LOG_USER-ZCALL_LOG_NO is not initial in your program then your object for manager create. Because of this object creation the tool will automatically appear on your screen while running the program. And with help of this tool you can attach multiple documents.

      Here, their is no need to use any function module or coding in save to save the document, it automatically saves.

      Now, when you leave the program or want to attach documents for other key, then first of all clear the obj and unpublish the manager as defined below.

      CLEAR obj.

         CALL METHOD manager->unpublish    .

         FREE manager.

      So, the tool refreshes and when you create again manager object for another key then will show documents or you can able to attach documents in correspond to another key.

      Many Thanks / Himanshu Gupta

      Author's profile photo Former Member
      Former Member

      Hi HIMANSHU GUPTA,

      Yes, i was not checking if WA_YISSUES_LOG_USER-ZCALL_LOG_NO is initial before assigning key to the object.

      My discussion would be helpful for those who are having similar doubts:

      http://scn.sap.com/thread/3438274

      Thankyou for taking time to respond!

      KS

      Author's profile photo Former Member
      Former Member

      Nice one. Keep publishing stuff like this

      Author's profile photo Former Member
      Former Member

      Hi Himanshu,

      Thank you for your sample code especially clearing out the GOS Objects. It helped me add the services for Object feature to module pool in a very short time.

      Rajesh

      Author's profile photo Former Member
      Former Member

      Thanks Himanshu for such a nice document.