Hi ,

I have been facing an issue where I am getting 16 position as garbage value

When we are trying the see decrypted value of a field then Decryption API
returning the garbage value at 16th position character and rest of
decrypted character value's are correct .

Decrypted value>>>122222222222222u222


below code returns the Decrypted value as below when data of field is
greater than 15 character. It has garbage value at 16th position which is
wrong.
Decrypted value>>>122222222222222u222

value should be return as: 1222222222222222222 but API return garbage vaule
at 16th position VALUE returns as --122222222222222u222

Code details-
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.

SOURCE-COMPUTER. IBM-AS400.
OBJECT-COMPUTER. IBM-AS400.

SPECIAL-NAMES. I-O-FEEDBACK IS I-O-F
LOCAL-DATA IS LDA-AREA.
DATA DIVISION.
FILE SECTION.

WORKING-STORAGE SECTION.

90798A EXEC SQL
90798A SET OPTION COMMIT = *NONE
90798A END-EXEC.
90798A
90798A EXEC SQL
90798A SET OPTION DATFMT = *ISO
90798A END-EXEC.
90798A
90798A EXEC SQL
90798A SET OPTION TIMFMT = *ISO
90798A END-EXEC.
90798A
EXEC SQL
INCLUDE SQLCA
END-EXEC.

************************************************
* Declaring SQL host variables
************************************************
EXEC SQL BEGIN DECLARE SECTION END-EXEC.

COPY CPYSQLRET.
COPY CPYMSGWS03.
COPY CPYERRWS04.
01 SYSP01REC.
COPY DDS-ALL-FORMATS OF BASSYSP01.

01 WS-RETURN-CODE PIC X(07) VALUE SPACES.
01 WS-FIELD-COUNT PIC 9(02) COMP-3 VALUE 1.
01 WS-MASKTYPE PIC X(30).
01 WS-MASK-CHAR PIC X(01) .
01 WS-MASK-CHAR-TYPE PIC X(01) .
01 WS-COUNT PIC 9(02) COMP-3 VALUE 1.
01 WS-MASK-CHAR-COUNT PIC 9(02) VALUE ZEROES.
*
01 WS-KEYSTRING PIC X(300) VALUE SPACES.
01 WS-KEYSTRING-FINAL PIC X(320) VALUE SPACES.
01 WS-ENCDATA PIC X(1024) VALUE SPACES.
01 FIELD-INDEX PIC 9(1) VALUE ZEROS.
01 WS-LENGTH PIC 9(02) COMP-3 VALUE ZEROES.
01 IN-FILE-NAME PIC X(10) VALUE SPACES.
01 IN-FIELD-NAME PIC X(10) VALUE SPACES.
01 WS-KEYVALUE PIC X(16) VALUE SPACES.
01 WS-KEY-LENGTHS.
05 WS-KF1LEN PIC S9(05) VALUE ZEROES.
05 WS-KF2LEN PIC S9(05) VALUE ZEROES.
05 WS-KF3LEN PIC S9(05) VALUE ZEROES.
05 WS-KF4LEN PIC S9(05) VALUE ZEROES.
05 WS-KF5LEN PIC S9(05) VALUE ZEROES.
05 WS-KF6LEN PIC S9(05) VALUE ZEROES.
05 WS-KF7LEN PIC S9(05) VALUE ZEROES.
05 WS-KF8LEN PIC S9(05) VALUE ZEROES.
05 WS-KF9LEN PIC S9(05) VALUE ZEROES.
05 WS-KF10LEN PIC S9(05) VALUE ZEROES.
05 WS-KF11LEN PIC S9(05) VALUE ZEROES.
05 WS-KF12LEN PIC S9(05) VALUE ZEROES.
05 WS-KF13LEN PIC S9(05) VALUE ZEROES.
05 WS-KF14LEN PIC S9(05) VALUE ZEROES.
05 WS-KF15LEN PIC S9(05) VALUE ZEROES.

