Skip to Content
0
Former Member
Oct 14, 2010 at 02:37 PM

IW52 add attachment converted to binary

81 Views

Hello,

I'm currently trying to attach to SAP, on transaction IW52, a file that is sent from a web portal. This file is sent on the format of XTRING, which then i convert it to binary and upload into SAP.

When going into transaction IW52 the attachment appears, which means that i can attach it, but the problem is when i'm trying to open it which instead of performing a display of the document it asks me for a path to save the file.

I can handle the saving part changing a variable (EXTCT) from value 'K' to ' ', which is suposed to control the display of the file, but when i set it up to space (' ') it opens the file, but without any content.

Technical details:

The web portal sends the file in a variable of the type XTRING which in SAP (using FM SCMS_XTRING_TO_BINARY) is converted into binary and then using FM SO_OBJECT_INSERT is attached to transaction IW52.

Part of the code is displayed bellow:

lv_type = 'EXT'.

            CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
              EXPORTING
                buffer        = im_path_portal
              IMPORTING
                output_length = bytecount
              TABLES
                binary_tab    = file_tab.

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

            SPLIT im_path AT '.' INTO object_hd_change-objdes
                                      object_hd_change-file_ext.
            object_hd_change-extct = 'K'.
            object_hd_change-objlen = bytecount.

            CALL FUNCTION 'SO_OBJECT_INSERT'
              EXPORTING
                folder_id                  = folder_id
                object_type                = lv_type
                object_hd_change           = object_hd_change
              IMPORTING
                object_id                  = object_id
                object_hd_display          = object_hd_display
                object_fl_display          = object_fl_display
              TABLES
                objcont                    = file_tab
                objhead                    = objhead
              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.
          ENDIF.

          IF sy-subrc EQ 0.
            is_object-objkey = im_qmnum.
            is_object-objtype = 'BUS2080'.

            CONCATENATE folder_id object_id
              INTO attachement-objkey.
            attachement-objtype = 'MESSAGE'.

            CALL FUNCTION 'BINARY_RELATION_CREATE_COMMIT'
              EXPORTING
                obj_rolea      = is_object
                obj_roleb      = attachement
                relationtype   = 'ATTA'
              EXCEPTIONS
                no_model       = 1
                internal_error = 2
                unknown        = 3
                OTHERS         = 4.
            IF sy-subrc EQ 0.
            ELSE.
              conversion_out im_qmnum im_qmnum.
              tab_return-msgtyp = 'E'.
              CONCATENATE 'Erro a anexar ficheiro' im_path
                          'a nota de serviço' im_qmnum
                          INTO tab_return-msgv1
                          SEPARATED BY space.
              APPEND tab_return.
              lv_error = 'X'.
            ENDIF.
          ELSE.
            conversion_out im_qmnum im_qmnum.
            tab_return-msgtyp = 'E'.
            CONCATENATE 'Erro a anexar ficheiro' im_path
                        'a nota de serviço' im_qmnum
                        INTO tab_return-msgv1
                        SEPARATED BY space.
            APPEND tab_return.
            lv_error = 'X'.
          ENDIF.

Does anybody knows how i can handle this?

Edited by: Smitholic on Oct 14, 2010 4:41 PM