View previous topic :: View next topic
|
Author |
Message |
riponrai
New User
Joined: 15 Jun 2005 Posts: 2 Location: Somerset
|
|
|
|
hello friends,
i am confused in mapping this field from an input application to my code.
You can consider my receiving field as CONTENT X
05 HELLO OCCURS 25 TIMES.
10 SAYONARA PIC 9 VALUE 0.
10 NAMASTE PIC X(03).
How to map this ??
If NAMASTE (3:1) is 'A' in any occurence then pull corresponding SAYONARA field ??
I'm confused in declaring NAMASTE field
Thanks for any help.
Ripon |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Code: |
05 HELLO OCCURS 25 TIMES.
10 SAYONARA PIC 9 VALUE 0.
10 NAMASTE.
15 FILLER PIC XX.
15 NAMASTE-SAYONARA-NEEDED-CHECK PIC X. |
|
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
implementing CONDITION-NAMEs (Level 88)- makes the code easier to understand
- removes the need for literals in PROCEDURE DIVISION.
Code: |
05 HELLO OCCURS 25 TIMES.
10 SAYONARA PIC 9 VALUE 0.
10 NAMASTE.
15 FILLER PIC XX.
15 NAMASTE-SAYONARA-NEEDED-CHECK PIC X.
88 VALUE-IS-A-PULL-SAYONARA VALUE 'A'.
|
|
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
I am certainly in agreement, dbz.
I hope no-one is going to show the TS how to subcript/index the reference modification so that they can use a literal.
1) Look it up yourself, so you know how to use it when you need to (not for occasions like this).
2) Use the 88, like dbz points out. If you are not going to reference the PIC X field, you can make it a FILLER so that no-one wonders why the field is not used.
blah, blah, blah - did you look? |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
yes, i did look; couldn't help myself.
the quote button makes it very easy to read posts,
as well as find out how BBCode works.
and you certainly did not think that I would pass up a chance to respond? |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6248 Location: Mumbai, India
|
|
|
|
I'm, on the other hand, thinking about the "varibale names" used to demonstrate the example:
Hello - well, we all know.
SAYONARA - Japanese way of farewell remark.
Namaste - Indian way of saying Hello or good-bye.
Sorry Dick... |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
Anuj Dhawan wrote: |
Sorry Dick |
no problem. |
|
Back to top |
|
|
Marso
REXX Moderator
Joined: 13 Mar 2006 Posts: 1353 Location: Israel
|
|
|
|
Maybe the TS is confused about using both OCCURS and reference modification.
I opened the COBOL Language Reference, looked for "reference modification". The third example provides a clear answer. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
excellent post Marso, as usual. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Not that easy... :-)
We don't want him to use the subscripted reference modification in this case, because you can't put an 88-level on it and we don't like literals in the Procedure Division (do we, dbz?). Perfect link for him, though. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
ok, Bill, you win. you can have the last post. |
|
Back to top |
|
|
Marso
REXX Moderator
Joined: 13 Mar 2006 Posts: 1353 Location: Israel
|
|
|
|
Last post ? hey, wait! I'm not finished!
Technically, I think I got the right answer.
But the "reference modification / 88-level / literal" issue is interesting too, and maybe to solve it there is a way around:
Code: |
SPECIAL-NAMES.
CLASS SAYONARA-PULL IS 'A'.
IF NAMASTE (SUBSCR) (3:1) IS SAYONARA-PULL THEN
pull sayonara
ELSE
don't pull
END-IF |
Still using reference modification, because after all it's nice not to have to cut the field into small parts,
but no need for level 88 and no literal in PD.
Is this acceptable ? |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Like |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Have to say I do prefer dbz's solution. All the definition in the Data Division, clear what the individual field is if necessary (else FILLLER, so it is clear the field is only tested).
W-h-a-t d-o y-o-u t-h-i-n-k, dbz? |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
I go out of my way to generate the required data layout in order
to avoid reference modification
in modules that i release.
honestly though, my personal modules (utilities, etc...)
look like assembler - only it is compiled with a cobol compiler.
so, it is one of those do as I say, not what I do |
|
Back to top |
|
|
|