You are on page 1of 5

cobol

1. copy statement:
COPY copybookname REPLACING ==oldfield== BY ==newfield==
----
2. How to edit comp-3 variable in cobol?
We cant move the variable of type S9(10)V99 COMP-3 to ALPHANUMERIC directly.
Plz declare a intermediate variable of type +9(10).99 and move it to the alphanu
meric.. It works.

In your case if we take the exmaple of date and define the variable as
"WS-DATE PIC 9(8) COMP-3 VALUE 20101010."
"WS-DATE-TEMP PIC 9(8)."

Then we need to move WS-DATE to WS-DATE-TEMP


"MOVE WS-DATE TO WS-DATE-TEMP."
Then if you want the date in DD-MM-YYYY format then define the group variables a
s below
01 WS-DATE-TEMP1.
05 WS-TEMP-YYYY PIC 9(4).
05 WS-TEMP-MM PIC 9(2).
05 WS-TEMP-DD PIC 9(2).
01 WS-DATE-FORMAT.
05 WS-DD PIC X(2).
05 FILLER PIC X(1) VALUE '-'
05 WS-MM PIC X(2).
05 FILLER PIC X(1) VALUE '-'
05 WS-YYYY PIC X(4).
Then...
MOVE WS-DATE-TEMP TO WS-DATE-TEMP1"
MOVE WS-TEMP-YYYY TO WS-YYYY.
MOVE WS-TEMP-MM TO WS-MM.
MOVE WS-TEMP-DD TO WS-DD.

DISPLAY "WS-YYYY-" WS-YYYY.


DISPLAY "WS-MM-" WS-MM.
DISPLAY "WS-DD-" WS-DD.
DISPLAY "WS-DATE-FORMAT-" WS-DATE-FORMAT.

WS-DATE-FORMAT will have the date in desired format like "10-10-2010"


---
3. comp is a binary usage , comp-3 is a packed decimal
-------
4. diff b/w include and copy?
As far as I know, we use INCLUDE in COBOL-DB2 programs to copy the contents of t
he DCLGEN to the program.
The only difference between INCLUDE and COPY is that while INCLUDE is executed a
t pre-compile time (by the SQL compiler), COPY is executed at compile time(by th
e COBOL compiler).

Hence, you can even use COPY for your DCLGEN's but you may get a return code of
4 from the precompiler because the pre-compiler searches for the host variables
used in a query and if it does not find them returns 4.
-----------------------
5. why we cant use occurs in 01level when it is defi...
there is repeat field with the same format not the record.
-------------
6. 77 WS-AMT PIC ZZZ999.
ADD 100 TO WS-AMT WILL RESULT IN
a) COMPILATION ERROR - i guess.. because numeric op not possible on edited item
s
b) SOC7 ERROR
C) NO ERROR
----
7. 77 I PI 9.
PERFORM VARYING I FROM 1 BY 1 UNTIL>10
DISPLAY 'OK'
END-PERFORM.
What output/msg is likely when this program is executed thru JCL?

It Won't give the compilation error.


