I am tasked with converting ABAP to xs Javascript using an ODATA service. The POST request will have a body.data object containing headers and an array of objects in the following format:
{
"IvCompCode":"1710",
"IvDocType":"NB",
"IvPurchOrg":"1710",
"IvPurGroup":"002",
"IvVendor":"17386001",
"ItemsSet":[
{
"Ebelp":"00010",
"Matnr":"MZ-RM-M500-09",
"Werks":"1710",
"Lgort":"171S",
"Menge":"5.000",
"Netpr":"100.000"
},
{
"Ebelp":"00020",
"Matnr":"MZ-RM-M500-07",
"Werks":"1710",
"Lgort":"171S",
"Menge":"4.000",
"Netpr":"105.000"
}
]
}
My challenge is how to pass variables from the ODATA service and use them in an ABAP function within the JavaScript function, ensuring they remain accessible for other logic as well. This is what I currently have:
<script language="JavaScript">
function callABAPMethod()
{
<%
DATA: po_header LIKE bapimepoheader,
poheaderx LIKE bapimepoheaderx,
tab_poitem TYPE STANDARD TABLE OF bapimepoitem,
tab_poitemx TYPE STANDARD TABLE OF bapimepoitemx,
tab_poitem_struct LIKE bapimepoitem,
tab_poitemx_struct LIKE bapimepoitemx,
ebelp_num(5) TYPE n,
ebelp_char(5) TYPE c.
// ABAP function code goes here...
%>
}
</script>