How To Attach Documents To Any Custom Program Using Generic Object Services
How To Attach Documents To Any Custom Program Using Generic Object Services
How to Attach Documents to Any Custom Program Using Generic Object Services
Applies to:
SAP R/3 4.6C
Summary
This sample code describes the steps needed to easily add file attachment feature to any custom report/module pool by using Generic Object Services (GOS). Users will have the possibility to store documents or notes for a specific application (instead of for a specific document as usual). Created on: 23 March 2006
Author Bio
Manuel Bassani lives in Vicenza (Italy) and has worked with SAP technologies as a freelancer since 2001. After some years as an ABAP senior developer in several projects, he actually works as an Exchange Infrastructure technical analyst. His other skills and interests are Java/C++ programming, XML, and SOAP.
2006 SAP AG
Table of Contents
Applies to: ........................................................................................................................................ 1 Summary.......................................................................................................................................... 1 Author Bio ........................................................................................................................................ 1 Table of Contents ............................................................................................................................ 2 Business Object Creation ................................................................................................................ 2 Integrating GOS in Custom Programs............................................................................................. 4 Case 1: File Attachment in Report Selection Screen................................................................... 4 Case 1: Screenshot .................................................................................................................. 5 Case 2: File Attachment in Lists .................................................................................................. 6 Case 2: Screenshot .................................................................................................................. 6 Case 3: File Attachment in Module Pool...................................................................................... 7 Case 3: Main program .............................................................................................................. 7 Case 3: Dynpro 100 logic ....................................................................................................... 10 Case 3: Screenshot GOS toolbar........................................................................................ 10 Case 3: Screenshot GOS Integrated in Dynpro Toolbar..................................................... 11 Related Content............................................................................................................................. 11 Disclaimer and Liability Notice....................................................................................................... 12
2006 SAP AG
2. A popup appears. Fill fields Object type, Object name, Name, Description and Program. Choose Application = '*'. Leave Supertype blank.
3. In the main page position the mouse pointer on Interfaces and press F5 (add object). In the popup choose interface IFGOSASERV
4. Add key fields by position on Key Fields and press F5. Choose table field TRDIR-NAME
2006 SAP AG
5. Position on method GOSAddObjects 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.
2006 SAP AG
AT SELECTION-SCREEN OUTPUT.
CLEAR OBJ.
* SET OBJECT KEY = REPORT NAME SELECT SINGLE NAME FROM TRDIR INTO OBJ-OBJKEY WHERE NAME = SY-REPID.
* CALL GOS MANAGER WITHOUT CONTAINER (WILL BE DISPLAYED IN THE TOOLBAR) CREATE OBJECT MANAGER EXPORTING IS_OBJECT = OBJ EXCEPTIONS OTHERS = 1.
Case 1: Screenshot
2006 SAP AG
* SET OBJECT KEY = REPORT NAME SELECT SINGLE NAME FROM TRDIR INTO OBJ-OBJKEY WHERE NAME = SY-REPID.
* CALL GOS MANAGER WITHOUT CONTAINER (WILL BE DISPLAYED IN THE TOOLBAR) CREATE OBJECT MANAGER EXPORTING IS_OBJECT = OBJ EXCEPTIONS OTHERS = 1.
Case 2: Screenshot
2006 SAP AG
Case 3: File Attachment in Module Pool This example shows how to integrate GOS features both via GOS toolbar and via dynpro toolbar Case 3: Main program
REPORT ZGOS_3.
DATA: MANAGER TYPE REF TO CL_GOS_MANAGER, OBJ TYPE BORIDENT, OK_CODE TYPE SY-UCOMM, EXCLUDE_TAB TYPE STANDARD TABLE OF EXCLUDE_TYPE, EXCLUDE_WA TYPE EXCLUDE_TYPE.
* TOOLBAR: DISPLAY GOS TOOLBAR IN DYNPRO * DIRECT: CALL GOS SERVICES DIRECTLY FROM DYNPRO TOOLBAR PARAMETERS: TOOLBAR RADIOBUTTON GROUP GR1 DEFAULT 'X', DIRECT RADIOBUTTON GROUP GR1.
START-OF-SELECTION.
2006 SAP AG
OBJ-OBJTYPE = OBJTYPE. SELECT SINGLE NAME FROM TRDIR INTO OBJ-OBJKEY WHERE NAME = SY-REPID.
CLEAR: EXCLUDE_TAB, EXCLUDE_WA. MOVE 'ATTACH' TO EXCLUDE_WA-FCODE. APPEND EXCLUDE_WA TO EXCLUDE_TAB. MOVE 'LIST' TO EXCLUDE_WA-FCODE. APPEND EXCLUDE_WA TO EXCLUDE_TAB.
2006 SAP AG
EXCEPTIONS OTHERS = 1.
ENDIF.
CASE OK_CODE.
* CALL CREATE ATTACHMENT SERVICE FROM TOOLBAR WHEN 'ATTACH'. CALL METHOD MANAGER->START_SERVICE_DIRECT EXPORTING IP_SERVICE IS_OBJECT = 'CREATE_ATTA' = OBJ
2006 SAP AG
EXECUTION_FAILED = 3 OTHERS = 4.
WHEN 'LIST'. CALL METHOD MANAGER->START_SERVICE_DIRECT EXPORTING IP_SERVICE IS_OBJECT EXCEPTIONS NO_OBJECT OBJECT_INVALID = 1 = 2 = 'VIEW_ATTA' = OBJ
ENDMODULE.
" USER_COMMAND_0100
INPUT
2006 SAP AG
10
Related Content
Some useful links: Generic Object Services (BC-SRV-GBT) Generic Object Services (GOS) - in Background [by Ram Manohar Tiwari]
2006 SAP AG
11
2006 SAP AG
12