So it's not conversion, it's composition. Is this correct?
What will be the arguments to this routine? I'd imagine them to be the pathname to the file, the subject value on which to filter, the key value on which to filter and a specification of which fields are to be returned in the form "1:3". Is this correct, or are there more arguments (and, if so, what are they)?
Help needed in converting code which is in DS Server routine
Moderators: chulett, rschirm, roy
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
Last edited by ray.wurlod on Wed Feb 09, 2011 3:56 am, edited 1 time in total.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
Assuming that my assumptions about the arguments are correct, I would probably design the code to open the file, read each line in the file and output the fields mentioned in the second argument.
Code: Select all
FUNCTION Grabit(aSubjectValue, aFilePath, aKeyValue, aKeyPosition)
$INCLUDE UNIVERSE.INCLUDE FILEINFO.H
DEFFUN OpenSequenialFile(FilePath, OpenMode, WriteMode, LoggingFlag) Calling "DSU.OpenSequentialFile"
* First key and second key are parsed from KeyPosition.
FirstKey = Field(aKeyPosition, ":", 1, 1)
SecondKey = Field(aKeyPosition, ":", 2, 1)
FirstKeyList = ""
SecondKeyList = ""
Ans = @NULL ; * value returned if file can not be opened
hFile = OpenSequentialFile(aFilePath, "R", "A", "Y")
If FileInfo(hFile, FINFO$IS.FILEVAR)
Then
Loop
While ReadNext Line From hFile
If Line[",",1,1] = aSubjectValue
Then
If Line[",",3,1] = aKeyValue
Then
FirstKeyList<-1> = Line[",",FirstKey,1]
SecondKeyList<-1> = Line[",",SecondKey,1]
End
End
Repeat
Ans = FirstKeyList : @FM : SecondKeyList
End
RETURN(Ans)
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
-
- Premium Member
- Posts: 120
- Joined: Thu Oct 28, 2004 4:24 pm
UNIXcmd = 'cat ':TDPATHbin:'/SurrKeyGen_Index_csv | grep -e ':LogSubject:' | grep -e ':NaturalKeyColumnName' '
CALL DSExecute("UNIX", UNIXcmd, ScreenOutput,ReturnCode)
IF ReturnCode = 0
THEN
UNIXcmd = 'cat ':TDPATHbin:'/SurrKeyGen_Index_csv | grep -e ':LogSubject:' | grep -e ':NaturalKeyColumnName:' |cut -d "," -f2 '
CALL DSExecute("UNIX", UNIXcmd, ScreenOutput,ReturnCode)
InputFileName = ScreenOutput<1>
Looking quickly here , ScreenOutput is a VARIABLE then below you are trying to read the first element of an ARRAY
I would either do
CALL DSExecute("UNIX", UNIXcmd, ScreenOutput<1>,ReturnCode<1>)
or CALL DSExecute("UNIX", UNIXcmd, ScreenOutput<-1>,ReturnCode<-1>)
and llop through the output array
or InputFileName = ScreenOutput
to start with
CALL DSExecute("UNIX", UNIXcmd, ScreenOutput,ReturnCode)
IF ReturnCode = 0
THEN
UNIXcmd = 'cat ':TDPATHbin:'/SurrKeyGen_Index_csv | grep -e ':LogSubject:' | grep -e ':NaturalKeyColumnName:' |cut -d "," -f2 '
CALL DSExecute("UNIX", UNIXcmd, ScreenOutput,ReturnCode)
InputFileName = ScreenOutput<1>
Looking quickly here , ScreenOutput is a VARIABLE then below you are trying to read the first element of an ARRAY
I would either do
CALL DSExecute("UNIX", UNIXcmd, ScreenOutput<1>,ReturnCode<1>)
or CALL DSExecute("UNIX", UNIXcmd, ScreenOutput<-1>,ReturnCode<-1>)
and llop through the output array
or InputFileName = ScreenOutput
to start with
"Don't let the bull between you and the fence"
Thanks
Gregg J Knight
"Never Never Never Quit"
Winston Churchill
Thanks
Gregg J Knight
"Never Never Never Quit"
Winston Churchill