21/02/2011

SAP Community Network Blogs

Blogs

Generic object services (GOS) - in Background
Ram Manohar Tiwari Business Card Company: Logica Posted on Oct. 10, 2005 10:43 AM in ABAP
Just kidding ;-)

Subscribe Print Permalink Share

I saw a few un-answered questions on SDN on how to attach documents and URLs with the Business Objects, in background and then it should appear in GOS attachment list. So I am trying to understand the basics inside GOS. [Those un-answered question are years old so I am not sure if GOS is obsolete & now it is only used in Waldorf ;-) ] However, I did manage to write a program using the inside- logic of GOS, to attach Notes and URLs in background. [ Wow...finally I discovered that the earth is flat & it's standstill ;-)...any doubts.. ] Anyway ...here we go.. Attaching documents to Business Objects in background / providing a custom GOS like functionality for BSPs: [ Actually, I pretend that I know BSPs just because I have some experience with JSPs/HTML and..ABAP is...well no... It’s not my mother tongue ;-). So I confidently used to pass suggestions about BSPs as long as I don't have to write it by myself. ] The Problem: Since GOS can only be used with SAPGui Front-end ( OK..may be with ITS as well) and only in foreground, mass-attachment of documents (in background) can’t be handled with GOS. However, the basic applications (Classes & Methods), used in GOS, can be utilized to create a custom program for this purpose. Use: Since this new program will have the ability to run in background, irrespective of front-end, the same code can also be utilized to provide a GOS like facility in BSPs or while developing an upload program for attaching documents/URLs to Business Objects, in background. Inside GOS: Basically, inside the application, main business object and attachment, both are treated as Business Objects and then a link is maintained between both the object instances. The relationship type, while maintaining the link, describes whether the attached object is a URL or a file attachment, note and so on. However, while the main business object, to which you are trying to attach the document / URL is already known e.g. for Purchase order the Object type ('BUS2012’ )is known and instance (?) exists in database but the instance for the attachment has to be created first before the linking. Attachment can be a URL / a Note / a File and so you need to first upload (data as well in case of file) the attahcment info, and in the process also get a business object instance generated of BO type ‘MESSAGE’. The program The program-processing will have following steps: Upload the File to be attached or in case of URL just get the URL name. In case of mass upload, the input can be read from a datafile on application server, having info (e.g. URL / File Path ) against the Business Object key ( e.g. Purchase Order Number ). Create an instance of BO type ‘MESSAGE’ using BO Method MESSAGE.Create. In case you are not comfortable with BO macros, simply call the main FM used within. The important part here is to pass the document type e.g. URL, EXT (for external files), and contents of file as well the file type ( e.g. TXT, PDF ) in case of File attachments. Here the document type can be derived from the relationship type of the link. Now, the attachment is created in database as a ‘MESSAGE’ and instance is known. We’ll refer to this as object_b and main Business Object as objet_a. Now, maintain the link. Check the attached documents through GOS toolbar Purchase Orders. Sample Code Attachment List, using main business objects’ transaction e.g. ME23N for

*---------------------------------------------------------------------* * Report Z_RMTIWARI_ATTACH_DOC_TO_BO *---------------------------------------------------------------------* * Written By : Ram Manohar Tiwari * Function : We need to maintain links between Business Object and * the attachment.Attachment document is basiclally a * business object of type 'MESSAGE'.In order to maintain * links, first the attachment will be crated as Business * Object of type 'MESSAGE' using Message.Create method. * Need to check if we can also use FM * 'SO_DOC_INSERT_WITH_ORIG_API1' or SO_OBJECT_INSERT rather * than using Message.Create method. *---------------------------------------------------------------------* REPORT Z_RMTIWARI_ATTACH_DOC_TO_BO * Include for BO macros INCLUDE : <cntn01>. * Load class. CLASS CL_BINARY_RELATION definition load. .

www.sdn.sap.com/irj/scn/weblogs?blo…

1/24

21/02/2011
CLASS CL_OBL_OBJECT definition load.

SAP Community Network Blogs

PARAMETERS: * Object_a P_BOTYPE LIKE obl_s_pbor-typeid DEFAULT 'ZFRIENDS', " e.g. 'BUS2012' P_BO_ID LIKE OBL_S_PBOR-INSTID DEFAULT '00007', " Key e.g. PO No. * Object_b P_DOCTY LIKE obl_s_pbor-typeid DEFAULT 'MESSAGE' NO-DISPLAY, P_MSGTYP LIKE SOFM-DOCTP DEFAULT 'URL' NO-DISPLAY, Relationship P_RELTYP LIKE mdoblrel-reltype DEFAULT 'URL'. types: BEGIN OF TY_MESSAGE_KEY, FOLTP TYPE SO_FOL_TP, FOLYR TYPE SO_FOL_YR, FOLNO TYPE SO_FOL_NO, DOCTP TYPE SO_DOC_TP, DOCYR TYPE SO_DOC_YR, DOCNO TYPE SO_DOC_NO, FORTP TYPE SO_FOR_TP, FORYR TYPE SO_FOR_YR, FORNO TYPE SO_FOR_NO, END OF TY_MESSAGE_KEY. DATA : LV_MESSAGE_KEY type TY_MESSAGE_KEY. DATA : LO_MESSAGE type SWC_OBJECT. DATA : LT_DOC_CONTENT type standard table of SOLI-LINE with header line. * First derive the Attachment's ( MESSAGE )document type. P_DOCTY = 'MESSAGE'. CASE P_RELTYP. * In case of URls WHEN 'URL'. P_MSGTYP = 'URL'. * In case of Notes / Private Notes WHEN 'NOTE' OR 'PNOT'. P_MSGTYP = 'RAW'. WHEN 'ATTA'. P_MSGTYP = 'EXT'. * Not implemented as yet...exit EXIT. WHEN OTHERS. * ....exit EXIT. ENDCASE. *----------------------------------------------------------------* * Create an initial instance of BO 'MESSAGE' - to call the * instance-independent method 'Create'. swc_create_object LO_MESSAGE 'MESSAGE' LV_MESSAGE_KEY. * define container to pass the parameter values to the method call * in next step. swc_container LT_MESSAGE_CONTAINER. * Populate container with parameters for method swc_set_element LT_MESSAGE_CONTAINER 'DOCUMENTTITLE' 'Title'. swc_set_element LT_MESSAGE_CONTAINER 'DOCUMENTLANGU' 'E'. swc_set_element LT_MESSAGE_CONTAINER 'NO_DIALOG' 'X'. swc_set_element LT_MESSAGE_CONTAINER 'DOCUMENTNAME' P_DOCTY. swc_set_element LT_MESSAGE_CONTAINER 'DOCUMENTTYPE' P_MSGTYP. * 'DocumentContent' is a multi-line element ( itab ). * In case of URLs..it should be concatenated with &KEY& in the begining. CASE P_MSGTYP. WHEN 'URL'. LT_DOC_CONTENT = '&KEY&http://www.rmtiwari.com' . append LT_DOC_CONTENT. * In case of Notes or Private Notes, get the data from files on appl * server or from wherever(? - remember background). WHEN 'RAW'. LT_DOC_CONTENT = 'Hi How r u?' . append LT_DOC_CONTENT. * In case of File attachments WHEN 'EXT'.

*

www.sdn.sap.com/irj/scn/weblogs?blo…

2/24

. LO_IS_OBJECT_B-CATID = 'BO'. UK.' www.21/02/2011 * * * SAP Community Network Blogs Upload the file contents using open dataset in lt_doc_content . Some conversion ( Compress ) might be required.. swc_set_element LT_MESSAGE_CONTAINER 'DocumentContent' LT_DOC_CONTENT. LO_IS_OBJECT_A-CATID = 'BO'. *CATCH CX_OBL_MODEL_ERROR .. swc_call_method LO_MESSAGE 'CREATE' LT_MESSAGE_CONTAINER.who cares!! commit work. * Check if everything OK. Not sure at this point ENDCASE. We can now * attach it to our main business object instance. *TRY. *ENDTRY. LO_IS_OBJECT_B-INSTID = LV_MESSAGE_KEY. *CATCH CX_OBL_PARAMETER_ERROR . Ram Manohar Tiwari is a SAP Principal Consultant with Logica. LO_IS_OBJECT_B-TYPEID = P_DOCTY. * Create attachment BO object_b data: LO_IS_OBJECT_B type SIBFLPORB... CALL METHOD CL_BINARY_RELATION=>CREATE_LINK EXPORTING IS_OBJECT_A = LO_IS_OBJECT_A * IP_LOGSYS_A = IS_OBJECT_B = LO_IS_OBJECT_B * IP_LOGSYS_B = IP_RELTYPE = P_RELTYP * IP_PROPNAM = * I_PROPERTY = * IMPORTING * EP_LINK_ID = * EO_PROPERTY = . *CATCH CX_OBL_INTERNAL_ERROR .sdn. * Create main BO object_a data: LO_IS_OBJECT_A type SIBFLPORB. Main Topics Oldest First Is there a function module like this? CALL FUNCTION '. * Now we have attachment as a business object instance. I would like to find the attachment of a GOS(Generic Object Service) but I will not view attachment. LO_IS_OBJECT_A-INSTID = P_BO_ID. * Refresh to get the reference of create 'MESSAGE' object for attachment swc_refresh_object LO_MESSAGE. * Get Key of new object swc_get_object_key LO_MESSAGE LV_MESSAGE_KEY. Comment on this weblog Showing messages 1 through 27 of 27.sap.. Titles Only GOS attachment find 2010-12-15 13:25:26 ahmet sevil Business Card [Reply] Hi.com/irj/scn/weblogs?blo… 3/24 . LO_IS_OBJECT_A-TYPEID = P_BOTYPE.

.. I will give it icon in the ALV report.21/02/2011 . concatenate '&KEY&' l_url_id(250) into LT_DOC_CONTENT. don't forget to replace the line below swc_set_element LT_MESSAGE_CONTAINER 'DocumentContent' LT_DOC_CONTENT.. www.never tested it but I think it should work... endwhile. Please help me regarding this issue.. I have attachment stored in sales order using GOS. while not l_url_id is initial. Thanks. shift l_url_id left by 250 places.I was looking for a way to create external URLs for different objects for ages! Thank's a lot! BR Henrik Saved my day 2009-01-22 04:09:59 Ram Manohar Tiwari Business Card [Reply] just in case you face the 255 char limit issue the code below will help. SAP Community Network Blogs If there is attachment. Exporting attachmet = true / false .com/irj/scn/weblogs?blo… 4/24 . data l_url_id type so_url. To move the attachment stored in GOS 2009-09-16 09:02:52 Prabavathi Kalaimani Business Card [Reply] Hi. Thanks Praba Saved my day 2009-01-22 02:29:24 Henrik Binggl Business Card [Reply] Excellent .sap. with swc_set_table LT_MESSAGE_CONTAINER 'DocumentContent' LT_DOC_CONTENT. best regards.sdn. I have a requirement to read the attachment and move it to an external file path. l_url_id = "assign the url id > 255 char WHEN 'URL'. append LT_DOC_CONTENT.

I will be very thankful if you have any idea about it Thanks Pushkarinee attaching URLs more than 255 characters 2008-01-25 05:11:11 vikram patil Business Card [Reply] Hi. Ram SAP Community Network Blogs attaching URLs more than 255 characters 2008-01-22 09:08:43 Pushkarinee Date Business Card [Reply] Hello. swc_set_element lt_message_container 'DOCUMENTTYPE' xdoctype. This program was working fine in foreground also and like many others.com/irj/scn/weblogs?blo… 5/24 . sorted out the problem. Second Change: file from application server and doctype is the file extension. Could you please help me in that. Is it possible to attach URL more than 255 in length ? . TRANSLATE xdoctype TO UPPER CASE. First change in program: I used structure SOLIX * Binary contents DATA : lt_doc TYPE STANDARD TABLE OF solix WITH HEADER LINE. I also faced the problem at the time of opening attachment it was saying file corrupted.sdn. Anoop Uploading pictures / images JPG 2007-11-02 03:25:19 Anoop Dosi Business Card [Reply] Hi guys. CALL FUNCTION 'GUI_UPLOAD' EXPORTING filename = lf_fname www.' INTO xfname xdoctype..21/02/2011 cheers. Thanks. My problem is been sorted out by this way. I need to upload JPG images as attachment from presentation server using this program. Just thought of sharing so that in future other guys can give the try to this solution if attachment doesn't open. SPLIT lf_fname AT '.sap.I tried but it doesn't seem to work . I tried the ways which other used but those were not working in my case. Vikram Uploading pictures / images JPG 2007-10-30 09:40:30 Anoop Dosi Business Card [Reply] Hi Guys.. Please update me if u have some solutions.. thanks. I am also facing the same problem.

com/irj/scn/weblogs?blo… 6/24 . But when i try to open the file from the list of objects the file is empty. Do i need to make any conversion before uploading? Pls help.21/02/2011 filetype = 'BIN' IMPORTING filelength = length TABLES data_tab = lt_doc. Uploading pictures / images JPG 2008-04-02 07:35:33 Subba Krishna Business Card [Reply] Hello Anoop. But the problem i am not ableto dis the attachment. And with this it worked fine for BMP JPG PDF and DOC all type of attachment. could you please send me the latest code.sdn. guide what might be the problem? thanks.. The file which i am uploading is with the extension 'mht'. i have the same requirement to upload gif on Local PCto invoice documents. Can you pls. Subba Uploading pictures / images JPG 2007-12-21 22:58:56 Dadarao Padghane Business Card [Reply] Hi Anoop. The code given by you is attaching the file to the header and am able to see it in the list of objects. Dadarao Please help me for get attachment content from r/3 2006-08-01 11:17:20 srushti srushti Business Card [Reply] Steps Followed to Add attachment in Web dynpro Java + R/3 Code from web dynpro application passing file content as "xtring" parameter to RFC then 1)Convert Xstring to bin using SCMS_XSTRING_TO_BINARY 2)BINARY_RELATION_CREATE Create relations as attachment to network object www.sap. I am working on attaching a file to nomination header in TSW. Thanks. SAP Community Network Blogs Third change: Instead of "DocumentContent" used "Content_hex" method parameter swc_set_table lt_message_container 'Content_Hex' lt_doc. Thanks. I was trying to upload the PDF file. I was able to saw the PDF file after reffering the code by you along with Manoj . Anoop GOS 2008-10-08 23:02:38 ramanan rs Business Card [Reply] Hi Anoop.

