Submitted by Syd Nicholson on Wed, 08/19/2009 - 00:00
Forums

My ignorance of IceBreak features only makes me want to learn more. So I have a few more questions about features I think already exist:

1. Are there any procedures to decode JSON?
2. Is there an IceBreak procedure to determine the existence of a i5/OS user profile?
3. Is there an IceBreak procedure to determine the existence of an i5/OS object?
4. Are there IceBreak procedures to manipulate lists of i5/OS objects, and/or i5/OS IFS entries?
5. There seem to a large number of ILOB_ procedures in SVC200. What do these do, what parameters are required?
6. The same goes for the Record_ procedures?


Finally, do anybody know of an easy JavaScript feature for creating XML. The reason for this question is as follows:

I need to send data to the iSeries from a client created with Extjs. The data exists on a form and a grid. The entire form and all the grid records need to be sent as a single transaction. At present the obvious way is to code a JavaSript function to convert the data to XML and send this with an Ext.Ajax request to IceBreak. It would be easier if the JavaScript functions existed and I did not need to invent any new wheels. I can't find any XML creation stuff in Extjs.

Extjs is built on JSON, and it would be much easier to construct a json object to send back to IceBreak instead of using XML. However, I can't find a Json decoder in IceBreak so this would involve inventing new wheels to decode the json on the i5.

Many thanks in advance for your help
Syd

Anonymous (not verified)

Wed, 08/19/2009 - 15:57

Not specific to Icebreak but someone mentioned a JSON Service program over at the forums.systeminetwork.com board.

"The provided service program allows the creation, parsing and checking of JSON strings through a number of procedures. "

I use CGIDEV2 to generate JSON "objects" from the server - it's not any more difficult than generating XML, HTML or CSV.

I have not had to parse JSON on the server side yet. Typically web requests I see have a few paramaters in (eg: order number)and many more in the response (eg: complete order header & detail) so it has not been priority.

Note: Syd is correct. The utility sited above is more about generating JSON, than interpreting it

Thanks,

I checked the link, but unfortunately did not find anything on parsing JSON on the i5. Just creating JSON and sending it to the client.

I have an application that must return an entire despatch note to the i5. This consists of a the header details, an array of records for each item line (held in an Extjs grid) and then inside this array, a further array of optional line text.

I could return the data as XML (IceBreak includes an XML parser on the i5) but I need to biuld the XML first. I don't have any JavaScript functions that generate XML, so I am searching the web for appropriate code. I could, I suppose, create my own JavaScript to do this job.

Using Extjs, my data is already defined as JSON objects. It occured to me that it may be easier to return a JSON object to the i5, than convert the JSON to XML.

Most transactions with the i5 involve returning single records to the server. This is a little different, so I am searching arround to find the best way of sending a block (array) of records back to server, and procesing each record in the array on the i5.

Syd

Hi Syd,

> 1. Are there any procedures to decode JSON?

Yes, you can use function sql_execute to return the JSON format directly. Simply use it like this:
 

 
Sqlcmd = ‘select * from product’; 
SQL_Execute( 
       I_EXTJSMETA:  //' Return the resultset in extJS format including metadata 
       sqlcmd:       //' The SQL statement to run "Select ..." The first coloumn has to be a unique key (or rrn) if used for updates 
       1             //' Return only one row 
    );
 

> 2. Is there an IceBreak procedure to determine the existence of a i5/OS user profile? Yes – Look in the manual under “Utilities” and you will find a function called UserExists(UserProfile);. It returns a bool for true if the user exists;
 

 if UserExists(User);

     // The User exists

  else;

    // The User does not exists

   endif 

3. Is there an IceBreak procedure to determine the existence of an i5/OS object?

The same – look into the manual under “Utility” and you find a function called: ObjectExists(Library: Object: ObjectType);

4. Are there IceBreak procedures to manipulate lists of i5/OS objects, and/or i5/OS IFS entries?

Yes – first the os400 object – again look into the manual “Utility” under “ObjectOpenList and ObjectListRead” - with very few lines of code you will be able to read through objects I a library.

You should also check the MemberListOpen/Read and FieldListOpen/Read.

When it comes to IFS we have made an include source file called IFS. You can then read IFS objects directly from RPG like:

 
// Open the Stream file for read                                      
stream = open(%trim(Path) : O_RDONLY);                                
if (stream >= 0);                                                     
  l = read(stream: pDiplom : %size(Diplom));                          
                                                                      
  // Is this file a IceBreak framework version 1                      
  if (Stamp = 'IceBreak' and Version = 1);                            
    l = read(stream: %addr(I_Atr) : %size(I_ATR));                    
    // now read the entire stream file and put it to the save file    
    l = read(stream: %addr(Data) : %size(Data));                      
    dow (l > 0);                                                      
      except writeData;                                               
      l = read(stream: %addr(Data) : %size(Data));                    
    enddo;                                                            
  endif;                                                              
  l = Close (stream);                                                 
endif; 
 

5. There seem to a large number of ILOB_ procedures in SVC200. What do these do, what parameters are required?

I’ll come back

> 6. The same goes for the Record_ procedures?

I’ll come back

>Finally, do anybody know of an easy JavaScript feature for creating XML. The reason for this >question is as follows:

>I need to send data to the iSeries from a client created with Extjs. The data exists on a form and a >grid. The entire form and all the grid records need to be sent as a single transaction. At present the >obvious way is to code a JavaSript function to convert the data to XML and send this with an >Ext.Ajax request to IceBreak. It would be easier if the JavaScript functions existed and I did not >need to invent any new wheels. I can't find any XML creation stuff in Extjs.

>Extjs is built on JSON, and it would be much easier to construct a json object to send back to >IceBreak instead of using XML. However, I can't find a Json decoder in IceBreak so this would >involve inventing new wheels to decode the json on the i5.

You should try to look at the ExtJS tool wizard incorporated in the IceBreak ADMIN server. Here you will find a bunch of templates for generating ExtJS code to handle what you are looking for.


I hope this can help you

Regards

Bent Ronne
Technical manager
System & Method A/S

NB! I the future please split your questions up! This will help us answering your questions easier and it will become easier for the audience to understand what’s going on.

Thanks Bent,

This is good stuff. It will save a lot of time -- no programming required for API interfaces.

Just another question - Is there a procedure to return user information - things like the description, user class, user group, whether the user is enabled, the list of supplemental groups, etc.?

Regarding the JSON - it is a way of interpreting JSON received by IceBreak I am interested in.

Regards
Syd

Hi,

I just wanted to correct the above statement that the JSON service program cannot parse a JSON string. The service program is create from several modules. The modules support creating, parsing, checking a JSON string. The web site even states that parsing is supported.

The documentation about the API can be found here: http://iledocs.sourceforge.net/docs/index.php?program=/QSYS.LIB/FIST1.L…

There is even an example on the web site which demonstrates parsing a JSON string: http://www.rpgnextgen.com/downloads/json_par01.rpgle

Regards

Mihael

Hi,

feel free to link to my page or to copy the example code. No problem with that.

Perhaps it would be better to have an Icebreak program example on how to use the JSON parser module (though the main function of the parser module should be clear with the current example and the documentation).

Regards

Mihael