Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Need to know how many numbers are there in Sysin

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

New User


Joined: 12 Dec 2008
Posts: 96
Location: Gurgaon

PostPosted: Wed May 27, 2009 12:13 pm    Post subject: Need to know how many numbers are there in Sysin
Reply with quote

Hi,

I have some numbers in Sysin as shown:

SYSIN DD *
01
02
03
04

My requirement is that i want to know how many numbers are there in SYSIN and on basis of that need to perform some Para.

Can you please provide with COBOL code.
I gave ACCEPT WS-NUM but it gave only first number instead of total numbers.

regards,
rupesh gupta
Back to top
View user's profile Send private message

umasankarmf

New User


Joined: 08 Sep 2008
Posts: 43
Location: india

PostPosted: Wed May 27, 2009 12:26 pm    Post subject:
Reply with quote

Hi rupesh gupta,

If you have ACCEPT statement in the cobol code, it will take the value from SYSIN DD *. So, even though you have given more values at SYSIN DD * it will take dependens on how many times ACCEPT statement execute.

For ex. you have 10 values in SYSIN DD *, but only 5 times ACCEPT statement is executing in your program then it will take only 5 values from SYSIN.
Back to top
View user's profile Send private message
rupesh gullu

New User


Joined: 12 Dec 2008
Posts: 96
Location: Gurgaon

PostPosted: Wed May 27, 2009 12:43 pm    Post subject: Reply to: Need to know how many numbers are there in Sysin
Reply with quote

Hi Umasankar,

I tried with solution provided by you. Its working fine.Thanks
But if is there another way for this.I have to write ACCEPT 10 times. But if i have say 50 numbers then we will have 50 accept which will increase code size.

regards,
rupesh gupta
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10202
Location: italy

PostPosted: Wed May 27, 2009 12:47 pm    Post subject: Reply to: Need to know how many numbers are there in Sysin
Reply with quote

Quote:
But if i have say 50 numbers then we will have 50 accept which will increase code size.


ever heard about DO loops icon_question.gif icon_biggrin.gif icon_question.gif icon_biggrin.gif
Back to top
View user's profile Send private message
umasankarmf

New User


Joined: 08 Sep 2008
Posts: 43
Location: india

PostPosted: Wed May 27, 2009 12:58 pm    Post subject:
Reply with quote

Hey not like that. If you want to ACCEPT 50 times then put it in perform statement. But dont hard code as 50 times.........!
Back to top
View user's profile Send private message
rupesh gullu

New User


Joined: 12 Dec 2008
Posts: 96
Location: Gurgaon

PostPosted: Wed May 27, 2009 2:24 pm    Post subject: Reply to: Need to know how many numbers are there in Sysin
Reply with quote

Hi Umasankar,

Can you provide me with code for Perform.

Regards,
rupesh gupta
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10202
Location: italy

PostPosted: Wed May 27, 2009 2:26 pm    Post subject: Reply to: Need to know how many numbers are there in Sysin
Reply with quote

at the top of the page there is a link to the manuals
Back to top
View user's profile Send private message
rupesh gullu

New User


Joined: 12 Dec 2008
Posts: 96
Location: Gurgaon

PostPosted: Wed May 27, 2009 4:20 pm    Post subject: Reply to: Need to know how many numbers are there in Sysin
Reply with quote

Hi enrico,

I am getting some error while solving the problem.I have declared SYSIN in FD section and is opening it as a file. But I am not getting how to get number of records.Follwoing is my code:
Code:

READ SYSIN INTO SYSIN-REC AT END         
  MOVE 'YES' TO WS-EOD-SW               
NOT AT END                               
  ADD +1 TO WS-CNTR1                     
END-READ.                               
                                         
PERFORM UNTIL WS-EOD                     
  ACCEPT WS-TOT-NUM                     
  MOVE 'NO' TO WS-EOD-SW                 
END-PERFORM.                             
                                         
DISPLAY 'TOTAL NUMBERS' WS-TOT-NUM.     
                                         
CLOSE INPUT SYSIN.                       


I am getting following error:

Data-item "SYSIN-REC (NUMERIC INTEGER)" and record "SYSIN-REC (NUMERIC INTEGER)"
Movement of data may not occur at execution time.

Please help me with my problem.

regards,
rupesh gupta
Back to top
View user's profile Send private message
Succor

New User


Joined: 20 Feb 2009
Posts: 96
Location: Bangalore :)

PostPosted: Wed May 27, 2009 6:34 pm    Post subject: Reply to: Need to know how many numbers are there in Sysin
Reply with quote

