Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Not able to read HEX data in File

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX
View previous topic :: :: View next topic  
Author Message
scorp_rahul23

New User


Joined: 06 May 2008
Posts: 90
Location: Chennai

PostPosted: Mon Mar 05, 2012 1:46 pm    Post subject: Not able to read HEX data in File
Reply with quote

I am trying to search a HEX string in a file. Its not picking this up.



Code:

"ALLOC DA('"USERID()".TOOL.INPUT') F(MPRMAIN) OLD REUSE"         
"EXECIO * DISKR MPRMAIN (STEM MPRMAIN. FINIS"                     
DONE = 'NO'                                                       
LINENO = 0                                                       
DO WHILE DONE = 'NO'                                             
"EXECIO 1 DISKR MPRMAIN"                                         
IF RC = 0 THEN /* RECORD WAS READ */                             
DO                                                               
PULL RECORD                                                       
CHECK = X'0352856421901C'                                         
LINENO = LINENO + 1 /* COUNT THE RECORD */                       
   IF INDEX(RECORD,CHECK) \= 0 THEN                               
     DO                                                           
      SAY 'FOUND IN RECORD' LINENO                               
      SAY 'RECORD = ' RECORD                                     
      DONE = 'YES'                                               
     END                                                         
   ELSE NOP                                                       
    SAY "HI"                                                     
   END                           
   ELSE                         
    DONE = 'YES'                 
   END                           



Input file is like

Code:

           POS       r T074      e         P      0   0           0   0  ~   ~ 
0AB00000000DDE000040098EFFF4444058629144444D444004F004F00AB00AB004F004F00A200A20
4FA0000000C7625C043C09C30740000325410C0000070000290029004FA04FA02900290071007100



Can anyone suggest what I am doing wrong in this.
Back to top
View user's profile Send private message

dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Mon Mar 05, 2012 2:08 pm    Post subject:
Reply with quote

immediately after the
/* REXX */ statement
insert
trace ?r
then rerun you REXX Script
and tell us what is going on,
if you can not figure it out.
Back to top
View user's profile Send private message
scorp_rahul23

New User


Joined: 06 May 2008
Posts: 90
Location: Chennai

PostPosted: Mon Mar 05, 2012 2:35 pm    Post subject: Reply to: Not able to read HEX data in File
Reply with quote

Code:

     6 *-* "ALLOC DA('"USERID()".TOOL.INPUT') F(MPRMAIN) OLD REUSE" 
       >>>   "ALLOC DA('AAAAAAA.TOOL.INPUT') F(MPRMAIN) OLD REUSE"   
     7 *-* "EXECIO * DISKR MPRMAIN (STEM MPRMAIN. FINIS"             
   >>>   "EXECIO * DISKR MPRMAIN (STEM MPRMAIN. FINIS"               
 8 *-* DONE = 'NO'                                                   
   >>>   "NO"                                                         
 9 *-* LINENO = 0                                                     
   >>>   "0"                                                         
10 *-* DO WHILE DONE = 'NO'                                           
   >>>   "1"                                                         
11 *-*  "EXECIO 1 DISKR MPRMAIN"                                     
   >>>    "EXECIO 1 DISKR MPRMAIN"                                   
12 *-*  IF RC = 0                                                     
   >>>    "1"                                                         
   *-*   THEN /* RECORD WAS READ */                                   
13 *-*   DO                                                           
14 *-*    PULL RECORD                                                 
.
.
.                                            "                       
15 *-*    CHECK = X'0352856421901C'                                 
   >>>      "X0352856421901C"                                       
16 *-*    LINENO = LINENO + 1 /* COUNT THE RECORD */               
   >>>      "1"                                                     
17 *-*    IF INDEX(RECORD,CHECK) := 0                               
   >>>      "0"                                                     
23 *-*    ELSE                                                     
   *-*     NOP                                                     