. Iam using that code for the attachment. 1) CL_BINARY_RELATION=>READ_LINKS 2) SO_DOCUMENT_READ_API1 gives document data 3) convert document data using SCMS_BINARY_TO_XSTRING 4) pass that xstring as file data to front end While getting data file format gets corrupt . You can do this for any other business object.. 2006-08-08 02:41:56 Bhavani Somaraju LA Business Card [Reply] Hi Seema... Check this ocde below. www.. 2006-07-09 21:28:22 Seema Chand Business Card [Reply] Hello Mr Ram Manohar Tiwari. You can create an attachment by using Function modules also.chand@vikalpsolutions... Is there any other way i can read attachment ? Is any step missing here in reading attachments? Plz Guide me... U can also E-mail me at seema. it worked fine and I have done it for Warranty claim business object. Seema Chand..21/02/2011 SAP Community Network Blogs This part of upload file works fine . Actually i went through ur Blog in SDN named as 'GOS'(47).com/irj/scn/weblogs?blo… 7/24 .com Plz Guide me.sap.. Iam getting an output something likeFOLTP FOL FOLYR 25 FOLNO 000000000004 DOCTP EXT DOCYR 31 DOCNO 000000000075 link id C5E5FBEDCB90B4488A7BF3C4EB870E95 THIS IS THE LINK.This is by refreing you block !!!!!!!! ++++++++++++++++++++++++++++++++++++++++++++++++ Problem is when we do get attachment file contents get corrupted. IN WHICH TABLE DOES THIS LINK GETS STORED??? So that i can have a link between the document attachment and the business object??? also wht should b the approach if i use a Z-Business Object??? Or u can even tell me the name of the Function Module through which i can relate them??? Thank u so much!!! waiting.sdn.. Business Object is : BUS2222 Import parameters DEFAULT_FILENAME : Any name for your file.

