Get RECFM and Record Length from unknown file V,VB,F,FB,U



High Level Assembler(HLASM) for MVS & VM & VSE

Get RECFM and Record Length from unknown file V,VB,F,FB,U

Postby rogelinm » Wed Sep 06, 2017 1:41 am

Hi folks.

I have an assembly module that reads any kind of file (V,VB,F,FB,U) and returns it to a COBOL caller.
To process the record inside my COBOL program I need some information about the record obtained inside my Assembly program.
Anyone else know an easy way to get it when I execute my GET macro.

here is my DCB:
*                                                                      
         DS    0F                    
HARQVO   DS    F                      
ARQORIG  DCB   DDNAME=ARQORIG,DSORG=PS,MACRF=GM,DCBE=ARQORIGE          
ARQORIGE DCBE  EODAD=CLOSARQ,RMODE31=NONE                              
         READ  MODELDECB,SF,,,'S',MF=L                                
READLEN  EQU   *-MODELDECB                                            
LLARQORIG EQU  *-ARQORIG                  
*                                                                      
         LTORG                                                        
         SPACE 1 


I'm trying to use the RDJFCB macro after Opening file:

          L     R6,HARQVO            
          OPEN  ((R6),INPUT),MODE=31  
          LTR   R15,R15              
          BNZ   ERROPEN              
                           
          RDJFCB (ARQORIG,INPUT)             > S0C4 HAPPENS HERE
 *                                                      
          LH    R5,JFCLRECL             > LOAD LRECL FROM RDJFCB
          CVD   R5,WSPACK                              
          UNPK  WSZON8,WSPACK                          
          OI    WSZON8+7,X'F0'                          
 *                                                      


But i'm getting S0C4:
IEC190I USER01,TSO@PROC.TSO@PROC,ARQORIG INVALID DCBE: DCBE ID IS NOT 'DCBE'


I can provide more information if needed.
Any help is apreciated...

Thanks in advance.
rogelinm
 
Posts: 5
Joined: Tue Sep 05, 2017 11:14 pm
Has thanked: 2 times
Been thanked: 0 time

Re: Get RECFM and Record Length from unknown file V,VB,F,FB,

Postby steve-myers » Wed Sep 06, 2017 4:53 am

You have at least three problems here.
  1. The DCB does not specify the address of an exit list that has an entry that points to the storage area for the JFCB,
    ADCB     DCB   DCBE=*-*,DSORG=PS,MACRF=R,...,EXLST=*-*
    AEXLST   DC    0A(0),AL1(X'80'+7),AL3(AJFCB)
    AJFCB    DC    0XL176'0'
             IEFJFCBN ,
    ADCBE    DCBE  ...

    In a reenterable program, the exit list and JFCB must be in working storage, so the address of the exit list must be stored in the DCB, and the exit list must be stored in the real DCB, as opposed to the model DCB.
             LA    0,AJFCB
             ST    0,AEXLST
             MVI   AEXLST,X'80'+7
             LA    0,AEXLST
             STCM  0,B'0111',((DCBEXLST-IHADCB)+1)+ADCB
  2. As hinted at in my little example, a DCBE has a very precise format. Like a DCB, in a reenterable program, the model DCBE must be copied to your work area and its actual address must be stored in the DCB. Unlike the DCB, the exit list, and the JFCB, a DCBE can be located above the line.
             LA    0,ADCBE
             ST    0,(DCBDCBE-IHADCB)+ADCB

    You probably want to do this before you open the DCB.
  3. Your DCB specifies MACRF=GM. This implies you intend to use the GET macro with a record address specified. Other pieces of your code imply you want to use the READ and CHECK macros. You cannot mix the two interfaces; you must use one or the other.
In general, it is quite difficult to guess at DCB attributes based on a single block read using a DCB with RECFM=U,BLKSIZE=32760. Code that might detect if the data is V or VB might be
         READ  ADECB,SF,ADCB,IOBUFFER,'S',MF=E
         CHECK ADECB
         LH    0,(DCBBLKSI-IHADCB)+ADCB
         L     1,(DECIOBPT-DECB)+ADECB
         SH    0,8+6(,1)
         CLM   0,B'0011',IOBUFFER
         BNE   NOTVB
This code uses the DECB definition in the IHADECB macro. It calculates the actual length of the data read by the READ macro, and compares it with the possible BDW in the I/O buffer. If they are not equal, it is definitely not RECFM=V or VB.
steve-myers
Global moderator
 
