View previous topic :: View next topic
|
Author |
Message |
ctuserman Currently Banned New User
Joined: 12 Aug 2005 Posts: 12
|
|
|
|
I want to know whether can we validate a character at specified postion in cobol.
eg: 01 Name.
05 FirstName Pic X(10).
05 Filler Pic X value |.
05 LastName Pic X(20).
I want to know can we identify whether Symbol "|" (pipe) is present in between firstname and lastname.
and if the filler comes many times i mean at many positions is there any better way to validate it
Note: I cant change filler to variable name. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Is this a one-time test or something that will become production eventually (more below)?
Are you using the fillers as a delimiter for a file you will download or is there some other use for the | character(s)?
As long as the | cannot be in any of the data fields, you could INSPECT the group field TALLYING the number of | characters. That would get you a count in one statement which could be compared against the expected number.
If you are only interested in certain ones you could check each position you are interested in by using reference modification (which means you need the actual displacement in the code - not my favorite choice as the layout may change making the reference modified code invalid).
The following applies more to code that will be promoted to production versus something that is for testing only.
Other than a bit of mis-guided direction, is there some business reason you cannot name fields that are no longer merely filler? Just because someone "says so" it not a business reason - it is just poor direction. As the field(s) are to be actually used in the code, they are no longer really "filler". Maybe names like pipe-1, pipe-2, etc could be incorporated as a standard and not ruffle the feathers of those are of the "can't name them" group.
Good luck |
|
Back to top |
|
|
ctuserman Currently Banned New User
Joined: 12 Aug 2005 Posts: 12
|
|
|
|
yup this is due to buisness reason and filler "|"(pipe) is used to seperate values in sequential files and i need to make a check that this fillers do exist after every value in record except for the last one and i guess they do exist for atleast 20 times in a record
thanx for ur reply waiting for ur reply again......... |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
I understand completely your requirement - when i create delimited files, i tend to use the tab chatacter (x'05') as it works well for data going either direction - the pipe character should work well also.
The part that is not a business requirement is that you cannot name the pipe fields. That is basically both nonsense and not your fault. As at many places, you will have to work within the rule. After our first exchange of info, i looked at some COBOL code and a few EasyTrieve modules people wrote before i came onsite and their code (in both languages) have FIELD-1 TAB-01 FIELD-2 TAB-02 or the coder used STRING to build the files to download. . .
One thing i most often do is create or use the delimited data with STRING or UNSTRING. If i string together several fields/values with delimiter characters i "know" the delimiter is in place and do not need to refer to it later to check it. This may or may not work for you.
If you must work within the current "rules", i'd probably choose the INSPECT/TALLY. As long as the number of delimiters does not change, the code will not need to change even if a field length was modified.
Good luck and let us know if there are any questions. |
|
Back to top |
|
|
ParagChouguley
Active User
Joined: 03 Feb 2007 Posts: 175 Location: PUNE(INDIA)
|
|
|
|
Hi Dick,
Can this be one of the reasons of using FILLER insted of variable names ? When we INITAILIZE a group variable, all the variables under that group variable except FILLER are initialized depending on their PIC clause. But the FILLER value remains intact. So most of the times, to avoid handeling of these delimiters in code and to avoid the risk of them being initialized to something else, they are declared as FILLER.
--Parag |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello Parag,
I suppose it could be
Very few of the applications i've helped build/support use the INITIALIZE statement - there has been little need to set everyting to spaces and zeros as many of the data items require something else for their "default" value.
If i wanted to use INITIALIZE to set initial values and protect a delimiter character in filler items, i'd not later try to make sure that the delimiters were still intact - if the only "move" to the group level was INITIALIZE, the fillers would be safe (as you pointed out). |
|
Back to top |
|
|
Phrzby Phil
Senior Member
Joined: 31 Oct 2006 Posts: 1042 Location: Richmond, Virginia
|
|
|
|
If I were using INITIALIZE to clear all but FILLER's, in order to keep the delimiters in place, I'd surely at least want to comment this very clearly, as I think this would be a very infrequently used technique (trick?).
Proposal: Survey experienced COBOL programmers to see how many know that INITIALIZE leaves FILLER untouched. |
|
Back to top |
|
|
|