* Parameter for the API - QC3DECDT
01 IN-CIPHER-DATA PIC X(1024).
01 OUT-DECRYPTED-VALUE PIC X(36) VALUE SPACES.
01 LENGTH-CIPHER-DATA PIC 9(8) USAGE BINARY VALUE 32.
01 ALGO.
05 BLOCK-ALGO PIC 9(8) USAGE BINARY VALUE 22.
05 BLOCK-LENGTH PIC 9(8) USAGE BINARY VALUE 16.
05 MOD PIC X(1) VALUE '1'.
05 PAD-OPTION PIC X(1) VALUE '0'.
05 PAD-CHARACTER PIC X(1) VALUE '0'.
05 MAC-LENGTH PIC 9(8) USAGE BINARY VALUE ZEROS.
05 EFF-KEY-SIZE PIC 9(8) USAGE BINARY VALUE 0.
01 ALGO-FMT-NAME PIC X(8) VALUE 'ALGD0200'.
01 KEYD.
05 KEY-TYPE PIC 9(8) USAGE BINARY VALUE 22.
05 KEY-LENGTH PIC 9(8) USAGE BINARY VALUE 16.
05 KEY-FORMAT PIC X(1) VALUE '0'.
05 KEY-STRING PIC X(16).
01 KEYD-FMT-NAME PIC X(8) VALUE 'KEYD0200'.
01 CRYPTO-SP PIC X(1) VALUE '0'.
01 CRPTO-DEVICE PIC X(10) VALUE SPACES.
01 WS-CLEAR-DATA PIC X(36).
01 LOA-DECRYPTED-VALUE PIC 9(8) USAGE BINARY VALUE 1024.
01 LENGTH-DECRYPTED-VALUE PIC 9(8) USAGE BINARY.
01 ERR.
05 BYTES-PRVD PIC 9(8) USAGE BINARY VALUE 64.
05 BYTES-AVAIL PIC 9(8) USAGE BINARY.
05 EXC-ID PIC X(7).
05 EXC-DATA PIC X(20).

* Cursor for fetching records from BASSYSP01
EXEC SQL
DECLARE BASSYSP01_C1 CURSOR FOR
SELECT ENCDATA
FROM BASSYSP01
WHERE KEYSTRING = :WS-KEYSTRING-FINAL
END-EXEC.

EXEC SQL END DECLARE SECTION END-EXEC.

01 ARE-THERE-MORE-RECORDS PIC X(1) VALUE 'Y'.
88 NO-MORE-RECORDS VALUE 'N'.
88 ERROR-ON-RECORDS VALUE 'X'.

01 MASK-SEARCH-SW PIC X(1) VALUE 'N'.
88 MASK-SEARCH-END VALUE 'Y'.
88 MASK-SEARCH-NOT-END VALUE 'N'.

01 DECRYPTION-SWITCH-SW PIC X(1) VALUE 'N'.
88 DECRYPTION-REQUIRED VALUE 'Y'.
88 DECRYPTION-NOT-REQUIRED VALUE 'N'.

01 DECRYPTION-SWITCH-NUM PIC X(1) VALUE 'N'.
88 DECRYPTION-NUM-REQUIRED VALUE 'Y'.
88 DECRYPTION-NUM-NOT-REQUIRED VALUE 'N'.

LINKAGE SECTION.

COPY CPYSECDEC.
COPY CPYERRLIST.

PROCEDURE DIVISION USING
SEC-DEC-RECORD
ERROR-LIST-RECORD.

*****************************************************************
* M A I N *
*****************************************************************

0000-MAIN-SECTION.

PERFORM 1000-INIT-PARA
THRU 1000-EXIT.

PERFORM 2000-PROCESS-PARA
THRU 2000-EXIT
VARYING WS-FIELD-COUNT
FROM 1 BY 1
UNTIL WS-FIELD-COUNT > 10
OR WS-FIELD-NAME (WS-FIELD-COUNT) = SPACES.

PERFORM 9000-OVER-PARA
THRU 9000-EXIT.
/
*****************************************************************
* Housekeeping Routine *
*****************************************************************

1000-INIT-PARA.

* Set up error handling work area.
INITIALIZE WS04-ERROR-DETAIL-AREA.

