Get filename from a ddname



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

Get filename from a ddname

Postby Nilis1978 » Thu Feb 25, 2016 8:37 pm

Hey,

I try to make a cobol program what determine the file-name of a ddname of the

What functions / tool van I use?
Nilis1978
 
Posts: 2
Joined: Thu Feb 25, 2016 8:30 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Get filename from a ddname

Postby Robert Sample » Thu Feb 25, 2016 9:41 pm

You can use control blocks to get this type of data. There are sample programs on this and other fora.
Robert Sample
Global moderator
 
Posts: 3719
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 279 times

Re: Get filename from a ddname

Postby Nilis1978 » Thu Feb 25, 2016 10:07 pm

Do you have the url of a example?
Nilis1978
 
Posts: 2
Joined: Thu Feb 25, 2016 8:30 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Get filename from a ddname

Postby NicC » Thu Feb 25, 2016 10:48 pm

The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 3025
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisies (almost)
Has thanked: 4 times
Been thanked: 136 times

Re: Get filename from a ddname

Postby steve-myers » Fri Feb 26, 2016 12:30 pm

I don't think there is a solution within sort. The following Assembler program can be called by a Cobol program.
***********************************************************************
*                                                                     *
* Title -- GETDSN                                                     *
*                                                                     *
* Function / Operation -- GETDSN returns the data set name of the     *
*   data set specified for a DD name.                                 *
*                                                                     *
* Calling sequence(Assembler) --                                      *
*            CALL  GETDSN,(DDNAME,DSNAME)                             *
*            ...                                                      *
*   DDNAME   DC    CL8' '                                             *
*   DSNAME   DC    CL44' '                                            *
*                                                                     *
* Attributes -- GETDSN is reenterable, refreshable and reusable.  Its *
*   intended operating environment is enabled, task mode, problem key *
*   and problem state.  It is Language Environment compatible, but    *
*   not Language Environment compliant.                               *
*                                                                     *
***********************************************************************
         SPACE 5
GETDSN   CSECT
GETDSN   AMODE ANY
GETDSN   RMODE 31
         PUSH  PRINT
         PRINT NOGEN
         DCBD  DSORG=QS,DEVD=DA
         SPACE 2
WA       DSECT
OPARMS   OPEN  *-*,MF=L
OPARM    EQU   OPARMS,*-OPARMS
ADCBS    DCB   DSORG=PS,MACRF=E,DDNAME=FILLMEIN,EXLST=*-*
ADCB     EQU   ADCBS,*-ADCBS
XLIST    DS    A
JFCB     DS    0XL176
         IEFJFCBN
         DS    0D
WASIZE   EQU   *-WA
         POP   PRINT
         EJECT
