How many bytes occupied following comp example?
This is regarding COBOL comp.
PIC X(3) occupy the 3 bytes... but PIC 9(3)V9(7) COMP occupied how much bytes?
I said in interview that 10/2 = 5 bytes. V is specified for decimal point.
Is that correct? But interviewer looked at me differently when I said this answer?
If you are more confident, please reply this ...thanks...
- Feb 15th, 2023
We can store only 9 and S not V in comp ,if we want to store decimal use comp-3 not comp
- Aug 17th, 2022
N/2 for even number and than +1. (n+1/2) for odd number.
In the example below
05 WS-VAR1 PIC X(5),05 WS-VAR2 REDEFINES WA-VAR1 PIC 9(5),PROCEDURE DIVISION MOVE 'ABCDE' TO WS-VAR1.Now what is the value of WS-VAR1 and WS-VAR2 ?
- Apr 25th, 2021
WS_VAR1 - ABCDE
WS-VAR2 - A CDE
- Sep 5th, 2017
Here given 05 WS-VAR2 redefines WA-VAR1 pic 9(5). means WA-VAR1 should be defined in working storage so while compiling it will throw the error. but excluding this next statement in procedure division is move abcde to ws-var1. means value of ws-var1 is =abcde
What is the difference between Working-storage Section & Linkage Section?
- Aug 4th, 2020
there is much difference between Linkage and working-storage on how you define variables. linkage section has 01 level only. Linkage is to take in data from other programs or stored procedures. Wor...
- Jun 11th, 2010
There is no difference between Working and Linkage both are in Data Division.Working-Storage for declaring the variables in main program.Linkage section is used for declaring the variables for Sub program. Parm parameters also can be declared in Linkage section only.
Can Redefines clause be used in File section, if yes at which level number ?
- Jan 25th, 2020
- Aug 17th, 2012
Except 66 and 88 levels it will work.
What is redefine in COBOL?
- Sep 2nd, 2019
The REDEFINES clause is used to store more than one data items in the same storage area. Syntax: level-number Data-name1 REDEFINES Data-name-2 data-name-1 is the redefining item or the REDEFINES su...
- Dec 6th, 2018
redefines class is something you can use the existing memory location for your new variable using the redefines caluse 01 emp-data pic x(100) 05 emp-name pic x (40) 05 emp-no pic x(20) 05 fi...
How to initialize a group data which is containing occur clause?
- Jan 17th, 2019
Perform varying sub from 4 by 1 until sub is greater than the occurs area. Move spaces or zeros to the fields in the occurs.
- Apr 3rd, 2018
I have query regarding the initialization of occur clause.
02 WS-DETAIL OCCURS 20 TIMES.
COPY DDS-ALL-FORMAT OF TESTPF.
Query - How can I initialize WS-DETAIL for particular index 5 where up to index 4 having data in WS-DETAIL?
Concatinating two rec by using COBOL & JCL
I need to concatenate records by using cobol and jcl (both) as follows.
Split the file into two halves and
1st rec of first half and 2nd rec of second half records are concatinated and
2nd rec of first half and 2nd rec of second half records are...
- Dec 6th, 2018
Please post your requirement clearly .. If you have to concatenate the records from two different files you can use IEBGENERCode
- Mar 20th, 2018
How to separate to multi-field?
01 something PIC X(06).
01 one PIC 9(02).
01 two PIC 9(02).
01 three PIC X(02).
something = 1234ww
one = 12
two = 34
three = ww
- Dec 6th, 2018
We can declare something as a group variable
01 something pic x(06)
05 one pic 9(2)
05 two pic 9(2)
05three pic x(2)
- Nov 2nd, 2018
Redefines can be used
What is the difference between NEXT SENTENCE and CONTINUE?
NEXT SENTENCE gives control to the verb following the next period. CONTINUE gives control to the next verb after the explicit scope terminator. (This is not one of COBOL II's finer implementations). It's safest to use CONTINUE rather than NEXT SENTENCE in COBOL II.Read Best Answer
Editorial / Best Answer
Answered by: umapathi
- Jul 20th, 2006
the following code explains u clearly
it will display only 3. if a>b
it will display 1 2 3. if a>b. let me know if it is not correct.
- Sep 14th, 2018
Continue pushes the control to Add +1 to Input-count. Say if Input-count was 0 then the value will be iterated to 1
Next sentence will never add +1 to Input-count it will bypass the command. Say if Input-count was 0 then the value will remain same.
- Jan 17th, 2017
When NEXT SENTENCE is coded, Program will not add +1 to INPUT-COUNT.
When CONTINUE is coded, +1 will be added to INPUT-COUNT.
Ascending Order String Handling
Given a string for eg: MICROSOFT, How can you arrange each letter in this string in an ascending order?
- Mar 20th, 2018
In EBCDIC A- C1 , B - C2....Z- E9. Perform varying inx from 1 by 1 until ws-data >= 9 If not-first-time If ws-h < ws-data(inx:1) Move ws-h to ws-o(inx-1:1) ...
Called and calling program for cobol with cursor
I have program A which is calling B first time. B program is feaching data using cursor , but some mess happened and the control went back to pro A without closing cursor . Once again program A called program B then what will happen to cursor. will program fetch the data.
- Mar 20th, 2018
It depends on how program b is linked. Above answer is correct for statically linked. But if dynamically linked then program b will be in initial state in 2nd time and no error will come.
- Oct 26th, 2017
How do we avoid the error code of -502? How do we close the cursor in the calling program?
EMail Validation via COBOL
I have file with customer details and I need to process only those records who is having valid email id, so how we can validated these records using COBOL?
- Jan 29th, 2018
MOVE @ TO WS-CHAR
you can use INSPECT EMAILID TALLYING WS-COUNT-1 FOR ALL INITIAL WS-CHAR
IF WS-COUNT > 0 (means there is @)
- Feb 12th, 2017
It is partially correct answer @ symbol is part of the answer we have to check (.) for valid mail id ..
Correct me if I am wrong
There are 2 files. These 2 files contains some common (duplicate) records. How do you copy these common (matching) records into third file. Suggest the answer using COBOL as well as through JCL.
- Nov 21st, 2017
Using ICETOOL, Below syntax will get just all duplicates if duplicates are decided based first eight charactes
SELECT FROM(SORTIN) TO(SORTOUT) ON(1,8,CH) ALLDUPS DISCARD(SORTXSUM)
- May 26th, 2017
//STEP010 EXEC PGM=SORT //SYSOUT DD SYSOUT=* //SYSPRINT DD SYSOUT=* //SORTIN DD DSN=TEST...
What is the difference between COPY and INCLUDE
- Sep 8th, 2017
Copy - Expand the copybook statements during compilation time.
Include - Expand the copybook statements during pre-compilation time. Usually for DELGENS we use INCLUDE as DCLGEN statements needed during pre-compilation process.
- Dec 31st, 2015
Copy will be used in the cobol compile process and Include will be used during the Db2 precompile process. So we include a Dclgen. We cannot copy a dclgen..If so the program will fail the compilation.We can include a copybook too.
How to remove the duplicate records present in a PS dataset using JCL?
- Aug 22nd, 2017
Using sort utility, include the following command
- Mar 19th, 2015
Sum Fields = None will do it
What is the difference between static call and dynamic call?
- Jul 1st, 2017
Static Call: Sub programs compiled version of code is embedded with main program so if compile sub program with modified changes then main program is also being compiled. Dynamic Call:Sub programs ve...
- Jun 16th, 2015
We can identify whether the call is static or dynamic by seeing the CALL structure. Static Call: we refer the program name in the CALL statement. e.g. CALL PGM1 Dynamic call : we use one WS variabl...
COBOL File Handling
how do you read a file in reverse order through COBOL program?
- Jun 28th, 2017
Add a seq number to file thru JCL (1:seqnum,3,zd) and sort the file in descending order sortfields=copy, include cond=(1,3,zd,d) after this provide the file in Cobol as input.
- Jul 7th, 2016
Can be done in VSAM : by using Low and HIGH-VALUE
If you pass HIGH-VALUE to the key field, then it will read the record from bottom
Consider the following COBOL entries 05 X PIC 99 VALUE 10. ADD 40 X TO X. COMPUTE X = 3 * X - 40. The result in X is (a) 10 (b) 40 (c) Compile or Run time error (d) none of these
- Jun 22nd, 2016
Answer is 40 - value of X is 10 -- add 40+10+10 = 60 ---> x=(3*60)-40 = 180 -- but pic declared as 99 -- right to left move so Answer is 40
- May 28th, 2016
Add statement will add 40+10(value of X)+10(value of X) and the result will be stored in X as 60. Then, the compute statement multiples the value of X by 3 and subtract by 40. So, the value of X will ...
What is the difference between static & dynamic call?
In the case of static call the mainprogram and subpgms r loaded into the mainmemory initially.in the case of dynamic call only the mainpgm is loaded first and the subpgm is loaded only when a call to it is made.so the memory utilization is good in dynamic call.
- Jun 4th, 2016
Static and dynamic will be decided only on compiler if NODYNAM - it is static, if DYNUM then dynamic.
- Mar 8th, 2016
In case of Static Call, we use the call literal. For example, CALL PGM1. In case of dynamic call, we define a variable and pass the sub-program name to it before calling. Ex- 01 WS-VAR1 PIC...
Dynamic Linking in COBOL
I have two modules called 'A' and 'B'. Module 'A' opens the ORACLE database connection, and Calls 'B', which queries the database using the 'SELECT' statement.When I hard code the module name during CALL, the called module uses the database connection opened in the module 'A'. Pls refer below:CALL "B"But, when I moved the module name into a variable and try to call the module, as belowMOVE "B" TO...
- Feb 9th, 2016
This problem can be resolved by compiling the main program (Calling program) using the DYNAM compiler option
COBOL Interview Questions