SET NO-ERRORS TO TRUE.
MOVE 'BASSYS0013' TO WS04-HOLD-PROG-NAME.
MOVE 'POL' TO WS04-HOLD-KEY-TYPE.
STRING ' ' DELIMITED BY SIZE
';' DELIMITED BY SIZE
INTO WS04-HOLD-KEY-STRING
END-STRING.

MOVE SPACES TO WS-KEYSTRING
WS-KEYSTRING-FINAL
IN-CIPHER-DATA
CRPTO-DEVICE
WS-MASK-CHAR-COUNT
OUT-DECRYPTED-VALUE.
COMPUTE WS-FIELD-COUNT = 1.

1000-EXIT.
EXIT.
/
2000-PROCESS-PARA.

IF UNAUTHORIZED(WS-FIELD-COUNT)
MOVE WS-CIPHER-DATA(WS-FIELD-COUNT) TO
WS-DECRYPTED-VALUE(WS-FIELD-COUNT)
GO TO 2000-EXIT
END-IF.

MOVE WS-FILE-NAME TO IN-FILE-NAME.
MOVE WS-CIPHER-DATA(WS-FIELD-COUNT)
TO IN-CIPHER-DATA.
MOVE WS-FIELD-NAME(WS-FIELD-COUNT)
TO IN-FIELD-NAME.
INITIALIZE WS-MASK-CHAR-COUNT.

PERFORM 2005-GET-MASK-CHAR
THRU 2005-EXIT.

IF DECRYPTION-REQUIRED
PERFORM 2010-KEY-BUILD
THRU 2010-EXIT
PERFORM 2100-CURSOR-PARA-TRIGGER
THRU 2100-EXIT
END-IF.

2000-EXIT.
EXIT.
/
*****************************************************************
* Get Masking Character from Mask Format Table TBSYS006
*****************************************************************
2005-GET-MASK-CHAR.

EXEC SQL
SELECT MASKTYPE
INTO : WS-MASKTYPE
FROM TBSYS002
WHERE MASKNAME IN (
SELECT MASK
FROM TBSYS005
WHERE FILENAME = :IN-FILE-NAME
AND
FIELDNAME = :IN-FIELD-NAME
)
END-EXEC.

IF SQLCODE = SQL-IO-OK
CONTINUE
90798A ELSE
90798A IF SQLCODE = SQL-NO-RECORD
90798A SET DECRYPTION-NOT-REQUIRED TO TRUE
ELSE
PERFORM 2005E-GATHER-ERROR-EVENT-DATA
THRU 2005E-EXIT
90798A END-IF
90798A MOVE IN-CIPHER-DATA TO
90798A WS-DECRYPTED-VALUE(WS-FIELD-COUNT)
GO TO 2005-EXIT
END-IF.

* Calculate the length of the Mask Type

PERFORM 2006-GET-LENGTH-MASK
THRU 2006-EXIT.

SET MASK-SEARCH-NOT-END TO TRUE.

PERFORM 2007-MASK-SEARCH
THRU 2007-EXIT
VARYING WS-COUNT FROM 1 BY 1
UNTIL WS-COUNT > WS-LENGTH
OR MASK-SEARCH-END.

* Seting up the Decryption switch

IF WS-MASK-CHAR IS NOT NUMERIC
MOVE 'A' TO WS-MASK-CHAR-TYPE
ELSE
MOVE 'N' TO WS-MASK-CHAR-TYPE
END-IF.

IF WS-MASK-CHAR-TYPE = 'A'
INSPECT IN-CIPHER-DATA
TALLYING WS-MASK-CHAR-COUNT FOR ALL WS-MASK-CHAR
ELSE
SET DECRYPTION-NUM-REQUIRED TO TRUE
PERFORM 2008-SETUP-SWITCH-PARA
THRU 2008-EXIT
VARYING WS-COUNT FROM 1 BY 1
UNTIL WS-COUNT > WS-LENGTH
OR DECRYPTION-NUM-NOT-REQUIRED

IF DECRYPTION-NUM-REQUIRED
MOVE 1 TO WS-MASK-CHAR-COUNT
END-IF
END-IF.

