Invoking Sort from assembler



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

Invoking Sort from assembler

Postby sensuixel » Tue Jul 24, 2012 6:13 pm

Hello,

I'm trying to invoke DFSORT from Assembler.

So I read DFSORT Application Programming Guide (ice1ca50) and I wrote this code

ASMSRCT2 CSECT                                                 
         INITL 12,EQU=R      BASE REG = 12, R15 = 15   
OPEN_FIC EQU  *                                               
         OPEN   (SORTIN,(INPUT))                               
         OPEN   (SORTOUT,(OUTPUT))                             
         LA      R1,PARLST LOAD ADDR OF PARAM POINTER IN R1   
         LINK    EP=SORT                                       
ENDFIC   CLOSE   SORTIN                                       
         CLOSE   SORTOUT                                       
         RCNTL   RC=0                                         
*  WORKING STORAGE                                             
*  EXTENDED PARAMETR LIST                                     
PARLST   DC A(CTLST) ADDRESS OF CONTROL STATEMENTS             
PL2      DC A(0)     ADDRESS OF E15 ROUTINE                   
PL3      DC A(0)     ADDRESS OF E35 ROUTINE                   
PL4      DS A        USER EXIT ADDRESS CONSTANT               
PL5      DC F'-1'    INDICATE END OF LIST                     
CTLST    DS 0H       CONTROL STATEMENTS AREA                   
         DC AL2(CTL2-CTL1) LENGTH OF CHARACTER STRING         
CTL1     DC C' SORT FIELDS=(1,4,CH,A)'                         
CTL2     EQU *                                                 
*  FILE DCB                                   
SORTIN   DCB DDNAME=SORTIN,DSORG=PS,MACRF=(GL) EODAD=ENDFIC     
SORTOUT  DCB DDNAME=SORTOUT,DSORG=PS,MACRF=(PM)                 
*                                                               
         END ASMSRCT2                                           


I get the following sysout

ICE143I 0 BLOCKSET     SORT  TECHNIQUE SELECTED                               
ICE250I 0 VISIT http://www.ibm.com/storage/dfsort FOR DFSORT PAPERS, EXAMPLES A
ICE000I 0 - CONTROL STATEMENTS FOR 5694-A01, Z/OS DFSORT V1R10 - 14:17 ON TUE J
          SORT FIELDS=(1,4,CH,A)                                               
ICE201I G RECORD TYPE IS F - DATA STARTS IN POSITION 1                         
ICE751I 0 C5-K51707 C6-K51707 C7-K54603 C8-K51707 E4-K51707 C9-BASE   E5-K55337
ICE193I 0 ICEAM2 INVOCATION ENVIRONMENT IN EFFECT - ICEAM2 ENVIRONMENT SELECTED
ICE252I 1 PARMLIB OPTIONS WERE MERGED WITH INSTALLATION MODULE DEFAULTS       
ICE088I 1 APIASMT2.APIASMT2.        , INPUT LRECL = 300, BLKSIZE = 27900, TYPE
ICE093I 0 MAIN STORAGE = (MAX,4194304,4194304)                                 
ICE156I 0 MAIN STORAGE ABOVE 16MB = (4136944,4136944)                         
ICE127I 0 OPTIONS: OVFLO=RC0 ,PAD=RC0 ,TRUNC=RC0 ,SPANINC=RC16,VLSCMP=N,SZERO=Y
ICE128I 0 OPTIONS: SIZE=4194304,MAXLIM=1048576,MINLIM=450560,EQUALS=N,LIST=Y,ER
ICE129I 0 OPTIONS: VIO=N,RESDNT=ALL ,SMF=NO   ,WRKSEC=Y,OUTSEC=Y,VERIFY=N,CHALT
ICE130I 0 OPTIONS: RESALL=4096,RESINV=0,SVC=109 ,CHECK=Y,WRKREL=Y,OUTREL=Y,CKPT
ICE131I 0 OPTIONS: TMAXLIM=4194304,ARESALL=0,ARESINV=0,OVERRGN=16384,CINV=Y,CFW
ICE132I 0 OPTIONS: VLSHRT=N,ZDPRINT=Y,IEXIT=N,TEXIT=N,LISTX=N,EFS=NONE    ,EXIT
ICE133I 0 OPTIONS: HIPRMAX=OPTIMAL,DSPSIZE=MAX ,ODMAXBF=0,SOLRF=Y,VLLONG=N,VSAM
ICE235I 0 OPTIONS: NULLOUT=RC0                                             
ICE084I 0 EXCP ACCESS METHOD USED FOR SORTOUT                             
ICE084I 0 EXCP ACCESS METHOD USED FOR SORTIN                               
ICE750I 0 DC 27900 TC 0 CS DSVVV KSZ 4 VSZ 4                               
ICE752I 0 FSZ=93 RC  IGN=0 E  AVG=300 0  WSP=37 C  DYN=0 0                 
ICE751I 1 DE-K50430 D5-BASE   D9-BASE   E8-K51707                         
ICE090I 0 OUTPUT LRECL = 300, BLKSIZE = 27900, TYPE = FB                   
ICE080I 0 IN MAIN STORAGE SORT                                             
ICE055I 0 INSERT 0, DELETE 0                                               
ICE054I 0 RECORDS - IN: 17, OUT: 17                                       
ICE134I 0 NUMBER OF BYTES SORTED: 5100                                     
ICE253I 0 RECORDS SORTED - PROCESSED: 17, EXPECTED: 93                     
ICE199I 0 MEMORY OBJECT STORAGE USED = 0M BYTES                           
ICE180I 0 HIPERSPACE STORAGE USED = 0K BYTES                               
ICE188I 0 DATA SPACE STORAGE USED = 0K BYTES                               
ICE052I 0 END OF DFSORT                                                   


