Application Development and Automation Blog Posts
Learn and share on deeper, cross technology development topics such as integration and connectivity, automation, cloud extensibility, developing at scale, and security.
cancel
Showing results for 
Search instead for 
Did you mean: 
Abhijit74
Active Contributor
20,929

abhijit.mandal2/avatar/24.png?a=6389 Purpose & Overview: There are lot of threads, wiki’s and blogs available about GOS. Reading and downloading GOS attachment and also we will find lots of article on how to attach a document into GOS.

But there are not many documents which describes the complete cycle of reading GOS object and display it into adobe form dynamically. The idea of this document is to build a complete cycle of reading a GOS attachment and then embed it into SAP Adobe form.

Limitations & Restrictions: This document is to read GOS picture attachments and embedding it into SAP adobe form. As, I have tried for reading a .PDF GOS attachment and embedding it into SAP Adobe form but as per my knowledge SAP doesn’t provide such solutions till now. So, this is restricted to picture format (.JPG, .GIF, .BMP and .PNG etc.). For (.TIFF & .TIF) picture format first we have to convert from .TIF to .JPG format.   

Business Requirement & Descriptions: In this document I will read GOS attachments which are quality certificates and display the quality certificates into SAP Adobe form. This is applicable for other transactions which have got generic object service.

Create a structure & table type which will be sent to SAP adobe form as an import parameter.

Create table type:

Building the program:


REPORT  zabhi_gos_attachment_read.

DATAlv_lgsystm    TYPE logsys,
       lv_line      
TYPE i,
       lv_input_len 
TYPE i,
       ls_connection
TYPE bdn_con,
       lv_docid     
TYPE so_entryid,
       lv_objkey    
TYPE swo_typeid,
       ls_doc_data  
TYPE sofolenti1,
       ls_certattach
TYPE ztst_itab,
       lv_string    
TYPE xstring.


DATAlt_connection TYPE STANDARD TABLE OF bdn_con,
       lt_content   
TYPE STANDARD TABLE OF solisti1,
       lt_cont_hex  
TYPE STANDARD TABLE OF solix,
       lt_attachment
TYPE ztst_tt_itab.

FIELD-SYMBOLS<lfs_connection> TYPE bdn_con.

 
CLEAR: lv_lgsystm,
       lv_input_len
,
       lv_line
.



* Build selection screen



SELECTION-SCREEN BEGIN OF BLOCK b1.
PARAMETERS: p_bo   TYPE bds_clsnam OBLIGATORY DEFAULT 'BUS2117',
            p_cert
TYPE qcpr-certno OBLIGATORY.
SELECTION-SCREEN END OF BLOCK b1.

START-OF-SELECTION.
* To Get own logical system


CALL FUNCTION 'OWN_LOGICAL_SYSTEM_GET'
     IMPORTING
      own_logical_system            
= lv_lgsystm
     EXCEPTIONS
      own_logical_system_not_defined
= 1
            OTHERS                                                = 2.
     IF sy-subrc <> 0.
     
CLEAR lv_lgsystm .
     ENDIF.

* Retrieves list of attachment (quality certificate images) details through BDS_GOS_CONNECTIONS_GET function module .



CLEAR lv_objkey.
MOVE p_cert TO lv_objkey.

CALL FUNCTION 'BDS_GOS_CONNECTIONS_GET'
     EXPORTING
      logical_system    
= lv_lgsystm
      classname         
= p_bo
      objkey            
= lv_objkey

     TABLES
      gos_connections   
= lt_connection[]
     EXCEPTIONS
      no_objects_found  
= 1
      internal_error    
= 2
      internal_gos_error
= 3
     
OTHERS                         = 4.
     IF sy-subrc = 0.
     
SORT lt_connection .
     ENDIF.

LOOP AT lt_connection ASSIGNING <lfs_connection>.



     
TRANSLATE <lfs_connection>-docuclass TO UPPER CASE.
     
MOVE <lfs_connection>-loio_id TO lv_docid.

