Skip to Content
0

Print documents in External weblinks in GOS

May 02, 2017 at 05:13 PM

113

avatar image

Hi All,

The requirement is to print the documents attached in MM03 which are saved as external links (URL) in SAP.

Is there any standard procedure for this ?

How can this be achieved.

Regards,

Vamshi.

10 |10000 characters needed characters left characters exceeded

Could you please tell us which kind of URL you have? (http?)

Is the SAP system able to reach this URL? (RSICFCLTST01 program for instance, or create a program which uses CL_HTTP_* classes - refer to the forum/SAP library)

What are the types of files to be printed? (for instance, you cannot send directly a Word document to a printer, there must be a software to convert it to the language of the printer)

How do the client print these documents until now?

0
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Jelena Perfiljeva
May 02, 2017 at 05:36 PM
2

Short answer is "no", there is no standard process. Simply opening a link in browser and using the browser's print feature seems like an obvious low-cost solution.

If something more robust is expected (why?) then I believe it's out of scope of this question and free SCN consulting.

Show 4 Share
10 |10000 characters needed characters left characters exceeded

Hi Jelena,

The customer is expecting to print the attachments at once or at least one by one. But there is no such option in the GOS menu. It understood ABAP development can be done to print the attachments. Now trying to understand how to download the documents from the external links and print those.

Regards,

Vamshi.

0

Attachment and URL are two different types of object. You said "URL" in the original question, now you're saying "attachments". Might want to get the story straight. Either way, search a bit harder in Google, lots of GOS questions have already been covered on SCN over the years.

0

Hi Vamsi,

we came across the same requirement to download the attachments for sales order. Please find the below code for your reference.


TYPE-POOLS : abap.
*Structure Declarations
TYPES : BEGIN OF gty_attach,
         brelguid	TYPE os_guid,
         reltype  TYPE oblreltype,
         instid_a TYPE sibfboriid,
         typeid_a TYPE sibftypeid,
         catid_a  TYPE sibfcatid,
         instid_b TYPE sibfboriid,
         typeid_b TYPE sibftypeid,
        END OF gty_attach,
       BEGIN  OF gty_vbkd,
         vbeln    TYPE vbeln,
         bstkd    TYPE bstkd,
        END OF gty_vbkd,                     
*Internal Table and work area declarations
DATA : gt_attach    TYPE TABLE OF gty_attach,
       gw_attach    TYPE gty_attach,
       gt_vbkd      TYPE TABLE OF gty_vbkd,
       gw_vbkd      TYPE gty_vbkd,
       gt_objcont   TYPE TABLE OF soli,
       gw_fol_id    TYPE soodk,
       gw_doc_id    TYPE soodk,
       g_path       TYPE char255,
       g_comp_id    TYPE char255,
       gw_bor_id    TYPE swotobjid,
       g_descript   TYPE sdok_descr,
       gw_docuclass TYPE bdn_con-docuclass,
       g_count      TYPE i.

*Constants Declarations
CONSTANTS : c_reltyp   TYPE oblreltype   VALUE 'ATTA',
            c_objtyp   TYPE sibftypeid   VALUE 'BUS2032',
            c_cate     TYPE sibfcatid    VALUE 'BO',
            c_file     TYPE string       VALUE 'C:\SO Data\'. "#EC NOTEXT
*selection screen declarations
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-t01.
SELECT-OPTIONS : s_vbeln FOR gw_vbkd-vbeln.          
SELECTION-SCREEN END OF BLOCK b1.

*Selection screen validation
AT SELECTION-SCREEN.
  PERFORM vali_sel_screen.

*Start of selection declarations
START-OF-SELECTION.
  PERFORM get_attach_orders.

  IF g_count > 10000.

    MESSAGE text-i01 TYPE 'I'.

  ELSE.
 
      PERFORM pop_data.

  ENDIF.
*&---------------------------------------------------------------------*
*&      Form  VALI_SEL_SCREEN
*&---------------------------------------------------------------------*
*       this routine is validate selection screen
*----------------------------------------------------------------------*
FORM vali_sel_screen .

      SELECT instid_a
             FROM srgbtbrel
             UP TO 1 ROWS
             INTO gw_attach-instid_a
             WHERE instid_a IN s_vbeln.
      ENDSELECT.

      IF  sy-subrc <> 0.
        MESSAGE text-e01 TYPE 'E'.

     ENDIF.