According to this SYSOUT, the SORTIN file seems to be read normally but i end up with an empty SORTOUT file
after having run this JCL

//APIASMT2 EXEC PGM=APIASMT2                                   
//STEPLIB  DD DISP=SHR,DSN=EAPICH.AGRR.LOAD                     
//SORTIN   DD DISP=SHR,DSN=EAPICH.TD.FB300                     
//SORTOUT  DD DISP=(,CATLG),DSN=EAPICH.TD.OUT,                 
//         RECFM=FB,LRECL=300,AVGREC=M,SPACE=(1,(1,1),RLSE)     
//SYSOUT   DD SYSOUT=*                                         


I'm actually reading MVS Programming : Assembler Services Reference , volume 2 (IAR - XCT) ( iea2a9a0) to look further
on the Link macro, I may be missing something here but If anyone has an idea ...
sensuixel
 
Posts: 58
Joined: Mon Feb 21, 2011 8:55 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Invoking Sort from assembler

Postby dick scherrer » Tue Jul 24, 2012 9:17 pm

Hello,

I've not invoked sort this way, but in other languages, SORT controls the SORTIN and SORTOUT datasets. They should not be opened by the code invoking the sort.

Was the output dataset successfully created or did the catalog fail as it already existed?
Subsequent info says that being already cataloged was NOT an issue. d

Hopefully, this is just an experiment as invoking the sort to do nothing but sort the input and create the output wastes system resources.

To do something like i believe you want, the sort is typically invoked and then user "exit"s are used to control pre- and post-sort processing.

If there continues to be a problem, let us know and your topic can be relocated to the DFSORT part of the forum.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Re: Invoking Sort from assembler

Postby steve-myers » Tue Jul 24, 2012 10:18 pm

Read Mr. Scherrer's comments carefully. As Mr. Scherrer says, you do not open the SORTOUT dataset until the sort has completed, and then, presumably, you open it for input so you can read the sorted dataset. Your way, you effectively lost the sort generated SORTOUT output.

Though the sort documentation is unclear about this, a program can dynamically call sort in three ways.
  • Simulating JCL. Your JCL must specify a message dataset, a SYSIN dataset, and the SORTIN and SORTOUT datasets.
  • Using an AMODE 24/RMODE 24 compliant parameter list. The sort DD statements depend on the contents of the parameter list.
  • Using an AMODE ANY / RMODE ANY compliant parameter list. DFSORT calls this an "extended parameter list." The sort DD statements depend on the contents of the parameter list.
All the sort products use the same parameter list for a "basic" sort; each sort product enhances it in some way for their own purposes, It appears to me you tried to use the DFSORT "extended parameter list."

One minor hint: the control statements pointed to by either parameter list should have a blank at the end. Your SORT statement does not have a blank, but that didn't seem to bother DFSORT.

It's been 6 or 7 years since I did a sort call from a program, and then I simulated a JCL call, and probably 30 years since I did a full dynamic call to use E15 and E35 exits. The E35 exit in that program was the major report function in the program. As I recall, there was report code after sort completed, but the major portion of the report output was done in the E35 exit.
steve-myers
Global moderator
 