* Reading the content of the image file. Internal table lt_cont_hex is the converted binary format of the image is    generating.



CALL FUNCTION 'SO_DOCUMENT_READ_API1'
     
EXPORTING
           document_id                
= lv_docid
     
IMPORTING
           document_data              
= ls_doc_data
     
TABLES
            object_content            
= lt_content[]
            contents_hex              
= lt_cont_hex[]
     
EXCEPTIONS
            document_id_not_exist     
= 1
            operation_no_authorization
= 2
            x_error                   
= 3
           
OTHERS                                         = 4.
     
IF sy-subrc <> 0.
          
CLEAR ls_doc_data.
     
ENDIF.

CLEAR: lv_line, lv_input_len.

* The most important part is to get correct length. If you do not pass the correct length you image will not be displayed.
     DESCRIBE TABLE lt_cont_hex LINES lv_line.
   lv_input_len 
= lv_line * sy-tleng .

* Converting binary data to Xstring format

CALL FUNCTION 'SCMS_BINARY_TO_XSTRING'
     
EXPORTING
           input_length 
= lv_input_len
           first_line   
= 0
           last_line    
= 0
     
IMPORTING
          
buffer                   = lv_string
     
TABLES
           binary_tab  
= lt_cont_hex
     
EXCEPTIONS
           failed      
= 1
          
OTHERS             = 2.
         IF sy-subrc <> 0.
     
CLEAR lv_string.
   
ENDIF.

* Now we need to convert the Xstring data to string data otherwise the image will not be shown.
ls_certattach
-certno = p_cert.

     CALL FUNCTION 'SSFC_BASE64_ENCODE'
     
EXPORTING
           bindata
= lv_string

     
IMPORTING
           b64data
= ls_certattach-f_string.
     
IF sy-subrc <> 0.
          
CLEAR ls_certattach-f_string.
     
ENDIF.

     
APPEND ls_certattach TO lt_attachment.
     
CLEAR ls_certattach.

ENDLOOP.






* To print the image into adobe form call below subroutine.



PERFORM f_sub_print_form USING lt_attachment.
*&---------------------------------------------------------------------*
*&      Form  F_SUB_PRINT_FORM
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM f_sub_print_form  USING  p_gt_tab TYPE ztst_tt_itab.
     
DATA : ls_sfpoutputparams  TYPE sfpoutputparams,
            ls_docparams       
TYPE sfpdocparams,
            ls_pdf_file        
TYPE fpformoutput,
            lv_formname        
TYPE fpname VALUE 'ZTEST_DYNAMIC_PICTURE',
            lv_fmname          
TYPE funcname,
            lv_mseg            
TYPE  string,
            lv_w_cx_root       
TYPE  REF TO cx_root" Exception class


      ls_sfpoutputparams
-dest     = 'XX01'.
      ls_sfpoutputparams
-nodialog = 'X'.
      ls_sfpoutputparams
-preview  = 'X'.


     CALL FUNCTION 'FP_JOB_OPEN'
     
CHANGING
           ie_outputparams
= ls_sfpoutputparams
     
EXCEPTIONS
           cancel         
= 1
           usage_error    
= 2
           system_error   
= 3
           internal_error 
= 4
          
OTHERS          = 5.

     
IF sy-subrc <> 0.
          
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
          
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
     
ENDIF.

     TRY .
     
CALL FUNCTION 'FP_FUNCTION_MODULE_NAME'
          
EXPORTING
                i_name    
= lv_formname
          
IMPORTING
                e_funcname
= lv_fmname.

     
CATCH cx_root INTO lv_w_cx_root.
           lv_mseg
= lv_w_cx_root->get_text( ).
          
MESSAGE lv_mseg TYPE 'E'.

     ENDTRY.

     MOVE: sy-langu TO ls_docparams-langu.

     CALL FUNCTION lv_fmname
     
EXPORTING
           /1bcdwb/docparams 
= ls_docparams
           im_itab           
= p_gt_tab
     
