B98ORCH output : parsing the output value in vase of exception

ybuffetaud

ybuffetaud

Active Member
Hi I have the requirement to get the output from the orchestration response in case of failure. We would like to create a table dedicated to end users, so they could now why their request failed.
So if my output is like that :

{ "status":"ERROR", "message" : "SR_FR_GenerationCollecteCreationFicheLogCde:(1) Code-Control: 019U-13_51, Title: Error: Version Effective - From Date incorrecte, Description: - Mois incorrect (il doit être situé entre 1 et 12). - Jour incorrect (il doit être situé entre 1 et 31, et compatible avec le mois). - Année incorrecte (elle doit être située entre 00 et 99). - Date non entrée. SOLUTION - Entrez une valeur Effective - From Date correcte.", "exception" : "java.lang.Exception", "timeStamp" : "2019-01-25T09:27:41.840+0100", "userDefinedErrorText" : "stefan texte supplémentaire suite err création fiche log!", "type" : "application","exceptionProcessResponse":{"ServiceRequest1":{"fs_P90CB020_W90CB020D":{"title":"Recherche d'opportunités","data":{"gridData":{"id":1,"fullGridId":"1","columns":{"z_DSCRP1_19":"Description","z_AN8_17":"Client Facturation","z_ALPH_18":"Nom client Facturation","z_ALPH_81":"Nom contact Facturation","z_CUSAN8_89":"Client Expédition","z_ALPH_90":"Nom client Expédition","z_ALPH_91":"Nom contact Expédition","z_PBLTY_21":"%","z_CLDATE_22":"Date Clôture","z_PTAMT_23":"Montant Potentiel","z_CRCD_24":"Code Monétaire","z_OPTYCD_25":"Code type Opportunité","z_QUFSCR_26":"Note Qualification","z_QUFGL_27":"Objectif Qualification","z_OPPID_28":"Nº Opp.","z_PBLTYQ_44":"Probabilité Interr."},"rowset":[{"z_OPTYCD_25":"DIR","z_PBLTYQ_44":100,"z_ALPH_18":"Suepermarché 17","z_CRCD_24":"EUR","z_QUFSCR_26":0,"z_ALPH_81":null,"z_AN8_17":2083025,"z_CUSAN8_89":2083025,"z_CLDATE_22":"2018-11-23T01:00:00.000+0100","z_ALPH_91":null,"z_ALPH_90":"Suepermarché 17","z_QUFGL_27":0,"z_DSCRP1_19":"stef67","z_PBLTY_21":100,"z_OPPID_28":446,"z_PTAMT_23":0}],"summary":{"records":1,"moreRecords":false}}},"errors":[],"warnings":[]},"stackId":0,"stateId":0,"rid":"","currentApp":"P90CB020_W90CB020D_FRSAR0001","timeStamp":"2019-01-25:09.27.56","sysErrors":[]}}}

I'd like to get back the following subtext :
  • "status":"ERROR" => I'd like to know if the statut is ERROR or other
  • "message" : "SR_FR_GenerationCollecteCreationFicheLogCde:(1) Code-Control: 019U-13_51, Title: Error: Version Effective - From Date incorrecte, Description: - Mois incorrect (il doit être situé entre 1 et 12). - Jour incorrect (il doit être situé entre 1 et 31, et compatible avec le mois). - Année incorrecte (elle doit être située entre 00 et 99). - Date non entrée. SOLUTION - Entrez une valeur Effective - From Date correcte." => I'd like to have the entire message
  • "userDefinedErrorText" : "stefan texte supplémentaire suite err création fiche log!" => i'd like to have the entire message.

So how do I strip this information from the entire strin, I didn't found any cleaver C function in JDE to do that.
If you could help me, It will be great.

I'm running JDE 9.2, tools 9.2.3.1 under an AS400 V7R3.
Regards
 
Hi Yann,

I haven't tried this myself but I suggest you look for an ANSI C JSON parser. There are a few open source available that seem quite small and simple. I would think a parser could be integrated into a custom BSFN that could take the JSON response string as input and return the status, message and userDefinedErrorText back to you.

Another way to do it would be to compile the JSON parser into an external library. There are ways to parse JSON in RPG and you can make a wrapper to make an RPG program callable via JDE C. Personally I wouldn't complicate it and just stick to ANSI C inside of JDE.

My last wild idea would be to just leverage DB2 for i's JSON support. I have been away from the AS/400 for a few years so I haven't had a chance to use this but I have used its Oracle equivalent JSON_TABLE. You could just insert the message as is to a table. You could then create a view over that table that parses out the JSON as columns which could then further be exposed to JDE using the virtual table technique we have discussed many times.

See this article on DB2 i JSON. https://www.mcpressonline.com/analy...e-and-parse-json-data-natively-with-db2-for-i

I would be interested to hear how you go with this.
 
Hi I juste discovered that B98ORCH could already do this if you type as output parameter "userDefinedErrorText", tou get it in on of the 20 available output.
The only limitation is that those fields are only 200 characters long.
But it will just meet our requirement
 
When there is an AIS error, the C BSFN B98ORCH returns the error text automatically in the szOutputString_REPTEXT field, which is 32Kb.

[Edit: nevermind, I just remembered that this is still in JSON, so you'd probably still have to parse it]
 
You can just get the error by having one of the output param name as error and grab it in some string variable in b98orch
 
Back
Top