cancel
Showing results for 
Search instead for 
Did you mean: 

Attach File to Services to Object in VA03 (GOS) from SAP Gateway.

former_member420959
Participant
0 Kudos

Hello,

I have an requirement to select a file from front end and attach it in the Services for Objects of VA03.

For GOS its takes file path as input but we cannot use file path to create an attachment.

Please suggest how we can go ahead with the requirement.

Regards

Ujwal

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Ujwal,

The reason your file is getting damaged because it is damaging the PDF Stream,

replace the following code and it might work

DATA    lt_pdf         TYPE tline_tab.

CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'

     EXPORTING

       buffer          = im_xstring

       append_to_table = c_x

     TABLES

       binary_tab      = lt_pdf.

CALL FUNCTION 'SX_TABLE_LINE_WIDTH_CHANGE'

  TABLES

    content_in                        = lt_pdf

    content_out                       = SOLI_TAB( lt_cont)

EXCEPTIONS

   OTHERS                            = 4.

Regards

Gaurav Ahluwalia

AshwinDutt
Active Contributor
0 Kudos

Hello Ujwal,

Please have a look at the below and check if this can help in providing some idea  ->

Regards,

Ashwin

former_member420959
Participant
0 Kudos

Hi Ashwin,

I am able to attach the document to VA03 but when I try to open it show below error

Where can it be going wrong?

Regards

Ujwal ratakonda

former_member184867
Active Contributor
0 Kudos

Are you passing all the important fields in ls_obj_data () ? Also check if you are passing other input parameter to the FM.

Probably  you can also try class CL_FITV_GOS for file upload

former_member420959
Participant
0 Kudos

Hi Mallik,

please look into my below code, Im writing it inside a function module . I get XSTRINg value in IM_XSTRINg and sales document in IM_VBELN.

DATA :         ls_fol_id     TYPE soodk,

                  ls_obj_id     TYPE soodk,

                  ls_obj_data   TYPE sood1,

                  ls_objhead    TYPE soli,

                  lv_key        TYPE swo_typeid,

                  lv_type       TYPE swo_objtyp,

                  ls_object     TYPE borident,

                  ls_folmem_k   TYPE sofmk,

                  lv_ep_note    TYPE borident-objkey,

                  ls_note       TYPE borident,

                  lv_name       TYPE string,

                  lv_extension  TYPE string,

                  lv_offset     TYPE i,

                  lv_size       TYPE i,

                  lv_temp_len   TYPE i,

                  lv_offset_old TYPE i.

   DATA: lt_doc_content TYPE solix_tab,

         lt_cont        TYPE soli_tab,

         lt_objhead     TYPE STANDARD TABLE OF soli.

*-----Folder Root

   CALL FUNCTION 'SO_FOLDER_ROOT_ID_GET'

     EXPORTING

*     OWNER                 = ' '

       region                = 'B'

     IMPORTING

       folder_id             = ls_fol_id

     EXCEPTIONS

       communication_failure = 1

       owner_not_exist       = 2

       system_failure        = 3

       x_error               = 4

       OTHERS                = 5.

   CHECK sy-subrc = 0.

   CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'

     EXPORTING

       buffer          = im_xstring

       append_to_table = c_x

     TABLES

       binary_tab      = lt_doc_content.

   CALL FUNCTION 'SO_SOLIXTAB_TO_SOLITAB'

     EXPORTING

       ip_solixtab = lt_doc_content

     IMPORTING

       ep_solitab  = lt_cont.

   SPLIT im_fname AT '.' INTO lv_name lv_extension.

   TRANSLATE lv_extension TO UPPER CASE .

   ls_obj_data-objsns    = 'O'.

   ls_obj_data-objla     = sy-langu.

   ls_obj_data-objdes    = lv_name .

   ls_obj_data-file_ext  = lv_extension.

   ls_obj_data-objlen    = lines( lt_doc_content ) * 255.

*  ls_obj_data-objlen  = xstrlen( im_xstring ).

   CONCATENATE '&SO_FILENAME=' lv_name '.' lv_extension INTO ls_objhead-line.

   APPEND ls_objhead TO lt_objhead.

   ls_objhead-line = '&SO_FORMAT=BIN'.

   APPEND ls_objhead TO lt_objhead.

   CALL FUNCTION 'SO_OBJECT_INSERT'

     EXPORTING

       folder_id             = ls_fol_id

       object_type           = 'EXT'

       object_hd_change      = ls_obj_data

     IMPORTING

       object_id             = ls_obj_id

     TABLES

       objhead               = lt_objhead

       objcont               = lt_cont

     EXCEPTIONS

       active_user_not_exist = 35

       folder_not_exist      = 6

       object_type_not_exist = 17

       owner_not_exist       = 22

       parameter_error       = 23

       OTHERS                = 1000.

   IF sy-subrc EQ 0 .

* attach document as GOS attacment to realted bussiness object

     ls_object-objkey  = im_vbeln.

     ls_object-objtype = 'BUS2096'.

     ls_folmem_k-foltp = ls_fol_id-objtp.

     ls_folmem_k-folyr = ls_fol_id-objyr.

     ls_folmem_k-folno = ls_fol_id-objno.

     ls_folmem_k-doctp = ls_obj_id-objtp.

     ls_folmem_k-docyr = ls_obj_id-objyr.

     ls_folmem_k-docno = ls_obj_id-objno.

     lv_ep_note        = ls_folmem_k.

     ls_note-objtype   = 'MESSAGE'.

     ls_note-objkey    = lv_ep_note.

     CALL FUNCTION 'BINARY_RELATION_CREATE_COMMIT'

       EXPORTING

         obj_rolea    = ls_object

         obj_roleb    = ls_note

         relationtype = 'ATTA'

       EXCEPTIONS

         OTHERS       = 1.

     IF sy-subrc = 0.

       CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

         EXPORTING

           wait = c_x.

       COMMIT WORK.

       WAIT UP TO 10 SECONDS.

     ENDIF.

   ENDIF.

former_member184867
Active Contributor
0 Kudos

Not sure, but may be the issue is due to length calculation.

Refer to code from



WHILE lv_offset <= lv_size.
lv_offset_old
= lv_offset.
lv_offset
= lv_offset + 255.
IF lv_offset > lv_size.
lv_temp_len
= xstrlen( is_media_resource-value+lv_offset_old ).

former_member420959
Participant
0 Kudos

Mallik,

Tried with that code too.

Regards

former_member184867
Active Contributor
0 Kudos

Did you try passing ,  "DOCUMENT_TYPE"     parameter for Function module SO_OBJECT_INSERT?

However this is not an issue of Gateway. Due to missing/incorrect parameters in SO_OBJECT_INSERT the file is corrupting.

I would suggest you to post this question in relevant ABAP forums.