Application Development and Automation 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 Image Attachment to send via EMAIL

Former Member
0 Kudos
4,675

Hi,

I have a requirement to send GOS "IMAGE" attachment uploaded via QM01/02/03 via email to vendor.

I have used FM 'SO_OBJECT_READ' and i am able to attach image in mail and send.

But my when i open attachment in SOST and via MAIL it is showing No Preview Available.

Please help me here.

I have a urgent requirement.

Thanks,

Riya

1 ACCEPTED SOLUTION

former_member235395
Contributor
0 Kudos
2,867

Hi Riya,

When do you attach a file using GOS, this file is save on table SRGBTBREL.

You can use the method DISPLAY_ATTACHMENT of cl_gos_document_service class for display the attached file on GOS.

Do you can get this file using the method:

Use this method and FM

call method cl_binary_relation=>read_links

        exporting

          is_object           = gs_lpor

          it_relation_options = lt_relat

        importing

          et_links            = t_links.

MOVE s_links-instid_b TO lv_document_id.

* Read the data

        CALL FUNCTION 'SO_DOCUMENT_READ_API1'

          EXPORTING

            document_id                = lv_document_id

          IMPORTING

            document_data              = lwa_document_data

          TABLES

            contents_hex               = lt_hex

            object_content             = lt_content

          EXCEPTIONS

            document_id_not_exist      = 1

            operation_no_authorization = 2

            x_error                    = 3

            OTHERS                     = 4.

Use class for send the email with your attachment(doc, xls, jpeg, etc.)

cl_document_bcs, cl_bcs,

Regards,

18 REPLIES 18

Former Member
0 Kudos
2,867

hi riya ,

      Try this link

ronaldo_aparecido
Contributor

Former Member
0 Kudos
2,867

Hi,

I dont want to add image in mail body, rather i want to sent images as attachment via email.

Can anyone let me know is SO_OBJECT_READ can read image?

Or do any other FM reads images from Generic Object Services(GOS)?

Please help here.

Thanks.

former_member235395
Contributor
0 Kudos
2,868

Hi Riya,

When do you attach a file using GOS, this file is save on table SRGBTBREL.

You can use the method DISPLAY_ATTACHMENT of cl_gos_document_service class for display the attached file on GOS.

Do you can get this file using the method:

Use this method and FM

call method cl_binary_relation=>read_links

        exporting

          is_object           = gs_lpor

          it_relation_options = lt_relat

        importing

          et_links            = t_links.

MOVE s_links-instid_b TO lv_document_id.

* Read the data

        CALL FUNCTION 'SO_DOCUMENT_READ_API1'

          EXPORTING

            document_id                = lv_document_id

          IMPORTING

            document_data              = lwa_document_data

          TABLES

            contents_hex               = lt_hex

            object_content             = lt_content

          EXCEPTIONS

            document_id_not_exist      = 1

            operation_no_authorization = 2

            x_error                    = 3

            OTHERS                     = 4.

Use class for send the email with your attachment(doc, xls, jpeg, etc.)

cl_document_bcs, cl_bcs,

Regards,

2,867

Hi David,

You mentioned below sentence:

"You can use the method DISPLAY_ATTACHMENT of cl_gos_document_service class for display the attached file on GOS."


"Use class for send the email with your attachment(doc, xls, jpeg, etc.)

cl_document_bcs, cl_bcs,"


Can you  please give more details on this.

0 Kudos
2,867

Hi David,

I have used cl_binary_relation=>read_links and function SO_DOCUMENT_READ_API1

and passed attachment to FM SO_DOCUMENT_READ_API1 to send mail.

But again when i open image it shows "No Preview Available".

Please help.

0 Kudos
2,867

Please any inputs on this?

How to read BMP attachments from GOS?

2,867

Hi,

a part of example :

* Alimentation de la clef.

  MOVE : 'I'          TO is_role-sign ,
         'EQ'         TO is_role-option ,
         'GOSAPPLOBJ' TO is_role-low.
  APPEND is_role TO it_roles.
  MOVE : 'I'          TO is_relation-sign ,
         'EQ'         TO is_relation-option ,
         'ATTA'       TO is_relation-low .
  APPEND is_relation TO it_relations.
  MOVE : 'BIN' TO w_file_type.

*   Extraction des liens.

  TRY.
      CALL METHOD cl_binary_relation=>read_links_of_objects
        EXPORTING
          it_objects          = it_objects
          it_role_options     = it_roles
          it_relation_options = it_relations
        IMPORTING
          et_links_a          = it_link.
    CATCH cx_obl_model_error.
    CATCH cx_obl_parameter_error.
    CATCH cx_obl_internal_error.
  ENDTRY.

* Boucle sur les docs.

  MOVE w_cpt TO w_num.
  LOOP AT it_link
       INTO is_link.

*   Petit nom

    MOVE is_link-instid_b TO w_doc_id.
    MOVE '_' TO w_numc+0(1).
    w_num = w_num + 1.
    WRITE w_num+1(2) TO w_numc+1(2).

*   Extraction du contenu.

    CALL FUNCTION 'SO_DOCUMENT_READ_API1'
      EXPORTING
        document_id                = w_doc_id
      IMPORTING
        document_data              = is_doc_data
      TABLES
        contents_hex               = it_contentx
      EXCEPTIONS
        document_id_not_exist      = 1
        operation_no_authorization = 2
        x_error                    = 3
        OTHERS                     = 4.
    CONCATENATE is_cert-vbdpl-charg
                w_numc
                '.'
                is_doc_data-obj_type
                INTO w_file.
    CONCATENATE is_cert-vbdpl-charg
                w_numc
                '.'
                is_doc_data-obj_type
                INTO w_content_id.
    CLEAR w_content_type.

    w_obj_len      = is_doc_data-doc_size.

    CALL METHOD obj_doc->add_attachment
      EXPORTING
        i_attachment_type    = is_doc_data-obj_type
        i_attachment_subject = w_file
        i_attachment_size    = w_obj_len
        i_att_content_hex    = it_contentx.

regards

Fred

0 Kudos
2,867

Hi,

I am trying this method.

Where to specify email id? Any FM or class to be called after calling METHOD obj_doc->add_attachment?


Also i am getting error as  it_contentx is not type compatible with formal parameter  i_att_content_hex .


I have declared it_contentx as type solix occurs 0 with header line.


Please suggest.

0 Kudos
2,867

Have a look to this example for sending mail using Oo

Fred

0 Kudos
2,867

Hi,

Can anyone guide me how to convert jpeg into pdf in sap.

Thanks.

0 Kudos
2,867

Hi,

you can't you have to use an external program like ImageMagick 

regards

Fred

0 Kudos
2,867

My problem got resolved.

I have used CL_BCS class.

For reference: https://scn.sap.com/thread/3466624

Thanks for all your replies.

0 Kudos
2,867

Hi Riya,

if you could post a little explanation for people who will have the same issue

regards

Fred

0 Kudos
2,867

Thank you so much David and Fred. I solved my issue. I'm so happy, now.

ronaldo_aparecido
Contributor
0 Kudos
2,867

Plase See if this link help.

http://scn.sap.com/thread/418363

0 Kudos
2,494

Hi Riya,

I have a urgent requirement.

Can you send me the solution how you solved the problem i have the same requirement .could you please help 

Thanks 

Vijay