Over and under Hex display/edit

23730 pts.
Tags:
AS/400
Conversion
Hex
IBM iSeries
RPG
Hi, I'm busy with a utility program on the i-Series (written in OPM RPG - which is still the standard where I am) and I need to be able to show some fields in hex mode for editing, like the DSPPFM command when you press F10 and F11. So I'm looking to display the hex values "over and under", with the first hex digit on one line and the second hex digit on the line underneath. My question is : Is there an easy or neat way to do this, or do I have to translate everything from/to hex myself? Thanks in advance, Martin Gilbert.

Answer Wiki

Thanks. We'll let you know when a new response is added.

Here’s a lousy way to do it but it works and it is a quick and dirty fast way to do it:

For whatever file you have to display:

1) Do a copy file in *PRINT with OUTFMT in hexadecimal Ex: CPYF FROMFILE(YOURFILE) TOFILE(*PRINT) OUTFMT(*HEX)

2) create 2 temporarys file in QTEMP like CRTPF FILE(QTEMP/REP) RCDLEN(<Required len>) and CRTPF FILE(QTEMP/REP) RCDLEN(<Required len>)

3) Copy your spool file into the 1st created file with CPYSPLF FILE(QSYSPRT) TOFILE(QTEMP/REP)

4) remove the headers and other irrelevant information with another copy like CPYF FROMFILE(QTEMP/REP) TOFILE(QTEMP/REP2) MBROPT(*ADD) INCCHAR(REP 14 *EQ ‘ ‘) FMTOPT(*NOCHK)
Note that the position 14 always contain something when it is junk

If you want to remove the clear data, then you wolud have to repeat this last copy with position 17.

There you go ! Your REP2 file in QTEMP contain on 2 seperate record the information you want to display !

I told you it was a lousy way ….. but it work’s !

Have fun !

_________
DanTheMan

Discuss This Question: 6  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • Gilly400
    Hi Bruce, I could call an external program, that shouldn't be any problem. What did you have in mind? Best regards, Martin.
    23,730 pointsBadges:
    report
  • Gilly400
    Hi Dan, I wouldn't call it lousy - a bit of a strange way of doing it, I would never have thought of it. I may just give this a try. Will have to see how it performs and will have to write the data to a file first (it's coming from an MQ message queue). Best regards, Martin.
    23,730 pointsBadges:
    report
  • bvining
    Here's a little ILE CL program that will do the conversion:
    PGM        PARM(&DATA_IN &DATA_OUT &LEN_IN)             
    DCL        VAR(&DATA_IN) TYPE(*CHAR) LEN(1)             
    DCL        VAR(&DATA_OUT) TYPE(*CHAR) LEN(1)            
    DCL        VAR(&LEN_IN) TYPE(*INT)                      
    CALLPRC    PRC('cvthc') PARM((&DATA_OUT) (&DATA_IN) +   
                 (&LEN_IN *BYVAL))                          
    ENDPGM                                                  
    
    Create it with: CRTCLMOD MODULE(CHARTOHEX) DBGVIEW(*SOURCE) CRTPGM PGM(CHARTOHEX) BNDDIR(QC2LE) And call it from your OPM RPG program with three parameters: 1. The data you are starting from (the parameter can be any size X) 2. A receiver variable to get the converted data from (this variable must be defined twice the size as the first parameter - 2X) 3. A 4-byte binary value (9b 0) of 2X (ie - the size in bytes of the second parameter) After you've called the program, if parameter 1 was 'ABCDEF1234' then parameter 2 will have the value 'C1C2C3C4C5C6F1F2F3F4'. Loop through this taking the "odd" bytes and loading into your first line and the "even" bytes into the second display line. Bruce Vining
    6,510 pointsBadges:
    report
  • Gilly400
    Hi Bruce, I will give this a try, sounds like just the thing I need. Can I do something similar to convert the hex back to character after editing? Do I need to call 'cvtch' for that? Best regards, Martin.
    23,730 pointsBadges:
    report
  • bvining
    Hi, Martin You got it. cvtch provides the reverse function of cvthc. Bruce Vining http://www.brucevining.com/ Providing integrated solutions for the System i user community
    6,510 pointsBadges:
    report
  • Gilly400
    Hi Bruce, Thanks for the help on this - it works a treat. Best regards, Martin Gilbert.
    23,730 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following