IMPORTING
           /1bcdwb/formoutput
= ls_pdf_file
     
EXCEPTIONS
           usage_error       
= 1
           system_error      
= 2
           internal_error    
= 3
     
OTHERS             = 4.

     
IF sy-subrc <> 0.
          
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
          
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
     
ENDIF.

     CALL FUNCTION 'FP_JOB_CLOSE'
     
*   IMPORTING
     
*     E_RESULT             =
     
EXCEPTIONS
           usage_error         
= 1
           system_error        
= 2
           internal_error      
= 3
          
OTHERS               = 4.

     
IF sy-subrc <> 0.
          
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
          
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
     
ENDIF.



ENDFORM.                    " F_SUB_PRINT_FORM










Now build the simple form to test:


Go To SFP: Build an interface ZTEST_I_DYNAMIC_PICTURE and pass the import parameter in INPUT and OUTPUT parameter.

Now Build FORM Context.

Go to Layout:

Create one Image field into Design view and bind it with F_Sring which is the converted image in string format.



Activate it.


Now execute your program. Enter the parameters. Business object and Object key. Here object key is the certificate Number and Business object 'BUS2117'.


If you choose different Business object then you have to give correct object key. To get correct object key you can check the business object in SWO1 transaction.


After executing the output is coming like below.


Reference: I don't want to mention particular documents but I take help on few threads on GOS and Adobe form in SCN to build this document.


Suggestion: Please feel free to suggest.

21 Comments
Abhijit74
Active Contributor
0 Kudos

Expecting suggestions and recommendations.

maheshpalavalli
Active Contributor
0 Kudos

A good doc. i found till now on scn which has properly explained content related to GOS functionality.

Abhijit74
Active Contributor
0 Kudos

Thanks Mahesh ....

ashis_lohia
Explorer
0 Kudos

Nice one.

Abhijit74
Active Contributor
0 Kudos

Thanks...

arindam_samanta
Participant
0 Kudos

Excellent stuff...Keep posting.. Waiting for next one...

Abhijit74
Active Contributor
0 Kudos

Thanks Arindam

former_member188219
Participant
0 Kudos

Nice 1...:)

Abhijit74
Active Contributor
0 Kudos

Thanks....Could you please rate it?

former_member188219
Participant
0 Kudos

I have done It :smile:

Abhijit74
Active Contributor
0 Kudos

Thanks...

Former Member
0 Kudos

Superb Document!! Well done Abhijit!!

DanielP
Active Participant
0 Kudos

The restriction to use extension .PDF as a graphic comes from Adobe LiveCycle Designer, check online documentation:

former_member212490
Discoverer
0 Kudos

You are talking about Interface above but you have clicked on FORM.

If we create FORM then which Interface will be used here?

0 Kudos

Hello Abhijit,

Can we add multiple jpeg images into adobe forms using above?

Regards,

Siji Thomas

Abhijit74
Active Contributor
0 Kudos

Thanks for the information Daniel.

Abhijit74
Active Contributor
0 Kudos

Hello Siji,

It's possible.

Thanks ,

Abhijit

Former Member
0 Kudos

Hi Abhijit,

First of all - thanks for sharing the information in details. It really helps.

I have a similar requirement of displaying images (.JPG) linked to the notification, which is based on GOS. All steps are clear except the adobe form setting where I have bound the table field of type string to an image field. It doesn't show up. I thought we would have to map it to a table control, which would include an image field

Can you please share the setting in the form for the image field?

Abhijit74
Active Contributor
0 Kudos

Hello Shyam,

Thanks for your message and sorry for my late reply. Currently, I am serving different client whom doesn't have the adobe Life Cycle. So, not able to show the setting .

I will try to do it as early as possible.

Thanks & Regards,

Abhijit

ldzierza
Participant
0 Kudos
Hello

do you know how we can print GOS object on smartform?

 

thx

Lech
Abhishek_Parab
Active Participant
0 Kudos
Thanks a lot for this Wonderful document
Labels in this area