IF WS-MASK-CHAR-COUNT NOT = 0
SET DECRYPTION-REQUIRED TO TRUE
ELSE
SET DECRYPTION-NOT-REQUIRED TO TRUE
MOVE IN-CIPHER-DATA TO
WS-DECRYPTED-VALUE(WS-FIELD-COUNT)
END-IF.

2005-EXIT.
EXIT.
/
2005E-GATHER-ERROR-EVENT-DATA.

INITIALIZE WS04-ERROR-DETAIL-DATA-AREA.

SET SQL-ERROR TO TRUE.
MOVE SPACES TO
WS04-ERR-SQL-DTASTG-DTA.
STRING IN-FILE-NAME DELIMITED BY SPACE
';' DELIMITED BY SIZE
IN-FIELD-NAME DELIMITED BY SPACE
';' DELIMITED BY SIZE
INTO WS04-ERR-SQL-DTASTG-DTA
END-STRING.
MOVE SQLCODE TO WS04-ERR-ERROR-CODE.
MOVE '2005-GET-MASK-CHAR' TO WS04-ERR-PARA-NAME.
MOVE 'TBSYS002' TO WS04-ERR-FILE-NAME.
MOVE 'H' TO WS04-ERR-ERROR-TYP.

PERFORM R200-ERROR-HANDLING-ROUTINE
THRU R200-EXIT.

2005E-EXIT.
EXIT.

2006-GET-LENGTH-MASK.

PERFORM 2006-EXIT VARYING WS-LENGTH
FROM LENGTH OF WS-MASKTYPE
BY -1
UNTIL WS-MASKTYPE(WS-LENGTH:1) NOT EQUAL TO SPACE.

2006-EXIT.
EXIT.

2007-MASK-SEARCH.

IF WS-MASKTYPE(WS-COUNT:1) NOT EQUAL '-'
MOVE WS-MASKTYPE(WS-COUNT:1) TO WS-MASK-CHAR
SET MASK-SEARCH-END TO TRUE
END-IF.

2007-EXIT.
EXIT.

2008-SETUP-SWITCH-PARA.

IF WS-MASKTYPE(WS-COUNT:1) = WS-MASK-CHAR
IF IN-CIPHER-DATA(WS-COUNT:1) NOT = WS-MASK-CHAR
SET DECRYPTION-NUM-NOT-REQUIRED
TO TRUE
ELSE
SET DECRYPTION-NUM-REQUIRED
TO TRUE
END-IF
END-IF.

2008-EXIT.
EXIT.
/
*****************************************************************
* KEY BUILDING PARA
*****************************************************************

2010-KEY-BUILD.

EXEC SQL
SELECT KF1LEN,
KF2LEN,
KF3LEN,
KF4LEN,
KF5LEN,
KF6LEN,
KF7LEN,
KF8LEN,
KF9LEN,
KF10LEN,
KF11LEN,
KF12LEN,
KF13LEN,
KF14LEN,
KF15LEN
INTO
:WS-KF1LEN
,:WS-KF2LEN
,:WS-KF3LEN
,:WS-KF4LEN
,:WS-KF5LEN
,:WS-KF6LEN
,:WS-KF7LEN
,:WS-KF8LEN
,:WS-KF9LEN
,:WS-KF10LEN
,:WS-KF11LEN
,:WS-KF12LEN
,:WS-KF13LEN
,:WS-KF14LEN
,:WS-KF15LEN
FROM TBSYS005
WHERE FILENAME = :IN-FILE-NAME
AND FIELDNAME = :IN-FIELD-NAME
END-EXEC.

IF SQLCODE = SQL-IO-OK
CONTINUE
ELSE
PERFORM 2010E-GATHER-ERROR-EVENT-DATA
THRU 2010E-EXIT
GO TO 2010-EXIT
END-IF.

IF WS-KF1LEN NOT = 0
MOVE WS-KEY-FIELD-1(1:WS-KF1LEN)
TO WS-KEYSTRING(1:WS-KF1LEN)
END-IF.