21/02/2011 SAP Community Network Blogs FILETYPE : Type of the file cane be ppt.com/irj/scn/weblogs?blo… 8/24 . txt etc PATH_AND_FILE : Exact path like c:\text.txt TAR_FOL : This is user folder can be like this 'FOL25000000000004' CLAIMNO : Claim No UPDATE_FLAG : Always Null can be removed LOGSYSTEM : Logical System Tables : has nothing to do here. Pdf .00 * * Author : S L A Bhavani * * Company : Infotech Enterprises Ltd.sdn.sap. Hyderabad * * Date Written : 08/03/2004 www. that is for internal purpose function zgos_so_create_attachment . *"---------------------------------------------------------------------*"*"Local interface: *" IMPORTING *" VALUE(DEFAULT_FILENAME) LIKE RLGRAP-FILENAME DEFAULT SPACE *" VALUE(FILETYPE) LIKE RLGRAP-FILETYPE DEFAULT 'DOC' *" VALUE(PATH_AND_FILE) LIKE RLGRAP-FILENAME DEFAULT SPACE *" VALUE(TAR_FOL) LIKE SOFDK STRUCTURE SOFDK DEFAULT *" 'FOL25000000000004' *" VALUE(CLAIMNO) LIKE PNWTYH-CLMNO *" VALUE(UPDATE_FLAG) LIKE SONV-FLAG OPTIONAL *" VALUE(LOGSYSTEM) LIKE BORIDENT-LOGSYS DEFAULT 'DV3200' *" EXPORTING *" VALUE(FILELENGTH) LIKE SOXWD-DOC_LENGTH *" VALUE(F_CANCELLED) LIKE SONV-FLAG *" VALUE(ACT_FILETYPE) LIKE RLGRAP-FILETYPE *" VALUE(ACT_FILENAME) LIKE RLGRAP-FILENAME *" VALUE(ACT_OBJTYPE) LIKE SOODK-OBJTP *" VALUE(FILE_PUT_TO_KPRO) LIKE SONV-FLAG *" TABLES *" OBJECTCONT STRUCTURE SOLI OPTIONAL *" EXCEPTIONS *" FILE_READ_ERROR *" INVALID_TYPE *" X_ERROR *" OBJECT_TYPE_NOT_ALLOWED *" KPRO_INSERT_ERROR *" SUCCESS_MESSAGE *" LOGSYS_NOTDEFINED *" OBJECT_INSERT_ERROR *"---------------------------------------------------------------------**===================================================================== * Program Name : ZGOS_SO_CREATE_ATTACHMENT * * Version : 1. doc.

