View previous topic :: View next topic
|
Author |
Message |
rupesh gullu
New User
Joined: 12 Dec 2008 Posts: 96 Location: Gurgaon
|
|
|
|
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 |
|
|
umasankarmf
New User
Joined: 08 Sep 2008 Posts: 43 Location: india
|
|
|
|
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 |
|
|
rupesh gullu
New User
Joined: 12 Dec 2008 Posts: 96 Location: Gurgaon
|
|
|
|
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 |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10872 Location: italy
|
|
|
|
Quote: |
But if i have say 50 numbers then we will have 50 accept which will increase code size. |
ever heard about DO loops |
|
Back to top |
|
|
umasankarmf
New User
Joined: 08 Sep 2008 Posts: 43 Location: india
|
|
|
|
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 |
|
|
rupesh gullu
New User
Joined: 12 Dec 2008 Posts: 96 Location: Gurgaon
|
|
|
|
Hi Umasankar,
Can you provide me with code for Perform.
Regards,
rupesh gupta |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10872 Location: italy
|
|
|
|
at the top of the page there is a link to the manuals |
|
Back to top |
|
|
rupesh gullu
New User
Joined: 12 Dec 2008 Posts: 96 Location: Gurgaon
|
|
|
|
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 |
|
|
Succor
New User
Joined: 20 Feb 2009 Posts: 96 Location: Bangalore :)
|
|
|
|
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 |
|
|
rupesh gullu
New User
Joined: 12 Dec 2008 Posts: 96 Location: Gurgaon
|
|
|
|
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 |
|
|
Succor
New User
Joined: 20 Feb 2009 Posts: 96 Location: Bangalore :)
|
|
|
|
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 |
|
|
rupesh gullu
New User
Joined: 12 Dec 2008 Posts: 96 Location: Gurgaon
|
|
|
|
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 |
|
|
Marso
REXX Moderator
Joined: 13 Mar 2006 Posts: 1353 Location: Israel
|
|
|
|
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 |
|
|
rupesh gullu
New User
Joined: 12 Dec 2008 Posts: 96 Location: Gurgaon
|
|
|
|
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 |
|
|
Succor
New User
Joined: 20 Feb 2009 Posts: 96 Location: Bangalore :)
|
|
|
|
Rupesh gullu,
Inplace in of SYSIN DD * use a PS with the sysin data
Data in file
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 |
|
|
Succor
New User
Joined: 20 Feb 2009 Posts: 96 Location: Bangalore :)
|
|
|
|
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 |
|
|
rupesh gullu
New User
Joined: 12 Dec 2008 Posts: 96 Location: Gurgaon
|
|
|
|
Hi Succor,
Thanks for the reply Its working fine.
Regards,
rupesh gupta |
|
Back to top |
|
|
|