cancel
Showing results for 
Search instead for 
Did you mean: 

Upload attacment to IW22 via Process Integration

Former Member
0 Kudos

Dear Experts,

I have some problem when I upload attachment from PI for type file that has more than 3 characters, like : .xlsx and .docx . Others type like .txt, .xls, .doc are fine.

When I upload the 'more than 3 chars file type' from IW22 it won't have any problems.

Is there any special condition I have to attach in my code for uploading those files? Or something must doing first for uploading office 2007 files?

When I was debuging the program IW22, I found that the program call the Form 'loio_content_insert'. It is ok when I try to upload the file from SAP GUI (IW22), but when I upload from PI, the Form result in an error, because I cannot supply the Path File....

Any helpfull answer will be really appriciated...

Thank you

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hello,

Could you provide more details/info about your actual scenario ? How do you upload these files thru PI : custom code ? What error/issue do you get ?

Chris

Former Member
0 Kudos

I try to upload the file from PI, then it calls my custom Function Module. When I insert file like .txt, .doc, and .xls. The file saved and can be opened successfully. But when I try with .xlsx file, then the file can be saved but when I opened it, the excel gave me a warning message like :

"Excel find unreadable content in 'File_Name.xlsx'. Do you want to recover the contents of this workbook? If you trust the source of this workbook, click Yes"

This is my source code

==========================================================================================

 
 CONSTANTS so_format(11) VALUE '&SO_FORMAT='.

  DATA fol_id        LIKE soodk.
  DATA doc_id        LIKE soodk.
  DATA att_id        LIKE soodk.
  DATA hd_dat        LIKE sood1.
  DATA fm_dat        LIKE sofm1.
  DATA obj_type      LIKE soodk-objtp.
  DATA new_doc_id    LIKE soodk.
  DATA new_att_id    LIKE soodk.
  DATA new_hd_dat    LIKE sood2.
  DATA new_fm_dat    LIKE sofm2.
  DATA file_format   LIKE rlgrap-filetype.
  DATA object_type   LIKE soodk-objtp.
*  data path_and_file like rlgrap-filename.
*  data l_filename    like rlgrap-filename.
  DATA path_and_file TYPE string.
  DATA l_filename    TYPE string.
  DATA it_content LIKE STANDARD TABLE OF soli.
  DATA p_objhead  LIKE STANDARD TABLE OF soli.
  DATA p_objpara LIKE STANDARD TABLE OF selc.
  DATA p_objparb LIKE STANDARD TABLE OF soop1.
  DATA ls_object TYPE borident.
  DATA ls_folmem_k TYPE sofmk.
  DATA ls_note TYPE borident.
  DATA lv_ep_note TYPE borident-objkey.
  DATA lv_len TYPE i.
  DATA wa_content LIKE soli.
  DATA lv_lines TYPE i.
  DATA lv_last_len TYPE i.
  DATA loio_object LIKE sdokobject.
  DATA filelength_xl     TYPE i.
  DATA rcode             TYPE i.

  ls_object-objkey = notif_no.
*      ls_object-objtype = 'BUS2038'.
  ls_object-objtype = objtype.

  file_format = 'ASC'.

  CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
    EXPORTING
      buffer                = binary_file
*   APPEND_TO_TABLE       = ' '
 IMPORTING
   output_length         = lv_len
    TABLES
      binary_tab            = it_content.

  CALL FUNCTION 'SO_FOLDER_ROOT_ID_GET'
    EXPORTING
      region    = 'B'
    IMPORTING
      folder_id = fol_id
    EXCEPTIONS
      OTHERS    = 1.

  CLEAR: p_objhead, p_objhead[].
  PERFORM objhead_param_set IN PROGRAM sapfssoa             "946660
                            USING '&SO_FILENAME' file_name
                         CHANGING p_objhead[].
  PERFORM objhead_param_set IN PROGRAM sapfssoa
                            USING so_format file_format
                         CHANGING p_objhead[].

  PERFORM so_split_file_and_extension(saplso30)
                            USING file_name
                                  hd_dat-objdes
                                  object_type.
  hd_dat-objpri = 5.
  hd_dat-objlen = LINES( it_content ) * 255.
  hd_dat-file_ext = object_type.

  lv_lines = LINES( it_content ).
  lv_last_len =  lv_len - ( lv_lines - 1 ) * 255.
  READ TABLE it_content INTO wa_content INDEX lv_lines.
  IF lv_lines = 1.
    wa_content-line = wa_content-line+0(lv_len).
  ELSE.
    wa_content-line = wa_content-line+0(lv_last_len).
  ENDIF.
  IF it_content IS NOT INITIAL.
    MODIFY it_content INDEX lv_lines FROM wa_content
    TRANSPORTING line.
  ENDIF.


  CALL FUNCTION 'SO_OBJECT_INSERT'
    EXPORTING
      folder_id                  = fol_id
      object_type                = 'EXT'
      object_hd_change           = hd_dat
      object_fl_change           = fm_dat
    IMPORTING
      object_id                  = new_doc_id
      object_hd_display          = new_hd_dat
      object_fl_display          = new_fm_dat
    TABLES
      objcont                    = it_content
      objhead                    = p_objhead
      objpara                    = p_objpara
      objparb                    = p_objparb
    EXCEPTIONS
      active_user_not_exist      = 35
      communication_failure      = 71
      component_not_available    = 1
      dl_name_exist              = 3
      folder_no_authorization    = 5
      folder_not_exist           = 6
      object_type_not_exist      = 17
      operation_no_authorization = 21
      owner_not_exist            = 22
      parameter_error            = 23
      substitute_not_active      = 31
      substitute_not_defined     = 32
      system_failure             = 72
      x_error                    = 1000.

  IF sy-subrc = 0 AND ls_object-objkey IS NOT INITIAL.
    ls_folmem_k-foltp = fol_id-objtp.
    ls_folmem_k-folyr = fol_id-objyr.
    ls_folmem_k-folno = fol_id-objno.
    ls_folmem_k-doctp = new_doc_id-objtp.
    ls_folmem_k-docyr = new_doc_id-objyr.
    ls_folmem_k-docno = new_doc_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.
  ELSE.
    msg = 'Upload Not Success'.
    RETURN.
  ENDIF.

  IF sy-subrc = 0.
    msg = 'Upload Success'.
  ELSE.
    msg = 'Upload Not Success'.
  ENDIF.

==========================================================================================

Edited by: . Febrian on Mar 23, 2011 3:38 PM

Edited by: . Febrian on Mar 23, 2011 3:38 PM

Former Member
0 Kudos

Not sure it's only a matter of extension ... Maybe SAP does not know how to internally handle/store the new O2K7 formats (xlsx and docx) ? Or does your code need some change to deal with such format (any ABAPers out there ?) ?

Chris

PS: not sure it's only a matter of frontend, but this OSS note could be interesting #1286768 ! A lot of notes deal with these new formats as well ...

Edited by: Christophe PFERTZEL on Mar 23, 2011 4:50 PM

Former Member
0 Kudos

Actually, the IW22 can save the upload successfully. It was because they call this Form :

'loio_content_insert' . That Form store the file in logical IO first. I didn't call this form in my custom code.

I could not add this form either, because of this form required a parameter called Path and File Name, and from PI, I could only provide the file name but not the path name.

Edited by: . Febrian on Mar 23, 2011 11:30 PM

Former Member
0 Kudos

Dear experts,

Did anyone has some similar problem like me? did anyone have a hint how to solve it?