24 *-*    SAY "HI"                                                 
   >>>      "HI"                                                   
   25 *-*   END                                   
   28 *-* END                                     
   10 *-* DO WHILE DONE = 'NO'                     
      >>>   "1"                                   
   11 *-*  "EXECIO 1 DISKR MPRMAIN"               
      >>>    "EXECIO 1 DISKR MPRMAIN"             
      +++ RC(2) +++                               
   12 *-*  IF RC = 0                               
      >>>    "0"                                   
   26 *-*  ELSE                                   
   27 *-*   DONE = 'YES'                           
      >>>     "YES"                               
   28 *-* END                                     
   10 *-* DO WHILE DONE = 'NO'                     
      >>>   "0"                                   
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Mon Mar 05, 2012 3:11 pm    Post subject:
Reply with quote

why are you doing this:
Code:

"EXECIO 1 DISKR MPRMAIN"   
Back to top
View user's profile Send private message
scorp_rahul23

New User


Joined: 06 May 2008
Posts: 90
Location: Chennai

PostPosted: Mon Mar 05, 2012 3:26 pm    Post subject: Reply to: Not able to read HEX data in File
Reply with quote

It just I am trying to read one record at a time. I think my check for checkign for hex character is failing.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Mon Mar 05, 2012 3:33 pm    Post subject:
Reply with quote

a few comments:

1. POS is the preferred command. INDEX is not that portable.

2. instead of using a negation symbol, use <> for not equal.
the negation symbol is not that portable.

3. suggest that you learn how to use stems.
the second EXECIO that i mentioned in my last post is part of your problem.
after the first EXECIO:

Code:

"EXECIO * DISKR MPRMAIN (STEM MPRMAIN. FINIS" 

all the records are in stem MPRMAIN.

also, do not use the same word for a variable or filename and a stem name.
it can become problematic (as in sex) if you miss a period.

4. get into the habit of checking RC after each service call.
in this case, the first EXECIO.

by portable, i mean from one system to another.
Back to top
View user's profile Send private message
scorp_rahul23

New User


Joined: 06 May 2008
Posts: 90
Location: Chennai

PostPosted: Mon Mar 05, 2012 3:41 pm    Post subject: Reply to: Not able to read HEX data in File
Reply with quote

I changed my whole coding logic as per yous uggestion, but still its not working..

Code:

"ALLOC DA('"USERID()".TOOL.INPUT') F(MPRIN) OLD REUSE"                 
"ALLOC DA('"USERID()".TOOL.OUTPUT') F(MPROUT) OLD "                     
"EXECIO * DISKR MPRIN (STEM NEWVAR. FINIS"                             
IF RC = 0 THEN                                                         
DO                                                                     
DO I =1 TO NEWVAR.0                                                     
  RECORD = NEWVAR.I                                                     
  STRNG = X'0352856421901C'                                             
  STRNGPOS = POS(STRNG,NEWVAR.I)                                         
  IF STRNGPOS <> '0' THEN                                               
    DO                                                                 
    PUSH NEWVAR.I                                                       
    "EXECIO 1 DISKW MPROUT"                                             
    SAY "WRITTEN"                                                       
    END                                                                 
  ELSE                                                                 
    SAY "NOT WRITTEN"                                                   
END                                                                     
END                                                                     
    "EXECIO 0 DISKW MPROUT (FINIS"                                     
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7226

PostPosted: Mon Mar 05, 2012 4:14 pm    Post subject: Reply to: Not able to read HEX data in File
Reply with quote

Why didn't you run the Trace for the new code? Look at the trace output yourself, try to work out the problem. Don't start the trace where you think the problem might be, cover everything.

Why set the string each time in the loop? What do you now do with RECORD?
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Mon Mar 05, 2012 4:19 pm    Post subject:
Reply with quote

well, your problem is here

had you bothered to look at your trace (that is why you run a REXX Script in trace mode, by the way)
you would have found your problem:

