cancel
Showing results for 
Search instead for 
Did you mean: 

The following problem occurred: JSON parse Error: SyntaxError: Syntax error -

mashfaq
Contributor
0 Kudos

Dear All,

         I am facing this error "JSON parse Error" while executing IRPT page for I5Grid & I5Chart. for Java applet I did not face any error.

I am using this code in start of page

    <LINK href="https://answers.sap.com/XMII/CM/MII_Essentials/00_Common/00_CSS/Content.css" rel="stylesheet" type="text/css"/>

    <LINK href="https://answers.sap.com/XMII/CM/MII_Essentials/00_Common/00_CSS/FitToPage.CSS" rel="stylesheet" type="text/css"/>

    <SCRIPT type="text/javascript" src="/XMII/JavaScript/bootstrap.js" data-libs="i5Chart,i5Grid"></SCRIPT>

    <SCRIPT type="text/javascript" src="/XMII/CM/MII_Essentials/00_Common/10_JSFiles/UtilityFunctions.js" language="javascript"></script>

    <SCRIPT type="text/javascript" src="/XMII/CM/MII_Essentials/00_Common/10_JSFiles/cookie.js"></SCRIPT>

    <SCRIPT type="text/javascript" src="/XMII/CM/NRC_2010/Maintenance/Maintenance.js" language="javascript"></script>

Thanks

Muhammad Ashfaq

Accepted Solutions (0)

Answers (1)

Answers (1)

Private_Member_14935
Active Participant
0 Kudos

Hi Muhammad,

Will it be possible to share the code in .irpt page that you are trying which throws JSON.parse error.

I don't think the code you have shared helps identify the issue.

Thanks and Best Regards,

Ria

mashfaq
Contributor
0 Kudos

Dear Ria,

Here is JS coding & IRPT coding respectively:

//**-----------------------------------------------------------------------------------------