existing_kpro_doc like sonv-flag. put_to_kpro like sonv-flag. " for attachment type c_reltype(4) value 'ATTA'.com/irj/scn/weblogs?blo… 9/24 . phio_object like sdokobject. "final name of the file file_path like rlgrap-filename. data: folder_id_api1 like soobjinfi1-object_id. Path an File Name. " file lenght cancelled. " relation type c_objtype(3) value 'EXT'. *--------------decalre internal tables-----------------********** *------------. " total file path **** KPro variables data: filesize like sood-objlen. context like sdokpropty occurs 0.sdn. new_object_id_phio like sdokobject. c_objla(2) value 'EN'. sizelimit like sood-objlen.USED IN SO OBJECT INSERT----------------********** data: objhead like soli occurs 0 with header line. Doc etc) * * Input : File Name. "this is to get the path trunc_length type i. content_lines like sy-tabix. ******--------------End decalre constants ------------------********** ******--------------decalre variables ------------------********** data: command_line like rlgrap-filename. File Type. "Business object type c_tarfol(17) value 'FOL25000000000004'.Claim No * *--------------------------------------------------------------------- ******--------------decalre constants ---------------------********** constants: c_objnam(7) value 'MESSAGE'.21/02/2011 SAP Community Network Blogs * Purpose : Create attachment to warranty claim object. " attachment object type c_busobjtype(7) value 'BUS2222'. data screentype(30) type c. loio_object like sdokobject. www.sap. * : Attachment can be any type (TXT. doc_insert_api1 like sodocchgi1. "flag to know whther cancelled the operation stripped_name like rlgrap-filename.

* wait up to 5 seconds. ******-----used in create binary relation commit------********** ******-----Function Module calls----------------------********** act_filename = path_and_file. objparb like soop1 occurs 0 with header line. * commit work. * * check (and change) objtype and filetype perform check_object_type tables objcont using act_objtype act_filetype trunc_length. data: obj_rolea like borident occurs 0 with header line. object_type like soodk-objtp. ** get file extension from file name perform so_split_file_and_extension using act_filename stripped_name act_objtype. call function 'SO_KPRO_DATA_FROM_OBJCONT_GET' importing loio_object = loio_object tables objcont = objectcont context = context www. if not act_filename is initial. document_info like sofolenti1. if content_lines ne 0. obj_roleb like borident occurs 0 with header line. . * wait up to 5 seconds. * commit work. * path and file is already known act_filetype = filetype. document_id like tar_fol. * wait up to 5 seconds. * commit work. data: v_objtype like borident-objtype. *-----used in create binary relation commit------********** data: v_pnguid like pnwtyh-pnguid.com/irj/scn/weblogs?blo… 10/24 . * * Decide if a new document should be created describe table objectcont lines content_lines.sdn.sap.21/02/2011 document_type like soodk-objtp. objpara like selc occurs 0 with header line. data: objcont like soli occurs 1 with header line. SAP Community Network Blogs data: object_hd_change like sood1.

*-. endif. else. endif.21/02/2011 exceptions missing_kpro_data = 1 others = 2. * * Put file into KPro perform loio_content_insert(saplso25) using act_filename act_filetype loio_object filesize rcode. * * Create new document (in KPro or DB) SAP Community Network Blogs * Decide about KPro "It's on the PC so it's an external document call function 'SO_KPRO_DECIDE' exporting objtp = c_objtype importing put_into_kpro = put_to_kpro.sdn.Put new LOIO id to OBJCONT call function 'SO_KPRO_DATA_INTO_OBJCONT_PUT' exporting loio_object = loio_object tables objcont = objcont. exit. existing_kpro_doc = off. *-.Export extct file_put_to_kpro = on. raise kpro_insert_error. endif. * *-. f_cancelled = on.sap. * wait up to 5 seconds.Export file size filelength = filesize.com/irj/scn/weblogs?blo… 11/24 . * commit work. if rcode ne 0. if sy-subrc = 0. existing_kpro_doc = on. else. if existing_kpro_doc = off. existing_kpro_doc = off. www. endif. *. * commit work. if rcode = 8000. if put_to_kpro = on. * wait up to 5 seconds.

act_filetype = 'ASC'. cancelled = on.document as neighbor. if act_filetype = 'TRU'. *-.21/02/2011 else.sdn. * if update_flag ne 'X'. *-. object_hd_change-objla = c_objla. else.DETERMINE FILE EXTENSION BASED ON THE FILE TYEP. else. object_hd_change-objdes = default_filename. endif. object_hd_change-file_ext = filetype..Document attributes clear object_hd_change. *-.com/irj/scn/weblogs?blo… 12/24 . www. f_cancelled = cancelled. endif.sap. if not cancelled is initial.IT IS ATTACHMENT ALWAYS SO. UPLOAD will return cancel = 'x'.If cancelled. SAP Community Network Blogs *-. object_hd_change-extct = 'K'.Put document into database in classical manner endif. commit work. *-. *** Retrieve the root target folder call function 'SO_FOLDER_ROOT_ID_GET' exporting owner = sy-uname region = 'B' importing folder_id = tar_fol. endif. object_hd_change-objsns = 'O'. object_hd_change-objlen = filesize. object_type = c_objtype.Put new LOIO id to OBJCONT refresh objcont. endif. *-. *-. append loio_object to objcont.Insert object into Sap Object Definition Database and create *-. concatenate file_path sy-datum sy-uzeit into object_hd_change-objdes separated by space. OBJTYPE = MESSAGE object_hd_change-objnam = c_objnam.

SAP Community Network Blogs * * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO * * WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. raise object_insert_error. www. endif.sdn. *-. *-. else.21/02/2011 .Preapre application object role obj_rolea-objtype = v_objtype. if sy-subrc <> 0. call function 'SO_OBJECT_INSERT' exporting folder_id = tar_fol object_hd_change = object_hd_change object_type = object_type owner = sy-uname importing object_id = document_id tables objcont = objcont objhead = objhead objpara = objpara objparb = objparb exceptions active_user_not_exist = 1 communication_failure = 2 component_not_available = 3 dl_name_exist = 4 folder_not_exist = 5 folder_no_authorization = 6 object_type_not_exist = 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 <> 0. endif.get the application object id from the claim no. if tar_fol = '' .com/irj/scn/weblogs?blo… 13/24 . v_objtype = c_busobjtype.sap. select single pnguid from pnwtyh into v_pnguid where clmno = claimno and ( oldcn = claimno or oldcn = '' ). tar_fol = c_tarfol.

"MESSAGE *-. * endif.sdn. " DV3200 append obj_roleb.Get Logical system from claint call function 'OWN_LOGICAL_SYSTEM_GET' importing own_logical_system = logsystem exceptions own_logical_system_not_defined = 1 others = 2. if sy-subrc <> 0. obj_rolea-logsys = logsystem.sdn. raise logsys_notdefined... SAP Community Network Blogs concatenate tar_fol document_id into obj_roleb-objkey.com/irj/scn/weblogs?blo… 14/24 . endif. Cheers. "Update flag endfunction. Actually i tried almost everything but nothing worked dont knw wht approach should i take??? www. RE : Plz Guide me. 2006-07-10 09:30:27 Ram Manohar Tiwari Business Card [Reply] Please go through my answers in comments section including my other weblog https://weblogs. Ram RE : Plz Guide me. obj_roleb-objtype = c_objnam. check out the table SRGBTBREL..sap. 2006-07-11 06:39:15 Seema Chand Business Card [Reply] Hi again. *-. **-. endif.sap.preapare SAp Office object role.com/pub/wlg/3399 You should use the FMs/Methods for getting the relations but just for info.. obj_roleb-logsys = logsystem.create binary relation for application object and sap office object call function 'BINARY_RELATION_CREATE_COMMIT' exporting obj_rolea = obj_rolea obj_roleb = obj_roleb relationtype = c_reltype. append obj_rolea.21/02/2011 obj_rolea-objkey = v_pnguid.

PARAMETERS: P_BOTYPE LIKE OBL_S_PBOR-TYPEID DEFAULT 'BUS2032'.sdn. "Key e. FORYR TYPE SO_FOR_YR. P_FILE TYPE STRING. DOCNO TYPE SO_DOC_NO. P_MSGTYP = 'URL'. DATA : LV_MESSAGE_KEY TYPE TY_MESSAGE_KEY. 'BUS2012' P_BO_ID LIKE OBL_S_PBOR-INSTID DEFAULT '0000002000'.sap. FOLTP TYPE SO_FOL_TP. DATA : LT_DOC_CONTENT TYPE STANDARD TABLE OF SOLI-LINE WITH HEADER LINE. TYPES: BEGIN OF TY_MESSAGE_KEY.21/02/2011 SAP Community Network Blogs well here is my code jus let me knw if u can help me out and ya i also wanted to knw wht if i want to work with Z-Business Objects??? TABLES ZREL_KEY. WHEN 'NOTE' OR 'PNOT'. SWC_CONTAINER LT_MESSAGE_CONTAINER. P_MSGTYP = 'EXT'. CASE P_RELTYP. FORTP TYPE SO_FOR_TP. SWC_SET_ELEMENT LT_MESSAGE_CONTAINER 'DOCUMENTLANGU' 'E'. P_RELTYP LIKE MDOBLREL-RELTYPE DEFAULT 'ATTA'. "e. EXIT. SWC_CREATE_OBJECT LO_MESSAGE 'MESSAGE' LV_MESSAGE_KEY. CLASS CL_OBL_OBJECT DEFINITION LOAD. P_DOCTY = 'MESSAGE'. PO No P_DOCTY LIKE OBL_S_PBOR-TYPEID DEFAULT 'MESSAGE' NO-DISPLAY. DATA: EP_LINK_ID LIKE ZREL_KEY-LINKID. CLASS CL_BINARY_RELATION DEFINITION LOAD. SWC_SET_ELEMENT LT_MESSAGE_CONTAINER 'DOCUMENTTITLE' 'Title'. DATA : LO_MESSAGE TYPE SWC_OBJECT. www. WHEN 'URL'. P_MSGTYP LIKE SOFM-DOCTP DEFAULT 'URL' NO-DISPLAY. INCLUDE : <CNTN01>. END OF TY_MESSAGE_KEY. WHEN OTHERS.g. FOLYR TYPE SO_FOL_YR. FOLNO TYPE SO_FOL_NO. FORNO TYPE SO_FOR_NO. ENDCASE. DOCYR TYPE SO_DOC_YR.g. DOCTP TYPE SO_DOC_TP. WHEN 'ATTA'. P_MSGTYP = 'RAW'.com/irj/scn/weblogs?blo… 15/24 .

DATA: LO_IS_OBJECT_B TYPE SIBFLPORB. WHEN 'EXT'. WHEN 'URL'. SWC_REFRESH_OBJECT LO_MESSAGE. SWC_GET_OBJECT_KEY LO_MESSAGE LV_MESSAGE_KEY. CASE P_MSGTYP. LT_DOC_CONTENT = 'Hi How r u?' . LO_IS_OBJECT_A-INSTID = P_BO_ID. LO_IS_OBJECT_A-TYPEID = P_BOTYPE. IF SY-SUBRC <> 0. ENDIF. SWC_SET_TABLE LT_MESSAGE_CONTAINER 'DocumentContent' LT_DOC_CONTENT. CALL FUNCTION 'GUI_UPLOAD' EXPORTING FILENAME = P_FILE TABLES DATA_TAB = LT_DOC_CONTENT.com' .com/irj/scn/weblogs?blo… 16/24 . SWC_SET_ELEMENT LT_MESSAGE_CONTAINER 'DOCUMENTNAME' P_DOCTY.*. IF SY-SUBRC <> 0.All Files.' TITLE = 'Attachment' IMPORTING FILENAME = P_FILE EXCEPTIONS INV_WINSYS = 1 NO_BATCH = 2 SELECTION_CANCEL = 3 SELECTION_ERROR = 4 OTHERS = 5. APPEND LT_DOC_CONTENT. LO_IS_OBJECT_A-CATID = 'BO'.*.sap. CALL FUNCTION 'WS_FILENAME_GET' EXPORTING MASK = '.rmtiwari.21/02/2011 SAP Community Network Blogs SWC_SET_ELEMENT LT_MESSAGE_CONTAINER 'NO_DIALOG' 'X'. *SWC_SET_ELEMENT LT_MESSAGE_CONTAINER 'DocumentContent' LT_DOC_CONTENT. SWC_CALL_METHOD LO_MESSAGE 'CREATE' LT_MESSAGE_CONTAINER. www. APPEND LT_DOC_CONTENT. SWC_SET_ELEMENT LT_MESSAGE_CONTAINER 'DOCUMENTTYPE' P_MSGTYP. ENDCASE. LT_DOC_CONTENT = '&KEY&http://www.sdn. ENDIF. * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO * WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. DATA: LO_IS_OBJECT_A TYPE SIBFLPORB. * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO * WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. WHEN 'RAW'.

LO_IS_OBJECT_B-CATID = 'BO'. I have found one: BAPI_REL_GETRELATIONS Just enter in the import structure OBJECTID the following fields: .21/02/2011 SAP Community Network Blogs LO_IS_OBJECT_B-INSTID = LV_MESSAGE_KEY. one can use a BAPI to create a link. 2006-07-11 07:23:53 Ram Manohar Tiwari Business Card [Reply] Use commit work at the end.. Also this will work for Z objects as well. I tested: . Ram GOS through BAPI call (BAPI_REL) 2006-03-23 03:20:45 Tom Christiaens Hello. RE : Plz Guide me. You can search "sap gos" in Google & Yahoo and that will help. In the same function group BAPI_REL you finbd another BAPI BAPI_REL_CREATERELATION which enables you to create a LINK. CALL METHOD CL_BINARY_RELATION=>CREATE_LINK EXPORTING IS_OBJECT_A = LO_IS_OBJECT_A IS_OBJECT_B = LO_IS_OBJECT_B IP_RELTYPE = P_RELTYP. Well how can i allot rewards to the blogs??? Thanks.sdn.sap. MODIFY ZREL_KEY. Cheers. Seema. I have been trying to find a BAPI that can read the link between the OBJECT A (a PM notification for example) and the OBJECT B (the NOTE or URL).. *This is a table in which m storing links wit docno temporarily!!! ZREL_KEY-DOCNO = LV_MESSAGE_KEY-DOCNO.com/irj/scn/weblogs?blo… 17/24 . 0001000009) . LO_IS_OBJECT_B-TYPEID = P_DOCTY.OBJTYPE (for PM notif BUS2038) Business Card [Reply] The result is a internal table with the LISTOFRELATIONS where you find all the linked objects.Through BAPI_REL_GETRELATIONS I got a list of notes attached to NOTIF 1 www.OBJKEY (e.g. Instead of using the _BINARY_RELATION=>CREATE_LINK. ZREL_KEY-LINKID = EP_LINK_ID. Conclusion: The GOS is using the BINARY RELATIONSHIP framework (whatever that may be) in order to link the NOTES and URL's to the object (PM notif for example).

Dharmesh Tom Christiaens . how I can take a ". I don't arrive to understand which or how data I have to fill into the field OBJKEY_B OBJTYPE_B RELATION Could you help me ? Best Regards www.sdn.thanks !!!!!! Now if you can only tell me . When i create new attachment by reading existing attachment(BAPI_REL_GETRELATIONS ).. it's a gift from the gods. See this forum thread here: https://forums. rather than displayed in something like MS PicMgr. It worked fine. does it create new document (BAPI_REL_CREATERELATION)on server or it just points to the existing attachment? Regards..com/irj/scn/weblogs?blo… 18/24 . thanks very much for tqaking the time to point out that wonderful BAPI. I try to understand how is working (I have to write a specification to link in background URL to FI document)..sdn.bmp" stored as an onject of type "MESSAGE" in the BOR and provide it to a picture control ?????? My customer has a pressing need to have picture attachments brought into picture controls. Very best regards djh GOS through BAPI call (BAPI_REL) 2006-06-01 11:48:11 Philippe Gauthier Business Card [Reply] Hello.com/thread.sap..sap... GOS through BAPI call (BAPI_REL) 2007-07-31 05:35:49 Dharmesh Rathod Business Card [Reply] Hi TOM. Anyway. 2007-07-20 16:30:40 David Halitsky Business Card [Reply] .jspa?threadID=490827&tstart=0 for the way I'm using it .Through BAPI_REL_CREATERELATION I could attach that same note to NOTIF 2 in background.21/02/2011 SAP Community Network Blogs . etc...

Through BAPI_REL_CREATERELATION I could attach that same note to NOTIF 2 in background.sdn..21/02/2011 Philippe GOS through BAPI call (BAPI_REL) 2006-03-23 03:20:42 Tom Christiaens Hello. as 'DocumentContent' is a multiline attribute.g.OBJTYPE (for PM notif BUS2038) The result is a internal table with the LISTOFRELATIONS where you find all the linked objects. I tested: .sap. one can use a BAPI to create a link. Instead of using the _BINARY_RELATION=>CREATE_LINK. It worked fine. Conclusion: The GOS is using the BINARY RELATIONSHIP framework (whatever that may be) in order to link the NOTES and URL's to the object (PM notif for example). The only small change that was required was to change the line: swc_set_element lt_message_container 'DocumentContent' lt_doc_content. I have found one: BAPI_REL_GETRELATIONS Just enter in the import structure OBJECTID the following fields: . I managed to use your code and it worked a treat. 0001000009) .OBJKEY (e.com/irj/scn/weblogs?blo… 19/24 . to swc_set_table lt_message_container 'DocumentContent' lt_doc_content. In the same function group BAPI_REL you finbd another BAPI BAPI_REL_CREATERELATION which enables you to create a LINK..Through BAPI_REL_GETRELATIONS I got a list of notes attached to NOTIF 1 . SAP Community Network Blogs Business Card [Reply] I have been trying to find a BAPI that can read the link between the OBJECT A (a PM notification for example) and the OBJECT B (the NOTE or URL). Thanks www. Very helpful weblog 2005-11-04 03:57:10 Mark Briggs Business Card [Reply] We had a requirement to attach binary images to maintenance orders using a background job.

'BUS2012' P_BO_ID LIKE OBL_S_PBOR-INSTID DEFAULT '000300154116'. the file attached seems to be correupted. CLASS CL_BINARY_RELATION DEFINITION LOAD. but I have two problems. " e. Appreciate any help and suggestions. The file attached does not carry the right documnet type so when I try to double click from the attachment list. P_MSGTYP LIKE SOFM-DOCTP DEFAULT 'EXT' NO-DISPLAY. I can only extract it not open the document.XLS' LOWER CASE. FOLTP TYPE SO_FOL_TP. I could not figured what I did wrong.In order to maintain * links.Create method.com/irj/scn/weblogs?blo… 20/24 . FOLYR TYPE SO_FOL_YR. REPORT ZGOS_BACKGROUD . FOLNO TYPE SO_FOL_NO.Create method. PC_FILE(128) DEFAULT '/usr/sap/tmp/lam/lamdata/test1.g. *---------------------------------------------------------------------* * Include for BO macros INCLUDE : <CNTN01>. DOCTP TYPE SO_DOC_TP. * Object_b P_DOCTY LIKE BORIDENT-OBJTYPE DEFAULT 'MESSAGE' NO-DISPLAY. TYPES: BEGIN OF TY_MESSAGE_KEY.sdn. * Load class. *---------------------------------------------------------------------* * Function : We need to maintain links between Business Object and * the attachment. P_RELTYP LIKE BRELTYP-RELTYPE DEFAULT 'ATTA' NO-DISPLAY. 1.21/02/2011 Mark Briggs Very helpful weblog SAP Community Network Blogs 2006-05-09 19:01:05 SHUI-CHIANG (RAY) Ng Business Card [Reply] I am trying to make it work by attaching to the business objects. CLASS CL_OBL_OBJECT DEFINITION LOAD. www. first the attachment will be crated as Business * Object of type 'MESSAGE' using Message. DOCYR TYPE SO_DOC_YR. 2. the following is the test program. PARAMETERS: ** Object_a P_BOTYPE LIKE OBL_S_PBOR-TYPEID DEFAULT 'BUS2080'.Attachment document is basiclally a * business object of type 'MESSAGE'. DOCNO TYPE SO_DOC_NO.sap. * Need to check if we can also use FM * 'SO_DOC_INSERT_WITH_ORIG_API1' or SO_OBJECT_INSERT rather * than using Message.

DATA DEF_FILENAME(12). END OF TY_BINARY. P_DOCTY = 'MESSAGE'. DATA OBJECT_HD_DISPLAY LIKE SOOD2. DATA: LISTOBJECT LIKE ABAPLIST OCCURS 1 WITH HEADER LINE. WHEN 'ATTA'. DATA : LO_MESSAGE TYPE SWC_OBJECT. START-OF-SELECTION. *----------------------------------------------------------------* * Create an initial instance of BO 'MESSAGE' . * In case of Notes / Private Notes WHEN 'NOTE' OR 'PNOT'. P_MSGTYP = 'URL'.sap. DATA: FILESIZE TYPE SO_DOC_LEN. www. * define container to pass the parameter values to the method call * in next step. DATA H_FILENAME LIKE RLGRAP-FILENAME. P_MSGTYP = 'RAW'. * First derive the Attachment's ( MESSAGE )document type. END OF TY_MESSAGE_KEY. DATA: L_FILE_LINES TYPE I. DATA ACT_FILETYPE LIKE RLGRAP-FILETYPE. DATA DOC_LENGTH LIKE SOXWD-DOC_LENGTH. SWC_CONTAINER LT_MESSAGE_CONTAINER. EXIT. FORYR TYPE SO_FOR_YR. P_MSGTYP = 'EXT'. DATA HELP_OBJCONT LIKE SOLI OCCURS 0 WITH HEADER LINE. DATA ACT_FILENAME LIKE RLGRAP-FILENAME. SAP Community Network Blogs DATA : LT_BINARY TYPE TABLE OF TY_BINARY WITH HEADER LINE. * In case of URls WHEN 'URL'.com/irj/scn/weblogs?blo… 21/24 . DATA : LT_DOC_CONTENT TYPE STANDARD TABLE OF SOLI-LINE WITH HEADER LINE.sdn. ENDCASE. WHEN OTHERS.21/02/2011 FORTP TYPE SO_FOR_TP. DATA : LV_MESSAGE_KEY TYPE TY_MESSAGE_KEY. WA_BINARY TYPE TY_BINARY. BINARY_FIELD(255) TYPE C.to call the * instance-independent method 'Create'. DATA FILE_TYPE LIKE RLGRAP-FILETYPE. TYPES : BEGIN OF TY_BINARY. * Populate container with parameters for method SWC_SET_ELEMENT LT_MESSAGE_CONTAINER 'DOCUMENTTITLE' 'Ray Test title'. CASE P_RELTYP. FORNO TYPE SO_FOR_NO. DATA:FILESTRING TYPE XSTRING. SWC_CREATE_OBJECT LO_MESSAGE 'MESSAGE' LV_MESSAGE_KEY. DATA: LV_DOC_SIZE TYPE I.

CLOSE DATASET PC_FILE. CALL FUNCTION 'SCMS_XSTRING_TO_BINARY' EXPORTING BUFFER = FILESTRING * APPEND_TO_TABLE = ' ' IMPORTING OUTPUT_LENGTH = LV_DOC_SIZE TABLES BINARY_TAB = LT_BINARY . WHEN 'URL'. SWC_SET_ELEMENT LT_MESSAGE_CONTAINER 'FILEEXTENSION' 'DOC'.it should be concatenated with &KEY& in the begining. SWC_SET_ELEMENT LT_MESSAGE_CONTAINER 'DOCUMENTSIZE' LV_DOC_SIZE. * In case of File attachments WHEN 'EXT'. * Refresh to get the reference of create 'MESSAGE' object for attachment * swc_refresh_object lo_message. APPEND LT_DOC_CONTENT. ENDCASE. SWC_CALL_METHOD LO_MESSAGE 'CREATE' LT_MESSAGE_CONTAINER. READ DATASET PC_FILE INTO FILESTRING. * 'DocumentContent' is a multi-line element ( itab ). * In case of Notes or Private Notes.sap. SWC_SET_ELEMENT LT_MESSAGE_CONTAINER 'NO_DIALOG' 'X'. get the data from files on appl * server or from wherever(? .com/irj/scn/weblogs?blo… 22/24 .21/02/2011 SAP Community Network Blogs SWC_SET_ELEMENT LT_MESSAGE_CONTAINER 'DOCUMENTLANGU' 'E'.rmtiwari. SWC_SET_ELEMENT LT_MESSAGE_CONTAINER 'DOCUMENTNAME' P_DOCTY. APPEND LT_DOC_CONTENT. LT_DOC_CONTENT = '&KEY&http://www. * In case of URLs. * Get Key of new object SWC_GET_OBJECT_KEY LO_MESSAGE LV_MESSAGE_KEY. WHEN 'RAW'. We can now * attach it to our main business object instance. LT_DOC_CONTENT = 'Hi How r u?' . OPEN DATASET PC_FILE FOR INPUT IN BINARY MODE. www. * Create main BO object_a DATA: LO_IS_OBJECT_A TYPE BORIDENT. SWC_SET_TABLE LT_MESSAGE_CONTAINER 'DocumentContent' LT_BINARY. LO_IS_OBJECT_A-OBJKEY = P_BO_ID.com' . SWC_SET_ELEMENT LT_MESSAGE_CONTAINER 'DOCUMENTTYPE' P_MSGTYP. * open dataset p_fname for input in binarymode. CASE P_MSGTYP. SWC_REFRESH_OBJECT LO_MESSAGE..sdn.remember background). * Now we have attachment as a business object instance. LO_IS_OBJECT_A-OBJTYPE = P_BOTYPE.

com/pub/wlg/3399 Thanks. * Check if everything OK. Very helpful weblog 2006-05-09 21:36:30 Ram Manohar Tiwari Business Card [Reply] check out my other weblog. LO_IS_OBJECT_B-OBJKEY = LV_MESSAGE_KEY. Yes. LO_IS_OBJECT_B-OBJTYPE = P_DOCTY.. Ram Very helpful weblog 2006-03-21 08:19:28 SHUI-CHIANG (RAY) Ng Business Card [Reply] Mark. https://weblogs.. CALL FUNCTION 'BINARY_RELATION_CREATE' EXPORTING OBJ_ROLEA = LO_IS_OBJECT_A OBJ_ROLEB = LO_IS_OBJECT_B RELATIONTYPE = P_RELTYP EXCEPTIONS OTHERS = 1. Would you be kindly enough to share your code? Thanks. The macro swc_set_table should be used for multiline attributes ( internal tables ). Ram www.who cares!! COMMIT WORK AND WAIT.com/irj/scn/weblogs?blo… 23/24 . Thanks.sap.21/02/2011 * Create attachment BO object_b SAP Community Network Blogs DATA: LO_IS_OBJECT_B TYPE BORIDENT.sdn.sdn.you are right. Very helpful weblog 2005-11-06 04:17:57 Ram Manohar Tiwari Business Card [Reply] Thanks Mark. * *TRY.. * CALL METHOD cl_binary_relation=>create_link * EXPORTING * is_object_a = lo_is_object_a * is_object_b = lo_is_object_b * ip_reltype = p_reltyp..sap.

21/02/2011 SAP Community Network Blogs Showing messages 1 through 27 of 27. www.sap.com/irj/scn/weblogs?blo… 24/24 .sdn.

Sign up to vote on this title
UsefulNot useful