Skip to Content
h4. Background The table parameters in Remote Enabled Function modules do not work well with the Guided Procedure. According to the {code:html}sap note{code} it’s a coding error in NW 7.0 SP14. When the table parameter is tested with a single record it throws “Technical Exception” and with two records it gives an error ”    Interactive Form Callable object’s output structure has two useful attributes *+Content+* and +ContentType+ which will be used to retrieve the data from the form.     The code given below is to read xml type of data submitted by the form, so make sure the *+Submit+*+ +button has the given settings: h4. Logic BAPI_PR_CREATE is  wrapped in another RFC which will read the xml content of the form, pick up the contents filled in the form map it to structures which will be finally passed to the above mentioned BAPI. The interface of the function module is as follows: | Name | Type | Type of Parameter | | PDFOBJECT | XSTRING | Importing | | CONTENTTYPE | STRING | Importing | | RETURN | BAPIRET2 | Exporting | Got a head start with the code, thanks to this link Reading Offline PDF data to WD Context ( WD ABAP) (Reading Offline PDF data to WD Context ( WD ABAP)) Data: CONVERTER type ref to CL_ABAP_CONV_IN_CE.Data: FORMXML type STRING.CONVERTER = CL_ABAP_CONV_IN_CE=>CREATE( INPUT = PDFOBJECT ).CONVERTER->READ( importing DATA = FORMXML ).class CL_ABAP_CHAR_UTILITIES definition load.replace all occurences of CL_ABAP_CHAR_UTILITIES=>NEWLINE in FORMXML with ”.type-pools: IXML.*Get a reference to iXML object. data: L_IXML type ref to IF_IXML. L_IXML = CL_IXML=>CREATE( ). *Get iStream object from StreamFactory data: STREAMFACTORY type ref to IF_IXML_STREAM_FACTORY. data: ISTREAM type ref to IF_IXML_ISTREAM. STREAMFACTORY = L_IXML->CREATE_STREAM_FACTORY( ). ISTREAM = STREAMFACTORY->CREATE_ISTREAM_STRING( FORMXML ). *Create an XML Document class that will be used to process the XML data: DOCUMENT type ref to IF_IXML_DOCUMENT. DOCUMENT = L_IXML->CREATE_DOCUMENT( ). *Create the Parser class data: PARSER type ref to IF_IXML_PARSER. PARSER = L_IXML->CREATE_PARSER( STREAM_FACTORY = STREAMFACTORY ISTREAM = ISTREAM DOCUMENT = DOCUMENT ).*Parse the XML PARSER->PARSE( ). Since the data submitted is already *xml *content we do not need to make a call to the ADS. This section of the code deals with fetching the relevant content into the local variables and internal tables. Note this function module will have to be tweaked according to the field names available on the form. Define XML Node type object. data: NODE type ref to IF_IXML_NODE, NODECHILD type ref to IF_IXML_NODE. *Declare the fields present on the form. data: l_req_name type TEXT40, l_doc_type type BSART, l_pur_grp type EKGRP, l_pur_org type EKORG, l_date type String, l_preq_date type BADAT. * Fetching simple attributes NODE = DOCUMENT->FIND_FROM_NAME( NAME = ‘UserName’). l_req_name = NODE->GET_VALUE( ). *Reading Table Contents Data: IT_PRITMS type table of BAPIMEREQITEMIMP with header line, IT_RETURN type table of BAPIRET2 with header line. Data: RVAL type ref to IF_IXML_NODE_COLLECTION. Data: NODEITER type ref to IF_IXML_NODE_ITERATOR, NODEITER_ATTR type ref to IF_IXML_NODE_ITERATOR, NODELIST type ref to IF_IXML_NODE_LIST. Data: COUNT type I, LENGTH type I, INDEX type I value 0. * Fetch the node collection; this will be the row element RVAL = DOCUMENT->GET_ELEMENTS_BY_TAG_NAME( ‘Item1’ ). * Iterate through each element. LENGTH = RVAL->GET_LENGTH( ). NODEITER = RVAL->CREATE_ITERATOR( ). * Loop through the line items do LENGTH times. NODE = NODEITER->GET_NEXT( ). * Iterate thru the attributes. NODELIST = NODE->GET_CHILDREN( ). * Fetch number of attributes COUNT = NODELIST->GET_LENGTH( ). * Iterate through the attributes NODEITER_ATTR = NODELIST->CREATE_ITERATOR( ). do COUNT times. INDEX = 1 + INDEX. NODECHILD = NODEITER_ATTR->GET_NEXT( ). case INDEX. when 1. IT_PRITMS-PREQ_ITEM = NODECHILD->GET_VALUE( ). when 2. IT_PRITMS-PLANT = NODECHILD->GET_VALUE( ). when 3. IT_PRITMS-MATERIAL = NODECHILD->GET_VALUE( ). when 4. IT_PRITMS-QUANTITY = NODECHILD->GET_VALUE( ). when 5. IT_PRITMS-UNIT = NODECHILD->GET_VALUE( ). when 6. IT_PRITMS-PREQ_PRICE = NODECHILD->GET_VALUE( ). when 7. IT_PRITMS-PRICE_UNIT = NODECHILD->GET_VALUE( ). when 8. IT_PRITMS-CURRENCY = NODECHILD->GET_VALUE( ). when 9. IT_PRITMS-DELIV_DATE = NODECHILD->GET_VALUE( ). endcase. enddo. * Append IT_PRITMS. if IT_PRITMS-MATERIAL is not initial. append IT_PRITMS. endif. clear index. enddo. image +    +Once the contents are read into the appropriate internal tables and local fields, these can be then passed to the standard function module for further processing.Error occurring in the function module can be reported in the ‘Return’ structure which in turn can be used for error handling when the callable object is created.

image

To report this post you need to login first.

2 Comments

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

  1. Vishal D
    During the migration process problems have been reported for this blog. The blog content may look corrupt due to not supported HTML code on this platform. Please adjust the blog content manually before moving it to an official community.
    (0) 

Leave a Reply