Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

GOS, programmatically changing the URL attachment

Former Member
0 Kudos

Hello all,

I just started working on a project that will use generic object services to attach a URL to a business object. Programmatically I have determined how to create a URL attachment, delete the URL attachment, and create a report listing all of the URLs titles.

I'm having A much harder time trying to determine how to programmatically change the URL. I have some code that will display a list of the URLs. But I don't know how to actually change the value of the URL. I'm sure that at some point in the future we will need this functionality due to some change in the system where the URLs are stored.

Change www.OLD.document.pdf

to www.NEW.document.pdf.

Has anyone done this.

This is the code that I'm using to create a list of the actual URLs.

  • Include for BO macros

INCLUDE : <cntn01>.

PARAMETERS:

p_botype like borident-objtype default 'BUS3006',

p_bo_id like borident-objkey default '100 0001000012',

p_reltyp like breltyp-reltype default 'URL'.

DATA: lo_is_object_a TYPE sibflporb,

lt_links TYPE obl_t_link,

wa_links LIKE LINE OF lt_links.

DATA : lt_rel TYPE obl_t_relt,

wa_rel LIKE LINE OF lt_rel.

lo_is_object_a-instid = p_bo_id.

lo_is_object_a-typeid = p_botype.

lo_is_object_a-catid = 'BO'.

wa_rel-sign = 'I'.

wa_rel-option = 'EQ'.

wa_rel-low = p_reltyp.

APPEND wa_rel TO lt_rel.

*

CALL METHOD cl_binary_relation=>read_links

EXPORTING

is_object = lo_is_object_a

  • IP_LOGSYS =

  • IT_ROLE_OPTIONS =

it_relation_options = lt_rel

  • IP_NO_BUFFER = SPACE

IMPORTING

et_links = lt_links

  • ET_ROLES =

.

*

DATA : lv_document_id TYPE sofolenti1-doc_id.

DATA : lt_header TYPE STANDARD TABLE OF solisti1 WITH HEADER LINE,

lt_content TYPE STANDARD TABLE OF solisti1 WITH HEADER LINE.

DATA: i_attachment_list TYPE soattlsti1 OCCURS 0.

*

LOOP AT lt_links INTO wa_links WHERE typeid_b = 'MESSAGE'.

*

SKIP 1.

WRITE: '>>> lt_links ITAB <<<'.

SKIP 1.

MOVE wa_links-instid_b TO lv_document_id.

*

CALL FUNCTION 'SO_DOCUMENT_READ_API1'

EXPORTING

document_id = lv_document_id

  • FILTER = 'X '

  • IMPORTING

  • DOCUMENT_DATA =

TABLES

object_header = lt_header

object_content = lt_content

  • OBJECT_PARA =

  • OBJECT_PARB =

attachment_list = i_attachment_list

  • RECEIVER_LIST =

  • CONTENTS_HEX =

EXCEPTIONS

document_id_not_exist = 1

operation_no_authorization = 2

x_error = 3

OTHERS = 4

.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

LOOP AT lt_header.

WRITE /: 'Header ', lt_header.

SKIP 1.

ENDLOOP.

LOOP AT lt_content.

WRITE /: 'Content', lt_content.

ENDLOOP.

*

ENDLOOP. " lt_links INTO wa_links WHERE typeid_b = 'MESSAGE'.

Thanks

Bruce

7 REPLIES 7

Former Member

Use function module SO_OBJECT_UPDATE to update URL value.

Former Member
0 Kudos

Ken,

I have not determined how to use the function module "SO_OBJECT_UPDATE" to change a URL from the existing value to a new value.

ex.

www.OLD.com

to

www.NEW.com.

Do you have a code example that uses this FM to make the change?

Thanks

Bruce

Edited by: Bruce Tjosvold on Apr 21, 2008 1:08 PM

Former Member
0 Kudos

Thanks

Bruce

0 Kudos

Hi Bruce,

May i know how you resolved the probem. I also have same scenario as you, Hope you can help me.

Thanks.

Former Member
0 Kudos

Hi,

I have used the FM 'SO_DOCUMENT_UPDATE_API1' to change the URL.

Although it changes the URL, when i try to open it from FB03, it throws a HTTP404 error and says the page cannot be found.

Initially before changing the URL, when the URL was just opened in the browser it worked fine but when launching from FB03 it doesn't work.

has anyone faced such a situation before, please provide the solution.

P.S: SO_OBJECT_UPDATE is used internally within the FM 'SO_DOCUMENT_UPDATE_API1'.

Also what i have noticed is that once the URL was changed using the FM, and the error pops up, if i try to open this URL in the IE Browser then it doesn't work (prior to the change it worked perfectly fine when it was entered in the browser directly ).

SO_OBJECT_UPDATE works perfectly to change the URLs.

But if you are going bottom up ,

Start from SRGBTBREL (with docu no + Business object) ---> ---> SOOD to get the right attachments selected  (Basically Title) and then pass it to SO_OBJECT_UPDATE.

Thanks for the heads up information.

Best regards,

Dilip

Additionally , you can use the class : CL_GOS_API

*&---------------------------------------------------------------------*

*& Report ZDIL_CHANGE_ATTACHMENT

*&---------------------------------------------------------------------*

*&

*&---------------------------------------------------------------------*

REPORT zdil_change_attachment.

PARAMETERS p_bo TYPE sibftypeid DEFAULT 'BUS2012'.

PARAMETERS p_key TYPE sibfboriid DEFAULT '4500000000'.

PARAMETERS p_title TYPE string DEFAULT 'TEST'.

PARAMETERS url TYPE string.

DATA ls_object TYPE gos_s_obj.

ls_object-typeid = p_bo.

ls_object-instid = p_key.

ls_object-catid  = 'BO'.

DATA(lo_ins) = cl_gos_api=>create_instance( ls_object ).

SELECT SINGLE instid_b FROM srgbtbrel WHERE reltype = 'URL' AND

                                      instid_a = @p_key AND

                                      typeid_a = @p_bo AND

                                      typeid_b = 'MESSAGE'

   INTO @DATA(lv_atta_id).

*  DATA(lt_att_list) = lo_ins->get_atta_list( ).

DATA ls_atta_key TYPE gos_s_attkey.

ls_atta_key-atta_id = lv_atta_id.

ls_atta_key-atta_cat = 'MSG'.

DATA(ls_att_cont) = lo_ins->get_al_item( ls_atta_key ).

ls_att_cont-content = url.

lo_ins->update_al_item( is_attcont = ls_att_cont ).