Joined: 17 Dec 2015 Posts: 3 Location: South Africa
I went through the forum but could't find an answer to my question therefore this post. I am trying to convert an Assembler macro copybook to Cobol. The ASM copyboo is below:
Code:
MACRO
*
* This DG 142 maps a BSAM file named CKPTDS *
* *
* Size: 4100 *
* *
***********************************************************************
SPACE 2
P49$CSP DSECT
CS$AC DS HL2 ACTION
CS$RSLT DS HL2 RESULT
CS$HEAD DS 0F HEADER CONTROL FIELDS
***********************************************************************
* Header is in first record of CKPTDS only *
***********************************************************************
CS$JNME DS CL8 JOBNAME
CS$JSTP DS CL16 JOB STEPNAME/PROC STEP NAME
CS$XACT DS 0CL12 TRANSACTION ID
CS$COID DS HL2 COMPANY
CS$APPL DS HL2 APPLICATION
CS$FUNC DS HL2 FUNCTION
CS$DATE DS PL4 VALUE FROM STCK INSTRUCTION
CS$TIME DS PL4
CS$CKPID DS CL8 DLI CHECKPOINT ID
CS$RSTR DS CL7 IF = 'RESTART ', THIS REC VALID
CS$INIT DS X X'FF' - CHECKPOINT ACT. ISSUED BY PEM
CS$SACT DS FL4 IF CKPTING SORT, THE SORT OUT ACT ID
CS$SCNT DS FL4 SORT RECORD COUNT
SPACE
CS$NF DS HL2 NUMBER FILE ENTRIES, THIS RECORD
CS$NDG DS HL2 NUMBER DATA GROUP ENTRIES, THIS REC
CS$NUMR DS HL2 TOTAL BLOCKS/LOGICAL REC THIS CKPTDS
CS$LHEAD EQU *-CS$AC LENGTH OF HEADER INFO
***********************************************************************
* File entries are found in first record of CKPTDS only *
***********************************************************************
CS$ENTS DS 0C
CS$FILES DS 0C FILE ENTRIES
CS$FIL DS CL8 FILE ID, THIS ENTRY
CS$NOTE1 DS FL4 NOTE MACRO RESULTS, LAST IO
CS$NOTE2 DS HL2 RELATIVE VOLUME NUMBER
CS$NOTE3 DS HL2 RELATIVE LOG REC, THIS BLOCK
CS$FLEN EQU *-CS$FILES LENGTH, ONE FILE ENTRY
***********************************************************************
* Data group entries start after file entries in first record. *
* All other CKPTDS records are just DG entries. *
***********************************************************************
ORG CS$AC USE 0 DISPLACEMENT
CS$DGS DS 0C
CS$DGID DS FL4 DATA GROUP ID
CS$DGLEN DS HL2 DATA GROUP LENGTH
CS$DGD DS 0C CS$DGLEN BYTES OF DATA
SPACE 2
MEND
While my attempted conversion yielded the below. Many fields are viewable but date and time not so. The occurrences at the bottom of the layout also is messed up to some extent. Any help would be sincerely appreciated.
Joined: 30 Nov 2013 Posts: 917 Location: The Universe
Well, I see several issues.
Your C$DATE and C$TIME fields are not the result of a STCK instruction. STCK stores a 64 bit binary value, so neither data area is packed decimal and C$DATE is not going to be a date. More likely C$DATE is sort of packed decimal in the form (in hex) 0cyydddF.
If you share a hexadecimal dump of C$TIME we can make an informed guess as to its meaning. One likely possibility is 8 packed decimal digits of the form hhmmssss. with no packed decimal sign. Another possibility is a binary time of day in 1/100th second units, with a maximum value of 0083D600.
Joined: 30 Nov 2013 Posts: 917 Location: The Universe
Well, I concede that, together, they appear to be the result of a STCK instruction. I don't know any practical method available in Cobol to transform the value to a human usable date and time. Assembler programmers usually transform the value to the time of day clock equivalent of the local date and time as many shops store the time of day clock using GMT as a base, and then use the STCKTOD macro to create a more "normal" form of the date and time.
The first transformation is performed using two system provided values. These are usually fixed and change only when the local time changes between summer time and winter time. The STCKTOD macro is described in z/OS MVS Assm Services Reference for your z/OS release.
Running your TOD time without converting it to my local time through STCKCONV using TIMETYPE=DEC,DATETYPE=YYYYMMDD yields 08230160 30330000 20170926 00000000. The 20170926 is the date in 8 packed decimal digits, and 08230160 is the time of day, again, in 8 packed decimal digits. The 3033 after the time of day is additional precision, again in packed decimal digits. The entire program is
Code:
CNVTTOD CSECT
USING *,12
SAVE (14,12)
LR 12,15
STCKCONV STCKVAL=TOD,CONVVAL=RESULT, ->
TIMETYPE=DEC,DATETYPE=YYYYMMDD
UNPK WORD1(9),RESULT+00(5)
UNPK WORD2(9),RESULT+04(5)
UNPK WORD3(9),RESULT+08(5)
UNPK WORD4(9),RESULT+12(5)
NC WORD1,=8X'0F'
NC WORD2,=8X'0F'
NC WORD3,=8X'0F'
NC WORD4,=8X'0F'
TR WORD1,=C'0123456789ABCDEF'
TR WORD2,=C'0123456789ABCDEF'
TR WORD3,=C'0123456789ABCDEF'
TR WORD4,=C'0123456789ABCDEF'
MVI WORD1+L'WORD1,C' '
MVI WORD2+L'WORD2,C' '
MVI WORD3+L'WORD3,C' '
LA 0,L'MSG
LA 1,MSG
TPUT (1),(0),R
RETURN (14,12),RC=0
TOD DC X'D3323AAEA76D9B06'
RESULT DC XL16'0'
MSG DC 0C'00000000 00000000 00000000 00000000'
WORD1 DC C'00000000',C' '
WORD2 DC C'00000000',C' '
WORD3 DC C'00000000',C' '
WORD4 DC C'00000000',C' '
DC 0D'0'
LTORG ,
END CNVTTOD
as usual to understand an assembler csect
it is necessary to look also at the programs using it
unless needed for aligment and initialisations ( DC ) any <type> with the proper length will not make any difference to the program using it
anyway the dsect is murky ...
Code:
CS$XACT DS 0CL12 TRANSACTION ID
CS$COID DS HL2 COMPANY
CS$APPL DS HL2 APPLICATION
CS$FUNC DS HL2 FUNCTION
CS$DATE DS PL4 VALUE FROM STCK INSTRUCTION
CS$TIME DS PL4