Posts: 2105
Joined: Thu Jun 03, 2010 6:21 pm
Has thanked: 4 times
Been thanked: 243 times

Re: Get RECFM and Record Length from unknown file V,VB,F,FB,

Postby steve-myers » Thu Sep 07, 2017 6:59 am

I went back to the original post and realized you did not want to try to deduce the DCB attributes of a data set from the contents of the records. You just, mainly, want the the current record length.

Now here's the deal. With QSAM - nothing I say here applies to BSAM - for RECFM U and RECFM F, you get the current record length from DCBLRECL; for RECFM V you get the record length from the RDW.

Teasing the record format from DCBRECFM is a little more difficult since you do not want to alter DCBRECFM.
         GET   yourDCB
         MVC   SAVEREC,(DCBRECFM-IHADCB)+yourDCB
         NI    SAVEREC,DCBRECL
         CLI   SAVEREC,DCBRECV
         BE    ITSRECV
         LH    reg,(DCBLRECL-IHADCB)+yourDCB
         B     ...
ITSRECV  LA    0,4
         LH    reg,0(,1)
         SR    reg,0
         AR    1,0
...

Once this sequence exits, the length of data is in a register of your choosing and the address of the data is in register 1. Setting register 0 to 4 stores the length of the RDW of a V format record into the register; the SR and AR instruction s adjust the record length to indicate the data length and data address.

The DCBRECL and DCBRECV symbols are defined in the DCBD IBM macro.

These users thanked the author steve-myers for the post:
rogelinm (Fri Sep 22, 2017 11:03 pm)
steve-myers
Global moderator
 
Posts: 2105
Joined: Thu Jun 03, 2010 6:21 pm
Has thanked: 4 times
Been thanked: 243 times

Re: Get RECFM and Record Length from unknown file V,VB,F,FB,

Postby rogelinm » Fri Sep 22, 2017 11:03 pm

Thank you very much, @steve-myers.

My actual working code is something like this:

*
READFILE EQU   *
         L     R4,DATADRSS                 > MY DATA ADDRESS
         L     R6,FILEX                    > R6=HANDLE/MY DCB ADDRESS
*
         GET   ((R6)),0(R4)                > HERE I GET THE RECORD. WORKS OK.
*
         MVC   A273O_BUFFER_PTR,DATADRSS   > MOVE RECORD ADDRESS TO COBOL
         MVI   A273O_STATUS,C'O'           > MOVE MY SATUS (USED IN COBOL)
*
*
         B     FIMPROGR                    > RETURN TO COBOL CALLER CALLE
*

I'm trying to implement/merge your example in my code.

Regards.
rogelinm
 
Posts: 5
Joined: Tue Sep 05, 2017 11:14 pm
Has thanked: 2 times
Been thanked: 0 time

Re: Get RECFM and Record Length from unknown file V,VB,F,FB,

Postby steve-myers » Fri Sep 22, 2017 11:11 pm

For QSAM input, I think you're usually better off using locate mode (MACRF=GL in the DCB macro) rather than providing your own record area. This is much faster because GET does not have to move the data to your record buffer, and you don't have to provide the storage.

In your GET macro, you just need (R6) for your DCB address. A tiny hint, though: just load the DCB address into register 1, and use (1). GET does not have to copy the DCB address to register 1, and if you specify (1) rather than (R1) the macro is smart enough not to do something sort of dumb, like LR 1,R1.
steve-myers
Global moderator
 
Posts: 2105
Joined: Thu Jun 03, 2010 6:21 pm
Has thanked: 4 times
Been thanked: 243 times

Re: Get RECFM and Record Length from unknown file V,VB,F,FB,

Postby rogelinm » Sat Sep 23, 2017 1:16 am

Sorry,
But I didn't follow you on "SAVEREC" I suppose it's like my data area (where my record is after GET).
rogelinm
 
Posts: 5
Joined: Tue Sep 05, 2017 11:14 pm
Has thanked: 2 times
Been thanked: 0 time

Re: Get RECFM and Record Length from unknown file V,VB,F,FB,

Postby steve-myers » Sat Sep 23, 2017 1:36 am

