Submitted by John Foldager on Mon, 02/12/2007 - 00:00
Forums

Hi!

See the following code:

 
d ilobConfiguration...
d                 s               *                                    
    // Store all configurations in a single ILOB
d  MyValue                  40    varying
d SettingDS       ds 
d  Value                    40    varying
d Setting         ds              likeds(SettingDS)
d Configuration   ds              qualified
d                                 based(ilobConfiguration) 
d  MyValueArray... 
d                                 likeds(Setting) dim(99)              //

I do the following: Assign a value to 'MyValue': include tha dollar '$' character. Assign 'MyValue' to an element in 'MyValueArray'. Write 'MyValue' to trace using trace(). Write 'MyValueArray' value to trace using trace().

Both trace()'s output the dollar sign to the trace log.

Next I do: Assign 'MyValueArray' element back into 'MyValue'. Write 'MyValue' to trace using trace().

This trace() will write 'Ã…' instead of '$'.

Is there some kind of CCSID translation when something is stored and/or retrieved from content that is stored in an ILOB?

Best regards,

John Foldager
www.izone.dk
www.icebreakforum.org

Syd Nicholson

Mon, 02/12/2007 - 00:00

Hi John,

I have found problems with the first 50 bytes of an ILOB. For some reason IceBreak seems to overwrite the information with its own data.

Can I suggest that you offset you ILOB working area by 50 bytes and see if this helps.

Incidently - If this helps - I usually use the following approach ( note the column positioning is not accurate!!):

 
D H                   S                *                                Pointer to ILOB header
D D                   S                *                                Pointer to ILOB detail record

D pH                 DS                   BASED(H) 
D  reserved                       50A 
D  numrcds                        10I 0                            Num rcds in ILOB                           

D pD                 DS                   BASED(D)              Example data record        
D  fld1                               50A VARYING 
D  fld2                             128A VARYING  
D  fld3                                   Z 
D  fld4                               10I 0

The pointer D is a function of pointer H and can therefore can be calculated from H if the value of H is a known variable. Let us suppose we have data in the ILOB and that we have the pointer to H, then to process the data in the ILOB record by record, then we must use something like:

 
  FOR i = 1 TO numrcds;

   pD = pH + %LEN(H) + (%LEN(D) * (i -1));    // Gives us the next D record

   ------  Process D record

 ENDFOR; 

A similar process can be used to add data to the ILOB - don't forget to increment the record count in H

It is also worth noting that if you don't need to store information in the session you can perform a similar process using the RPG %ALLOC and %REALLOC BIFs and the DEALLOC op code.

Hope this helps
Syd

Gents;

When you are receiving the pointer to the ILOB - then it is a handle. so you have to retrive the data pointer from the handle. the workaround that Syd i sugesting actually work ... but use the real poiner please...

 
<% 
*' --------------------------------------------------------------------------------
*' Use ilob with datastructures: Get/Set data in persistant ILOB
*' --------------------------------------------------------------------------------

/include qasphdr,ilob

D*Name++++++++++ETDsFrom+++To/L+++IDc.Keywords++++++++++++++ 
d  AppLib         s             10 
d  MyIlob         s               *  
d  MyIlobDta      s               *   

d  MyDs           ds                  based(MyIlobdta) 
d    Used                         N 
d    Counter                    10i 0  
d    Name                       50  
*' --------------------------------------------------------------------  
*' Main logic  
*' --------------------------------------------------------------------

C/free    
   *inlr = *on;
   MyIlob = SesGetILOB('MyIlob'); 
   MyIlobDta = ILOB_GetDataPtr(MyIlob);   //' Get the data pointer to the ILOB 

   if (not used);                         //' Initialize contents if it's the first time 
     Counter = 0; 
     Used = *ON; 
   endif; 

   Counter = Counter + 1;       

   %><% = %char(Counter) %>