IF WS-KF2LEN NOT = 0
ADD 1 TO WS-KF1LEN
MOVE WS-KEY-FIELD-2(1:WS-KF2LEN)
TO WS-KEYSTRING(WS-KF1LEN:WS-KF2LEN)
END-IF.

IF WS-KF3LEN NOT = 0
ADD WS-KF1LEN TO WS-KF2LEN
MOVE WS-KEY-FIELD-3(1:WS-KF3LEN)
TO WS-KEYSTRING(WS-KF2LEN:WS-KF3LEN)
END-IF.

IF WS-KF4LEN NOT = 0
ADD WS-KF2LEN TO WS-KF3LEN
MOVE WS-KEY-FIELD-4(1:WS-KF4LEN)
TO WS-KEYSTRING(WS-KF3LEN:WS-KF4LEN)
END-IF.

IF WS-KF5LEN NOT = 0
ADD WS-KF3LEN TO WS-KF4LEN
MOVE WS-KEY-FIELD-5(1:WS-KF5LEN)
TO WS-KEYSTRING(WS-KF4LEN:WS-KF5LEN)
END-IF.

IF WS-KF6LEN NOT = 0
ADD WS-KF4LEN TO WS-KF5LEN
MOVE WS-KEY-FIELD-6(1:WS-KF6LEN)
TO WS-KEYSTRING(WS-KF5LEN:WS-KF6LEN)
END-IF.

IF WS-KF7LEN NOT = 0
ADD WS-KF5LEN TO WS-KF6LEN
MOVE WS-KEY-FIELD-7(1:WS-KF7LEN)
TO WS-KEYSTRING(WS-KF6LEN:WS-KF7LEN)
END-IF.

IF WS-KF8LEN NOT = 0
ADD WS-KF6LEN TO WS-KF7LEN
MOVE WS-KEY-FIELD-8(1:WS-KF8LEN)
TO WS-KEYSTRING(WS-KF7LEN:WS-KF8LEN)
END-IF.

IF WS-KF9LEN NOT = 0
ADD WS-KF7LEN TO WS-KF8LEN
MOVE WS-KEY-FIELD-9(1:WS-KF9LEN)
TO WS-KEYSTRING(WS-KF8LEN:WS-KF9LEN)
END-IF.

IF WS-KF10LEN NOT = 0
ADD WS-KF8LEN TO WS-KF9LEN
MOVE WS-KEY-FIELD-10(1:WS-KF10LEN)
TO WS-KEYSTRING(WS-KF9LEN:WS-KF10LEN)
END-IF.

IF WS-KF11LEN NOT = 0
ADD WS-KF9LEN TO WS-KF10LEN
MOVE WS-KEY-FIELD-11(1:WS-KF11LEN)
TO WS-KEYSTRING(WS-KF10LEN:WS-KF11LEN)
END-IF.

IF WS-KF12LEN NOT = 0
ADD WS-KF10LEN TO WS-KF11LEN
MOVE WS-KEY-FIELD-12(1:WS-KF12LEN)
TO WS-KEYSTRING(WS-KF11LEN:WS-KF12LEN)
END-IF.

IF WS-KF13LEN NOT = 0
ADD WS-KF11LEN TO WS-KF12LEN
MOVE WS-KEY-FIELD-13(1:WS-KF13LEN)
TO WS-KEYSTRING(WS-KF12LEN:WS-KF13LEN)
END-IF.

IF WS-KF14LEN NOT = 0
ADD WS-KF12LEN TO WS-KF13LEN
MOVE WS-KEY-FIELD-14(1:WS-KF14LEN)
TO WS-KEYSTRING(WS-KF13LEN:WS-KF14LEN)
END-IF.

IF WS-KF15LEN NOT = 0
ADD WS-KF13LEN TO WS-KF14LEN
MOVE WS-KEY-FIELD-15(1:WS-KF15LEN)
TO WS-KEYSTRING(WS-KF14LEN:WS-KF15LEN)
END-IF.

STRING IN-FILE-NAME DELIMITED BY SIZE
IN-FIELD-NAME DELIMITED BY SIZE
WS-KEYSTRING DELIMITED BY SIZE
INTO WS-KEYSTRING-FINAL.

