Page 1 of 1

Locating rows in an ISPF Table

PostPosted: Sun Apr 17, 2016 3:36 am
by zingysayal1985
Hi,
I'm displaying a table of 700 or so rows, and want to emulate the LOCATE
command in ISPF, by jumping to a row beginning with, say "F" by typing "L F"
in the command line.

How do I do it?

Re: Locating rows in an ISPF Table

PostPosted: Mon Apr 18, 2016 8:03 pm
by willy jensen
Some snippets that might help. Also look at TBSARG in the ISPF dialog guide.

 ttop=0                                                
 "tbtop"   $table                                      
 do while ttop=0 /* search table */                    
  "tbskip" $table "position(p)"                        
   if rc<>0 then ...  /* end of table */                
   if .... then then ttop=p /* found */                
 end                                                    
                                                       
 "tbtop"   $table                                      
 if ttop<>0 then "tbskip" $table "number("ttop") NOREAD"
 "tbdispl" $table "panel(........) rowid(trow)"        
 

Re: Locating rows in an ISPF Table

PostPosted: Mon Apr 18, 2016 9:44 pm
by Pedro
Also look at TBSARG

I think it is okay for this usage, per the listed requirement.

But in general, I prefer to use a FIND rather than a LOCATE. I do not like using TBSARG for the following reasons:
1. It searches for the text on a column by column basis. For example, if the text you search for is in the second column, it will not find it until it finds all of the instances in the first column. The user may get confused because they can see it there but it may jump to something off of the screen first.

2. The wildcard cannot be in the first character.

Re: Locating rows in an ISPF Table

PostPosted: Tue Apr 19, 2016 1:48 am
by zingysayal1985
Okay. The mentioned code can be used for locating particular string in ISPF table.
Now , I am facing challenges in catching the string from the Command line. I have used "ARG SRHSTR" for collecting the value of Sting from command line into code, but "SRHSTR" is displaying blank value.

Re: Locating rows in an ISPF Table

PostPosted: Tue Apr 19, 2016 4:55 am
by zingysayal1985
Thanks Willy. The provided code is working very much fine. Much appricated !!!!

@Pedro : How i can impelement "find" in ispf table search ? Can you please throw some light on it.

thanks
Rajeev

Re: Locating rows in an ISPF Table

PostPosted: Tue Apr 19, 2016 3:58 pm
by willy jensen
Pedro, I agree, I don't like TBSARG much either, hence the loop through the table in my snippet.
My main objection to TBSARG is that it only supports prefix search, not proper wildcard. And by the way, the same goes for TBSCAN.

Re: Locating rows in an ISPF Table

PostPosted: Wed Apr 20, 2016 9:33 pm
by Pedro
How i can impelement "find" in ispf table search ?


Follow Willy's example to scan the table, but on the subsequent TBDISPL service call, position the cursor at the desired row and column name, maybe even cursor position within the field.

I have modified Willy's example:
ttop=0                                                
 "tbtop"   $table                                      
 do while ttop=0 /* search table */                    
  "tbskip" $table "position(p)"                        
   if rc<>0 then ...  /* end of table */      
    do
       /* examine each column of this row.                       */
       /* remember the column name where search string is found, */
       /*    for example, 'columnx'                              */
       if Found then then ttop=p /* found */                
    end      
 end                                                    
                                                       
 "tbtop"   $table                                      
 if ttop<>0 then "tbskip" $table "number("ttop") NOREAD"
 "tbdispl" $table "panel(........) rowid(trow)   CSRROW(ttop) CURSOR(columnx) "  


You also need logic, so if the user repeats the 'find', that it will start from cursor position rather than from the top of the table.