Professional Documents
Culture Documents
SAP 4 ALL
Home
ABAP
Webdynpro/Workow
SAPUI5/FIORI
HANA
SAP
Adsby Google
AttachingfilestodocumentumusingGOSservicescanhavetwowayseithermanualor
automatic(earlyorlatearchival).RecentlyIcameacrosssomerequirementwheremy
customerwantedtodownloadtheattachmentsofaninvoiceforauditingpurpose.Thisis
somethingveryrareandyouwouldnotfindastraightawaysolutionforit.
Inmyrequirementtheinvoicedocumentcouldhavebotharchivedandnonarchivedfiles
whichwasneededtobedownloaded.HereishowIachievedit.
NonArchived/ManuallyattachedFiles
*LocalDataDeclartions
DATAl_i_relTYPEobl_t_relt.
DATAl_wa_relTYPEobl_s_relt.
DATAl_wa_objectTYPEsibflporb.
DATAl_v_sysTYPElogsys.
DATAl_i_linksTYPEobl_t_link.
DATAl_v_documntTYPEso_entryid.
DATAl_wa_document_dataTYPEsofolenti1.
DATAl_i_headerTYPESTANDARDTABLEOFsolisti1.
DATAl_wa_textTYPEtext200.
DATAl_v_filenamTYPEcacl_string.
DATAl_v_filetypTYPEsychar10.
DATAl_v_varTYPEcacl_string.
DATAl_v_sortfiTYPEsychar30.
DATAl_wa_documntidTYPEsofmk.
DATAl_i_contentTYPEswftlisti1.
DATAl_v_extctTYPEso_extct.
DATAl_v_doc_sizTYPEso_doc_len.
DATAl_v_flenameTYPEcacl_string.
DATA:l_i_tbl1024TYPESTANDARDTABLEOFtbl1024,
l_i_toa02TYPESTANDARDTABLEOFtoa02,
l_v_lengthTYPEsyindex,
POPULAR POSTS
l_v_archived_filenameTYPEsychar132.
FIELDSYMBOLS:<l_fs_tab>TYPEtoa02."toav0.
l_v_mimeTYPEsychar132,
l_cntTYPEbelnr_d,
https://saplatest.blogspot.com/2016/06/howtodownloadarchivedandnon.html
1/5
6/20/2016 HowtoDownloadArchivedandNonArchivedGOSattachmentsintoyourPC(attachmentsfromGenericObjectServices(GOS)Documentum)Sap4
FIELDSYMBOLS<l_fs_links>TYPEobl_s_link.
FIELDSYMBOLS<l_fs_header>TYPEsolisti1.
FIELDSYMBOLS<l_fs_content>TYPEsolisti1.
CONSTANTSl_c_eqTYPEddoptionVALUE'EQ'.
CONSTANTSl_c_attaTYPEoblreltypeVALUE'ATTA'.
CONSTANTSl_c_noteTYPEoblreltypeVALUE'NOTE'.
CONSTANTSl_c_dotTYPEsychar01VALUE'.'.
CONSTANTSl_c_slasTYPEsychar01VALUE'\'.
CONSTANTSl_c_equTYPEsychar01VALUE'='.
CONSTANTSl_c_kTYPEso_extctVALUE'K'.
CONSTANTSl_c_undTYPEsychar01VALUE'_'.
l_wa_relsign=l_c_i.
l_wa_reloption=l_c_eq.
l_wa_rellow=l_c_atta.
APPENDl_wa_relTOl_i_rel.
CLEARl_wa_rellow.
l_wa_rellow=l_c_note.
APPENDl_wa_relTOl_i_rel.
CLEARl_wa_rel.
l_wa_objectinstid=510000062009(YourObjectkeye.g.DocNo+DocYear).
l_wa_objecttypeid='BUS2081'(ForInvoiceDocument)
l_wa_objectcatid='BO'(Keepitasitis)
*DownloadNONARCHIVEDFiles.
TRY.
CALLMETHODcl_binary_relation=>read_links
EXPORTING
is_object=l_wa_object
ip_logsys=l_v_sys
it_relation_options=l_i_rel
IMPORTING
et_links=l_i_links.
CATCHcx_obl_parameter_error
cx_obl_internal_error
cx_obl_model_error.
RAISEno_link_found.
ENDTRY.
TRY.
LOOPATl_i_linksASSIGNING<l_fs_links>.
MOVE<l_fs_links>instid_bTOl_v_documnt.
IFl_v_documntISNOTINITIAL.
CALLFUNCTION'SO_DOCUMENT_READ_API1'
EXPORTING
CATEGORIES
Abap
document_id=l_v_documnt
ABAP OOPS
IMPORTING
Abap Tips
document_data=l_wa_document_data
BADI
TABLES
object_header=l_i_header
BTE
EXCEPTIONS
Complete_ABAP
document_id_not_exist=1
GOS
operation_no_authorization=2
HANA
x_error=3
OTHERS=4.
IFsysubrc<>0.
IDOC
Jobs
RAISEno_link_found.
LSMW
ELSE.
Sap
SAPUI5/FIORI
CONCATENATEl_wa_document_dataobj_descrl_c_dot
https://saplatest.blogspot.com/2016/06/howtodownloadarchivedandnon.html
Smartforms
2/5
6/20/2016 HowtoDownloadArchivedandNonArchivedGOSattachmentsintoyourPC(attachmentsfromGenericObjectServices(GOS)Documentum)Sap4
l_wa_document_dataobj_type
Webdynpro/Workow
INTOl_v_filenam.
ENDIF.
MOVEl_wa_document_dataobj_typeTOl_v_filetyp.
READTABLEl_i_headerASSIGNING<l_fs_header>INDEX2.
IFsysubrcISINITIAL.
BLOG ARCHIVES
2016 (80)
June (20)
Parallel Cursor technique
ENDIF.
CONDENSEl_v_filetyp.
l_wa_documntid=<l_fs_links>instid_b.
Debugging Skills
CONCATENATEl_wa_documntiddoctp
SPLIT<l_fs_header>lineATl_c_equINTOl_v_varl_v_filetyp.
l_wa_documntiddocyr
l_wa_documntiddocnoINTOl_v_sortfi.
IMPORTobjcont_tabTOl_i_content
FROMDATABASEsoc3(dt)IDl_v_sortfi.
IFsysubrcISINITIAL.
READTABLEl_i_contentASSIGNING<l_fs_content>INDEX1.
IFsysubrcISINITIAL.
IF<l_fs_content>lineCP'KPro'
l_v_extct=l_c_k.
ELSE.
CLEARl_v_extct.
ENDIF.
ENDIF.
ENDIF.
MOVEl_wa_document_datadoc_sizeTOl_v_doc_siz.
CALLFUNCTION'SO_OBJECT_DOWNLOAD'
EXPORTING
bin_filesize=l_v_doc_siz
filetype=l_v_filetyp
path_and_file=l_v_filenam
extct=l_v_extct
IMPORTING
act_filename=l_v_flename
no_dialog=abap_true
TABLES
objcont=l_i_content
EXCEPTIONS
file_write_error=1
May (37)
April (23)
invalid_type=2
x_error=3
kpro_error=4
OTHERS=5.
IFsysubrc<>0.
RAISEno_link_found.
ENDIF.
ENDIF.
CLEAR:l_i_content,l_v_extct.
ENDLOOP.
CATCHcx_sy_conversion_no_number
cx_sy_conversion_overflow
cx_sy_move_cast_error
cx_sy_conversion_codepage
cx_sy_import_format_error
cx_sy_import_mismatch_error.
RAISEno_link_found.
https://saplatest.blogspot.com/2016/06/howtodownloadarchivedandnon.html
3/5
6/20/2016 HowtoDownloadArchivedandNonArchivedGOSattachmentsintoyourPC(attachmentsfromGenericObjectServices(GOS)Documentum)Sap4
ENDTRY.
*DownloadArchivedFiles
WeneedtheSAPtoDocumentumlink,thisisavailableinTOA*tables,andit
dependsinwhichtableyoufindtherelation.FormeitsTOA02,itmaynotbe
sameforyou.
IncaseyoudontfinduseFunctionmodule
ARCHIV_CONNECTINFO_GET_METAandusetheparameterssap_object
andobject_idasinbelowselect.
IamusingtableTOA02togetallArchiveids.
Adsby Google
SapABAPTraining
SapWorkflow
DownloadPC
SELECT*FROMtoa02INTOTABLEl_i_toa02WHERE
sap_object='BUS2081'AND
object_id=5100000062009.(formeitsInvoicedocument)
IFsysubrcNE0.
RETURN.
ELSE.
LOOPATl_i_toa02ASSIGNING<l_fs_tab>.
l_cnt=l_cnt+1.
CLEAR:l_v_archived_filename,l_v_length,l_i_tbl1024.
CONCATENATE'C:\DATA\DOCUMENTUM''\''_Arc_'l_cnt'.'<l_fs_tab>reserve
INTOl_v_archived_filename.
CONDENSEl_v_archived_filename.
CALLFUNCTION'SCMS_AO_TABLE_GET'
EXPORTING
arc_id=<l_fs_tab>archiv_id
doc_id=<l_fs_tab>arc_doc_id
IMPORTING
length=l_v_length
TABLES
data=l_i_tbl1024
EXCEPTIONS
error_http=1
error_archiv=2
error_kernel=3
error_config=4
OTHERS=5.
IFsysubrc<>0.
CONTINUE.
ENDIF.
CALLFUNCTION'SCMS_DOWNLOAD'
EXPORTING
filename=l_v_archived_filename"'C:\DATA\DOCUMENTUM\....
filesize=l_v_length
mimetype=l_v_mime
TABLES
data=l_i_tbl1024
EXCEPTIONS
error=1
OTHERS=2.
IFsysubrc<>0.
CONTINUE.
ENDIF.
ENDLOOP.
https://saplatest.blogspot.com/2016/06/howtodownloadarchivedandnon.html
4/5
6/20/2016 HowtoDownloadArchivedandNonArchivedGOSattachmentsintoyourPC(attachmentsfromGenericObjectServices(GOS)Documentum)Sap4
ENDIF.
Free Shipping!
ThiscompletecodewillcreateafolderC:\Data\DocumentuminyourPCandyouwillfind
alldownloadedattachmentsthere.HappyDownloading
AT 06:54:00
LABELS: ABAP, ABAP TIPS, GOS, SAP
Share
NO COMMENTS:
POST A COMMENT
Enteryourcomment...
Commentas:
Publish
Newer Post
Unknown(Google)
Signout
Notifyme
Preview
Home
Older Post
2016BigDataTrends
Top8TrendsinBigDatafor2016.GettheWhitepaper!
Powered by Blogger.
https://saplatest.blogspot.com/2016/06/howtodownloadarchivedandnon.html
5/5