The code is as follows.
*****************************************
* Write data that is to persist *
*****************************************
SYSSTATE ARCHLVL=2 *
* Previous code would have saved data into area the buff *
* and saved the number of bytes to write in thelen *
* HZSPWRIT BUFFER=thebuff,DATALEN=thelen, *
* RETCODE=LRETCODE,RSNCODE=LRSNCODE, *
* MF=(E,PWRITL) *
*
* Place code to check return/reason codes here *
*
* LTORG ,
* HZSZCONS , Return Code information
* DYNAREA DSECT
* thelen DS F Length of output buffer
* LRETCODE DS F
* LRSNCODE DS F
* HZSPWRIT MF=(L,PWRITL),PLISTVER=MAX
* DS 0D
* DS 8192X Output buffer