2010-EXIT.
EXIT.
/
2010E-GATHER-ERROR-EVENT-DATA.

INITIALIZE WS04-ERROR-DETAIL-DATA-AREA.

SET SQL-ERROR TO TRUE.
MOVE SPACES TO
WS04-ERR-SQL-DTASTG-DTA.
STRING IN-FILE-NAME DELIMITED BY SPACE
';' DELIMITED BY SIZE
IN-FIELD-NAME DELIMITED BY SPACE
';' DELIMITED BY SIZE
INTO WS04-ERR-SQL-DTASTG-DTA
END-STRING.
MOVE SQLCODE TO WS04-ERR-ERROR-CODE.
MOVE '2010-KEY-BUILD' TO WS04-ERR-PARA-NAME.
MOVE 'TBSYS005' TO WS04-ERR-FILE-NAME.
MOVE 'H' TO WS04-ERR-ERROR-TYP.

PERFORM R200-ERROR-HANDLING-ROUTINE
THRU R200-EXIT.

2010E-EXIT.
EXIT.
/
*****************************************************************
* Processing Cursor paragraph *
*****************************************************************

2100-CURSOR-PARA-TRIGGER.

PERFORM 2110-OPEN-CURSOR-PARA
THRU 2110-EXIT.

PERFORM 2120-FETCH-BASSYSP01-RCDS
THRU 2120-EXIT
UNTIL NO-MORE-RECORDS.

PERFORM 2130-CLOSE-CURSOR-PARA
THRU 2130-EXIT.

2100-EXIT.
EXIT.
/
*****************************************************************
2110-OPEN-CURSOR-PARA.
*****************************************************************

MOVE 'Y' TO ARE-THERE-MORE-RECORDS.

EXEC SQL
OPEN BASSYSP01_C1
END-EXEC.

IF (SQLCODE = SQL-IO-OK)
CONTINUE
ELSE
IF SQLCODE = SQL-CURSOR-ALREADY-OPEN
PERFORM 2130-CLOSE-CURSOR-PARA
THRU 2130-EXIT
PERFORM 2110-OPEN-CURSOR-PARA
THRU 2110-EXIT
ELSE
PERFORM 2110E-GATHER-ERROR-EVENT-DATA
THRU 2110E-EXIT
GO TO 2110-EXIT
END-IF.

2110-EXIT.
EXIT.
/
*****************************************************************
2110E-GATHER-ERROR-EVENT-DATA.

INITIALIZE WS04-ERROR-DETAIL-DATA-AREA.
SET SQL-ERROR TO TRUE.
MOVE SQLCODE TO WS04-ERR-ERROR-CODE.
MOVE 'BASSYSP01' TO WS04-ERR-FILE-NAME.
MOVE '2110-OPEN-CURSOR-PARA' TO WS04-ERR-PARA-NAME.
MOVE 'H' TO WS04-ERR-ERROR-TYP

PERFORM R200-ERROR-HANDLING-ROUTINE
THRU R200-EXIT.
2110E-EXIT.
EXIT.
/
*****************************************************************
* If record exist then Identifying field name to be encrypted *
*****************************************************************

2120-FETCH-BASSYSP01-RCDS.

* Fetch records from BASSYSP01
EXEC SQL
FETCH BASSYSP01_C1 INTO :WS-ENCDATA
END-EXEC.

IF (SQLCODE = SQL-IO-OK)
PERFORM 2200-DECRYPT-DATA THRU 2200-EXIT
ELSE
IF SQLCODE = SQL-NO-RECORD
CONTINUE
ELSE
MOVE 'H' TO WS04-ERR-ERROR-TYP
PERFORM 2120E-GATHER-ERROR-EVENT-DATA
THRU 2120E-EXIT
END-IF
MOVE 'N' TO ARE-THERE-MORE-RECORDS
GO TO 2120-EXIT
END-IF.

2120-EXIT.
EXIT.
/
*****************************************************************

2120E-GATHER-ERROR-EVENT-DATA.

