How to pull related filds from input file into terminal



IBM's Command List programming language & Restructured Extended Executor

How to pull related filds from input file into terminal

Postby dash123 » Thu Nov 10, 2011 4:03 pm

Input file:

XXXXXX.TESTIN.FILE
----+----1----+----2----+----3----
ID1 NAME1 NAME2 NAME3 PHONE1 TYPE1
ID2 NAME4 NAME5 NAME6 PHONE2 TYPE2


Requirement
---------------
User will be asked to enter ID and once user enters ID (=ID1), then remaining field values associated with ID1 (NAME1 NAME2 NAME3 PHONE1 TYPE1) needs to be populted in screen

Present Code
---------------
/* REXX : READ FROM FILE AND DISPLAY IN SCREEN*/
SAY "PLEASE ENTER SYS ID"                       
PULL SYSID                                       
IF SYSID=""THEN SAY "PLEASE ENTER SYS ID"       
ELSE SAY "SYS ID        :" SYSID                 
"EXECIO * DISKR INDD (STEM REC. FINIS"           
DO I=1 TO REC.0                                 
       SAY REC.I                                 
END



Present OUTPUT IN SCREEN
--------------------------------
 PLEASE ENTER SYS ID                 
 ID1                                 
 SYS ID        : ID1               
 ID1 NAME1 NAME2 NAME3 PHONE1 TYPE1                                   
 ID2 NAME4 NAME5 NAME6 PHONE2 TYPE2



PRESENT STATUS
--------------------
Right now i am just able to read records from input file into the terminal.


Help required
----------------
It is required to read the remaining field values into screen which are associated with a particular ID (that is feed in screen) [as mentioned above in requirement]

Thanks,
dash
dash123
 
Posts: 8
Joined: Wed Nov 02, 2011 5:42 pm
Has thanked: 0 time
Been thanked: 0 time

Re: How to pull related filds from input file into terminal

Postby Akatsukami » Thu Nov 10, 2011 5:49 pm

A moderator did some serious (and seriously needed) editing on your post whilst I was reading it. However:

  • I do not recall your ever having defined "screen": are you trying to use an ISPF panel?
  • The Rexx code that you show bears only a vague resemblance to what you say that you seek to accomplish. Whilst your profile does not claim Rexx to be among your skills, you seem not to be applying some fundamental programming concepts here.
Please make your intent clearer, so that something definite may be said about your attempts to achieve it.
"You have sat too long for any good you have been doing lately ... Depart, I say; and let us have done with you. In the name of God, go!" -- what I say to a junior programmer at least once a day
User avatar
Akatsukami
Global moderator
 
Posts: 1058
Joined: Sat Oct 16, 2010 2:31 am
Location: Bloomington, IL
Has thanked: 6 times
Been thanked: 51 times

Re: How to pull related filds from input file into terminal

Postby NicC » Thu Nov 10, 2011 6:18 pm

On the code that you posted: what if the user hits enter a second time without entering an id? When you have an id and you read the records into a stem - go through the stem looking for the id then display the remaining fields for that record. Then exit or go back to the top and get the next ID. If you are going back you do not need to allocate or read the file again so put that code elsewhere.
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 3025
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisies (almost)
Has thanked: 4 times
Been thanked: 136 times

Re: How to pull related filds from input file into terminal

Postby dash123 » Fri Nov 11, 2011 11:03 am

Hi Akatsukami/NicC,

Thanks for your kind responses.

As a new comer, my knowledge is very limited in REXX and seeking your assistance in coding.

To explain my above requirement further in detail:

To built a screen (REXX screen) and read information from a file (based on a condition) and display back those information in the screen

Condition is as follows
• There will a SYSID field in REXX screen asking user to enter SYSID in the REXX screen

• Once user enters a valid SYSID in screen and if that is matched with any of the SYSID (SYSID first field in input file) present in input file, then remaining information (of that particular SYSID from input file : here remaining 5 fields) will be read from input file and displayed back in 5 respective fields in the REXX screen

• In total REXX screen should have 6 fields for display/communication of 6 fields of input file

As I could not get knowledge about field level processing in a file, (what I know is processing at record level and shown here), please assist in relevant coding as required above.

Thanks,
Dash
dash123
 
Posts: 8
Joined: Wed Nov 02, 2011 5:42 pm
Has thanked: 0 time
Been thanked: 0 time

Re: How to pull related filds from input file into terminal

Postby mongan » Fri Nov 11, 2011 1:27 pm

Judging by what you have posted so far you indeed have limited knowledge, so, I would suggest you learn by looking at already existing solutions at your site, in the internet, on this forum, online courses, ..... Until you get the basics of panel and ispf program set up we can not really help, and we do not want to do your job for you.
User avatar
mongan
 
Posts: 211
Joined: Tue Jan 11, 2011 8:32 pm
Has thanked: 1 time
Been thanked: 5 times

Re: How to pull related filds from input file into terminal

Postby NicC » Fri Nov 11, 2011 4:19 pm

There is no such thing as a 'Rexx panel' - it is an ISPF panel which can be displayed via several different programming languages of which Rexx is one.

Rexx does not handle record structures - it deals with records. It is up to you to extract the fields from the record either by PARSE or SUBSTR.
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 3025
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisies (almost)
Has thanked: 4 times
Been thanked: 136 times

Re: How to pull related filds from input file into terminal