ENDFORM.                    " VALI_SEL_SCREEN
*&---------------------------------------------------------------------*
*&      Form  GET_ATTACH_ORDERS
*&---------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
FORM get_attach_orders .
      SELECT   brelguid
               reltype
               instid_a
               typeid_a
               catid_a
               instid_b
               typeid_b
               FROM srgbtbrel
               INTO TABLE gt_attach
               WHERE reltype  = c_reltyp
               AND   instid_a IN s_vbeln
               AND   typeid_a = c_objtyp
               AND   catid_a  = c_cate.

      g_count = sy-dbcnt.
      IF  sy-subrc = 0.

       SELECT vbeln
               bstkd
               FROM vbkd
               INTO TABLE gt_vbkd
               FOR ALL ENTRIES IN gt_attach
               WHERE vbeln = gt_attach-instid_a+0(10).

      ENDIF.

ENDFORM.                    " GET_ATTACH_ORDERS
*&---------------------------------------------------------------------*
*&      Form  POP_DATA
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM pop_data .
  SORT : gt_attach BY instid_a,
         gt_vbkd   BY vbeln.

  LOOP AT gt_attach INTO gw_attach.
    MOVE gw_attach-instid_b        TO gw_fol_id.
    MOVE gw_attach-instid_b+17(25) TO gw_doc_id.

    gw_bor_id-objtype = gw_attach-typeid_b.
    gw_bor_id-objkey  = gw_attach-instid_b.

    CALL FUNCTION 'SNOTE_TOOL_GET_GOS_INFOS'
      EXPORTING
        bor_id             = gw_bor_id
      IMPORTING
        descript           = g_descript
        docuclass          = gw_docuclass
      EXCEPTIONS
        internal_error     = 1
        internal_gos_error = 2
        OTHERS             = 3.

    CALL FUNCTION 'SO_OBJECT_READ'
      EXPORTING
        folder_id                  = gw_fol_id
        object_id                  = gw_doc_id
      TABLES
        objcont                    = gt_objcont
      EXCEPTIONS
        active_user_not_exist      = 1
        communication_failure      = 2
        component_not_available    = 3
        folder_not_exist           = 4
        folder_no_authorization    = 5
        object_not_exist           = 6
        object_no_authorization    = 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.

   CLEAR gw_vbkd.
    READ TABLE gt_vbkd INTO gw_vbkd
                       WITH KEY vbeln = gw_attach-instid_a+0(10)
                       BINARY SEARCH.

    IF sy-subrc = 0.

      IF gw_vbkd-bstkd CA '/'.

        REPLACE ALL OCCURRENCES OF '/' IN gw_vbkd-bstkd WITH space.

      ENDIF.

    ENDIF.

    CONCATENATE c_file
                gw_attach-instid_a
                '_'
                gw_vbkd-bstkd
                '_'
                g_descript
                '.'
                gw_docuclass
                INTO g_path.


    CONCATENATE gw_attach-instid_a
                '.'
                gw_docuclass
                INTO g_comp_id .

    CALL FUNCTION 'SO_OBJECT_DOWNLOAD'
      EXPORTING
        default_filename = g_comp_id
        filetype         = 'BIN'
        path_and_file    = g_path
        extct            = 'K'
        no_dialog        = 'X'
      TABLES
        objcont          = gt_objcont
      EXCEPTIONS
        file_write_error = 1
        invalid_type     = 2
        x_error          = 3
        kpro_error       = 4
        OTHERS           = 5.

    IF sy-subrc = 0.

      MESSAGE text-t02 TYPE 'S'.

    ENDIF.
  ENDLOOP.

ENDFORM.                    " POP_DATA



Regards.
Sridhar.A

1

Hi Sridhar,

Thank you for your inputs. This code works well for documents of type ATTA (Attachments). Your reply is surely helpful.

The problem is when the list has some URL (External Links). These links are nothing but addresses of some documents. Those documents are to be printed onto SAP printer.

Regards,

Vamshi.

0