$(document).ready(function(){

jQuery.sap.require("sap.m.DateTimeInput");

  var nNow = new Date();

var application = "Equipment Status";

 

/*-------------------- stDate -------------------- */

//*2011-02-10T00:00:00

//*yyyy-MM-dd'T'hh:mm:ss

/*-------------------- stDate -------------------- */

  

var stDate = new sap.m.DateTimeInput({

    width : "99%",

    type : "DateTime",

    displayFormat : "dd MMMM, yyyy H'h' m'm' a",

    dateValue : new Date(nNow-1000*24*60*60),

    valueState : "Warning"

  });

  stDate.placeAt("divStDate");

/*-------------------- endDate -------------------- */

  var nNow = new Date();

 

  var endDate = new sap.m.DateTimeInput({

    width : "99%",

    type : "DateTime",

   displayFormat : "dd MMMM, yyyy h'h' m'm' a",

    dateValue : new Date(nNow),

    valueendDate : "Warning"

  });

 

  endDate.placeAt("divEndDate");

/*-------------------- endDate -------------------- */

var oDateFormat = sap.ui.core.format.DateFormat.getDateTimeInstance({pattern: "yyyy-MM-ddTHH:mm:ss"});

var addProps = '{'+

  '"DisplayTemplate":"NRC_2010/Notifications/UI/EuquipmentStatusUI5",'+

  '"QueryTemplate":"NRC_2010/Notifications/UI/XGetEquipmentListAndStatus",'+

  '"Content-Type":"image/png"'+

  '}';

var EquipStatus = new com.sap.xmii.grid.init.i5Grid('NRC_2010/Notifications/UI/EuquipmentStatusUI5','NRC_2010/Notifications/UI/XGetEquipmentListAndStatus',addProps);

EquipStatus.setGridWidth("450px");

EquipStatus.setGridHeight("400px");

EquipStatus.draw('EquipStatus');

EquipStatus.update(true);

//***-----------------------------------------------------------------------------------------------------------------

//***-------------------------------TagStatisticlist----------------------------------------------------------***///

var addProps = '{'+

    '"DisplayTemplate":"NRC_2010/Notifications/UI/StatisticTagListUI5",'+

    '"QueryTemplate":"NRC_2010/Notifications/UI/XGetStatisticTagList",'+

    '"Content-Type":"image/png"'+

    '}';

  var TagStatisticlist = new com.sap.xmii.grid.init.i5Grid('NRC_2010/Notifications/UI/StatisticTagListUI5','NRC_2010/Notifications/UI/XGetStatisticTagList',addProps);

  TagStatisticlist.setGridWidth("800px");

  TagStatisticlist.setGridHeight("400px");

 

 

var fnEquipStatusSel = (function(){

var c = EquipStatus.getGridObject().getSelectedCellValue(3);

 

  var oDateFormat = sap.ui.core.format.DateFormat.getDateTimeInstance({pattern: "yyyy-MM-ddTHH:mm:ss"});

  TagStatisticlist.getQueryObject().setParameter('Param.1', c);

  TagStatisticlist.getQueryObject().setParameter('Param.2', oDateFormat.format(stDate.getDateValue()));

  TagStatisticlist.getQueryObject().setParameter('Param.3', oDateFormat.format(endDate.getDateValue()));

 

  TagStatisticlist.draw('TagStatisticlist');

  TagStatisticlist.update(true);

});

  EquipStatus.registerRowSelectionEventHandler(fnEquipStatusSel);

//***-------------------------------TagStatisticlist----------------------------------------------------------***///

//***-------------------------------TagStatistic----------------------------------------------------------***///

 

var fntagSel = (function(){

var addProps = '{'+

    '"DisplayTemplate":"NRC_2010/Notifications/UI/TagStatisticChartUI5",'+

    '"QueryTemplate":"NRC_2010/Notifications/Queries/TagStatisticDetail1",'+

    '"Content-Type":"image/png"'+

    '}';

  var TagStatistic = new com.sap.xmii.chart.hchart.i5Chart('NRC_2010/Notifications/UI/TagStatisticChartUI5','NRC_2010/Notifications/Queries/TagStatisticDetail1',addProps);

  TagStatistic.setChartWidth("800px");

  TagStatistic.setChartHeight("200px");

var d = TagStatisticlist.getGridObject().getSelectedCellValue(8);

 

  var oDateFormat = sap.ui.core.format.DateFormat.getDateTimeInstance({pattern: "yyyy-MM-ddTHH:mm:ss"});

  //var Query1= TagStatistic.getQueryObject();

                //Query1.setParameter("Param.1",d); 

                //Query1.setParameter("Param.2",oDateFormat.format(stDate.getDateValue()));

     //Query1.setParameter("Param.3",oDateFormat.format(endDate.getDateValue()));

  TagStatistic.getQueryObject().setTagName(1,TagStatisticlist.getGridObject().getSelectedCellValue(8));

  TagStatistic.getQueryObject().setStartDate(oDateFormat.format(stDate.getDateValue()));

  TagStatistic.getQueryObject().setEndDate(oDateFormat.format(endDate.getDateValue()));

   TagStatistic.draw('TagStatistic');

  TagStatistic.update(true);

});

  TagStatisticlist.registerRowSelectionEventHandler(fntagSel);

//***-------------------------------TagStatistic----------------------------------------------------------***///

//***-------------------------------Refresh----------------------------------------------------------***///

var refresh = new sap.ui.commons.Button({

  text:'Refresh Data',

  press:function(){

var oDateFormat = sap.ui.core.format.DateFormat.getDateTimeInstance({pattern: "yyyy-MM-ddTHH:mm:ss"});

var startdate = oDateFormat.format(stDate.getDateValue());

var enddate = oDateFormat.format(endDate.getDateValue());

var c = EquipStatus.getGridObject().getSelectedCellValue(3);

var addProps = '{'+

    '"DisplayTemplate":"NRC_2010/Notifications/UI/StatisticTagListUI5",'+

    '"QueryTemplate":"NRC_2010/Notifications/UI/XGetStatisticTagList",'+

    '"Content-Type":"image/png"'+

    '}';

  var TagStatisticlist = new com.sap.xmii.grid.init.i5Grid('NRC_2010/Notifications/UI/StatisticTagListUI5','NRC_2010/Notifications/UI/XGetStatisticTagList',addProps);

  TagStatisticlist.setGridWidth("800px");

  TagStatisticlist.setGridHeight("400px");

  TagStatisticlist.draw('TagStatisticlist');

TagStatisticlist.getQueryObject().setParameter('Param.1', c);

  TagStatisticlist.getQueryObject().setParameter('Param.2', oDateFormat.format(stDate.getDateValue()));

  TagStatisticlist.getQueryObject().setParameter('Param.3', oDateFormat.format(endDate.getDateValue()));

  TagStatisticlist.update(true);

}

});

refresh.placeAt('refresh');

});

