<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Map the database table data to Purchase Order JSON format in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/map-the-database-table-data-to-purchase-order-json-format/m-p/12715456#M2019423</link>
    <description>&lt;P&gt;Hi, Here is the code : TYPES: BEGIN OF ty_purchase_order_item_results,&lt;/P&gt;PurchaseOrderItem TYPE string,&lt;BR /&gt;Plant TYPE string,&lt;BR /&gt;OrderQuantity TYPE string,&lt;BR /&gt;PurchaseOrderQuantityUnit TYPE string,&lt;BR /&gt;OrderPriceUnit TYPE string,&lt;BR /&gt;NetPriceAmount TYPE string,&lt;BR /&gt;NetPriceQuantity TYPE string,&lt;BR /&gt;Material TYPE string,&lt;BR /&gt;ManufacturerMaterial TYPE string,&lt;BR /&gt;ProductType TYPE string,&lt;BR /&gt;END OF ty_purchase_order_item_results.&lt;BR /&gt;&lt;BR /&gt;TYPES: BEGIN OF ty_purchase_order_item,&lt;BR /&gt;RESULTS TYPE ty_purchase_order_item_results,&lt;BR /&gt;END OF ty_purchase_order_item.&lt;BR /&gt;&lt;BR /&gt;TYPES: BEGIN OF ty_purchase_order,&lt;BR /&gt;CompanyCode TYPE string,&lt;BR /&gt;PurchaseOrderType TYPE string,&lt;BR /&gt;Supplier TYPE string,&lt;BR /&gt;Language TYPE string,&lt;BR /&gt;PurchasingOrganization TYPE string,&lt;BR /&gt;PurchasingGroup TYPE string,&lt;BR /&gt;DocumentCurrency TYPE string,&lt;BR /&gt;to_PurchaseOrderItem TYPE ty_purchase_order_item,&lt;BR /&gt;END OF ty_purchase_order.&lt;BR /&gt;&lt;BR /&gt;DATA :&lt;BR /&gt;lt_purchase_order_item_results type standard table of ty_purchase_order_item_results,&lt;BR /&gt;ls_purchase_order_item_results type ty_purchase_order_item_results,&lt;BR /&gt;&lt;BR /&gt;lt_purchase_order_item type STANDARD TABLE OF ty_purchase_order_item,&lt;BR /&gt;ls_purchase_order_item type ty_purchase_order_item,&lt;BR /&gt;&lt;BR /&gt;lt_purchase_order type STANDARD TABLE OF ty_purchase_order,&lt;BR /&gt;ls_purchase_order type ty_purchase_order.&lt;BR /&gt;&lt;BR /&gt;* Declare internal table to hold ZEC_MEX_PO_LOG data&lt;BR /&gt;DATA: lt_zec_mex_po_log TYPE STANDARD TABLE OF zec_mex_po_log.&lt;BR /&gt;&lt;BR /&gt;SELECT REGIONNAME&lt;BR /&gt;SUPPLIERCONTACTID&lt;BR /&gt;LINENUMBER&lt;BR /&gt;ORDEREDQUANTITY&lt;BR /&gt;UNITPRICE&lt;BR /&gt;INTO CORRESPONDING FIELDS OF TABLE lt_zec_mex_po_log&lt;BR /&gt;FROM zec_mex_po_log&lt;BR /&gt;where purchaseordernumber = 'G9623'.&lt;BR /&gt;&lt;BR /&gt;Loop at lt_zec_mex_po_log into data(ls_zec_mex_po_log).&lt;BR /&gt;ls_purchase_order-CompanyCode = ls_zec_mex_po_log-regionname.&lt;BR /&gt;ls_purchase_order-PurchaseOrderType = 'ZMX'.&lt;BR /&gt;ls_purchase_order-Supplier = ls_zec_mex_po_log-SUPPLIERCONTACTID.&lt;BR /&gt;ls_purchase_order-Language = 'EN'.&lt;BR /&gt;ls_purchase_order-PurchasingOrganization = 'PO02'.&lt;BR /&gt;ls_purchase_order-PurchasingGroup = 'PGP'.&lt;BR /&gt;ls_purchase_order-DocumentCurrency = 'AUD'.&lt;BR /&gt;ls_purchase_order-to_PurchaseOrderItem-RESULTS-PurchaseOrderItem = ls_zec_mex_po_log-LINENUMBER.&lt;BR /&gt;ls_purchase_order-to_PurchaseOrderItem-RESULTS-Plant = ls_zec_mex_po_log-regionname.&lt;BR /&gt;ls_purchase_order-to_PurchaseOrderItem-RESULTS-OrderQuantity = ls_zec_mex_po_log-ORDEREDQUANTITY.&lt;BR /&gt;ls_purchase_order-to_PurchaseOrderItem-RESULTS-PurchaseOrderQuantityUnit = 'EA'.&lt;BR /&gt;ls_purchase_order-to_PurchaseOrderItem-RESULTS-OrderPriceUnit = 'EA'.&lt;BR /&gt;ls_purchase_order-to_PurchaseOrderItem-RESULTS-NetPriceAmount = ls_zec_mex_po_log-UNITPRICE.&lt;BR /&gt;ls_purchase_order-to_PurchaseOrderItem-RESULTS-NetPriceQuantity = '1'.&lt;BR /&gt;ls_purchase_order-to_PurchaseOrderItem-RESULTS-Material = 'TG11'.&lt;BR /&gt;ls_purchase_order-to_PurchaseOrderItem-RESULTS-ManufacturerMaterial = 'TG11'.&lt;BR /&gt;ls_purchase_order-to_PurchaseOrderItem-RESULTS-ProductType = '1'.&lt;BR /&gt;Append ls_purchase_order to lt_purchase_order.&lt;BR /&gt;endloop.&lt;BR /&gt;&lt;BR /&gt;*DATA(lv_json) = /ui2/cl_json=&amp;gt;serialize( data = lt_purchase_order ).&lt;BR /&gt;&lt;BR /&gt;*WRITE : LV_JSON.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;DATA(lv_json) = /ui2/cl_json=&amp;gt;serialize(&lt;BR /&gt;data = lt_purchase_order&lt;BR /&gt;compress = abap_true&lt;BR /&gt;pretty_name = /ui2/cl_json=&amp;gt;pretty_mode-camel_case ).&lt;BR /&gt;&lt;BR /&gt;" Display JSON in ABAP&lt;BR /&gt;CALL TRANSFORMATION sjson2html SOURCE XML lv_json&lt;BR /&gt;RESULT XML DATA(lvc_html).&lt;BR /&gt;cl_abap_browser=&amp;gt;show_html(&lt;BR /&gt;title = 'Sample JSON'&lt;BR /&gt;html_string = cl_abap_codepage=&amp;gt;convert_from( lvc_html ) ).&lt;BR /&gt;&lt;BR /&gt;DATA(lo_reader) = cl_sxml_string_reader=&amp;gt;create( cl_abap_codepage=&amp;gt;convert_to( lv_json ) ).&lt;BR /&gt;TRY.&lt;BR /&gt;lo_reader-&amp;gt;next_node( ).&lt;BR /&gt;lo_reader-&amp;gt;skip_node( ).&lt;BR /&gt;cl_demo_output=&amp;gt;display( 'JSON is valid' ).&lt;BR /&gt;CATCH cx_sxml_parse_error INTO DATA(lx_parse_error).&lt;BR /&gt;cl_demo_output=&amp;gt;display( lx_parse_error-&amp;gt;get_text( ) ).&lt;BR /&gt;ENDTRY.&lt;P&gt;&lt;/P&gt;&lt;P&gt;This program is producing the below JSON format :&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;[
  {
    "companycode": "ECG",
    "purchaseordertype": "ZMX",
    "supplier": "348",
    "language": "EN",
    "purchasingorganization": "PO02",
    "purchasinggroup": "PGP",
    "documentcurrency": "AUD",
    "toPurchaseorderitem": {
      "results": {
        "purchaseorderitem": "1",
        "plant": "ECG",
        "orderquantity": "1.0000000",
        "purchaseorderquantityunit": "EA",
        "orderpriceunit": "EA",
        "netpriceamount": "15000.0000",
        "netpricequantity": "1",
        "material": "TG11",
        "manufacturermaterial": "TG11",
        "producttype": "1"
      }
    }
  } &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;]&lt;/P&gt;&lt;P&gt;But the expected format :&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;"CompanyCode": " ",&lt;/P&gt;&lt;P&gt;"PurchaseOrderType": " ",&lt;/P&gt;&lt;P&gt;"Supplier": " ",&lt;/P&gt;&lt;P&gt;"Language": " ",&lt;/P&gt;&lt;P&gt;"PurchasingOrganization": " ",&lt;/P&gt;&lt;P&gt;"PurchasingGroup": " ",&lt;/P&gt;&lt;P&gt;"DocumentCurrency": " ",&lt;/P&gt;&lt;P&gt;"to_PurchaseOrderItem": {&lt;/P&gt;&lt;P&gt;"results": [&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;"PurchaseOrderItem": " ",&lt;/P&gt;&lt;P&gt;"Plant": " ",&lt;/P&gt;&lt;P&gt;"OrderQuantity": " ",&lt;/P&gt;&lt;P&gt;"PurchaseOrderQuantityUnit": " ",&lt;/P&gt;&lt;P&gt;"OrderPriceUnit": " ",&lt;/P&gt;&lt;P&gt;"NetPriceAmount": " ",&lt;/P&gt;&lt;P&gt;"NetPriceQuantity": " ",&lt;/P&gt;&lt;P&gt;"Material": " ",&lt;/P&gt;&lt;P&gt;"ManufacturerMaterial": " ",&lt;/P&gt;&lt;P&gt;"ProductType": " "&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;]&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;The system produced JSON format is different from the expected format. First difference : starting and ending with square brackets ([ ]). This is to be removed. As per the expectation, Results are expecting in array format. Could any one please help me on this?&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;</description>
    <pubDate>Tue, 09 May 2023 23:11:46 GMT</pubDate>
    <dc:creator>former_member139597</dc:creator>
    <dc:date>2023-05-09T23:11:46Z</dc:date>
    <item>
      <title>Map the database table data to Purchase Order JSON format</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/map-the-database-table-data-to-purchase-order-json-format/m-p/12715449#M2019416</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
  &lt;P&gt;I have the below JSON format which needs to passed to Purchase Order API:&lt;/P&gt;
  &lt;P&gt;{&lt;/P&gt;
  &lt;P&gt; "CompanyCode": " ",&lt;/P&gt;
  &lt;P&gt; "PurchaseOrderType": " ",&lt;/P&gt;
  &lt;P&gt; "Supplier": " ",&lt;/P&gt;
  &lt;P&gt; "Language": " ",&lt;/P&gt;
  &lt;P&gt; "PurchasingOrganization": " ",&lt;/P&gt;
  &lt;P&gt; "PurchasingGroup": " ",&lt;/P&gt;
  &lt;P&gt; "DocumentCurrency": " ",&lt;/P&gt;
  &lt;P&gt; "to_PurchaseOrderItem": {&lt;/P&gt;
  &lt;P&gt; "results": [&lt;/P&gt;
  &lt;P&gt; {&lt;/P&gt;
  &lt;P&gt; "PurchaseOrderItem": " ",&lt;/P&gt;
  &lt;P&gt; "Plant": " ",&lt;/P&gt;
  &lt;P&gt; "OrderQuantity": " ",&lt;/P&gt;
  &lt;P&gt; "PurchaseOrderQuantityUnit": " ",&lt;/P&gt;
  &lt;P&gt; "OrderPriceUnit": " ",&lt;/P&gt;
  &lt;P&gt; "NetPriceAmount": " ",&lt;/P&gt;
  &lt;P&gt; "NetPriceQuantity": " ",&lt;/P&gt;
  &lt;P&gt; "Material": " ",&lt;/P&gt;
  &lt;P&gt; "ManufacturerMaterial": " ",&lt;/P&gt;
  &lt;P&gt; "ProductType": " "&lt;/P&gt;
  &lt;P&gt; }&lt;/P&gt;
  &lt;P&gt; ]&lt;/P&gt;
  &lt;P&gt; }&lt;/P&gt;
  &lt;P&gt;}&lt;/P&gt;
  &lt;P&gt;I have a log table in SAP ECC system with the following fileds :&lt;/P&gt;
  &lt;P&gt;REGION NAME&lt;/P&gt;
  &lt;P&gt;SUPPLIERCONTACTID&lt;/P&gt;
  &lt;P&gt;LINE NUMBER&lt;/P&gt;
  &lt;P&gt;REGION NAME&lt;/P&gt;
  &lt;P&gt;ORDERQUANTITY&lt;/P&gt;
  &lt;P&gt;UNIT PRICE&lt;/P&gt;
  &lt;P&gt;And, I need to map the region name to Company code, &lt;/P&gt;
  &lt;P&gt; suppliercontactid to supplier &lt;/P&gt;
  &lt;P&gt; line number to purchaseorderitem&lt;/P&gt;
  &lt;P&gt; region name to plant&lt;/P&gt;
  &lt;P&gt; orderquantity to OrderQuantity&lt;/P&gt;
  &lt;P&gt; UnitPrice to NetPriceAmount&lt;/P&gt;
  &lt;P&gt; to the above json from the database table.&lt;/P&gt;
  &lt;P&gt;Could you please any one let me know how can I achieve this in ABAP?&lt;/P&gt;</description>
      <pubDate>Tue, 09 May 2023 04:53:40 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/map-the-database-table-data-to-purchase-order-json-format/m-p/12715449#M2019416</guid>
      <dc:creator>former_member139597</dc:creator>
      <dc:date>2023-05-09T04:53:40Z</dc:date>
    </item>
    <item>
      <title>Re: Map the database table data to Purchase Order JSON format</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/map-the-database-table-data-to-purchase-order-json-format/m-p/12715450#M2019417</link>
      <description>&lt;P&gt;Perform first some search on methods such as /ui2/cl_json=&amp;gt;serialize. There are already many threads, tutorials and &lt;A href="https://community.sap.com/search/?ct=blog&amp;amp;q=convert%20to%20json"&gt;blogs&lt;/A&gt; in the forum.&lt;/P&gt;</description>
      <pubDate>Tue, 09 May 2023 05:14:07 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/map-the-database-table-data-to-purchase-order-json-format/m-p/12715450#M2019417</guid>
      <dc:creator>RaymondGiuseppi</dc:creator>
      <dc:date>2023-05-09T05:14:07Z</dc:date>
    </item>
    <item>
      <title>Re: Map the database table data to Purchase Order JSON format</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/map-the-database-table-data-to-purchase-order-json-format/m-p/12715451#M2019418</link>
      <description>&lt;P&gt;Hi Raymond, I have posted my question after going through many blogs. I didn't see the relavent blog to my question.  My mapping was not working and not converted to the expected JSON format. Hence reaching out.&lt;/P&gt;&lt;P&gt;Kind regards&lt;/P&gt;&lt;P&gt;Ramesh&lt;/P&gt;</description>
      <pubDate>Tue, 09 May 2023 05:49:39 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/map-the-database-table-data-to-purchase-order-json-format/m-p/12715451#M2019418</guid>
      <dc:creator>former_member139597</dc:creator>
      <dc:date>2023-05-09T05:49:39Z</dc:date>
    </item>
    <item>
      <title>Re: Map the database table data to Purchase Order JSON format</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/map-the-database-table-data-to-purchase-order-json-format/m-p/12715452#M2019419</link>
      <description>&lt;P&gt;Please use the COMMENT button for comments, asking for complements, adding details, &lt;STRONG&gt;replying to a comment&lt;/STRONG&gt; or a proposed solution or to the OP question, etc., ANSWER is only to propose a solution, dixit SAP text at the right of the answer area.&lt;/P&gt;&lt;P&gt;If you want to target someone, if this person has posted an Answer, use the button COMMENT, if this person is the Original Poster of the question he/she will be automatically informed, &lt;STRONG&gt;otherwise copy/paste their hyperlinked name&lt;/STRONG&gt; (e.g. yourself: &lt;SPAN class="mention-scrubbed"&gt;rmasetty80&lt;/SPAN&gt;) so that the person receives a warning (NB: @ doesn't work/but typing this character will suggest hyperlinked names). &lt;/P&gt;</description>
      <pubDate>Tue, 09 May 2023 07:02:53 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/map-the-database-table-data-to-purchase-order-json-format/m-p/12715452#M2019419</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2023-05-09T07:02:53Z</dc:date>
    </item>
    <item>
      <title>Re: Map the database table data to Purchase Order JSON format</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/map-the-database-table-data-to-purchase-order-json-format/m-p/12715453#M2019420</link>
      <description>&lt;P&gt;Also, post your code concerning /ui2/cl_json=&amp;gt;serialize so that you can understand what you did wrong...&lt;/P&gt;&lt;P&gt;NB: you can edit your question via Actions &amp;gt; Edit.&lt;/P&gt;</description>
      <pubDate>Tue, 09 May 2023 07:04:24 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/map-the-database-table-data-to-purchase-order-json-format/m-p/12715453#M2019420</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2023-05-09T07:04:24Z</dc:date>
    </item>
    <item>
      <title>Re: Map the database table data to Purchase Order JSON format</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/map-the-database-table-data-to-purchase-order-json-format/m-p/12715454#M2019421</link>
      <description>&lt;P&gt;Hi, Here is the code : TYPES: BEGIN OF ty_purchase_order_item_results,&lt;/P&gt;         PurchaseOrderItem TYPE string,&lt;BR /&gt;         Plant TYPE string,&lt;BR /&gt;         OrderQuantity TYPE string,&lt;BR /&gt;         PurchaseOrderQuantityUnit TYPE string,&lt;BR /&gt;         OrderPriceUnit TYPE string,&lt;BR /&gt;         NetPriceAmount TYPE string,&lt;BR /&gt;         NetPriceQuantity TYPE string,&lt;BR /&gt;         Material TYPE string,&lt;BR /&gt;         ManufacturerMaterial TYPE string,&lt;BR /&gt;         ProductType TYPE string,&lt;BR /&gt;       END OF ty_purchase_order_item_results.&lt;BR /&gt;&lt;BR /&gt;TYPES: BEGIN OF ty_purchase_order_item,&lt;BR /&gt;          RESULTS TYPE ty_purchase_order_item_results,&lt;BR /&gt;       END OF ty_purchase_order_item.&lt;BR /&gt;&lt;BR /&gt;TYPES: BEGIN OF ty_purchase_order,&lt;BR /&gt;         CompanyCode TYPE string,&lt;BR /&gt;         PurchaseOrderType TYPE string,&lt;BR /&gt;         Supplier TYPE string,&lt;BR /&gt;         Language TYPE string,&lt;BR /&gt;         PurchasingOrganization TYPE string,&lt;BR /&gt;         PurchasingGroup TYPE string,&lt;BR /&gt;         DocumentCurrency TYPE string,&lt;BR /&gt;         to_PurchaseOrderItem TYPE ty_purchase_order_item,&lt;BR /&gt;       END OF ty_purchase_order.&lt;BR /&gt;&lt;BR /&gt;DATA :&lt;BR /&gt;      lt_purchase_order_item_results type standard table of ty_purchase_order_item_results,&lt;BR /&gt;      ls_purchase_order_item_results type ty_purchase_order_item_results,&lt;BR /&gt;&lt;BR /&gt;      lt_purchase_order_item type STANDARD TABLE OF ty_purchase_order_item,&lt;BR /&gt;      ls_purchase_order_item type ty_purchase_order_item,&lt;BR /&gt;&lt;BR /&gt;      lt_purchase_order type STANDARD TABLE OF ty_purchase_order,&lt;BR /&gt;      ls_purchase_order type ty_purchase_order.&lt;BR /&gt;&lt;BR /&gt;* Declare internal table to hold ZEC_MEX_PO_LOG data&lt;BR /&gt;DATA: lt_zec_mex_po_log TYPE STANDARD TABLE OF zec_mex_po_log.&lt;BR /&gt;&lt;BR /&gt;SELECT REGIONNAME&lt;BR /&gt;       SUPPLIERCONTACTID&lt;BR /&gt;       LINENUMBER&lt;BR /&gt;       ORDEREDQUANTITY&lt;BR /&gt;       UNITPRICE&lt;BR /&gt;  INTO CORRESPONDING FIELDS OF TABLE lt_zec_mex_po_log&lt;BR /&gt;  FROM zec_mex_po_log&lt;BR /&gt;  where purchaseordernumber = 'G9623'.&lt;BR /&gt;&lt;BR /&gt;Loop at lt_zec_mex_po_log into data(ls_zec_mex_po_log).&lt;BR /&gt;  ls_purchase_order-CompanyCode = ls_zec_mex_po_log-regionname.&lt;BR /&gt;  ls_purchase_order-PurchaseOrderType = 'ZMX'.&lt;BR /&gt;  ls_purchase_order-Supplier = ls_zec_mex_po_log-SUPPLIERCONTACTID.&lt;BR /&gt;  ls_purchase_order-Language = 'EN'.&lt;BR /&gt;  ls_purchase_order-PurchasingOrganization = 'PO02'.&lt;BR /&gt;  ls_purchase_order-PurchasingGroup = 'PGP'.&lt;BR /&gt;  ls_purchase_order-DocumentCurrency = 'AUD'.&lt;BR /&gt;  ls_purchase_order-to_PurchaseOrderItem-RESULTS-PurchaseOrderItem = ls_zec_mex_po_log-LINENUMBER.&lt;BR /&gt;  ls_purchase_order-to_PurchaseOrderItem-RESULTS-Plant = ls_zec_mex_po_log-regionname.&lt;BR /&gt;  ls_purchase_order-to_PurchaseOrderItem-RESULTS-OrderQuantity = ls_zec_mex_po_log-ORDEREDQUANTITY.&lt;BR /&gt;  ls_purchase_order-to_PurchaseOrderItem-RESULTS-PurchaseOrderQuantityUnit = 'EA'.&lt;BR /&gt;  ls_purchase_order-to_PurchaseOrderItem-RESULTS-OrderPriceUnit = 'EA'.&lt;BR /&gt;  ls_purchase_order-to_PurchaseOrderItem-RESULTS-NetPriceAmount = ls_zec_mex_po_log-UNITPRICE.&lt;BR /&gt;  ls_purchase_order-to_PurchaseOrderItem-RESULTS-NetPriceQuantity = '1'.&lt;BR /&gt;  ls_purchase_order-to_PurchaseOrderItem-RESULTS-Material = 'TG11'.&lt;BR /&gt;  ls_purchase_order-to_PurchaseOrderItem-RESULTS-ManufacturerMaterial = 'TG11'.&lt;BR /&gt;  ls_purchase_order-to_PurchaseOrderItem-RESULTS-ProductType = '1'.&lt;BR /&gt;  Append ls_purchase_order to lt_purchase_order.&lt;BR /&gt;endloop.&lt;BR /&gt;&lt;BR /&gt;*DATA(lv_json) = /ui2/cl_json=&amp;gt;serialize( data = lt_purchase_order ).&lt;BR /&gt;&lt;BR /&gt;*WRITE : LV_JSON.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;DATA(lv_json) = /ui2/cl_json=&amp;gt;serialize(&lt;BR /&gt;  data        = lt_purchase_order&lt;BR /&gt;  compress    = abap_true&lt;BR /&gt;  pretty_name = /ui2/cl_json=&amp;gt;pretty_mode-camel_case ).&lt;BR /&gt;&lt;BR /&gt;" Display JSON in ABAP&lt;BR /&gt;CALL TRANSFORMATION sjson2html SOURCE XML lv_json&lt;BR /&gt;                           RESULT XML DATA(lvc_html).&lt;BR /&gt;cl_abap_browser=&amp;gt;show_html(&lt;BR /&gt;  title = 'Sample JSON'&lt;BR /&gt;  html_string = cl_abap_codepage=&amp;gt;convert_from( lvc_html ) ).&lt;BR /&gt;&lt;BR /&gt;DATA(lo_reader) = cl_sxml_string_reader=&amp;gt;create( cl_abap_codepage=&amp;gt;convert_to( lv_json ) ).&lt;BR /&gt;TRY.&lt;BR /&gt;    lo_reader-&amp;gt;next_node( ).&lt;BR /&gt;    lo_reader-&amp;gt;skip_node( ).&lt;BR /&gt;    cl_demo_output=&amp;gt;display( 'JSON is valid' ).&lt;BR /&gt;  CATCH cx_sxml_parse_error INTO DATA(lx_parse_error).&lt;BR /&gt;    cl_demo_output=&amp;gt;display( lx_parse_error-&amp;gt;get_text( ) ).&lt;BR /&gt;ENDTRY.&lt;P&gt;&lt;/P&gt;&lt;P&gt;This program is producing the below JSON format : &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;[
  {
    "companycode": "ECG",
    "purchaseordertype": "ZMX",
    "supplier": "348",
    "language": "EN",
    "purchasingorganization": "PO02",
    "purchasinggroup": "PGP",
    "documentcurrency": "AUD",
    "toPurchaseorderitem": {
      "results": {
        "purchaseorderitem": "1",
        "plant": "ECG",
        "orderquantity": "1.0000000",
        "purchaseorderquantityunit": "EA",
        "orderpriceunit": "EA",
        "netpriceamount": "15000.0000",
        "netpricequantity": "1",
        "material": "TG11",
        "manufacturermaterial": "TG11",
        "producttype": "1"
      }
    }
  } &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;]&lt;/P&gt;&lt;P&gt;But the expected format :&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;   "CompanyCode": " ",&lt;/P&gt;&lt;P&gt;   "PurchaseOrderType": " ",&lt;/P&gt;&lt;P&gt;   "Supplier": " ",&lt;/P&gt;&lt;P&gt;   "Language": " ",&lt;/P&gt;&lt;P&gt;   "PurchasingOrganization": " ",&lt;/P&gt;&lt;P&gt;   "PurchasingGroup": " ",&lt;/P&gt;&lt;P&gt;   "DocumentCurrency": " ",&lt;/P&gt;&lt;P&gt;   "to_PurchaseOrderItem": {&lt;/P&gt;&lt;P&gt;      "results": [&lt;/P&gt;&lt;P&gt;         {&lt;/P&gt;&lt;P&gt;            "PurchaseOrderItem": " ",&lt;/P&gt;&lt;P&gt;            "Plant": " ",&lt;/P&gt;&lt;P&gt;            "OrderQuantity": " ",&lt;/P&gt;&lt;P&gt;            "PurchaseOrderQuantityUnit": " ",&lt;/P&gt;&lt;P&gt;            "OrderPriceUnit": " ",&lt;/P&gt;&lt;P&gt;            "NetPriceAmount": "  ",&lt;/P&gt;&lt;P&gt;            "NetPriceQuantity": " ",&lt;/P&gt;&lt;P&gt;            "Material": " ",&lt;/P&gt;&lt;P&gt;            "ManufacturerMaterial": " ",&lt;/P&gt;&lt;P&gt;            "ProductType": " "&lt;/P&gt;&lt;P&gt;         }&lt;/P&gt;&lt;P&gt;      ]&lt;/P&gt;&lt;P&gt;   }&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;The system produced JSON format is different from the expected format. First difference : starting and ending with square brackets ([ ]). This is to be removed. As per the expectation, Results are expecting in array format. Could any one please help me on this?&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Tue, 09 May 2023 11:23:57 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/map-the-database-table-data-to-purchase-order-json-format/m-p/12715454#M2019421</guid>
      <dc:creator>former_member139597</dc:creator>
      <dc:date>2023-05-09T11:23:57Z</dc:date>
    </item>
    <item>
      <title>Re: Map the database table data to Purchase Order JSON format</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/map-the-database-table-data-to-purchase-order-json-format/m-p/12715455#M2019422</link>
      <description>&lt;P&gt;Please use the COMMENT button for comments, asking for complements, adding details, replying to a comment or a proposed solution or to the OP question, etc., ANSWER is only to propose a solution, dixit SAP text at the right of the answer area.&lt;/P&gt;&lt;P&gt;To edit your question, use Actions &amp;gt; Edit.&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Tue, 09 May 2023 11:54:01 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/map-the-database-table-data-to-purchase-order-json-format/m-p/12715455#M2019422</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2023-05-09T11:54:01Z</dc:date>
    </item>
    <item>
      <title>Re: Map the database table data to Purchase Order JSON format</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/map-the-database-table-data-to-purchase-order-json-format/m-p/12715456#M2019423</link>
      <description>&lt;P&gt;Hi, Here is the code : TYPES: BEGIN OF ty_purchase_order_item_results,&lt;/P&gt;PurchaseOrderItem TYPE string,&lt;BR /&gt;Plant TYPE string,&lt;BR /&gt;OrderQuantity TYPE string,&lt;BR /&gt;PurchaseOrderQuantityUnit TYPE string,&lt;BR /&gt;OrderPriceUnit TYPE string,&lt;BR /&gt;NetPriceAmount TYPE string,&lt;BR /&gt;NetPriceQuantity TYPE string,&lt;BR /&gt;Material TYPE string,&lt;BR /&gt;ManufacturerMaterial TYPE string,&lt;BR /&gt;ProductType TYPE string,&lt;BR /&gt;END OF ty_purchase_order_item_results.&lt;BR /&gt;&lt;BR /&gt;TYPES: BEGIN OF ty_purchase_order_item,&lt;BR /&gt;RESULTS TYPE ty_purchase_order_item_results,&lt;BR /&gt;END OF ty_purchase_order_item.&lt;BR /&gt;&lt;BR /&gt;TYPES: BEGIN OF ty_purchase_order,&lt;BR /&gt;CompanyCode TYPE string,&lt;BR /&gt;PurchaseOrderType TYPE string,&lt;BR /&gt;Supplier TYPE string,&lt;BR /&gt;Language TYPE string,&lt;BR /&gt;PurchasingOrganization TYPE string,&lt;BR /&gt;PurchasingGroup TYPE string,&lt;BR /&gt;DocumentCurrency TYPE string,&lt;BR /&gt;to_PurchaseOrderItem TYPE ty_purchase_order_item,&lt;BR /&gt;END OF ty_purchase_order.&lt;BR /&gt;&lt;BR /&gt;DATA :&lt;BR /&gt;lt_purchase_order_item_results type standard table of ty_purchase_order_item_results,&lt;BR /&gt;ls_purchase_order_item_results type ty_purchase_order_item_results,&lt;BR /&gt;&lt;BR /&gt;lt_purchase_order_item type STANDARD TABLE OF ty_purchase_order_item,&lt;BR /&gt;ls_purchase_order_item type ty_purchase_order_item,&lt;BR /&gt;&lt;BR /&gt;lt_purchase_order type STANDARD TABLE OF ty_purchase_order,&lt;BR /&gt;ls_purchase_order type ty_purchase_order.&lt;BR /&gt;&lt;BR /&gt;* Declare internal table to hold ZEC_MEX_PO_LOG data&lt;BR /&gt;DATA: lt_zec_mex_po_log TYPE STANDARD TABLE OF zec_mex_po_log.&lt;BR /&gt;&lt;BR /&gt;SELECT REGIONNAME&lt;BR /&gt;SUPPLIERCONTACTID&lt;BR /&gt;LINENUMBER&lt;BR /&gt;ORDEREDQUANTITY&lt;BR /&gt;UNITPRICE&lt;BR /&gt;INTO CORRESPONDING FIELDS OF TABLE lt_zec_mex_po_log&lt;BR /&gt;FROM zec_mex_po_log&lt;BR /&gt;where purchaseordernumber = 'G9623'.&lt;BR /&gt;&lt;BR /&gt;Loop at lt_zec_mex_po_log into data(ls_zec_mex_po_log).&lt;BR /&gt;ls_purchase_order-CompanyCode = ls_zec_mex_po_log-regionname.&lt;BR /&gt;ls_purchase_order-PurchaseOrderType = 'ZMX'.&lt;BR /&gt;ls_purchase_order-Supplier = ls_zec_mex_po_log-SUPPLIERCONTACTID.&lt;BR /&gt;ls_purchase_order-Language = 'EN'.&lt;BR /&gt;ls_purchase_order-PurchasingOrganization = 'PO02'.&lt;BR /&gt;ls_purchase_order-PurchasingGroup = 'PGP'.&lt;BR /&gt;ls_purchase_order-DocumentCurrency = 'AUD'.&lt;BR /&gt;ls_purchase_order-to_PurchaseOrderItem-RESULTS-PurchaseOrderItem = ls_zec_mex_po_log-LINENUMBER.&lt;BR /&gt;ls_purchase_order-to_PurchaseOrderItem-RESULTS-Plant = ls_zec_mex_po_log-regionname.&lt;BR /&gt;ls_purchase_order-to_PurchaseOrderItem-RESULTS-OrderQuantity = ls_zec_mex_po_log-ORDEREDQUANTITY.&lt;BR /&gt;ls_purchase_order-to_PurchaseOrderItem-RESULTS-PurchaseOrderQuantityUnit = 'EA'.&lt;BR /&gt;ls_purchase_order-to_PurchaseOrderItem-RESULTS-OrderPriceUnit = 'EA'.&lt;BR /&gt;ls_purchase_order-to_PurchaseOrderItem-RESULTS-NetPriceAmount = ls_zec_mex_po_log-UNITPRICE.&lt;BR /&gt;ls_purchase_order-to_PurchaseOrderItem-RESULTS-NetPriceQuantity = '1'.&lt;BR /&gt;ls_purchase_order-to_PurchaseOrderItem-RESULTS-Material = 'TG11'.&lt;BR /&gt;ls_purchase_order-to_PurchaseOrderItem-RESULTS-ManufacturerMaterial = 'TG11'.&lt;BR /&gt;ls_purchase_order-to_PurchaseOrderItem-RESULTS-ProductType = '1'.&lt;BR /&gt;Append ls_purchase_order to lt_purchase_order.&lt;BR /&gt;endloop.&lt;BR /&gt;&lt;BR /&gt;*DATA(lv_json) = /ui2/cl_json=&amp;gt;serialize( data = lt_purchase_order ).&lt;BR /&gt;&lt;BR /&gt;*WRITE : LV_JSON.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;DATA(lv_json) = /ui2/cl_json=&amp;gt;serialize(&lt;BR /&gt;data = lt_purchase_order&lt;BR /&gt;compress = abap_true&lt;BR /&gt;pretty_name = /ui2/cl_json=&amp;gt;pretty_mode-camel_case ).&lt;BR /&gt;&lt;BR /&gt;" Display JSON in ABAP&lt;BR /&gt;CALL TRANSFORMATION sjson2html SOURCE XML lv_json&lt;BR /&gt;RESULT XML DATA(lvc_html).&lt;BR /&gt;cl_abap_browser=&amp;gt;show_html(&lt;BR /&gt;title = 'Sample JSON'&lt;BR /&gt;html_string = cl_abap_codepage=&amp;gt;convert_from( lvc_html ) ).&lt;BR /&gt;&lt;BR /&gt;DATA(lo_reader) = cl_sxml_string_reader=&amp;gt;create( cl_abap_codepage=&amp;gt;convert_to( lv_json ) ).&lt;BR /&gt;TRY.&lt;BR /&gt;lo_reader-&amp;gt;next_node( ).&lt;BR /&gt;lo_reader-&amp;gt;skip_node( ).&lt;BR /&gt;cl_demo_output=&amp;gt;display( 'JSON is valid' ).&lt;BR /&gt;CATCH cx_sxml_parse_error INTO DATA(lx_parse_error).&lt;BR /&gt;cl_demo_output=&amp;gt;display( lx_parse_error-&amp;gt;get_text( ) ).&lt;BR /&gt;ENDTRY.&lt;P&gt;&lt;/P&gt;&lt;P&gt;This program is producing the below JSON format :&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;[
  {
    "companycode": "ECG",
    "purchaseordertype": "ZMX",
    "supplier": "348",
    "language": "EN",
    "purchasingorganization": "PO02",
    "purchasinggroup": "PGP",
    "documentcurrency": "AUD",
    "toPurchaseorderitem": {
      "results": {
        "purchaseorderitem": "1",
        "plant": "ECG",
        "orderquantity": "1.0000000",
        "purchaseorderquantityunit": "EA",
        "orderpriceunit": "EA",
        "netpriceamount": "15000.0000",
        "netpricequantity": "1",
        "material": "TG11",
        "manufacturermaterial": "TG11",
        "producttype": "1"
      }
    }
  } &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;]&lt;/P&gt;&lt;P&gt;But the expected format :&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;"CompanyCode": " ",&lt;/P&gt;&lt;P&gt;"PurchaseOrderType": " ",&lt;/P&gt;&lt;P&gt;"Supplier": " ",&lt;/P&gt;&lt;P&gt;"Language": " ",&lt;/P&gt;&lt;P&gt;"PurchasingOrganization": " ",&lt;/P&gt;&lt;P&gt;"PurchasingGroup": " ",&lt;/P&gt;&lt;P&gt;"DocumentCurrency": " ",&lt;/P&gt;&lt;P&gt;"to_PurchaseOrderItem": {&lt;/P&gt;&lt;P&gt;"results": [&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;"PurchaseOrderItem": " ",&lt;/P&gt;&lt;P&gt;"Plant": " ",&lt;/P&gt;&lt;P&gt;"OrderQuantity": " ",&lt;/P&gt;&lt;P&gt;"PurchaseOrderQuantityUnit": " ",&lt;/P&gt;&lt;P&gt;"OrderPriceUnit": " ",&lt;/P&gt;&lt;P&gt;"NetPriceAmount": " ",&lt;/P&gt;&lt;P&gt;"NetPriceQuantity": " ",&lt;/P&gt;&lt;P&gt;"Material": " ",&lt;/P&gt;&lt;P&gt;"ManufacturerMaterial": " ",&lt;/P&gt;&lt;P&gt;"ProductType": " "&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;]&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;The system produced JSON format is different from the expected format. First difference : starting and ending with square brackets ([ ]). This is to be removed. As per the expectation, Results are expecting in array format. Could any one please help me on this?&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Tue, 09 May 2023 23:11:46 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/map-the-database-table-data-to-purchase-order-json-format/m-p/12715456#M2019423</guid>
      <dc:creator>former_member139597</dc:creator>
      <dc:date>2023-05-09T23:11:46Z</dc:date>
    </item>
    <item>
      <title>Re: Map the database table data to Purchase Order JSON format</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/map-the-database-table-data-to-purchase-order-json-format/m-p/14019024#M2038541</link>
      <description>&lt;P&gt;Did you find out how to remove the square brackets?&lt;/P&gt;</description>
      <pubDate>Mon, 17 Feb 2025 18:55:59 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/map-the-database-table-data-to-purchase-order-json-format/m-p/14019024#M2038541</guid>
      <dc:creator>kmoore007</dc:creator>
      <dc:date>2025-02-17T18:55:59Z</dc:date>
    </item>
  </channel>
</rss>

