I am facing an issue with writing data into an o/p PS from an easytrieve program.
I have moved the data properly into the o/p fields & can see the correct values after displaying the same.
But I am receiving junk values in the o/p file for these fields.
The easytrieve code is as follows:
//WIP04DD JOB (T,476),'KSHITIJ',CLASS=1,MSGCLASS=X,
// NOTIFY=&SYSUID
//BR14 EXEC PGM=IEFBR14
//*DD1 DD DISP=(MOD,DELETE,DELETE),DSN=CCS.WIP04.CMRO1
//*************************************************************
//EZTSQL EXEC PGM=EZTPA00,REGION=4M
//*************************************************************
//STEPLIB DD DSN=SYSTEMS.LINKLIB,DISP=SHR
// DD DSN=DB2P.SDSNLOAD,DISP=SHR
//EZTVFM DD SPACE=(CYL,(20,20)),UNIT=SYSDA,DCB=BUFNO=40
//SYSPRINT DD SYSOUT=*
//SYSPUNCH DD DUMMY
//SYSOUT DD SYSOUT=*
//SYSUDUMP DD SYSOUT=Y
//SORTWK01 DD SPACE=(CYL,(5,50)),UNIT=SYSDA
//SORTWK02 DD SPACE=(CYL,(5,50)),UNIT=SYSDA
//INFILE DD DSN=CCS.WIP04.CMRO1,DISP=SHR
//OUTFILEA DD DSN=CCS.WIP04.CMRO2,DISP=(NEW,CATLG,DELETE),
// DCB=(RECFM=FB,LRECL=100,BLKSIZE=0),UNIT=SYSDA,
// DATACLAS=MB010
//SYSIN DD *
PARM BIND(DYNAMIC) SSID(DB2P) LIST(NOPARM)
FILE INFILE
IN-REC 1 080 A
IN-CRNCL 01 20 A
IN-SALN 22 08 A
FILE OUTFILEA
OUT-REC 1 800 A
OUT-CRNCL 01 20 A
OUT-SALN 22 08 A
OUT-GR-RSV 32 06 P 2
OUT-NET-RSV 40 06 P 2
OUT-RP-GR-RSV 48 06 P 2
OUT-RP-NET-RSV 56 06 P 2
*
WS-CRNCL W 20 A
WS-SALN W 08 A
WS-GR-RSV W 06 P 2
WS-NET-RSV W 06 P 2
WS-RP-GR-RSV W 06 P 2
WS-RP-NET-RSV W 06 P 2
WS-SQL-FUNCTION W 10 A
WS-CURSOR-NAME W 10 A
WS-END-CURSOR W 01 A
*
SQL DECLARE GETRSRV CURSOR FOR +
SELECT GROSS_RESV_AMT,NET_RESV_AMT,RLP_GROSS_RESV_AMT, +
RLP_NET_RESV_AMT +
FROM DB2P.DFCSP.FI_UNIT_HISTORY +
WHERE SALN = :IN-SALN +
AND CURRENT_IND = 'C' +
WITH UR
*
JOB INPUT NULL
*
MOVE SPACES TO WS-SALN
MOVE SPACES TO WS-CRNCL
MOVE ZEROES TO WS-GR-RSV
MOVE ZEROES TO WS-NET-RSV
MOVE ZEROES TO WS-RP-GR-RSV
MOVE ZEROES TO WS-RP-NET-RSV
GET INFILE
IF EOF INFILE
STOP
END-IF
DISPLAY 'IN-SALN' IN-SALN
PERFORM RESERVE-DETAILS
RESERVE-DETAILS. PROC
SQL OPEN GETRSRV
MOVE 'OPEN' TO WS-SQL-FUNCTION
MOVE 'GETRSRV' TO WS-CURSOR-NAME
PERFORM CHECKSQL
MOVE 'FETCH' TO WS-SQL-FUNCTION
MOVE 'GETRSRV' TO WS-CURSOR-NAME
DO UNTIL WS-END-CURSOR = 'Y'
PERFORM FETCH-RSRV
END-DO
SQL CLOSE GETRSRV
MOVE 'CLOSE' TO WS-SQL-FUNCTION
MOVE 'GETRSRV' TO WS-CURSOR-NAME
PERFORM CHECKSQL
END-PROC.
FETCH-RSRV. PROC
SQL FETCH GETRSRV +
INTO :WS-GR-RSV, +
:WS-NET-RSV, +
:WS-RP-GR-RSV, +
:WS-RP-NET-RSV
IF SQLCODE EQ 100
MOVE 'Y' TO WS-END-CURSOR
END-IF
IF SQLCODE = 0
MOVE WS-GR-RSV TO OUT-GR-RSV
MOVE WS-NET-RSV TO OUT-NET-RSV
MOVE WS-RP-GR-RSV TO OUT-RP-GR-RSV
MOVE WS-RP-NET-RSV TO OUT-RP-NET-RSV
MOVE IN-SALN TO OUT-SALN
MOVE IN-CRNCL TO OUT-CRNCL
DISPLAY 'OUT-CRNCL' OUT-CRNCL
DISPLAY 'OUT-SALN ' OUT-SALN
DISPLAY 'OUT-GR-RSV ' OUT-GR-RSV
DISPLAY 'OUT-NET-RSV ' OUT-NET-RSV
DISPLAY 'OUT-RP-GR-RSV ' OUT-RP-GR-RSV
DISPLAY 'OUT-RP-NET-RSV' OUT-RP-NET-RSV
DISPLAY 'OUT-SALN ' OUT-SALN
PUT OUTFILEA
END-IF
IF SQLCODE NE 0 AND SQLCODE NE 100
DISPLAY 'CURSOR FETCH ERROR : ' SQLCODE
STOP
END-IF
END-IF
END-PROC.
CHECKSQL. PROC
IF SQLCODE NE 0 AND SQLCODE NE 100
DISPLAY '****************************************************'
DISPLAY 'SQL FUNCTION ' WS-SQL-FUNCTION
DISPLAY 'CURSOR ' WS-CURSOR-NAME
DISPLAY 'SQLCODE = ' SQLCODE
DISPLAY '****************************************************'
END-IF
END-PROC.
// NOTIFY=&SYSUID
//BR14 EXEC PGM=IEFBR14
//*DD1 DD DISP=(MOD,DELETE,DELETE),DSN=CCS.WIP04.CMRO1
//*************************************************************
//EZTSQL EXEC PGM=EZTPA00,REGION=4M
//*************************************************************
//STEPLIB DD DSN=SYSTEMS.LINKLIB,DISP=SHR
// DD DSN=DB2P.SDSNLOAD,DISP=SHR
//EZTVFM DD SPACE=(CYL,(20,20)),UNIT=SYSDA,DCB=BUFNO=40
//SYSPRINT DD SYSOUT=*
//SYSPUNCH DD DUMMY
//SYSOUT DD SYSOUT=*
//SYSUDUMP DD SYSOUT=Y
//SORTWK01 DD SPACE=(CYL,(5,50)),UNIT=SYSDA
//SORTWK02 DD SPACE=(CYL,(5,50)),UNIT=SYSDA
//INFILE DD DSN=CCS.WIP04.CMRO1,DISP=SHR
//OUTFILEA DD DSN=CCS.WIP04.CMRO2,DISP=(NEW,CATLG,DELETE),
// DCB=(RECFM=FB,LRECL=100,BLKSIZE=0),UNIT=SYSDA,
// DATACLAS=MB010
//SYSIN DD *
PARM BIND(DYNAMIC) SSID(DB2P) LIST(NOPARM)
FILE INFILE
IN-REC 1 080 A
IN-CRNCL 01 20 A
IN-SALN 22 08 A
FILE OUTFILEA
OUT-REC 1 800 A
OUT-CRNCL 01 20 A
OUT-SALN 22 08 A
OUT-GR-RSV 32 06 P 2
OUT-NET-RSV 40 06 P 2
OUT-RP-GR-RSV 48 06 P 2
OUT-RP-NET-RSV 56 06 P 2
*
WS-CRNCL W 20 A
WS-SALN W 08 A
WS-GR-RSV W 06 P 2
WS-NET-RSV W 06 P 2
WS-RP-GR-RSV W 06 P 2
WS-RP-NET-RSV W 06 P 2
WS-SQL-FUNCTION W 10 A
WS-CURSOR-NAME W 10 A
WS-END-CURSOR W 01 A
*
SQL DECLARE GETRSRV CURSOR FOR +
SELECT GROSS_RESV_AMT,NET_RESV_AMT,RLP_GROSS_RESV_AMT, +
RLP_NET_RESV_AMT +
FROM DB2P.DFCSP.FI_UNIT_HISTORY +
WHERE SALN = :IN-SALN +
AND CURRENT_IND = 'C' +
WITH UR
*
JOB INPUT NULL
*
MOVE SPACES TO WS-SALN
MOVE SPACES TO WS-CRNCL
MOVE ZEROES TO WS-GR-RSV
MOVE ZEROES TO WS-NET-RSV
MOVE ZEROES TO WS-RP-GR-RSV
MOVE ZEROES TO WS-RP-NET-RSV
GET INFILE
IF EOF INFILE
STOP
END-IF
DISPLAY 'IN-SALN' IN-SALN
PERFORM RESERVE-DETAILS
RESERVE-DETAILS. PROC
SQL OPEN GETRSRV
MOVE 'OPEN' TO WS-SQL-FUNCTION
MOVE 'GETRSRV' TO WS-CURSOR-NAME
PERFORM CHECKSQL
MOVE 'FETCH' TO WS-SQL-FUNCTION
MOVE 'GETRSRV' TO WS-CURSOR-NAME
DO UNTIL WS-END-CURSOR = 'Y'
PERFORM FETCH-RSRV
END-DO
SQL CLOSE GETRSRV
MOVE 'CLOSE' TO WS-SQL-FUNCTION
MOVE 'GETRSRV' TO WS-CURSOR-NAME
PERFORM CHECKSQL
END-PROC.
FETCH-RSRV. PROC
SQL FETCH GETRSRV +
INTO :WS-GR-RSV, +
:WS-NET-RSV, +
:WS-RP-GR-RSV, +
:WS-RP-NET-RSV
IF SQLCODE EQ 100
MOVE 'Y' TO WS-END-CURSOR
END-IF
IF SQLCODE = 0
MOVE WS-GR-RSV TO OUT-GR-RSV
MOVE WS-NET-RSV TO OUT-NET-RSV
MOVE WS-RP-GR-RSV TO OUT-RP-GR-RSV
MOVE WS-RP-NET-RSV TO OUT-RP-NET-RSV
MOVE IN-SALN TO OUT-SALN
MOVE IN-CRNCL TO OUT-CRNCL
DISPLAY 'OUT-CRNCL' OUT-CRNCL
DISPLAY 'OUT-SALN ' OUT-SALN
DISPLAY 'OUT-GR-RSV ' OUT-GR-RSV
DISPLAY 'OUT-NET-RSV ' OUT-NET-RSV
DISPLAY 'OUT-RP-GR-RSV ' OUT-RP-GR-RSV
DISPLAY 'OUT-RP-NET-RSV' OUT-RP-NET-RSV
DISPLAY 'OUT-SALN ' OUT-SALN
PUT OUTFILEA
END-IF
IF SQLCODE NE 0 AND SQLCODE NE 100
DISPLAY 'CURSOR FETCH ERROR : ' SQLCODE
STOP
END-IF
END-IF
END-PROC.
CHECKSQL. PROC
IF SQLCODE NE 0 AND SQLCODE NE 100
DISPLAY '****************************************************'
DISPLAY 'SQL FUNCTION ' WS-SQL-FUNCTION
DISPLAY 'CURSOR ' WS-CURSOR-NAME
DISPLAY 'SQLCODE = ' SQLCODE
DISPLAY '****************************************************'
END-IF
END-PROC.
I am receiving junk for the following fields in the o/p file:
OUT-GR-RSV
OUT-NET-RSV
OUT-RP-GR-RSV
OUT-RP-NET-RSV
The table fields; where I am moving these values (which are turning into junk) have the COBOL declaration: S9(9)V9(2) USAGE COMP-3
Please let me know if you have across this issue & let me know if your require any more info on this.
Thanks a lot !!!!!!!!