View previous topic :: View next topic
|
Author |
Message |
Bert
New User
Joined: 22 Oct 2008 Posts: 5 Location: Canada
|
|
|
|
Hi all, my first post and may I applaud all those who take the time/effort to answer questions.
I dont have access to a mainframe so am not able to test this question.
What does the numbers within the parenthesis mean ? e.g.
Code: |
MOVE WS-AREA (SUBSCR:100) TO WORK-RECORD |
I'm guessing this is (displacement:length), but need to be sure. Tried scanning here and Cobol manuals for ' colon ', but not getting anything concrete.
Also, what other COBOL instructions can this be used against ?
e.g. IF FIELD-A (10:5) = FIELD-B ?
TIA, |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
Back to top |
|
|
rajulan
New User
Joined: 11 Jan 2008 Posts: 66 Location: India
|
|
|
|
MOVE WS-AREA (SUBSCR:100) TO WORK-RECORD
numbers within the parenthes are (starting Position:Length)
I have tested one for you.
Code: |
IDENTIFICATION DIVISION.
PROGRAM-ID. TES.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 A PIC X(35) VALUE 'ABCD1234ABCD1234ABCD1234'.
01 B PIC X(5) VALUE 'XXXXX'.
01 C PIC X(5) VALUE 'YYYYY'.
PROCEDURE DIVISION.
MAIN-PARA.
MOVE 'XXXXX' TO A(1:5).
DISPLAY A.
IF B NOT EQUAL TO C
DISPLAY 'NOT EQUAL'
ELSE
DISPLAY 'EQUAL'.
STOP RUN. |
Output:
XXXXX234ABCD1234ABCD1234
NOT EQUAL
Here you can see the (starting postion and length)
IF FIELD-A (10:5) = FIELD-B ?
Exactly i do not know how to achieve this
But if it is like
IF FIELD-A = FIELD-B , you can go thru the above pgm.
Thanks,
Rajulan R.C |
|
Back to top |
|
|
Bert
New User
Joined: 22 Oct 2008 Posts: 5 Location: Canada
|
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello and welcome to the forum,
At the very top of the page is a link to "IBM Manuals". In addition to several versions of COBOL, there are manuals for many of the "standard" components of the IBM mainframe environment.
It will be to your advantage to become familiar and comfortable with these.
In addition to the MOVE of 100 bytes, it would be important to know how SUBSCR was determined. |
|
Back to top |
|
|
Bert
New User
Joined: 22 Oct 2008 Posts: 5 Location: Canada
|
|
|
|
Thanks also Rajulan,
Perhaps you could try :
IF A (10:5) = B ...
Also,
IF A = B (1:2)...
Both s/b ' NOT EQUAL', but out of curiousity confirm if the syntax will work.
TIA, |
|
Back to top |
|
|
Bert
New User
Joined: 22 Oct 2008 Posts: 5 Location: Canada
|
|
|
|
Thanks all, a wealth of info
Did try scanning libraries, but was not sure what term to look for.
Now I do....Reference Modification |
|
Back to top |
|
|
rajulan
New User
Joined: 11 Jan 2008 Posts: 66 Location: India
|
|
|
|
You are welcome Bert.
It works...
Teseted code is below....
Code: |
000100 IDENTIFICATION DIVISION.
000200 PROGRAM-ID. TES.
000300 ENVIRONMENT DIVISION.
000400 DATA DIVISION.
000500 WORKING-STORAGE SECTION.
000600 01 A PIC X(35) VALUE 'AAAAABBBBBXXXXXYYYYY'.
000700 01 B PIC X(5) VALUE 'XXXXX'.
000800 01 C PIC X(5) VALUE 'YYYYY'.
000900 PROCEDURE DIVISION.
001000 MAIN-PARA.
001100 IF A(11:5) = B
001200 DISPLAY 'SUCCESS'
001300 ELSE
001400 DISPLAY 'FAILURE'.
001500 STOP RUN. |
Output:
********************************* TOP OF DATA **********************************
SUCCESS
******************************** BOTTOM OF DATA ********************************
Thanks,
Rajulan. |
|
Back to top |
|
|
Bert
New User
Joined: 22 Oct 2008 Posts: 5 Location: Canada
|
|
|
|
Thanks again Rajulan, my curiousity is satiated
Dick, SUBSCR was a PIC 9(5) value containing a positive integer.
After going thru some of the links above, got a much better picture of this feature. All I'm missing is a mainframe |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Quote: |
All I'm missing is a mainframe |
Depending on how much time/effort you are able to put into it, there is a free product called Hercules that will "put a maniframe" on your pc. There are several topics in our forum.
Which would be a good time to become familiar with the forum SEARCH (above) |
|
Back to top |
|
|
|