SET SQL-ERROR TO TRUE.
MOVE 'BASSYSP01' TO WS04-ERR-FILE-NAME.
MOVE '2120-FETCH-BASSYSP01-RCDS' TO WS04-ERR-PARA-NAME.

PERFORM R200-ERROR-HANDLING-ROUTINE
THRU R200-EXIT.

2120E-EXIT.
EXIT.
/
*****************************************************************
* *
*****************************************************************

2130-CLOSE-CURSOR-PARA.

EXEC SQL
CLOSE BASSYSP01_C1
END-EXEC.

IF SQLCODE = SQL-IO-OK
CONTINUE
ELSE
MOVE 'H' TO WS04-ERR-ERROR-TYP
PERFORM 2130E-GATHER-ERROR-EVENT-DATA
THRU 2130E-EXIT
END-IF.

2130-EXIT.
EXIT.
/
*****************************************************************
2130E-GATHER-ERROR-EVENT-DATA.

SET SQL-ERROR TO TRUE.
MOVE 'BASYSYP01' TO WS04-ERR-FILE-NAME.
MOVE '2130-CLOSE-CURSOR-PARA' TO WS04-ERR-PARA-NAME.

PERFORM R200-ERROR-HANDLING-ROUTINE
THRU R200-EXIT.
2130E-EXIT.
EXIT.
/
*****************************************************************
* Preparing data to be encrypted and key values. *
*****************************************************************
2200-DECRYPT-DATA.

MOVE WS-ENCDATA TO IN-CIPHER-DATA

EXEC SQL

SELECT KEYVALUE
INTO :WS-KEYVALUE
FROM TBSYS006
WHERE
KEYLABEL = :IN-FILE-NAME

END-EXEC.

IF SQLCODE = SQL-IO-OK
CONTINUE
ELSE
PERFORM 2200E-GATHER-ERROR-EVENT-DATA
THRU 2200E-EXIT
GO TO 2200-EXIT
END-IF.
MOVE WS-KEYVALUE TO KEY-STRING OF KEYD.

CALL 'QC3DECDT' USING IN-CIPHER-DATA
LENGTH-CIPHER-DATA
ALGO
ALGO-FMT-NAME
KEYD
KEYD-FMT-NAME
CRYPTO-SP
CRPTO-DEVICE
OUT-DECRYPTED-VALUE
LOA-DECRYPTED-VALUE
LENGTH-DECRYPTED-VALUE
ERR.

MOVE OUT-DECRYPTED-VALUE TO
WS-DECRYPTED-VALUE(WS-FIELD-COUNT).

2200-EXIT.
EXIT.
/
2200E-GATHER-ERROR-EVENT-DATA.

INITIALIZE WS04-ERROR-DETAIL-DATA-AREA.

SET SQL-ERROR TO TRUE.
MOVE SPACES TO
WS04-ERR-SQL-DTASTG-DTA.
STRING IN-FILE-NAME DELIMITED BY SPACE
';' DELIMITED BY SIZE
IN-FIELD-NAME DELIMITED BY SPACE
';' DELIMITED BY SIZE
INTO WS04-ERR-SQL-DTASTG-DTA
END-STRING.
MOVE SQLCODE TO WS04-ERR-ERROR-CODE.
MOVE '2200-DECRYPT-DATA' TO WS04-ERR-PARA-NAME.
MOVE 'TBSYS006' TO WS04-ERR-FILE-NAME.
MOVE 'H' TO WS04-ERR-ERROR-TYP.

PERFORM R200-ERROR-HANDLING-ROUTINE
THRU R200-EXIT.

2200E-EXIT.
EXIT.
/
*****************************************************************
* End of processing routine. *
*****************************************************************
9000-OVER-PARA.

GOBACK.

9000-EXIT.
EXIT.
/
*---------------------------------------------------------------*
*Copy book for SQL Error Routine.
*---------------------------------------------------------------*
COPY CPYMSGRRTN.
COPY CPYERRHRTN.
*****************************************************************


Any inputs/insights will really help us.

Regards,
Anil Kumar

As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2021 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.