SAVEREC is intended to be a one byte data area - its location is up to you. The NI instruction just leaves the two bits that define the record type - F, V, or U. The DCBRECV symbol defines the two bits used for V.
steve-myers
Global moderator
 
Posts: 2105
Joined: Thu Jun 03, 2010 6:21 pm
Has thanked: 4 times
Been thanked: 243 times

Re: Get RECFM and Record Length from unknown file V,VB,F,FB,

Postby steve-myers » Mon Sep 25, 2017 6:48 am

rogelinm wrote:Thank you very much, @steve-myers.

My actual working code is something like this:

*
READFILE EQU   *
         L     R4,DATADRSS                 > MY DATA ADDRESS
         L     R6,FILEX                    > R6=HANDLE/MY DCB ADDRESS
*
         GET   ((R6)),0(R4)                > HERE I GET THE RECORD. WORKS OK.
*
         MVC   A273O_BUFFER_PTR,DATADRSS   > MOVE RECORD ADDRESS TO COBOL
         MVI   A273O_STATUS,C'O'           > MOVE MY SATUS (USED IN COBOL)
*
*
         B     FIMPROGR                    > RETURN TO COBOL CALLER CALLE
*

I'm trying to implement/merge your example in my code.

Regards.
Your GET is OK, but I'd use
         GET   (R6),(R4)           READ THE NEXT RECORD
         USING IHADCB,R6           ESTABLISH DCB ADDRESSABILITY
         LH    0,DCBLRECL          LOAD THE RECORD LENGTH
* DEDUCE THE RECORD FORMAT
         MVC   12(1,R13),DCBRECFM  COPY DCBRECFM TO A WORK AREA
         NI    12(13),DCBRECL      ISOLATE THE RECORD TYPE BITS
         CLI   12(13),DCBRECV      VARIABLE LENGTH RECORDS?
         BNE   NOTRECV             NO
* DCB IS RECFM = V
         LA    R15,4               LOAD BYTES IN A VARIABLE LENGTH RDW
         LH    R0,0(,R1)           LOAD RECORD LENGTH FROM THE RDW
         AR    R1,R15              COMPUTE DATA ADDRESS
         SR    R0,R15              COMPUTE DATA LENGTH
* THE ADDRESS OF THE DATA IS IN REGISTER 1, LENGTH IN REG 0
         DROP  R6                  KILL DCB ADDRESSABILITY
NOTRECV  ...

Beginners don't appreciate that the register save area can be used as a short term work area when a subroutine (or data management macro like GET) you're calling is not using it for registers. Offset 12 in the save area is normally where register 14 is saved, though data management macros do not seem to use the "standard" convention.

These users thanked the author steve-myers for the post:
rogelinm (Mon Sep 25, 2017 11:08 pm)
steve-myers
Global moderator
 
Posts: 2105
Joined: Thu Jun 03, 2010 6:21 pm
Has thanked: 4 times
Been thanked: 243 times

Re: Get RECFM and Record Length from unknown file V,VB,F,FB,

Postby rogelinm » Mon Sep 25, 2017 7:19 am

Thank you very much, steve-myers.
It actually solved my 4 weeks problem... I almost gave up on this.
You are very helpful.
rogelinm
 
Posts: 5
Joined: Tue Sep 05, 2017 11:14 pm
Has thanked: 2 times
Been thanked: 0 time

Re: Get RECFM and Record Length from unknown file V,VB,F,FB,

Postby rogelinm » Tue Sep 26, 2017 1:02 am

SOLVED.

Thanks again, Steve.

I just changed it a little...

*                                      
         USING IHADCB,R6              
         LH    R0,DCBLRECL            
*                                      
         MVC   WKRECFM,DCBRECFM        
         NI    WKRECFM,DCBRECL        
         CLI   WKRECFM,DCBRECV        
         BE    ISVAR                  > VARIABLE ROUTINE
*                                      
         CLI   WKRECFM,DCBRECF        
         BE    ISFIX                  > FIXED ROUTINE                 
*                                      
         MVI   A273O_RECFM,C'U'        
         B     ISUND                
*      


The WKRECFM is DS B in my working area.
WKRECFM  DS    B                       > RECFM CHECK BYTE

Regards.
rogelinm
 
Posts: 5
Joined: Tue Sep 05, 2017 11:14 pm
Has thanked: 2 times
Been thanked: 0 time

Next

Return to Assembler

 


  • Related topics
    Replies
    Views
    Last post