Posts: 2105
Joined: Thu Jun 03, 2010 6:21 pm
Has thanked: 4 times
Been thanked: 243 times

Re: Invoking Sort from assembler

Postby sensuixel » Wed Jul 25, 2012 12:10 pm

Both of you have guessed where my mistake was.

I have removed the OPEN/CLOSE SORTOUT from my code (assuming that it was somehow made by SORT as Dick Scherrer said) and it
works, my SORTOUT file is now populated.

Thanks you really much for your help ;)
sensuixel
 
Posts: 58
Joined: Mon Feb 21, 2011 8:55 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Invoking Sort from assembler

Postby steve-myers » Wed Jul 25, 2012 7:32 pm

sensuixel wrote:Both of you have guessed where my mistake was. ...
You're welcome,

I don't know about Mr. Scherrer, but there was no guessing involved, just a basic knowledge of how things work. When you open, then close a dataset without writing anything to the dataset as your code did, data management writes what amounts to an EOF to the dataset. This effectively destroys anything in the dataset. In fact, had SORTOUT been a tape dataset rather than a disk dataset, sort would have gotten some sort of Sx13 ABEND when it tried to open the dataset because you cannot have two open datasets on tape at the same time.
steve-myers
Global moderator
 
Posts: 2105
Joined: Thu Jun 03, 2010 6:21 pm
Has thanked: 4 times
Been thanked: 243 times

Re: Invoking Sort from assembler

Postby dick scherrer » Wed Jul 25, 2012 7:41 pm

Nope - not a guess here either.

Looking at the code made me say "Hmmm - that's not gonna work". :)

d
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Re: Invoking Sort from assembler

Postby BillyBoyo » Wed Jul 25, 2012 11:08 pm

Just in case there is any confusion arising.

Chapter 4 of the DFSORT Application Programming Guide covers the requirements for your programs to be called by DFSORT as one of several "exits".

Chapter 6 of the same manual covers calling DFSORT from a program, concentrating on the requirements for Assembler as for Cobol and PL/I it is covered in their appropriate manuals.

Nowhere does it suggest that you should open SORTIN or SORTOUT. How you opened SORTIN and DFSORT successfully opened SORTIN and correctly processed the file, I don't know.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: Invoking Sort from assembler

Postby steve-myers » Thu Jul 26, 2012 1:20 am

BillyBoyo wrote:... How you opened SORTIN and DFSORT successfully opened SORTIN and correctly processed the file, I don't know.
It was SORTOUT, not SORTIN.

Since there were two DCBs involved, the system treats each DCB as a separate entity. What he did was roughly comparable to this -
         OPEN  (DCB1,OUTPUT)
         OPEN  (DCB2,OUTPUT)       
         PUT   DCB2,RECORD                     
         CLOSE DCB2                           
         CLOSE DCB1                           
         ...                                   
DCB1     DCB   DSORG=PS,MACRF=PM,DDNAME=SORTOUT
DCB2     DCB   DSORG=PS,MACRF=PM,DDNAME=SORTOUT

This won't work if the DD is assigned to tape; the second OPEN will get some sort of Sx13 ABEND.
steve-myers
Global moderator
 
Posts: 2105
Joined: Thu Jun 03, 2010 6:21 pm
Has thanked: 4 times
Been thanked: 243 times

Re: Invoking Sort from assembler

Postby BillyBoyo » Thu Jul 26, 2012 5:01 am

ASMSRCT2 CSECT                                                 
         INITL 12,EQU=R      BASE REG = 12, R15 = 15   
OPEN_FIC EQU  *                                               
         OPEN   (SORTIN,(INPUT))                               
         OPEN   (SORTOUT,(OUTPUT))                             
         LA      R1,PARLST LOAD ADDR OF PARAM POINTER IN R1   
         LINK    EP=SORT                                       
ENDFIC   CLOSE   SORTIN                                       
         CLOSE   SORTOUT 


It was the above that "threw" me :-)

sensuixel,

This is the latest DFSORT Application Programming Guide (ice1ca60), if your DFSORT is up-to-date.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: Invoking Sort from assembler

Postby steve-myers » Thu Jul 26, 2012 10:22 am

The SORTIN use was immaterial. It is not that uncommon for a program to have 2 DCBs open for the same dataset.
steve-myers
Global moderator
 
Posts: 2105
Joined: Thu Jun 03, 2010 6:21 pm
Has thanked: 4 times
Been thanked: 243 times

Next

Return to Assembler

 


  • Related topics
    Replies
    Views
    Last post