CL_GOS_DOCUMENT_SERVICE / DELETE_ATTACHMENT
Hi,
I have requirement to delete an attachment attach to a sales document.
For this i am using the following class CL_GOS_DOCUMENT_SERVICE and method DELETE_ATTACHMENT.
My issue is in method DELETE_ATTACHMENT the parameter IP_ATTACHMENT is mandatory . I don't know how to arrive the value of IP_ATTACHMENT.
Here i have value for OBJKEY = (sales document numner) and OBJTYPE.= (YSALESATTA).
I like to know to how to arrive value IP_ATTACHMENT ( This is value for folder information).
Thanks
aRs
try this FM
BDS_BUSINESSDOCUMENT_DELETE
where you need to pass logical system, calssname, classtype (BO),client and ojbect key (which is sales docu number)
Raja
Similar Messages
-
Hi,
I am deleting a GOS attachment using following code.
data: i_borident type borident,
i_attsrv type ref to cl_gos_document_service.
i_objectd-objtype = 'YATTA'.
i_objectd-logsys = 'BO'.
i_objectd-objkey = inumber.
select * from srgbtbrel " Get GOS Link
into table i_srgbtbrel
where instid_a eq i_objectd-objkey
and typeid_a eq i_objectd-objtype
and catid_a eq i_objectd-logsys
and reltype eq 'ATTA'.
if sy-subrc eq 0.
create object i_attsrv.
loop at i_srgbtbrel.
i_borident-objkey = i_srgbtbrel-instid_b.
call method i_attsrv->delete_attachment
exporting
* is_object = i_objectd
ip_attachment = i_borident-objkey.
commit work.
endloop.
endif.
I am getting proper binary key from table SRGBTBREL and passing to method DELETE_ATTACHMENT , and getting sy-subrc eq 0, then also attachment are showing in the document. But if you are going thru service object delete it has been deleting the attachment perfectly. What is the error in the code?
Thanks
aRs
Message was edited by:
aRsHi.
You are missing SO_OBJECT_DELETE_IN_VB:
data ls_folder_id type soodk.
data ls_object_id type soodk.
loop at i_srgbtbrel.
i_borident-objkey = i_srgbtbrel-instid_b.
call method i_attsrv->delete_attachment
exporting
* is_object = i_objectd
ip_attachment = i_borident-objkey.
ls_folder_id = i_borident-objkey(17).
ls_object_id = i_borident-objkey+17(17).
call function 'SO_OBJECT_DELETE_IN_VB'
in update task
exporting
folder_id = ls_folder_id
object_id = ls_object_id.
endloop.
commit work and wait.
At the end of cl_gos_document_service->delete_attachment, there is the line:
call function 'GOS_ADD_KEY' exporting ip_objkey = ip_attachment.
This function adds the deleted item to table gt_obj_to_delete.
Later, the standard makes the call to SO_OBJECT_DELETE_IN_VB at include LSGOSITSF01, form DELETE_OBJECTS using gt_obj_to_delete.
Thanks. -
Edit_Attachment method of CL_GOS_DOCUMENT_SERVICE
Hi ABAPers,
I have used the method create_attachment of the class CL_GOS_DOCUMENT_SERVICE and i am able to attach the file.
but i have a need to edit the attached file.
Anybody can please tell me that how i may use the edit_attachment of the same class? It would be good for editing the filename?
Please also tell me what i have to pass in the parameters of the method edit_attachment for ip_attachment.
Thanks
DhananjayAm i Asking the wrong question or am i at wrong place for this type of questions??
Please help me Gurus, I am new to this SAP and fresher also.
Regards
Dhananjay -
I would like to delete attachment in items object services in batch using ABAP program. Can i use function module or class to do that.
Regards,HI Daniel,
try with this class CL_GOS_DOCUMENT_SERVICE, the method DELETE_ATTACHMENT sounds good.
Regards,
Gianluca -
Unable to see the uploaded file using gos object
Hi Experts,
I uploaded the file to server by using the below code. But I am unable to see the uploaded file. Please help me out hot to view the uploaded files (list the file name and view the content) (i want to upload the file by getting the url as input and by clicking the button)
Code to upload the file.
DATA: wa_zqtc_gos_request TYPE zqtc_gos_request.
DATA: l_attachment TYPE swo_typeid.
DATA: lo_gos_service TYPE REF TO cl_gos_document_service.
obj-objkey = req_num.
obj-objtype = objtype.
CREATE OBJECT lo_gos_service.
CALL METHOD lo_gos_service->create_attachment
EXPORTING
is_object = obj
IMPORTING
ep_attachment = l_attachment.
I tyied with this to view the files but the attachement link is disabled. (i want to view the files by clicking the icon-GOS icon in tool bar)
DATA: wa_zqtc_gos_request TYPE zqtc_gos_request.
DATA: l_attachment TYPE swo_typeid.
DATA: lo_gos_service TYPE REF TO cl_gos_document_service.
obj-objtype = objtype.
obj-objkey = req_num.
CREATE OBJECT manager
EXPORTING
is_object = obj
EXCEPTIONS
OTHERS = 1.
Please help me out how to view the file and list.
thanks & regards
T.Tamodarane
Edited by: T.Tamodarane on Oct 23, 2009 9:55 AM
Edited by: T.Tamodarane on Oct 23, 2009 9:56 AMHi,
Please post ur thred below:
PL/SQL
Regards
Meher Irk -
Create Attachments to Generic Object Services from Webdynpro appliccation
Hi,
I have requirement to Create Attachments to Generic Object Services(GOS) in equipment master (IE03) from webdynpro when a user clicks on upload button and also allow the user to delete the attachments .
Can anyone advice me of any Function Modules or logic to use from Web GUI.
I used below logic from R/3 to create attachments, but from webdynpro this method doesn't work.
DATA lo_attachment TYPE REF TO cl_gos_document_service.
CREATE OBJECT lo_attachment.
CALL METHOD lo_attachment->create_attachment
EXPORTING is_object = ls_object
IMPORTING ep_attachment = lp_attachment
Your inputs are appreciated.
Thanks
Rajesh YaldaHi,
try using the Class CL_GOS_SRV_ATTACHMENT_CREATE with Method EXECUTE_ITS.
best regards,
Michael -
Hi,
I have a requirement to read Purchase Order attachments and e-mail them.
Is there a FM to read the attachemnts with the document number as input? or is there any other way to do it?
Thanks,
K.Hi,
The following program may get you started.
It displays attached notes and lets the user click to display attached Word, Excel etc.
REPORT YJNM_DISPLAY_GOS_NOTES.
Displays contents of notes attached to a business object.
Displays header info for attached files, and displays the
attached files via drill-down.
parameters:
p_botype like tojtb-name default 'BUS2080', " e.g. 'BUS2012'
p_bo_id like borident-objkey default '000200000591'.
data:
msg(80) type c,
ntext like tojtt-ntext,
folder_id type soodk,
object_id like soodk,
object_hd_display type sood2,
objects like table of sood5,
rf type ref to CL_GOS_DOCUMENT_SERVICE,
is_object type sibflporb,
et_links type obl_t_link,
et_links_s type obl_s_link,
document type sood4,
header_data type sood2,
icx_obl_parameter_error type ref to cx_obl_parameter_error,
icx_obl_internal_error type ref to cx_obl_internal_error,
icx_obl_model_error type ref to cx_obl_model_error,
header_row type solisti1,
content_row type solisti1,
object_header like table of header_row,
object_content like table of content_row,
document_data type sofolenti1,
subline like content_row,
subline_fragment like subline-line,
subline_temp like subline,
sublines like table of subline,
all_sublines like table of subline,
document_id type sofOlenti1-doc_id,
exception_string type string.
include:
<icon>,
RSSOCONS.
*include <CNTN01>.
at line-selection.
check not document is initial.
CALL FUNCTION 'SO_DYNP_DOCUMENT_DISPLAY'
EXPORTING
OBJECTS = document.
start-of-selection.
class CL_GOS_DOCUMENT_SERVICE definition load.
create object rf.
is_object-instid = p_bo_id.
is_object-typeid = p_botype.
is_object-catid = 'BO'.
perform:
header,
notes,
attachments.
FORM notes .
find links to the notes
try.
call method cl_binary_relation=>read_links_of_binrel
exporting
is_object = is_object
ip_relation = 'NOTE'
importing
et_links = et_links.
catch cx_obl_parameter_error into icx_obl_parameter_error.
exception_string = icx_obl_parameter_error->get_longtext( ).
catch cx_obl_internal_error into icx_obl_internal_error .
exception_string = icx_obl_internal_error->get_longtext( ).
catch cx_obl_model_error into icx_obl_model_error.
exception_string = icx_obl_model_error->get_longtext( ).
endtry.
use the links to where the notes are stored
sort et_links by utctime.
loop at et_links into et_links_s.
at first.
format reset.
format color col_total.
skip.
write: / 'Note(s):'.
endat.
get the data for a note
refresh all_sublines.
document_id = et_links_s-instid_b .
CALL FUNCTION 'SO_DOCUMENT_READ_API1'
EXPORTING
DOCUMENT_ID = document_id
IMPORTING
DOCUMENT_DATA = document_data
TABLES
OBJECT_HEADER = object_header
OBJECT_CONTENT = object_content.
display a header for the note
format reset.
skip.
format color col_heading.
write: /3 'Note description:',
document_data-obj_descr,
/3 'Created by:',
document_data-creat_name,
document_data-creat_fnam,
'Last changed:',
document_data-chang_date.
interpret and display the note contents
format reset.
clear subline_fragment.
EOL (end of line) in the table object_content has nothing to do
with EOL for the note.
The table object_content is just a stream of characters - including
embedded CRLFs (carriage return & line feed) - that happens to be
255-character rows.
loop at object_content into content_row.
split content row at embedded CRLFs
split content_row-line
at cl_abap_char_utilities=>cr_lf into table sublines.
loop at sublines into subline.
store in subline_temp for full visibility within AT/ENDAT
subline_temp = subline.
at first.
subline_fragment from end of previous content_row needs to be
stuck on to the first subline of this content_row
concatenate subline_fragment subline_temp-line
into subline_temp-line.
endat.
at last.
final subline may not be a complete line of the note -
so save it to use with beginning of next content_row
subline_fragment = subline_temp-line.
exit.
endat.
if we reach here, subline_temp will be a complete note-line
append subline_temp to all_sublines.
endloop.
endloop.
subline-line = subline_fragment.
append subline to all_sublines.
loop at all_sublines into subline.
write: /3 subline-line.
endloop.
endloop.
ENDFORM. " notes
FORM attachments .
find links to attachments
refresh et_links.
try.
call method cl_binary_relation=>read_links_of_binrel
exporting
is_object = is_object
ip_relation = 'ATTA'
importing
et_links = et_links.
catch cx_obl_parameter_error into icx_obl_parameter_error.
exception_string = icx_obl_parameter_error->get_longtext( ).
catch cx_obl_internal_error into icx_obl_internal_error .
exception_string = icx_obl_internal_error->get_longtext( ).
catch cx_obl_model_error into icx_obl_model_error.
exception_string = icx_obl_model_error->get_longtext( ).
endtry.
use the links to where the attachments are stored
sort et_links by utctime.
loop at et_links into et_links_s.
at first.
skip.
format reset.
format color col_total.
write: / 'Attachment(s):'.
endat.
document-foltp = et_links_s-instid_b+0(3).
document-folyr = et_links_s-instid_b+3(2).
document-folno = et_links_s-instid_b+5(12).
document-objtp = et_links_s-instid_b+17(3).
document-objyr = et_links_s-instid_b+20(2).
document-objno = et_links_s-instid_b+22(12).
folder_id-objtp = document-foltp.
folder_id-objyr = document-folyr.
folder_id-objno = document-folno.
move-corresponding document to object_id.
CALL FUNCTION 'SO_OBJECT_READ'
EXPORTING
FOLDER_ID = folder_id
OBJECT_ID = object_id
IMPORTING
OBJECT_HD_DISPLAY = object_hd_display
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 eq 0.
skip.
format color col_heading.
write: /3 icon_display as icon hotspot,
object_hd_display-objdes,
object_hd_display-file_ext.
hide document.
write: /3 'Created by:',
object_hd_display-cronam,
object_hd_display-croadr,
'Last changed:',
object_hd_display-chdat.
hide document.
else.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
clear document. "in case of drill-down
endloop.
ENDFORM. " attachments
FORM header .
select single ntext
from tojtt
into ntext
where
name = p_botype and
language = sy-langu.
if sy-subrc eq 0.
format reset.
format color col_positive.
write: / 'Business object:',
20 ntext.
write: / 'Key:',
20 p_bo_id.
else.
concatenate 'Business-object type' p_botype 'not found.'
into msg separated by space.
write: / msg.
endif.
ENDFORM. " header
For a purchase order, the business-object type is BUS2012,
and the business-object key is just the document number (internal format).
John -
GOS(Generic Object Services) for Custom program ?
Hi All,
My requirement is to have GOS option to attach document for Custom program against each record.
Do anybody have faced the same kind of requirement,please let me know how to do.
Bharathi.JHi Bharathi
i to got the same requirement
through manually im attaching the files,notes and URL's
but how to attach through any class
i use CL_GOS_DOCUMENT_SERVICE in that
CREATE_ATTACHMENT method
but it is not attaching the files to my GOS menu
can u help me
Thanks
Surendra -
Download business document (T-code: OAOR) in background mode
I have attached a file to a production order and it is saved as a business document. From t-code OAOR (business document navigator), I can view the attachment (or directly from the production order).
I would like to download the attachment in background mode. Up to now, I only find a method export_attachment in the ABAP object cl_gos_document_service which can download the attachment in frontend.
Is there any ABAP object / FM which can cater this? Or please kindly suggest what can I do in order to achieve this. Your help is greatly appreciatedly. Thanks!
Below is the material that I can find in this forum
Re: Sales Order Attachmentcheck out this weblog.
/people/rammanohar.tiwari/blog/2006/03/25/generic-object-services-gos--in-background--part-ii
this for loading gos documents in background (not downloading) but should give you a pointer on how to go about it.
Regards
Raja -
Generate an Attachment from an XDATA
Hello,
i have the following problem:
i've written an WebDynpro where you can upload some files. Later after an approve there will be a creation of an prelimanary posted accounting doccument.
in this step i want to attach data to the acc-document. The data i want to add is in a customer table declared as xdata.
i tried to use CL_GOS_DOCUMENT_SERVICE and CL_GOS_SRV_ATTACHMENT_CREATE but there will always be a popup for selecting the file.
i just have the data on the server, i don't need this popup.
i hope anyone can help me.
best regards,
MichaelHi,
https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/0e6b0d95-0a01-0010-4696-ca0a48de5fb3
thanks and tregards
Durga.K -
Automatic GOS create attachment in ME51n
Hi,
I need to find a FM that adds an attachment to a requirement which is created from IDOC.
IDOC itself contains a link to the document that should be attached. The document is located on a network drive. The link is visable in created requirement in item texts.
As far as I could see it is imposible to use GOS in create tcode ME51n. However it is available in ME52n.
The attachment creation should be automatic.
Will appreciate ideas, clues and codes.
Regards,
MMTry to find an userexit after save in ME51N and get the url from IDoc and try to use
data lo_attachment type ref to cl_gos_document_service.
clear ls_url.
create object lo_attachment.
call method lo_attachment->create_url
exporting is_object = ls_object
importing ep_url = lp_url.
In After save userexit you will also get the pur req docno also. this is needed for INSTID_A in the link table.
a®s
Edited by: a®s on Mar 4, 2008 12:28 PM -
GOS - Create Attachment for Order in Background.
Hi,
My Requirement is to attach a document (.PDF, .DOC, .TIF or .JPG) to transaction JHA1X with respect to Order in background and it wll be stored in Open Text Server.
Document details wiil be passed throuh Portal, as XSTRING to ECC. Is there any BAPI ( Something that helps) available to upload this to transaction ?
Note : Through transaction I am able to do this ( By BO and Doc Type ) using store business document.
Thanks,
Praveen NI would call the method CREATE_ATTACHMENT of class CL_GOS_DOCUMENT_SERVICE
this will allow to select the file on PC and will attach it to the business object
if you already have the binary contents of the file and don't want to change the way to get it, then you can look into this method how to do it -
GOS: How to display attachment?
Hello,
I want to display the first attachment. I found the function GOS_ATTACHMENT_LIST_POPUP, but I haven't found a possibility to display an attachment directly. Does anybody know how to do this?
Please help.
Have a nice day. Bye.
FrankThis may not be the purist way of doing it, but hopefully it may help you along the way.
Jonathan
report zlocal_jc_sdn_gos_test.
tables:
srgbtbrel. "Relationships in GOS Environment
parameters:
*"Defaults here are an FI doc with GOS Note visible in FB03
p_objkey like borident-objkey
default '100000120618312008',
p_objtyp like borident-objtype
default 'BKPF'.
start-of-selection.
perform display_attachment.
*& Form display_attachment
form display_attachment.
data:
l_objkey type swo_typeid,
lo_gos_service type ref to cl_gos_document_service,
ls_srgbtbrel type srgbtbrel,
lt_srgbtbrel type srgbtbrel occurs 10.
*" Get a list of the links and choose one:
select *
into corresponding fields of table lt_srgbtbrel
from srgbtbrel
where instid_a = p_objkey
and typeid_a = p_objtyp
and reltype = 'NOTE'.
*" Exit if no attachments found
if lines( lt_srgbtbrel ) is initial.
exit.
endif.
*" Choose first one and set up the ident for the BOR
sort lt_srgbtbrel by utctime. "put oldest top for this demo
read table lt_srgbtbrel into ls_srgbtbrel index 1.
l_objkey = ls_srgbtbrel-instid_b. "i.e. the Note's ID
create object lo_gos_service.
call method lo_gos_service->display_note
exporting
ip_note = l_objkey
ip_disp_html = 'X'.
*"Methods in cl_gos_document_service include:
*" DISPLAY_ATTACHMENT
*" DISPLAY_NOTE
*" DISPLAY_PERSONAL_NOTE
*" DISPLAY_URL
endform. "display_attachment -
GOS Attachments Display URL in WD ABAP
HI,
We have to display the GOS attachments list in the the WD ABAP application. Unfortunately the class and Function module which can do that are not working in the WD ABAP application. Like CL_GOS_DOCUMENT_SERVICE...
Any thoughts?
Thanks
Raghavhi Kumar,
Please go through this...
GOS and FileUpload UiElement
Global object Services ( GOS ) in WD4A
Attachement Details (GOS) in Web Dynpro (ABAP)
cheers,
Kris. -
hello,
i have a requirement to attach a file to our own ztransactions for a particular field.kindly help me regarding this issue.
thanks and regards,
siri.Hi,
Just check this code: -
Reward points if it solve your problem: -
FUNCTION z_mi_create_attachment.
""Local Interface:
*" IMPORTING
*" VALUE(CLAIM_NUM) TYPE CHAR9
*" VALUE(SUBCLAIM_NUM) TYPE CHAR2
*" EXPORTING
*" VALUE(DOCUMENT_KEY) TYPE SWO_TYPEID
*" EXCEPTIONS
*" INVALID_CLAIM
*" NO_ATTACH
TABLES: zmit_clma,
zmit_clmd.
DATA: lo_attachment TYPE REF TO cl_gos_document_service,
ls_object TYPE borident,
lp_attachment TYPE swo_typeid,
ls_attachment TYPE sibflporb,
i_clma TYPE STANDARD TABLE OF zmit_clma INITIAL SIZE 0,
wa_clma TYPE zmit_clma.
DATA: lv_claim TYPE char9,
lv_sub TYPE char2,
lv_logsys TYPE logsys.
USEFUL INFORMATION -
*-- Message class- SGOS_MSG; Link saved in table- ;Tcode-SO00
SELECT SINGLE claim_number
sub_claim_num
FROM zmit_clmd
INTO (lv_claim, lv_sub)
WHERE claim_number = claim_num AND
sub_claim_num = subclaim_num.
IF sy-subrc NE 0.
RAISE invalid_claim.
ENDIF.
CALL FUNCTION 'OWN_LOGICAL_SYSTEM_GET'
IMPORTING
own_logical_system = lv_logsys
EXCEPTIONS
own_logical_system_not_defined = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ls_object-objkey = lv_claim.
ls_object-objtype = lv_sub.
ls_object-logsys = lv_logsys.
CREATE OBJECT lo_attachment.
CALL METHOD lo_attachment->create_attachment
EXPORTING
is_object = ls_object
IMPORTING
ep_attachment = lp_attachment.
IF lp_attachment IS INITIAL.
RAISE no_attach.
ENDIF.
wa_clma-claim_number = lv_claim.
wa_clma-sub_claim_num = lv_sub.
wa_clma-attach_item = ' '.
wa_clma-attach_remarks = lp_attachment.
wa_clma-sort_order = ' '.
wa_clma-created_by = sy-uname.
wa_clma-created_date = sy-datum.
wa_clma-created_time = sy-uzeit.
wa_clma-last_modified_by = sy-uname.
wa_clma-last_modify_date = sy-datum.
wa_clma-last_modify_time = sy-uzeit.
APPEND wa_clma TO i_clma.
CLEAR wa_clma.
MODIFY zmit_clma FROM TABLE i_clma.
document_key = lp_attachment.
CLEAR: lv_claim, lv_sub, lv_logsys, lp_attachment.
ENDFUNCTION.
Maybe you are looking for
-
I am trying to move iPod touch to a new computer. My iTunes library was already on a 1 TB external hard drive. I downloaded iTunes on my new computer, plugged in my external hard drive with my iTunes library, and changed my iTunes media folder loca
-
Getting error in alert log file in DR SITE
Database Characterset is WE8ISO8859P1 replication_dependency_tracking turned off (no async multimaster replication fou nd) Completed: alter database open read only Tue Oct 14 13:30:15 2008 Errors in file /arch/dump/udump/icai_ora_12168.trc: ORA-00600
-
Equivalent to windows home button
Reading the MacBook manual, I am on page 63. How do I get back to page 1 without scrolling up for ten minutes? On PC's there's a "Home" button that takes you to the top. What's the Mac (Lion 10.7) equivalent? Thank you!
-
SMS at the time Invoice invoice is saved
Hi I want to send SMS to the Customer Moblie when his Invoice is Created in the SAP system. The SMS should have the SAP invoice no. and the Amount of Invoice.
-
I can remove the shading on fillable fields, save the change, but when other users open the file, the field is still blue. I don't want the fields shaded blue when the users opens the file. How can I resolve this issue? I'm using Adobe Reader X, and