Advertisement
rplantiko

Transforming a sharepoint list to ABAP

Jun 13th, 2016
964
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
ABAP 3.63 KB | None | 0 0
  1. report zz_transform_sharepoint.
  2.  
  3. * You may use data types prefixed with XSD... for conversion to special formats
  4. types: begin of ty_row,
  5.          link_title type string,
  6.          plant      type string,
  7.          created    type xsddatetime_iso,
  8.        end of ty_row,
  9.        ty_rows type standard table of ty_row with empty key.
  10.  
  11. start-of-selection.
  12.   perform start.
  13.  
  14. * ---
  15. form start.
  16.  
  17.   data: lv_doc  type xstring,
  18.         lt_rows type ty_rows.
  19.  
  20.   perform get_sharepoint changing lv_doc.
  21.  
  22.   call transformation zshare
  23.     source xml lv_doc
  24.     result rows = lt_rows.
  25.  
  26.   cl_demo_output=>display( lt_rows ).
  27.  
  28. * The simple transformation looks like this
  29.  
  30. *<?sap.transform simple?>
  31. *<tt:transform xmlns:tt="http://www.sap.com/transformation-templates">
  32. *  <tt:root name="ROWS"/>
  33. *  <tt:template>
  34. *    <n0:GetListItemsResponse xmlns:n0="http://schemas.microsoft.com/sharepoint/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  35. *      <n0:GetListItemsResult xmlns:z="#RowsetSchema" xmlns:rs="urn:schemas-microsoft-com:rowset" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882">
  36. *        <n0:listitems>
  37. *          <rs:data>
  38. *            <tt:loop name="row" ref=".ROWS">
  39. *              <z:row>
  40. *                <tt:attribute name="ows_LinkTitle" value-ref="$row.link_title"/>
  41. *                <tt:attribute name="ows_Plant" value-ref="$row.plant"/>
  42. *                <tt:attribute name="ows_Created" value-ref="$row.created"/>
  43. *              </z:row>
  44. *            </tt:loop>
  45. *          </rs:data>
  46. *        </n0:listitems>
  47. *      </n0:GetListItemsResult>
  48. *    </n0:GetListItemsResponse>
  49. *  </tt:template>
  50. *</tt:transform>
  51.  
  52. endform.
  53.  
  54.  
  55.  
  56. form get_sharepoint changing cv_doc type xstring.
  57.  
  58. * A sharepoint example list, given as UTF-8 string (like in an HTTP request)
  59.   cv_doc = cl_abap_codepage=>convert_to(
  60.   `<?xml version="1.0"?>` &&
  61.   `<n0:GetListItemsResponse xmlns:n0="http://schemas.microsoft.com/sharepoint/soap/"` &&
  62.   `                         xmlns:xsd="http://www.w3.org/2001/XMLSchema"` &&
  63.   `                         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"` &&
  64.   `                         xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">` &&
  65.   `  <n0:GetListItemsResult xmlns:z="#RowsetSchema"` &&
  66.   `                         xmlns:rs="urn:schemas-microsoft-com:rowset"` &&
  67.   `                         xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882"` &&
  68.   `                         xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882">` &&
  69.   `    <n0:listitems>` &&
  70.   `      <rs:data ItemCount="8">` &&
  71.   `        <z:row ows_LinkTitle="1337"` &&
  72.   `               ows_Plant="10"` &&
  73.   `               ows_MetaInfo="1;#"` &&
  74.   `               ows__ModerationStatus="0"` &&
  75.   `               ows__Level="1"` &&
  76.   `               ows_Title="1337"` &&
  77.   `               ows_ID="1"` &&
  78.   `               ows_UniqueId="1;#{05F8EDB7-D0CA-4024-8125-AC3628394B69}"` &&
  79.   `               ows_owshiddenversion="5"` &&
  80.   `               ows_FSObjType="1;#0"` &&
  81.   `               ows_Created_x0020_Date="1;#2016-02-16 14:20:31"` &&
  82.   `               ows_Created="2016-02-16 14:20:31"` &&
  83.   `               ows_FileLeafRef="1;#1_.000"` &&
  84.   `               ows_PermMask="0x7fffffffffffffff"` &&
  85.   `               ows_Modified="2016-05-27 23:18:38"` &&
  86.   `               ows_FileRef="1;#Lists/Testlist/1_.000"/>` &&
  87.   `      </rs:data>` &&
  88.   `    </n0:listitems>` &&
  89.   `  </n0:GetListItemsResult>` &&
  90.   `</n0:GetListItemsResponse>` ).
  91.  
  92. endform.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement