Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Parsing Issue 1

Status
Not open for further replies.

kumatae

IS-IT--Management
Apr 9, 2013
4
0
0
US
Hi Everyone,

I've been working on this relatively simple code for weeks and I'm unable to get it working properly. I recieve a CSV with about 15 data elements like below

Seattle, Lastname, Firstname, DOB, SEX, etc, etc
Seattle, Lastname, Firstname, DOB, SEX, etc, etc
Portland, Lastname, Firstname, DOB, SEX, etc, etc
Portland, Lastname, Firstname, DOB, SEX, etc, etc

Okay, you get the idea. There can be several to thousands so it's time consuming to enter this data to our mainframe server using an interface. I'd like to get this parsed in REXX so that I can automatically enter it on our mainframe interface. So far I have the following,

SOURCEFILE = "C:\DATA\DATA.TXT"
IF A=2 THEN DO COUNTER=1 TO LINES(SOURCEFILE)
PARSE VALUE LINEIN(SOURCEFILE) WITH CITY "," LAST_NAME "," FIRST_NAME "," MOM_NAME "," MIDDLE_NAME "," DAD_NAME "," DOB "," etc "," etc "," etc "," etc "," SEX "," etc "," etc
CALL SETCURSOR 4,23
CALL CREATEDATA
END
CREATEDATA:
CALL TYPE CITY
CALL PRESS TAB
CALL TYPE LAST_NAME
CALL PRESS TAB
CALL TYPE DATE(U)
CALL PRESS TAB
CALL TYPE FIRST_NAME
CALL PRESS TAB
CALL TYPE MOM_NAME
CALL PRESS TAB
CALL TYPE MIDDLE_NAME
CALL PRESS TAB
CALL TYPE DAD_NAME
CALL PRESS TAB
CALL TYPE DOB
CALL PRESS TAB
CALL TYPE etc
CALL PRESS TAB
CALL TYPE etc
CALL PRESS TAB
CALL TYPE etc
CALL PRESS TAB
CALL TYPE etc
CALL PRESS TAB
CALL PRESS TAB
CALL TYPE SEX
CALL PRESS TAB
CALL PRESS TAB
CALL PRESS TAB
CALL PRESS TAB
CaLL TYPE etc
CALL PRESS TAB
CALL PRESS TAB
CALL TYPE etc
CALL PRESS ENTER
RETURN

I know my function CREATDATA works because it actually types out the CITY as is and not the parsed value. I've tried using PARSE VAR LINEIN(DATA) etc with no luck. Anyone have any ideas on what I'm doing wrong here? Any help would be much appreciated. I'm going crazy trying to figure this out. Thanks in advance!
 
Do while lines(SOURCEFILE) > 0
InLine = linein(SOURCEFILE)
Parse var InLine CITY "," LAST_NAME "," FIRST_NAME "," MOM_NAME "," MIDDLE_NAME "," DAD_NAME "," DOB "," etc "," etc "," etc "," etc "," SEX "," etc ","
etc
Call SETCURSOR 4,23
Call CREATEDATA
End
 
Hi RxUsr,

It's still not parsing properly. My function Call CREATEDATA just types in "CITY" and "LAST_NAME" rather than the value from the CSV.
 
What does a trace show? What is the format of your output record? I do not understnd what all this CALL PRESS TAB etc is. Why not just upload the file to the mainframe and prse it into its component parts with either Rexx or DFSort. I have done both ways.


Nic
 
Hi Nic,

Yes I would love to just upload it to the mainframe but it's political and it's just not feasible right now. So basically, I'm using a database interface to the mainframe and for this particular problem I'm trying to solve, there are several fields where one can enter the data and you can navigate from one field to another by pressing TAB and when you are done you press ENTER and data gets entered to mainframe. It would be a waste of time having to re-enter the data I receive when someone already has taken the time to type it out. So I'm trying to automate it. Right now, data still isn't parsing correctly as it is just typing out the Variable name that I'm trying to assign like "CITY" and "LAST_NAME".
 
Try Interpret with quotes around the 'CALL TYPE' but not the variable CITY, LAST_NAME, etc.
Interpret 'CALL TYPE' CITY
CALL PRESS TAB
Interpret 'CALL TYPE' LAST_NAME
CALL PRESS TAB
Interpret 'CALL TYPE' DATE(U)
etc
 
I use PARSE from a CSV file to input into our Nortel PBX system. Here is a small script, so maybe it may assist you how we are using PARSING from CSV?

/* Create New Phantom Extensions from .csv file 04-29-2010*/

CALL ZocSend "****^M"
CALL ZocDelay 1.5
CALL ZocSend "LD 20^M"

[highlight #FCE94F]file = "c:\HERITAGE_DES.csv"
do while( lines(file) )
data=LINEIN(file)
Parse Var data v1","v2","v3[/highlight]

CALL ZocTimeout 60
CALL ZocWaitForSeq 1

CALL ZocWait "REQ:"
CALL ZocSend "chg^M"

CALL ZocWait "TYPE:"
CALL ZocSend v1"^M"

CALL ZocWait "TN"
CALL ZocSend v2"^M"

CALL ZocWait "ECHG"
CALL ZocSend "Yes^M"

CALL ZocWait "ITEM"
CALL ZocSend "des "[highlight #FCE94F]v3[/highlight]"^M"

CALL ZocWait "ITEM"
CALL ZocSend "^M"

END
 
OMG jaime2!! Thank you so much!!! It worked!!!
Was so close all these time!!

I've been using fixed delimited text file to make it work but this parsing deal is so much better. Thank you once again!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top