Midrange News for the IBM i Community


Posted by: WestCoastGuy
chaining to logical file using binary input
has no ratings.
Published: 20 Sep 2011
Revised: 23 Jan 2013 - 1767 days ago
Last viewed on: 25 Nov 2017 (3868 views) 

Using IBM i? Need to create Excel, CSV, HTML, JSON, PDF, SPOOL reports? Learn more about the fastest and least expensive tool for the job: SQL iQuery.

chaining to logical file using binary input Published by: WestCoastGuy on 20 Sep 2011 view comments(4)

Hi Folks,

I am reading a database file which in turning uses a field from that file to access another file.

 

Problem is, the field I get from the first read file is in binary format and thus outputs as zeros when using the debug tool. The key field in the second file is binary also (nevermind the 'why is that done' - I have no idea and I didnt write it).

 

How do I convert this mess and access the second file , which really has the information I need.

Return to midrangenews.com home page.
Sort Ascend | Descend

COMMENTS

(Sign in to Post a Comment)
Posted by: neilrh
Premium member *
Jackson, MI
Comment on: chaining to logical file using binary input
Posted: 6 years 2 months 7 days 11 hours 49 minutes ago

I can't see any issue with what you're trying to do.  Common coding problems on the 2nd file tend to be missing of the KEYED designation in the F-Spec - since the field is numeric, missing this would result in CHAIN by RRN, rather than KEYFIELD.

Binary field data should be fully readable in debug mode when you run the program, though they're not particularly friendly if you look on the file, viewing in hex you can calculate what the Base10 number contained in the binary field is.

Your code should be something along the lines of:

 

fFileA     if   e           k disk   prefix('A.')
fFileB     if   e           k disk   prefix('B.')

 /free
   chain (KeyField) FileA;
   if %found(FileA);
     chain (A.Index) FileB;

 

Posted by: DaleB
Premium member *
Reading, PA
Comment on: chaining to logical file using binary input
Posted: 6 years 2 months 6 days 17 hours 32 minutes ago

Which debugger are you using? I'm not aware of any of them not being able to handle binary data. If in doubt try displaying in hex.

Posted by: bobcozzi
Site Admin ****
Chicagoland
Comment on: chaining to logical file using binary input
Posted: 6 years 2 months 6 days 11 hours 47 minutes ago

Can you define what you think "Binary Format" means?

I find that some people use a term in the context of RPG, so that we (in this example) think you mean legacy 4-byte binary fields or "B" data-types. But after reading your question, I'm thinking its a character field with hex data below X'40' in it.

Posted by: DaleB
Premium member *
Reading, PA
Comment on: chaining to logical file using binary input
Posted: 6 years 2 months 5 days 18 hours 18 minutes ago

Perhaps if you showed us the DDS, or SQL CREATE TABLE statement, and indicate which field/column is the foreign key...