Skip to Content

Scenario:

Transaction Code – ME53N ( Attaching files through Adobe Interactive Form )

Building a Webdynpro Component with Online interactive adobe form which will have a free input field purchase requisition number , a button Add Attachment which will take any attachment file from any of the drive from Presentation Server and send the file as attachment using Generic object service when we click on a submit button on the form. Once we attach a document in the interactive form and submit we can go to transaction code ME53N and for the corresponding Purchase requisition number we can find the attached file in the attachment list.

Steps:

Before proceeding there are two parts :

i) Creating a Adobe interactive form in transaction code(SFP).

     Adobe interactive field have 1 input field for user entry and two buttons, one to attach the files and other to submit to connect with webdynpro component.

      The interactive form is created through webdynpro component and hence a ZCI layout should be selected format for the adobe form.

ii) Creating a webdynpro component and link the adobe interactive form through webdynpro.

     Here webdynpro component name is ZATTACH_ANYDOC

  1. First is to create a webdynpro component with a single view.

/wp-content/uploads/2013/08/first_269864.jpg

     2.Create a PDF source node and Input Node.

Data type for PDF_SOURCE TYPE XSTRING and BANFN TYPE BANFN.

/wp-content/uploads/2013/08/second_269865.jpg

     3.In the Layout ROOTUIELEMENTCONTAINER  we will create an element INTERACTIVE_FORM OF TYPE INTERACTIVEFORM

/wp-content/uploads/2013/08/third_269866.jpg

   4.     Properties for the UI element to be set are

/wp-content/uploads/2013/08/fourth_269870.jpg   

5.

  1. Designing of the Adobe interactive form in SFP transaction code with Purchase Requisition field which is a free entry field for a Requisition Number to be entered by user with two buttons where one button is to attach files from Local drive or presentation server and Submit button will take the files and attach in ME52N / ME53N using Generic Object Service.

/wp-content/uploads/2013/08/fifth_269871.jpg

6. Purchase Requisition field is created which binding is done with BANFN of INPUT Node.

    We are taking two buttons one Add Attachment and Submit buttons.

     For ADD Attachment button

     The JavaScript Screenshot syntax :

    Add Attachment JavaScript on click* Event Code#

  1. INPUT.#subform[0].submitToSAP2::click – (JavaScript, client)
  2. app.execMenuItem(“AddFileAttachment”);

/wp-content/uploads/2013/08/sixth_269872.jpg

   For Submit Button Javascript on Click* Event Code#

  1. INPUT.#subform[0].submitToSAP1::click – (JavaScript, client)

                      // DO NOT MODIFY THE CODE BEYOND THIS POINT – 980.20101129104103.769764.508401 – SubmitToSAP.xfo

ContainerFoundation_JS.SendMessageToContainer(event.target, “submit”, “”, “”, “”, “”);

                      // END OF DO NOT MODIFY

/wp-content/uploads/2013/08/seventh_269873.jpg

Now because of the above javascript syntax the Submit Button will be linked to the Button in webdynpro on action field to interact with the Adobe Form.\

     6.  In WEBDYNPRO Component ZATTACH_ANYDOC in the View

In WDDOMODIFYVIEW we will write the following code:

method WDDOMODIFYVIEW .

TYPES : BEGIN OF ty_itab,
str
(255),
END OF ty_itab.
DATA: it_bin TYPE  STANDARD TABLE OF soli,
wa_bin
TYPE soli.

DATA: ls_fol_id   TYPE soodk,
ls_obj_id  
TYPE soodk,
ls_obj_data
TYPE sood1,
ls_folmem_k
TYPE sofmk,
ls_note    
TYPE borident,
ls_object  
TYPE borident,
lv_ep_note 
TYPE boridentobjkey,
lv_offset  
TYPE i,
l_subrc    
TYPE subrc,
lv_lines   
TYPE i,
it_objhead 
TYPE STANDARD TABLE OF soli,
it_content 
TYPE STANDARD TABLE OF soli,
wa_content 
TYPE soli.

DATA: ls_lporb TYPE sibflporb.
DATA: lt_objhead TYPE STANDARD TABLE OF soli,
lx_content
TYPE TABLE OF  soli.

DATA: lx_fol_id TYPE soodk,
lx_obj_id
TYPE soodk,
lx_obj_data
TYPE sood1,
lx_folmem_k
TYPE sofmk,
lx_note
TYPE borident,
lx_object
TYPE borident.

DATA: it_tab TYPE TABLE OF ty_itab,
wa_tab
TYPE ty_itab.
*****   Data type declaration to get the attachement files from Adobe form
DATA l_ifba TYPE REF TO cl_wd_interactive_form.
l_ifba ?= view
->get_element( `INTERACTIVE_FORM` ).
DATA l_form_method_handler TYPE REF TO if_wd_iactive_form_method_hndl.
DATA l_attachments TYPE tfpattachments.
DATA wa_attach TYPE LINE OF tfpattachments.

*****  Using the parameter View of WDDOMODIFYVIEW we get the attachement list in an internal table
l_form_method_handler ?= l_ifba
->_method_handler.
REFRESH l_attachments[].
l_attachments
= l_form_method_handler->get_attachments( ).

if wd_Comp_controller->pr_number IS NOT INITIAL.

ls_objectobjkey  = wd_Comp_controller->pr_number.
ls_object
objtype = ‘BUS2105’.   ” Object Service for Purchase Requisition ME51N,ME52N,ME53N