GETDSN   CSECT
         BASR  15,0                Store current address in reg 15
         USING WA,9                Establish work area addressability
         USING *,10                Establish program addressability
         SAVE (14,10),,'GETDSN &SYSDATE &SYSTIME'  Save registers
         LR    10,15               Prepare program base register
         LM    2,3,0(1)            Load the parameter list
         LA    0,WASIZE            Load work area length
         GETMAIN R,LV=(0)          Obtain storage for the work area
         LR    9,1                 Copy work area address to reg 9
         MVC   OPARM,MASTOPEN      Initialze the RDJFCB parameter list
         MVC   ADCB,MASTDCB        Initialize the DCB
         LA    0,XLIST
         STCM  0,B'0111',(DCBEXLSA-IHADCB)+ADCB
         LA    0,JFCB              Initalize XLIST
         ST    0,XLIST
         MVI   XLIST,X'80'+7
         MVC   (DCBDDNAM-IHADCB)+ADCB,0(2)  Copy DD name to the DCB
         RDJFCB ADCB,MF=(E,OPARM)  Read the JFCB
         LTR   15,15               RDJFCB RC = 0?
         BNZ   EXIT                No
         MVC   0(L'JFCBDSNM,3),JFCBDSNM  Copy data set name to user
EXIT     LR    8,15                Copy RDJFCB return code to reg 8
         LA    0,WASIZE            Free the work area
         FREEMAIN R,LV=(0),A=(9)
         LR    15,8                Copy RDJFCB RC to reg 15
         RETURN (14,10),RC=(15)    Restore registers & return
MASTOPEN OPEN  *-*,MF=L
MASTDCB  DCB   DSORG=PS,MACRF=E,DDNAME=FILLMEIN,EXLST=*-*
         DC    0D'
0'
         LTORG ,
         DC    0D'
0'
         END
steve-myers
Global moderator
 
Posts: 2105
Joined: Thu Jun 03, 2010 6:21 pm
Has thanked: 4 times
Been thanked: 243 times

Re: Get filename from a ddname

Postby madooeiei » Sat Feb 27, 2016 2:59 pm

It is very useful at all I have much more knowledge


Spam removed
madooeiei
 
Posts: 4
Joined: Mon Oct 12, 2015 2:53 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Get filename from a ddname

Postby LasseH » Tue May 17, 2016 12:35 pm

You can use BPXWDYN

One thing thou, I havn't found out how to get concatenated allocations

Example (from the head)

01          bpxwdyn-stuff.                                      
     05      c01-bpxwdyn     pic  x(08)    value 'BPXWDYN '.      
                                                                 
     05      c01-parm.                                            
      10     c01-length      pic s9(04)    binary value 230.      
      10     c01-function    pic  x(200).                        
      10     c01-norecall    pic  x(08)    value space.          
      10     c01-msg         pic  x(10)    value ' MSG(WTP) '.    
      10     filler          pic  x(12)    value space.          
     05      c01-return      pic s9(08)    binary value zero.    
      88     c01-ok                        value 0.              
*            Invalid parameter list                              
      88     c01-parmerror                 value 20.              
*            Key error (offset by 20, first is 21)                
      88     c01-keyerror                  value -9999 thru -21.  
*            Message processing error. IEFDB476 returned code nn.
      88     c01-msgerror                  value -10099          
                                            thru -10000.          
      88     c01-dynouterror               value 1 thru 19,      
                                                21 thru 9999.    
     05      c01-returnx     redefines                            
             c01-return.                                          
      10     c01-returnhigh  pic  x(02).                          
      10     c01-returnlow   pic  x(02).

     move 'ALLOC FI(TEST) DA(TESTDSN) SHR' to c01-function      
     call c01-bpxwdyn        using c01-parm                    
                             returning c01-return              
     end-call                                                  
     if return-code > 0 then                                    
        display  ' Result=' c01-return ' / rc=' return-code                                            
        goback                                          
     end-if                                                    
                         


//Lasse
LasseH
 
Posts: 70
Joined: Mon Nov 08, 2010 2:51 pm
Has thanked: 7 times
Been thanked: 1 time

Re: Get filename from a ddname

Postby LasseH » Fri May 20, 2016 11:34 am

LasseH wrote:You can use BPXWDYN

One thing thou, I havn't found out how to get concatenated allocations

Example (from the head)

01          bpxwdyn-stuff.                                      
     05      c01-bpxwdyn     pic  x(08)    value 'BPXWDYN '.      
                                                                 
     05      c01-parm.                                            
      10     c01-length      pic s9(04)    binary value 230.      
      10     c01-function    pic  x(200).                        
      10     c01-norecall    pic  x(08)    value space.          
      10     c01-msg         pic  x(10)    value ' MSG(WTP) '.    
      10     filler          pic  x(12)    value space.          
     05      c01-return      pic s9(08)    binary value zero.    
      88     c01-ok                        value 0.              
*            Invalid parameter list                              
      88     c01-parmerror                 value 20.              
*            Key error (offset by 20, first is 21)                
      88     c01-keyerror                  value -9999 thru -21.  
*            Message processing error. IEFDB476 returned code nn.
      88     c01-msgerror                  value -10099          
                                            thru -10000.          
      88     c01-dynouterror               value 1 thru 19,      
                                                21 thru 9999.    
     05      c01-returnx     redefines                            
             c01-return.                                          
      10     c01-returnhigh  pic  x(02).                          
      10     c01-returnlow   pic  x(02).

     move 'ALLOC FI(TEST) DA(TESTDSN) SHR' to c01-function      
     call c01-bpxwdyn        using c01-parm                    
                             returning c01-return              
     end-call                                                  
     if return-code > 0 then                                    
        display  ' Result=' c01-return ' / rc=' return-code                                            
        goback                                          
     end-if                                                    
                         


The command should be something like "INFO DD(ddname) ...."

//Lasse
LasseH
 
Posts: 70
Joined: Mon Nov 08, 2010 2:51 pm
Has thanked: 7 times
Been thanked: 1 time


Return to IBM Cobol