At Run time when Varibale I reached to 10 then in working storage variable which
is declared as 9(01) can hold 0 not 10
So Program goes into loop result in Timeout Error S322.
-----------
8. diff b/w abend and error
abend occures during the execution of program.error occures before execution of
the program due to the syntax coding in a program.
9. A RETURN_CODE shows the status of each step within a job, the maximum RETURN_
CODE is 256, where as
MAXCC is used for the final output of the programe. If the MAXCC is ZERO then jo
b is executed successfully. In MAXCC we have 0,2, 4, 8.
-----------
10. define comp-1 pic clause
No picture clause to be given. Example 01 WS-VAR USAGE COMP-1.
--------
11. sign storage in comp-3
It is stored in the last nibble. For example if your number is +100, it store
s hex 0C in the last byte
-----
12. 'IS NUMERIC' clause is to check the given IDENTIFIER contains numeric data o
r not. It returns 'TRUE' when the given IDENTIFIED contains all numeric digits,
otherwise it returns 'FALSE'.
-->the following are the different conditions can be used within COBOL
CONDITIONAL PROGRAMMING
=======================
IS NUMERIC (to check it is numeric or not)
IS ALPHABETIC (to check it is alphabetic or alphanumeric, or not)
IS ZEROS (to check it is zero or not)
IS POSITIVE (to check it is positive numeric or not)
IS NEGATIVE (to check it is negative numeric or not)
--------------
13. if stop run not given then program might through user abend or s322 abend al
so..results are unpredictable.
-------
14. What is the difference between STOP & STOP RUN ?
Stop statement provides a means to temporarily suspend execution of an object pr
ogram...wheares STOP used with RUN causes the entire run unit to cease execution
when it is encountered....
moreover stop will be same as stop run when no sub program is involved.
-------
15. FINISH - may realease all database resources..
------
16. Mismatch in LRECL or BLOCKSIZE or RECFM between your COBOL program & the JCL
(or the dataset label). You will get file status 39 on an OPEN.
-------
17. Can rewrite (record length must be same), but not delete.
------
18. redefine
05 MY-NUM-ALPHA PIC X(9).
05 MY-NUM REDEFINES MY-NUM-ALPHA PIC S9(17) COMP-3.
MOVE 'ABCDEFGHI' to MY-NUM-ALPHA.
note that comp-3 stores 2 numbers per byte so 17 digits
takes 9 bytes (half of one byte stores the sign.) So you
could move a 19-character variable to a 9-byte field but it
will be truncated.
The function NUMVAL can be used to change the X(19) to S9(17) and then moved to
comp-3
Ex:
ws-variable PIC X(19)
ws-variable-1 PIC S9(17)
ws-variable-1 PIC S9(17) comp-3
Compute ws-variable-1 = function numval(ws-variable)
move ws-variable-1 to ws-variable-2.
Ofcourse you should be expecting a signed 9(17) value in
the ws-variable. Check out NUMVAL-C too. Both functions are
a great help in such situations.
-------
19. If the ARITH(COMPAT) compiler option is in effect, the composite of operand
s can be a maximum of 30 digits. If the ARITH(EXTEND) compiler option is in effe
ct, the composite of operands can be a maximum of 31 digits.
rent - make the program as reentrant
test - debug mode on
-------
20. ON SIZE ERROR for aritmetic
ON OVERFLOW ERROR for string
-------
21. Redifine is a clause which reuses the existing storage space
1)redifine must be coded immediate after orginal dataname.
2)level no must be same as orginal data name.
3)level no should be 01-49.
4)data tpye length must be same.
ex:
01 a pic 9(6).
01 b redifine a pic 9(6).
01 c redifine a pic 9(6).
-----------
22. how to find specific columns and exclude specific lines in mainframe?
x all; f all 't' 1 <- search string is t and in 1st col only and display only fi
nd items.. rest will shows -----
f all 'td' 1 2 nx <- search string is td and b/w 1st and 2nd columns only and
nx -> only in displayed after the excluded list
---------------
23. how to delete all members in pds in ispf?
go to ispf option 3.4
list Your dataset
choose the option m
on the command line issue the command
s * d
to delete all the members ( You can in the next panel turn confirm off )
or for a pattern
s aa* d
same as before
after deletion it would be better to compress te dataset if PDS
-------------------
if i'm getting file from other system but the file itself not found. what can be
done to avoid abend in jcl?
option:1
//STEP010I EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
LISTCAT ENTRIES(yourfile)
//STEP020P EXEC PGM=yourprogram,COND=(0,NE,STEP010I)
option:2
///EXIST EXEC IDCAMS
PRINT INDATASET('dataset-name') CHARACTER COUNT(1)
If the dataset does not exist, you get RC=0012.
you can check for RC using IF THEN ELSE logic in the JCL...
---------
which is better dfhresp or handle aid condition?
dfhresp is better. it gives readability
handle conditon not more than 16 single condition in single handle. need to have
another handle condition.
if handle aid used, to check the PF keys we have to use receive command
but EIBAID can be used directly.... this is the biggest disadvantage.
-------
How will you run map and typical cics program?
declare in ppt table(program processing table)
can create using bms(basic mapping support) or through dfh macros (assmebler)
----------
if the column name is changed in db2 what will happen when i execute program?
no errro in precompile and error during execution
------------------
what will happen if u code stop run in cics?
STOP RUN ends the program and returns control to the operating system and discar
ding all information about the job.
Since YOUR program is running as a subtask of CICS "STOP RUN" would shut down th
e entire CICS region. In the past there has been a prohibition against using it
in an application.
However CICS now ignores "STOP RUN". This question is out dated. Anyone asking t
his damn sure has grey hair.
------
how to test map?
CECI SEND MAP(MAPNAME) MAPSET (MAPSET NAME) FREEKB ERASE
-------
we can create the maps through sdf(Screen Definition Facility). This is one way
of creating the maps without using dfhmacro. This is like a menu driven
BMS:means basic mapping support ,by using this we can create maps which supports
format indepedece as well as device independece.
SDF:means screen defintion facility. by using SDF we can define maps which suppo
rts device as well as format independence.

----
differnece b/w systsin and sysin?
SYSTSIN is the standard input DD (i.e. Terminal Input) for either the TSO progra
m (IJKEFT**) or the REXX interpreter (IRXJCL).
SYSIN is a standard input DD, usually used to supply run-time parameters to the
associated program.
to continue a line in sysin or systsin use -
do until always executes one time
do while we can save w/o executing
------------

You might also like