View previous topic :: View next topic
|
Author |
Message |
ballalsachin
New User
Joined: 22 Sep 2005 Posts: 15 Location: USA
|
|
|
|
Hi All,
Mine in on the similar lines. hence posting this question here
I have defined
01 WK-DETAIL-LINE PIC X(132)
01 WK-BD-EDITED PIC X(10)
In the procedure division, I am trying to concatenate as follows:
STRING 'MY FIRST STRING' DELIMITED BY SIZE
WK-BD-EDITED DELIMITED BY SIZE
INTO WK-DETAIL-LINE(38:40)
I am getting an error while compiling :
IGYPA2135-S - WK-DETAIL-LINE (ALPHANUMERIC)" WAS FOUND AS THE "STRING" RECEIVING FIELD BUT WAS REFERENCE MODIFIED. THE
STATEMENT WAS DISCARDED
What can be an issue here ?
Appreciate your help
Thanks |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
maybe you can not use reference modification to override the RECEIVING FIELD of a STRING command? |
|
Back to top |
|
|
CICS Guy
Senior Member
Joined: 18 Jul 2007 Posts: 2146 Location: At my coffee table
|
|
|
|
IBM COBOL for MVS® & VM Language Reference SC26-4769-04 wrote: |
INTO Phrase
identifier-3 Represents the receiving field.
X It must not represent an edited data item or external floating-point
X item and must not be described with the JUSTIFIED clause. As an IBM
X extension, identifier-3 can be reference-modified. |
|
|
Back to top |
|
|
CICS Guy
Senior Member
Joined: 18 Jul 2007 Posts: 2146 Location: At my coffee table
|
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
maybe if 15 (length of the literal) --- delimited by size
plus 10, length of WK-BD-EDITED -- delimited by size
equaled 40, there may not have been a problem. |
|
Back to top |
|
|
CICS Guy
Senior Member
Joined: 18 Jul 2007 Posts: 2146 Location: At my coffee table
|
|
|
|
dbzTHEdinosauer wrote: |
maybe if 15 (length of the literal) --- delimited by size
plus 10, length of WK-BD-EDITED -- delimited by size
equaled 40, there may not have been a problem. |
Are you saying that the compiler checks the length of all the sources to insure they will fill the destination? |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
well it could, all the info is there.
if the delimiter was variable (delimited by spaces),
then the compiler would not know that you are trying to force a 40 char fill with only 25 char.
what is the STRING supposed to do when you demand a 40 char fill with only 25.
and demand is the word.
reference modification was improperly used.
in this case forcing a greater than possible length override.
If the length override was 20 instead of 40
Code: |
INTO WK-DETAIL-LINE(38:20)
|
the OP probably would not have received an error. |
|
Back to top |
|
|
CICS Guy
Senior Member
Joined: 18 Jul 2007 Posts: 2146 Location: At my coffee table
|
|
|
|
I'm going to have to disagree with you Dick.
Stringing into a data area smaller than the strung data will trigger the "on overflow" (if present).
Stringing into a data area bigger than the strung data is why we always initialize the into area. |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8700 Location: Dubuque, Iowa, USA
|
|
|
|
From the COBOL Language Reference:
Quote: |
Conceptually, when the STRING statement is executed, the initial pointer value (explicit or implicit) is the first character position within the receiving field into which data is to be transferred. Beginning at that position, data is then positioned, character-by-character, from left to right. After each character is positioned, the explicit or implicit pointer is increased by 1. The value in the pointer field is changed only in this manner. At the end of processing, the pointer value always indicates a value equal to one character position beyond the last character transferred into the receiving field. |
Which implies, but does not explicitly state, that the receiving field of a STRING operation cannot be reference modified since the starting position must be the first character. |
|
Back to top |
|
|
CICS Guy
Senior Member
Joined: 18 Jul 2007 Posts: 2146 Location: At my coffee table
|
|
|
|
From the COBOL Language Reference:
Quote: |
Reference modification creates a unique data item that is a subset of data-name-1 or a subset of the value referenced by function-name-1 and its arguments, if any. |
Which implies, but does not explicitly state, that the compiler has a valid beginning address and an implied length with which to work. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
Quote: |
starting position must be the first character |
I apologize to you Robert for my briskness, but that is not true.
I have used reference mod with STRING before, because I was to lazy to define an explicit pointer (though I did with the ref mod).
but, I appreciate your quote from the doc, because the 40 (from the ref mod) says move 40 when you only have 25 to deal with.
normally, I use ref mod with a calculated length.
The OP has used a literal length that is greater than the sum of the calculable lengths of the sending fields.
The compiler was able to figure that out, since all the lengths were literals.
(delimited by size, 40).
Also, considering the compiler gave an error to the OPs code,
I tend to trust the compiler.
I have laid a lot of dumb code in my life, have not yet found a bug in the compiler. Not saying there have not been any bugs, just this kind of stuff, which if you look at the assembler code generated, is sort of obvious.
I don't have machine access at present, but if some one was to code the STRING with 40 and then again with 20, I think I will be proved correct.
Actually, do the 20 first, since we know the 40 will cause an error.
But, then again, I never used ref mod with a literal length. If I know the length, I will define my data properly so that I don't need to rookie-up the STRING with ref mod. Also, sets a precedent so that then next pgmr dealing with my program is not mislead.
(Sorry, been reading the OP-EDs and am really pissed about what is happening to my country.) |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8700 Location: Dubuque, Iowa, USA
|
|
|
|
OK, I was wrong ... when I tested
Code: |
01 WK-DETAIL-LINE PIC X(132) VALUE SPACES.
01 WK-BD-EDITED PIC X(10) VALUE 'CCYY/MM/DD'.
/
PROCEDURE DIVISION.
S1000-MAIN SECTION.
STRING 'MY FIRST STRING' DELIMITED BY SIZE
WK-BD-EDITED DELIMITED BY SIZE
INTO WK-DETAIL-LINE (38 : 40)
.
DISPLAY WK-DETAIL-LINE. |
produces as output
Code: |
----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+---->
MY FIRST STRINGCCYY/MM/DD |
so your problem is either syntax or data. What version of COBOL are you running in? Try copying my STRING statement exactly as is and use it; if that still doesn't work then there's probably some problem with WK-DETAIL-LINE. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
I was, also, wrong. |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8700 Location: Dubuque, Iowa, USA
|
|
|
|
Dick: whatever's going on (and I'm starting to suspect the OP hasn't given us the full picture), the length doesn't figure into it. The pseudoassembler generated by COBOL is
Code: |
000018 STRING
000378 5820 905C L 2,92(0,9) TGTFIXD+92
00037C 58F0 2098 L 15,152(0,2) V(IGZCSTG )
000380 4110 A0BD LA 1,189(0,10) PGMLIT AT +181
000384 05EF BALR 14,15 |
so I don't see how the compiler would have flagged a length problem -- runtime, maybe, but not at compile time. |
|
Back to top |
|
|
Mickeydusaor
Active User
Joined: 24 May 2006 Posts: 258 Location: Salem, Oregon
|
|
|
|
I do this all of the time, but the total length as described in his example do not total up to 40 bytes which will generate the error. here is just a few examples using reference modifications in a string clause.
Code: |
STRING 'TRANSID - ' DELIMITED BY SIZE
CMDLINEI(01:04) DELIMITED BY SIZE
' FAILED' DELIMITED BY SIZE
INTO WS-USER-MESSAGE
END-STRING
STRING WSSUT13W-TIME(1:2) DELIMITED BY SIZE
WSSUT13W-TIME(4:2) DELIMITED BY SIZE
WSSUT13W-TIME(7:2) DELIMITED BY SIZE
INTO WS-CURRENT-TIME
END-STRING
STRING PRNTREQI(WS-FIELD-OFFSET:WS-FIELD-COUNTS)
DELIMITED BY SIZE
INTO WS-WRK-FIELD
END-STRING
IF WS-FMT04-BUCKS-AMT > 0
MOVE 0 TO F04-INDEX
INSPECT WS-FMT04-BUCKS-AMT TALLYING F04-INDEX
FOR LEADING ZEROES
ELSE
MOVE 3 TO F04-INDEX
END-IF
IF WS-FMT07-BUCKS-AMT > 0
MOVE 0 TO F07-INDEX
INSPECT WS-FMT07-BUCKS-AMT TALLYING F07-INDEX
FOR LEADING ZEROES
ELSE
MOVE 3 TO F07-INDEX
END-IF
IF WS-FMT05-BUCKS-AMT > 0
MOVE 0 TO F05-INDEX
INSPECT WS-FMT05-BUCKS-AMT TALLYING F05-INDEX
FOR LEADING ZEROES
ELSE
MOVE 3 TO F05-INDEX
END-IF
IF WS-FMT06-BUCKS-AMT > 0
MOVE 0 TO F06-INDEX
INSPECT WS-FMT06-BUCKS-AMT TALLYING F06-INDEX
FOR LEADING ZEROES
ELSE
MOVE 3 TO F06-INDEX
END-IF
STRING 'COURT ORDER ' DELIMITED BY SIZE
'AMT FOR ' DELIMITED BY SIZE
'BENE CHG FROM ' DELIMITED BY SIZE
' - ' DELIMITED BY SIZE
WS-FAD-SEQ DELIMITED BY SIZE
'$' DELIMITED BY SIZE
WS-FMT04-BUCKS-AMT(F04-INDEX + 1:)
DELIMITED BY SIZE
'.' DELIMITED BY SIZE
WS-FMT04-CENTS-AMT DELIMITED BY SIZE
' $' DELIMITED BY SIZE
WS-FMT07-BUCKS-AMT(F07-INDEX + 1:)
DELIMITED BY SIZE
'.' DELIMITED BY SIZE
WS-FMT07-CENTS-AMT DELIMITED BY SIZE
' TO ' DELIMITED BY SIZE
'$' DELIMITED BY SIZE
WS-FMT05-BUCKS-AMT(F05-INDEX + 1:)
DELIMITED BY SIZE
'.' DELIMITED BY SIZE
WS-FMT05-CENTS-AMT DELIMITED BY SIZE
' $' DELIMITED BY SIZE
WS-FMT06-BUCKS-AMT(F06-INDEX + 1:)
DELIMITED BY SIZE
'.' DELIMITED BY SIZE
WS-FMT06-CENTS-AMT DELIMITED BY SIZE
INTO TEXT-LOG-ACT-SUP-WKR-SYS
END-STRING |
|
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8700 Location: Dubuque, Iowa, USA
|
|
|
|
Quote: |
but the total length as described in his example do not total up to 40 bytes which will generate the error. |
Check my code -- the lengths to not add up to 40, I did not get the error, and my code has been compiled and executed under Enterprise COBOL 3.4 so I know it works. |
|
Back to top |
|
|
CICS Guy
Senior Member
Joined: 18 Jul 2007 Posts: 2146 Location: At my coffee table
|
|
|
|
Quote: |
IGYPA2135-S - WK-DETAIL-LINE (ALPHANUMERIC)" WAS FOUND AS THE "STRING" RECEIVING FIELD BUT WAS REFERENCE MODIFIED. THE
STATEMENT WAS DISCARDED |
Does anything look a bit off about the error message? Like the isolated quote following the dataname? |
|
Back to top |
|
|
Mickeydusaor
Active User
Joined: 24 May 2006 Posts: 258 Location: Salem, Oregon
|
|
|
|
I did read that wrong, his output is defined a 132 which would not have created the error as stated. |
|
Back to top |
|
|
|