//***-------------------------------Refresh----------------------------------------------------------***///

//**------------------------------IRPT------------------------------------------------------------------**//

<!DOCTYPE HTML>

<HTML>

  <HEAD>

<title>{Area}</title>

  <META http-equiv="X-UA-Compatible" content="IE=edge">

    <META http-equiv='cache-control' content='no-cache'>

    <META http-equiv='expires' content='0'>

    <META http-equiv='pragma' content='no-cache'>

    <LINK href="https://answers.sap.com/XMII/CM/MII_Essentials/00_Common/00_CSS/Content.css" rel="stylesheet" type="text/css"/>

    <LINK href="https://answers.sap.com/XMII/CM/MII_Essentials/00_Common/00_CSS/FitToPage.CSS" rel="stylesheet" type="text/css"/>

    <SCRIPT type="text/javascript" src="/XMII/JavaScript/bootstrap.js" data-libs="i5Chart,i5Grid"></SCRIPT>

    <SCRIPT type="text/javascript" src="/XMII/CM/MII_Essentials/00_Common/10_JSFiles/UtilityFunctions.js" language="javascript"></script>

    <SCRIPT type="text/javascript" src="/XMII/CM/MII_Essentials/00_Common/10_JSFiles/cookie.js"></SCRIPT>

    <SCRIPT type="text/javascript" src="/XMII/CM/NRC_2010/Maintenance/Maintenance.js" language="javascript"></script>

  </HEAD>

  <SPAN class="ContentTitle">{##Equipment Status}</SPAN>

<BODY>

  <form name="frmMain" action id="frmMain">

  <table border="0"  cellspacing="1"  width="1000" id="table1" valign="top">

  <tr>

  <td colspan="2">

<table  border="0"  cellspacing="1"  width="100%" id="table3" align="left">

                <TABLE style="width:100%;height:100%;CELLPADDING=0;CELLSPACING=0;" >

                  <TR style="height:50%;">

                    <TD style="width:8%;text-align:left;">{##Start Date}:</TD>

                    <TD style="width:22%;">

                      <DIV id="divStDate" style="text-align: left;"></DIV>

                    </TD>

                    <TD style="width:8%;text-align:left;">{##End Date}:</TD>

                    <TD style="width:22%;">

                      <DIV id="divEndDate" style="text-align: left;"></DIV>

                    </TD>

  <TD style="width:10%;text-align:right;">

                     <div id='refresh'></div>

                    </TD>

</table>

</td>

<input type="hidden" id="Area" name="Area" value="{Area}"/>

  </tr>

  <tr>

  <td>

  <table border="0" cellspacing="1" id="table2" valign="top" >

  <tr>

  <td>

  <DIV id="EquipStatus"/></DIV>

</td>

  </tr>

  <tr>

  <td>

</table>

  <td>

  <table border="0" cellspacing="1" id="table3" valign="top" >

  <tr>

  <td>

  <DIV id="TagStatisticlist"/></DIV>

  <tr>

  <td>

  <DIV id="TagStatistic"/></DIV>

</td>

  </tr>

  </table>

  </td>

  </tr>

</form>

</BODY>

</HTML>

//**------------------------------IRPT------------------------------------------------------------------**//

Thanks

Muhammad Ashfaq

Private_Member_14935
Active Participant
0 Kudos

Hi Muhammad,

I checked the above code, looks fine.. but couldn't try it out.

Have you tried running the display templates (that you have passed in the constructor of i5Chart/i5Grid in your IRPT page) independently - by using "Test" button- does it work then.. ?

If the issue still persists for you then may be you can try adding one MII UI5 component (i5Grid or i5Chart) at a time and debug the same.

Thanks,

Ria