GOS Grafik in SAP Adobe Form

Integration of a GOS graphic into an SAP Adobe form

In many SAP objects, Generic Object Services (GOS) can be used to link additional information to the object. In many cases, files (Word documents, Excel sheets), i.a. also graphics are uploaded to the object.

The following section describes how to read a graphic (BMP, JPG, PNG, …) for an SAP object and pass the binary content to the form to be displayed there.

Problem

A graphic from the customer master, here in particular a signature, is to be displayed in an SAP Adobe form “Sales order”. The signature itself was uploaded as an attachment to the generic object service and linked to the customer master. The convention is that the file name of the signature is always the same as the customer number, including leading zeros.

GOS Graik auf SAP Adobe Form

Steps for integrating the GOS graphic in the SAP Adobe form

Step 1) Extend the structure in the form interface

  • Structure is extended by a field of type XSTRING (or RAWDATA)
  • Here, the content of the graphics file is passed to the form as a binary object
SAP GOS Struktur

Step 2) Extend the form context with a graphic node

  • Extension of the form context by a graphic node of type graphic content
SAP Formularkontext

Step 3) Add an image field the form layout

  • Include the signature as an image field in the form layout
SAP Formularlayout

Step 4) Create a function module to read the GOS graphic

  • Transfer of the customer number
  • Return the file contents in a field of type XSTRING
 


SPAN {
font-family: "Courier New";
font-size: 10pt;
color: #000000;
background: #FFFFFF;
}
.L0S31 {
font-style: italic;
color: #808080;
}
.L0S32 {
color: #3399FF;
}
.L0S33 {
color: #4DA619;
}
.L0S52 {
color: #0000FF;
}
.L0S55 {
color: #800080;
}
.L0S70 {
color: #808080;
}

FUNCTION z_le_get_gos_attachment. *”———————————————————————- *”*”Lokale Schnittstelle: *”  IMPORTING *”     VALUE(IV_KUNNR) TYPE  KUNNR OPTIONAL *”  EXPORTING *”     VALUE(EV_GOS_ATTACHMENT) TYPE  XSTRING *”———————————————————————- * Deklarationen —————————————————— *   DATAlt_object    TYPE sibflporbt,         ls_object    LIKE LINE OF lt_object,         lt_links_a   TYPE obl_t_link,         lt_links_b   TYPE obl_t_link,         lt_links     TYPE obl_t_link,         ls_links     LIKE LINE OF lt_links_a,         lv_obj_descr type sofolenti1obj_descr,         lv_doc_id    TYPE sofolenti1doc_id,         lt_obj_head  TYPE TABLE OF solisti1,         lt_obj_cont  TYPE TABLE OF solisti1,         ls_obj_cont  TYPE solisti1,         lt_cont_hex  TYPE TABLE OF solix,         lt_att_list  TYPE TABLE OF soattlsti1,         ls_doc_data  TYPE sofolenti1,         lv_file_cont TYPE xstring,         lv_file_len  TYPE i,         crlf      TYPE string,         itab      TYPE TABLE OF string,         itab2     TYPE TABLE OF string,         lv_string TYPE string.   FIELD-SYMBOLS<f> TYPE any. * Initialisieren —————————————————– *   CLEARev_gos_attachment. * Anlagen zum Objekt ermitteln ————————————— *   ls_objecttypeid ‘BUS2088’.    “Serviceauftrag   ls_objecttypeid ‘KNA1’.       “Debitor master   ls_objectcatid  ‘BO’.   ls_objectinstid iv_kunnr. * 1) Ermitteln der binären Anhänge ———————————– *   TRY.       ” Read the links for business object.       CALL METHOD cl_binary_relation=>read_links_of_binrel         EXPORTING           is_object    ls_object           ip_relation  ‘ATTA’ *         IP_ROLE      = *         IP_PROPNAM   = *         IP_NO_BUFFER = SPACE         IMPORTING           et_links     lt_links.     CATCH cx_obl_parameter_error.     CATCH cx_obl_internal_error .     CATCH cx_obl_model_error .   ENDTRY.   LOOP AT lt_links INTO ls_links.     MOVEls_linksinstid_b TO lv_doc_id,           iv_kunnr          to lv_obj_descr.     CALL FUNCTION ‘SO_DOCUMENT_READ_API1’       EXPORTING         document_id                lv_doc_id *       FILTER                     = ‘X ‘       IMPORTING         document_data              ls_doc_data       TABLES         object_header              lt_obj_head         object_content             lt_obj_cont         attachment_list            lt_att_list         contents_hex               lt_cont_hex       EXCEPTIONS         document_id_not_exist      1         operation_no_authorization 2         x_error                    3         OTHERS                     4.     check ls_doc_dataobj_descr lv_obj_descr.     “Convert to XString     lv_file_len ls_doc_datadoc_size.     CALL FUNCTION ‘SCMS_BINARY_TO_XSTRING’       EXPORTING         input_length lv_file_len       IMPORTING         buffer       lv_file_cont       TABLES         binary_tab   lt_cont_hex       EXCEPTIONS         failed       1         OTHERS       2.     CHECK sysubrc 0.     ev_gos_attachment lv_file_cont.     exit.   ENDLOOP. ENDFUNCTION.

The function module can now be integrated into the print program to fill the field of type XSTRING to transfer the file to the form.

More information

 

SAP forms at a fixed price

SAP form development

Special topics on SAP Forms