Code:
15 *-*    CHECK = X'0352856421901C'                                 
   >>>      "X0352856421901C"         


in addition:

Code:

"ALLOC DA('"USERID()".TOOL.INPUT') F(MPRIN) OLD REUSE"                 
RTNCD = RC
IF RTNCD <> 0 THEN
   DO
     SAY 'ALLOCATION OF INPUT FILE SUCKS: ' RTNCD
     FREE MPRIN
     EXIT                                                         
   END     
               
"EXECIO * DISKR MPRIN (STEM NEWVAR. FINIS"
RTNCD = RC
IF RTNCD <> 0 THEN
   DO
     SAY 'EXECIO OF INPUT FILE SUCKS: ' RTNCD
     FREE MPRIN
     EXIT                                                         
   END
/*  */
OUTSTEM. = ""
OUTSTEM.0 = 0
OCNT = 0
STRNG = X'0352856421901C'   /* fix this ====================*/
                                                                     
DO I = 1 TO NEWVAR.0                                                     
  IF POS(STRNG,NEWVAR.I)  <> 0 THEN                                               
    DO                                                                 
      OCNT = OCNT + 1
      OUTSTEM.OCNT = NEWVAR.I                                                     
    END                                                                 
END                                                                     

OUTSTEM.0 = OCNT

"ALLOC DA('"USERID()".TOOL.OUTPUT') F(MPROUT) OLD "
RTNCD = RC
IF RTNCD <> 0 THEN
   DO
     SAY 'ALLOCATION OF OUTPUT FILE SUCKS: ' RTNCD
     FREE MPROUT
     EXIT                                                         
   END     

"EXECIO 0 DISKW MPROUT (STEM OUTSTEM. FINIS" 
RTNCD = RC
IF RTNCD <> 0 THEN
   DO
     SAY 'EXECIO OF OUTPUT FILE SUCKS: ' RTNCD
     FREE MPROUT
     EXIT                                                         
   END
FREE MPROUT
SAY NEWVAR.0 ' RECORDS READ'
SAY OUTSTEM.0 ' RECORDS WRITTEN'
EXIT


i provided you what i think is a better script.......
Back to top
View user's profile Send private message
scorp_rahul23

New User


Joined: 06 May 2008
Posts: 90
Location: Chennai

PostPosted: Mon Mar 05, 2012 4:33 pm    Post subject: Reply to: Not able to read HEX data in File
Reply with quote

Thanks for a better REXX script.

I tried one more combination, but still it didnt work

Code:

27 *-*  /*IF POS(STRNG,NEWVAR.I)  <> 0 THEN */                 
28 *-*  IF POS(X'0352856421901C',NEWVAR.I)  <> 0               
   >>>    "0"                                                   
33 *-* END                                                     
26 *-* DO I = 1 TO NEWVAR.0                                     
34 *-* OUTSTEM.0 = OCNT                                         
   >>>   "0"                                                   
Back to top
View user's profile Send private message
scorp_rahul23

New User


Joined: 06 May 2008
Posts: 90
Location: Chennai

PostPosted: Mon Mar 05, 2012 4:40 pm    Post subject: Reply to: Not able to read HEX data in File
Reply with quote

Got it.....

Thanks a lot.

Code:

IF POS('0352856421901C'X,NEWVAR.I)  <> 0 THEN 
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7226

PostPosted: Mon Mar 05, 2012 4:41 pm    Post subject: Reply to: Not able to read HEX data in File
Reply with quote

EDIT: Subtle advice no longer required.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Is the 'prompt' data for the DSLIST p... Willy Jensen TSO/ISPF 2 Tue Dec 06, 2016 4:38 am
No new posts How to move a long alphanumeric data ... lind sh COBOL Programming 6 Mon Dec 05, 2016 7:51 pm
No new posts Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm
No new posts File Aid to File Manager conversion murali3955 IBM Tools 4 Thu Nov 24, 2016 3:41 pm
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us