rupesh gullu, show us the Select clause and FD entries with SYSIN-REC declaration. In-between, how this jcl is prepared, if some indicator could be added to the SYSIN list then you would be exempted of the file processing.For example :
Code:

//SYSIN DD *   
1               
2               
3               
/               
/*             

And in your program
Code:

PERFORM UNTIL A = '/' 
ACCEPT A
DISPLAY "VALUE OF SYSIN CHANGES TO:" A                   
ADD +1   TO I                         
END-PERFORM.       
COMPUTE I = I -1
DISPLAY 'THE NUMBER OF OCCURENCES :' I

SYSOUT
Code:

VALUE OF A CHANGES TO:1         
VALUE OF A CHANGES TO:2         
VALUE OF A CHANGES TO:3         
VALUE OF A CHANGES TO:/         
THE NUMBER OF OCCURENCES :000003
 
Back to top
View user's profile Send private message
rupesh gullu

New User


Joined: 12 Dec 2008
Posts: 96
Location: Gurgaon

PostPosted: Wed May 27, 2009 6:42 pm    Post subject: Reply to: Need to know how many numbers are there in Sysin
Reply with quote

Hi Succor,

Thanks for reply. My FD entries are as:

Code:

FILE-CONTROL.                                   
                                               
    SELECT SYSIN ASSIGN TO SYSIN.               
                                               
DATA DIVISION.                                 
                                               
FILE SECTION.                                   
                                               
FD SYSIN                                       
                                               
    LABEL RECORDS ARE STANDARD                 
    RECORD CONTAINS 02 CHARACTERS               
    DATA RECORD IS SYSIN-REC.                   
                                               
01  SYSIN-REC                     PIC  9(02).



and the JCL code is :

Code:

//STEP020  EXEC PGM=TESTCOB4                 
//STEPLIB  DD DSN=TSUDQ3O.TEST.LOAD,DISP=SHR 
//CNTLOUT  DD DUMMY                           
//METLCPU  DD DUMMY                           
//CEEDUMP  DD SYSOUT=(,)                     
//ABNLTERM DD SYSOUT=(,)                     
//SYSOUT   DD SYSOUT=(,)                     
//SYSIN    DD *                               
01                                           
02                                           
03                                           
04                                           
05                                           
06                                           
07                                           
/*                                           
//*   


I will try solution provided by you. Can you please help me with mine.I am facing problem how to accept the values if i need to do it in for of files as i am doing.

regards,
rupesh gupta
Back to top
View user's profile Send private message
Succor

New User


Joined: 20 Feb 2009
Posts: 96
Location: Bangalore :)

PostPosted: Wed May 27, 2009 7:01 pm    Post subject: Reply to: Need to know how many numbers are there in Sysin
Reply with quote

Try defining SYSIN-REC as PIC X(02).
Show us the exact error as displayed in spool.
Correct the logic of your code as well, perform the READ in a loop until end of file, though it is not the reason for the present error.
Back to top
View user's profile Send private message
rupesh gullu

New User


Joined: 12 Dec 2008
Posts: 96
Location: Gurgaon

PostPosted: Wed May 27, 2009 7:12 pm    Post subject: Reply to: Need to know how many numbers are there in Sysin
Reply with quote

Hi Succor,

Following is error which i am getting.

Code:

Data-item "SYSIN-REC (NUMERIC INTEGER)" and record "SYSIN-REC (NUMERIC INTEGER)"
Movement of data may not occur at execution time.                               


regards,
rupesh gupta[/quote]
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1219
Location: Israel

PostPosted: Wed May 27, 2009 7:33 pm    Post subject: Re: Reply to: Need to know how many numbers are there in Sy
Reply with quote

rupesh gullu wrote:
Can you provide me with code for Perform.


rupesh gullu wrote:
READ SYSIN INTO SYSIN-REC AT END
MOVE 'YES' TO WS-EOD-SW
NOT AT END
ADD +1 TO WS-CNTR1
END-READ.

PERFORM UNTIL WS-EOD
ACCEPT WS-TOT-NUM
MOVE 'NO' TO WS-EOD-SW
END-PERFORM.

DISPLAY 'TOTAL NUMBERS' WS-TOT-NUM.

CLOSE INPUT SYSIN.


Obviously, the first thing you should do is... learn COBOL (seriously).

As explained, you have to count the lines by yourself.

You have to choose between using ACCEPT or using OPEN/READ/CLOSE.
You cannot mix these commands (well, maybe you can, but I wouldn't recommend it).

You do not need the "INTO SYSIN-REC" in the READ statement, as this field is defined in the FILE section.

Do you also have some processing to do on the lines or do you only need to count them ???
Back to top
View user's profile Send private message
rupesh gullu

New User


Joined: 12 Dec 2008
Posts: 96
Location: Gurgaon

PostPosted: Wed May 27, 2009 7:43 pm    Post subject: Reply to: Need to know how many numbers are there in Sysin
Reply with quote

Hi Marso,

I need to do little compution after gettting num od records.
actually i was interested in using open//read/close instead of accept.This is first time I am reading data from SYSIN.I usually get task using files.
Can you please provide me with proper code.

regards,
rupesh gupta
Back to top
View user's profile Send private message
Succor

New User


Joined: 20 Feb 2009
Posts: 96
Location: Bangalore :)

PostPosted: Wed May 27, 2009 11:47 pm    Post subject: Reply to: Need to know how many numbers are there in Sysin
Reply with quote

Rupesh gullu,
Inplace in of SYSIN DD * use a PS with the sysin data
Data in file
Code:

11
22
33
44
55

JCL definition:
Code:

//SYSIN DD DISP=SHR,DSN=INPUT.SYSIN.TEST.DATA

Program
Code:
FILE-CONTROL.
SELECT SYSIN  ASSIGN SYSIN
ORGANIZATION IS SEQUENTIAL.
DATA DIVISION.
FILE SECTION.
 FD  SYSIN                                     
     RECORDING MODE IS F                       
     BLOCK CONTAINS 0 RECORDS.                 
  01  SYSIN-REC                     PIC  9(02).

PROCEDURE DIVISION.
OPEN INPUT SYSIN.                                 
PERFORM UNTIL END-OF-FILE                       
READ SYSIN AT END                                 
  SET END-OF-FILE  TO TRUE                         
NOT AT END                                         
  ADD +1 TO B                                     
  DISPLAY 'THE CURRENT VALUE OF SYSIN:' SYSIN-REC 
END-READ                                           
END-PERFORM.       
DISPLAY 'THE NUMBER OF OCCURENCES :' B             
CLOSE SYSIN                                       

SYSOUT
Code:

THE CURRENT VALUE OF SYSIN:11   
THE CURRENT VALUE OF SYSIN:22   
THE CURRENT VALUE OF SYSIN:33   
THE CURRENT VALUE OF SYSIN:44   
THE CURRENT VALUE OF SYSIN:55   
THE NUMBER OF OCCURENCES :000005

Remember the LRCL of sysin file should be equal to SYSIN-REC length.

WTH.
Back to top
View user's profile Send private message
Succor

New User


Joined: 20 Feb 2009
Posts: 96
Location: Bangalore :)

PostPosted: Wed May 27, 2009 11:53 pm    Post subject: Reply to: Need to know how many numbers are there in Sysin
Reply with quote

Tested for
Code:
//SYSIN DD *                       
023216C0000000000000000000000000000
012                               
113                               
/*                                 

Change in FD entry
Code:
 01  SYSIN-REC                     PIC  X(80).

Rest of code will remain as in my previous post.Add your logic accordingly.
SYSOUT
Code:
THE CURRENT VALUE OF SYSIN:023216C0000000000000000000000000000
THE CURRENT VALUE OF SYSIN:012                                 
THE CURRENT VALUE OF SYSIN:113                                 
THE NUMBER OF OCCURENCES :000003                               


WTH.
Back to top
View user's profile Send private message
rupesh gullu

New User


Joined: 12 Dec 2008
Posts: 96
Location: Gurgaon

PostPosted: Thu May 28, 2009 11:26 am    Post subject: Reply to: Need to know how many numbers are there in Sysin
Reply with quote

Hi Succor,

Thanks for the reply Its working fine.

Regards,
rupesh gupta
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:

Similar Topics
Topic Author Forum Replies Posted
No new posts Row-Numbers of distinct rows? Auryn DB2 1 Thu Oct 20, 2016 4:38 pm
No new posts Need to know what sysin for DFHTU690 ... pkmurali CICS 3 Mon Jul 25, 2016 1:36 pm
No new posts Symbolic Parameters in SYSIN DD state... madishpa DFSORT/ICETOOL 3 Mon Jun 27, 2016 6:23 pm
No new posts comparing comp-3 and unpacked numbers juares castro COBOL Programming 3 Mon May 30, 2016 6:46 pm
No new posts Sort Trick for numbers pshongal DFSORT/ICETOOL 4 Tue Mar 22, 2016 1:33 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us