CALL FUNCTION ‘SO_FOLDER_ROOT_ID_GET’         ” Call the Function Module to get the Folder Id
EXPORTING
region   
= ‘B’
IMPORTING
folder_id
= lx_fol_id
EXCEPTIONS                                            “#EC FB_RC
OTHERS    = 1.

LOOP AT l_attachments INTO wa_attach.

CALL FUNCTION ‘SCMS_XSTRING_TO_BINARY’
EXPORTING
buffer          = wa_attachdata
*         append_to_table = ‘X’ “Do not clear/refresh table
TABLES
binary_tab     
= it_bin.

CALL FUNCTION ‘SO_CONVERT_CONTENTS_BIN’
EXPORTING
it_contents_bin
= it_bin
IMPORTING
et_contents_bin
= it_bin.

ls_obj_dataobjsns = ‘O’.
ls_obj_data
objla = sylangu.
ls_obj_data
objdes = wa_attachfilename.
SPLIT wa_attachfilename AT ‘.’ INTO TABLE it_tab.
DESCRIBE TABLE it_tab LINES lv_lines.
READ TABLE it_tab INTO wa_tab INDEX lv_lines.
if sysubrc eq 0.
MOVE wa_tab TO ls_obj_datafile_ext.
CLEAR wa_tab.
ENDIF.
SHIFT wa_attachfilesize LEFT DELETING LEADING ‘0’.
MOVE wa_attachfilesize TO lx_obj_dataobjlen.
CONDENSE lx_obj_dataobjlen.
lx_obj_data
objsns = ‘O’.
lx_obj_data
objla = sylangu.
lx_obj_data
objdes = wa_attachfilename. “c_testfile.
lx_obj_data
file_ext  = ls_obj_datafile_ext. “c_pdf.
* Object header
CLEAR wa_content.
CONCATENATE ‘&SO_FILENAME=’ wa_attachfilename INTO wa_content. “wa_attach-filename INTO wa_content.
APPEND wa_content TO it_objhead.
wa_content
= ‘&SO_FORMAT=BIN’ .
APPEND wa_content TO it_objhead.

lx_objectobjkey = wd_Comp_controller->pr_number.
lx_object
objtype = ‘BUS2105’.

CALL FUNCTION ‘SO_OBJECT_INSERT’
EXPORTING
folder_id            
= lx_fol_id
object_type          
= ‘EXT’ “c_ext
object_hd_change     
= lx_obj_data
IMPORTING
object_id            
= lx_obj_id
TABLES
objhead              
= it_objhead
objcont              
= it_bin
EXCEPTIONS
active_user_not_exist
= 35
folder_not_exist     
= 6
object_type_not_exist
= 17
owner_not_exist      
= 22
parameter_error      
= 23
OTHERS                = 1000.

IF sysubrc = 0 AND lx_objectobjkey IS NOT INITIAL.
lx_folmem_k
foltp = lx_fol_idobjtp.
lx_folmem_k
folyr = lx_fol_idobjyr.
lx_folmem_k
folno = lx_fol_idobjno.
lx_folmem_k
doctp = lx_obj_idobjtp.
lx_folmem_k
docyr = lx_obj_idobjyr.
lx_folmem_k
docno = lx_obj_idobjno.
lv_ep_note
= lx_folmem_k.
lx_note
objtype = ‘MESSAGE’. “c_message.
lx_note
objkey = lv_ep_note.
CALL FUNCTION ‘BINARY_RELATION_CREATE_COMMIT’
EXPORTING
obj_rolea   
= lx_object
obj_roleb   
= lx_note
relationtype
= ‘ATTA’
EXCEPTIONS
OTHERS       = 1.
ELSE.
*    MESSAGE ‘Not OK’ TYPE ‘I’.
*    RETURN.
ENDIF.

ENDLOOP.

ENDIF.

endmethod.

7. In WEBDYNPRO Component  ONACTIONSUBMIT

method ONACTIONSUBMIT .

DATA lo_nd_input TYPE REF TO if_wd_context_node.

DATA lo_el_input TYPE REF TO if_wd_context_element.
DATA ls_input TYPE wd_this->Element_input.
DATA lv_banfn TYPE wd_this->Element_inputbanfn.

*     navigate from <CONTEXT> to <INPUT> via lead selection
lo_nd_input
= wd_context->get_child_node( name = wd_this->wdctx_input ).

*     @TODO handle non existant child
*     IF lo_nd_input IS INITIAL.
*     ENDIF.

*     get element via lead selection
lo_el_input
= lo_nd_input->get_element( ).
*     @TODO handle not set lead selection
IF lo_el_input IS INITIAL.
ENDIF.

*     get single attribute
lo_el_input
->get_attribute(
EXPORTING
name
`BANFN`
IMPORTING
value = lv_banfn ).

wd_comp_controller->pr_number = lv_banfn.
endmethod.

In Webdynpro at Component Controller level we are creating an attribute to store the Purchase requisition number.

When we submit after entering a purchase requisition number in the Online Interactive Form and attach some files in that, the ONSUBMIT will read the Purchase requisition number and store in the component controller attribute PR_NUMBER.

In WDDOMODIFYVIEW we will check attribute PR_NUMBER is having value and not then we will attach the documents in ME52N and ME53N using BUS2105.

Output : We will test the application now.

And the test results are attached .

Thanks,

Rabi

To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply