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.
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.
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;
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.
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.