Postby Akatsukami » Fri Nov 11, 2011 4:45 pm

To expand on what mongan and NicC have said:

You seem to lack knowledge of ISPF. You will want to know both dialog design and ISPF services to go forward with this (these manuals are for the z/OS 1.11 version, but can tweakfor your shop's implementation later).

Rexx deals with everything -- records, rows, numbers -- as a string. The parsing features of Rexx are subtle and powerful -- that is, in large part, what the language was designed to do -- but they are used only at the developer's explicit will.

You may have taken a bigger bite than you can chew here. Start by deciding if and how your can design and develop your panel, and come back with your decision on if and how you can go forward. Although it may seem harsh, I must remind you that, although we will answer questions and even provide code snippets, we will not write your application (and thus do your job) for you.
"You have sat too long for any good you have been doing lately ... Depart, I say; and let us have done with you. In the name of God, go!" -- what I say to a junior programmer at least once a day
User avatar
Akatsukami
Global moderator
 
Posts: 1058
Joined: Sat Oct 16, 2010 2:31 am
Location: Bloomington, IL
Has thanked: 6 times
Been thanked: 51 times

Re: How to pull related filds from input file into terminal

Postby dash123 » Mon Nov 21, 2011 4:19 pm

Progress and summary of above post
-------------------------------------------

Requirement : USER ENTERS ID VALUE = ID1 in screen and any first 3 charater of input file got matched with that,
then column 2 and 3 of that ID need to appear in output Screen


XXXXXXX.INPUT.FILE
----+----1----+----2----+----3----+
ID1 NAME1 NAME2 NAME3 PHONE1 TYPE1
ID2 NAME4 NAME5 NAME6 PHONE2 TYPE2


Desired Output (when user enters ID value as 'ID1')
------------------
NAMEX : NAME1
NAMEX : NAME2



Present CODE
----------------
SAY "PLEASE ENTER ID"
PULL SYSID
SELECT
WHEN SYSID = "" THEN SAY "PLEASE ENTER ID"
OTHERWISE CALL PROCESS VAR2,VAR3
SAY 'NAMEX :'||VAR2
SAY 'NAMEY :'||VAR3
END
RETURN

PROCESS : PROCEDURE
"ALLOC DDN(INDD) DA('XXXXXXX.INPUT.FILE')SHR"
"EXECIO * DISKR INDD (STEM REC. FINIS"
DO I=1 TO REC.0
VAR1=SUBSTR(REC.I,1,3)
IF SYSID=VAR1 THEN
DO
VAR2=SUBSTR(REC.I,5,5)
VAR3=SUBSTR(REC.I,11,5)
END
END


Present Problem
-------------------
After user enters ID value as 'ID1' output screen becomes empty, no output

can anybody please suggest what problem is with above CALL statement ?



Note
------
WITHOUT USING CALL CONCEPT (CALL PROCESS VAR2,VAR3), above DESIRED OUTPUT comes cprrectly

But once we introduced CALL concept (CALL PROCESS VAR2,VAR3), output screen becomes empty, no output

So it seems it might be a syntax error associated with CALL statement somewhere.

can anybody please suggest what problem is with above CALL statement ?


Thanks,
dash123
 
Posts: 8
Joined: Wed Nov 02, 2011 5:42 pm
Has thanked: 0 time
Been thanked: 0 time

Re: How to pull related filds from input file into terminal

Postby Akatsukami » Mon Nov 21, 2011 8:56 pm

dash123 wrote: SAY "PLEASE ENTER ID"
PULL SYSID
SELECT
WHEN SYSID = "" THEN SAY "PLEASE ENTER ID"
OTHERWISE CALL PROCESS VAR2,VAR3
SAY 'NAMEX :'||VAR2
SAY 'NAMEY :'||VAR3
END
RETURN

PROCESS : PROCEDURE
"ALLOC DDN(INDD) DA('XXXXXXX.INPUT.FILE')SHR"
"EXECIO * DISKR INDD (STEM REC. FINIS"
DO I=1 TO REC.0
VAR1=SUBSTR(REC.I,1,3)
IF SYSID=VAR1 THEN
DO
VAR2=SUBSTR(REC.I,5,5)
VAR3=SUBSTR(REC.I,11,5)
END
END


Present Problem
-------------------
After user enters ID value as 'ID1' output screen becomes empty, no output

can anybody please suggest what problem is with above CALL statement ?

Nothing; read about and understand the Rexx PROCEDURE instruction.
"You have sat too long for any good you have been doing lately ... Depart, I say; and let us have done with you. In the name of God, go!" -- what I say to a junior programmer at least once a day
User avatar
Akatsukami
Global moderator
 
Posts: 1058
Joined: Sat Oct 16, 2010 2:31 am
Location: Bloomington, IL
Has thanked: 6 times
Been thanked: 51 times

Re: How to pull related filds from input file into terminal

Postby NicC » Tue Nov 22, 2011 1:34 am

Either omit the PROCEDURE keyword or read up on the EXPOSE keyword.
Also - do not use SYSID as a variable - it is a system variable and things could get chaotic. And, unless you are planning to add more WHENs to your select IF-THEN-ELSE would be perfectly good.
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 3025
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisies (almost)
Has thanked: 4 times
Been thanked: 136 times

Next

Return to CLIST & REXX

 


  • Related topics
    Replies
    Views
    Last post