Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
What does value in parenthesis mean, example (10:5) ?

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
Bert

New User


Joined: 22 Oct 2008
Posts: 5
Location: Canada

PostPosted: Mon Feb 09, 2009 1:41 am    Post subject: What does value in parenthesis mean, example (10:5) ?
Reply with quote

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
View user's profile Send private message

William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3158
Location: Tucson AZ

PostPosted: Mon Feb 09, 2009 2:17 am    Post subject:
Reply with quote

Take a look at: Reference modification defines a data item by specifying a leftmost character and optional length for the data item.
Back to top
View user's profile Send private message
rajulan

New User


Joined: 11 Jan 2008
Posts: 66
Location: India

PostPosted: Mon Feb 09, 2009 2:28 am    Post subject: Reply to: What does value in parenthesis mean, example (10:5
Reply with quote

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
View user's profile Send private message
Bert

New User


Joined: 22 Oct 2008
Posts: 5
Location: Canada

PostPosted: Mon Feb 09, 2009 2:38 am    Post subject: Reference Modification
Reply with quote

Thank You William, very good indeed.

Have included some examples from above URL for others to peruse

Reference modification examples
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3158
Location: Tucson AZ

PostPosted: Mon Feb 09, 2009 2:49 am    Post subject:
Reply with quote

Have you looked at Reference modifiers in the Programming guide?
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Mon Feb 09, 2009 2:52 am    Post subject:
Reply with quote

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
View user's profile Send private message
Bert

New User


Joined: 22 Oct 2008
Posts: 5
Location: Canada

PostPosted: Mon Feb 09, 2009 2:54 am    Post subject: Reference Modification
Reply with quote

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
View user's profile Send private message
Bert

New User


Joined: 22 Oct 2008
Posts: 5
Location: Canada

PostPosted: Mon Feb 09, 2009 3:06 am    Post subject: Reference Modification
Reply with quote

Thanks all, a wealth of info

Did try scanning libraries, but was not sure what term to look for.

Now I do....Reference Modification icon_biggrin.gif
Back to top
View user's profile Send private message
rajulan

New User


Joined: 11 Jan 2008
Posts: 66
Location: India

PostPosted: Mon Feb 09, 2009 3:19 am    Post subject:
Reply with quote

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
View user's profile Send private message
Bert

New User


Joined: 22 Oct 2008
Posts: 5
Location: Canada

PostPosted: Mon Feb 09, 2009 3:30 am    Post subject:
Reply with quote

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 icon_biggrin.gif
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Mon Feb 09, 2009 3:40 am    Post subject:
Reply with quote

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) icon_smile.gif
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:


Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us