Error 1002

Discussions relating to the ScottKlement.com port of the open source YAJL JSON Reader/Generator. This includes the YAJL tool as well as the YAJLR4, YAJLGEN, YAJLINTO and YAJLDTAGEN add-ons from ScottKlement.com. http://www.scottklement.com/yajl/
Post Reply
imaxeman69
Posts: 23
Joined: Thu Mar 17, 2022 2:29 pm

Error 1002

Post by imaxeman69 »

I'm getting an 1002 error when trying to use Data-Into with YAJLINTO. This is in the joblog:
1002: lexical error: invalid character inside string.█
The parser for the DATA-INTO operation detected error code 1002.
Function check. RNX0357 unmonitored by WSPROCJSON at statement 0000000228,
instruction X'0000'.

I've verified with JSONLINT that the JSON is valid. I'm also able to parse the json with javascript JSON.Parse.

Below is the actual Json since it's not very large:

Code: Select all

{
	"shipment": {
		"id": "f038828b-13f7-4c82-ab7d-d5597b8bcd03",
		"identifiers": [
			{
				"type": "BILL_OF_LADING",
				"value": "ONEYSGNCN2809600"
			},
			{
				"type": "CARRIER_SCAC",
				"value": "ONEY"
			}
		],
		"shipmentShareLink": "https://na12.voc.project44.com/portal/v2/public/ma/tracking-details?shipmentShareToken=1adf56b9-aeb1-4d9f-8ec6-6e43f6d0477c",
		"createdDateTime": "2022-09-06T22:08:47+0000",
		"lastModifiedDateTime": "2022-09-06T22:08:47+0000",
		"routeInfo": {
			"stops": [
				{
					"id": "5e22c9df-9a5a-4168-9762-205b3998c6f7",
					"type": "ORIGIN"
				},
				{
					"id": "f0643ca9-6ad4-4f42-ae31-dca4b4bd5f82",
					"type": "DESTINATION"
				}
			],
			"routeSegments": [
				{
					"id": "97b17b48-f436-49a1-bd40-f4ac8c4822c9",
					"fromStopId": "5e22c9df-9a5a-4168-9762-205b3998c6f7",
					"toStopId": "f0643ca9-6ad4-4f42-ae31-dca4b4bd5f82",
					"transportationMode": "OCEAN"
				}
			]
		},
		"relatedShipments": [
			{
				"id": "e23eb3b9-e7d7-4d73-8cfb-afcf93d057df",
				"identifiers": [
					{
						"type": "CONTAINER_ID",
						"value": "KKFU9157200"
					},
					{
						"type": "CARRIER_SCAC",
						"value": "ONEY"
					}
				],
				"shipmentShareLink": "https://na12.voc.project44.com/portal/v2/public/ma/tracking-details?shipmentShareToken=6a938250-319a-4fc0-94d3-3739c75f92fb",
				"createdDateTime": "2022-09-06T22:08:47+0000",
				"lastModifiedDateTime": "2022-09-06T22:08:47+0000"
			}
		]
	},
	"events": [
		{
			"dateTime": "2022-10-20T08:18:15+0000",
			"receivedDateTime": "2022-10-20T08:18:15+0000",
			"type": "TRACKING_START",
			"description": "Shipment tracking active"
		}
	]
}
jonboy49
Posts: 200
Joined: Wed Jul 28, 2021 8:18 pm

Re: Error 1002

Post by jonboy49 »

Basically a 1002 error is saying the data is invalid for the intended target. Since you didn't post the DS you are using or the DATA-INTO itself we have no idea what it might be.

Show us the code and we'll have a better idea.
jonboy49
Posts: 200
Joined: Wed Jul 28, 2021 8:18 pm

Re: Error 1002

Post by jonboy49 »

P.S. I just ran your json through the program generated by YAJLGEN and had no errors. So there has to be something in your definitions that is causing the issue.
imaxeman69
Posts: 23
Joined: Thu Mar 17, 2022 2:29 pm

Re: Error 1002

Post by imaxeman69 »

Code: Select all

         // inbound json structure.
         dcl-ds result qualified dim(1);
           dcl-ds shipment;
             id char(36);

             dcl-ds identifiers dim(99);
               type char(50);
               value char(50);
             end-ds;

             dcl-ds attributes dim(99);
               blanks char(100);
             end-ds;

             shipmentShareLink varchar(500);
             createdDateTime char(24);
             lastModifiedDateTime char(24);

             dcl-ds routeInfo;

               dcl-ds stops dim(99);
                 id char(36);
                 type char(100);
                 dcl-ds location;
                   name char(50);
                   dcl-ds identifiers dim(99);
                     type char(50);
                     value char(50);
                   end-ds;
                   dcl-ds coordinates;
                     latitude packed(9:6) inz;
                     longitude packed(9:6) inz;
                   end-ds;
                 end-ds;
               end-ds;

               dcl-ds routeSegments dim(99);
                 id char(36);
                 fromStopId char(36);
                 toStopID char(36);
                 transportationMode char(50);
                 dcl-ds identifiers dim(99);
                   type char(50);
                   value char(50);
                 end-ds;
               end-ds;
             end-ds;
           end-ds;


           dcl-ds relatedShipments dim(99);
             id char(36);
             dcl-ds identifiers dim(99);
               type char(50);
               value char(50);
             end-ds;
             dcl-ds attributes dim(99);
               blank char(100);
             end-ds;
             shipmentShareLink char(500);
             createdDateTime char(24);
             lastModifiedDateTime char(24);
           end-ds;

           dcl-ds states dim(99);
             type char(50);
             startDateTime char(24);
             endDateTime char(24);
             stopId char(36);
           end-ds;

           dcl-ds events dim(99);
             dateTime char(24);
             receivedDateTime char(24);
             type char(50);
             stopId char(36);
             routeSegmentId char(36);
             estimateDateTime char(24);
             plannedDateTime char(24);

           end-ds;

           dcl-ds positions dim(500);
             dateTime char(24);
             routeSegmentId char(36);
             latitude packed(9:6) inz;
             longitude packed(9:6) inz;
           end-ds;

         end-ds;   
         
         
                  data-into result %data(jsonData:
                                 'case=any +
                                  allowMissing=yes +
                                  allowExtra=yes')
                            %parser('YAJLINTO');                 
jonboy49
Posts: 200
Joined: Wed Jul 28, 2021 8:18 pm

Re: Error 1002

Post by jonboy49 »

I just used your code as-is - except that I added doc=file to read in the json you supplied - no errors.

So you're going to have to show some json that actually makes it go wrong - cos the stuff you posted works fine!

You could use a few countprefix fields for your arrays so that you can easily tell how many elements are populated. Also why have a dim(1) at the top level? That doesn't seem to serve any purpose and forces you to add the (1) to every data reference.
imaxeman69
Posts: 23
Joined: Thu Mar 17, 2022 2:29 pm

Re: Error 1002

Post by imaxeman69 »

The problem was a series of Hex 3Fs in the data. It may have not translated when I copied and posted the JSON. I did a %SCANRPL to replace the 3Fs with a blank, and it worked. Thanks for all the help.
Post Reply