Call a program in SORT.



IBM's flagship sort product DFSORT for sorting, merging, copying, data manipulation and reporting. Includes ICETOOL and ICEGENER

Call a program in SORT.

Postby Mehdi shri » Sat Oct 20, 2012 7:00 pm

Dear friends.
I want to inverse an string on a field of input record. For example consider below:
XYZABCD001
XYZEFGH001
XYZIJKL001
XYZMNOP001

I want to exract like below:
XYZDCBA001
XYZHGFE001
XYZLKJI001
XYZPONM001

Is there a program to inverse the string form col4 to col7.(Or a control statement parameter to do this)
If isn't there how I can call my program (a load module that inverse an string) in sort control statment. And how my program must receieve input and send output to the SORT program.
Mehdi shri
 
Posts: 138
Joined: Sun Jan 16, 2011 6:30 pm
Has thanked: 57 times
Been thanked: 0 time

Re: Call a program in SORT.

 

Re: Call a program in SORT.

Postby BillyBoyo » Sat Oct 20, 2012 8:59 pm

No, it doesn't work like that.

The only way to use a seperate program is to write an EXIT. This is documented in the manual. I've left it deliberately vague at this point, as there is no need for you to do this, try:

  INREC BUILD=(1,3,7,1,6,1,5,1,4,1,8,3)


That will copy bytes 1 for a length of 3 from the input, followed by bytes 7, 6, 5 and 4 in that order, then bytes 8 for a length of three.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times

Re: Call a program in SORT.

Postby Mehdi shri » Sun Oct 21, 2012 10:56 am

Dear BillyBoyo
I want to inverse a larg string. For example col3 to col35 (33 byte lenght string). This is very dificault to code based on your suggestion.
Mehdi shri
 
Posts: 138
Joined: Sun Jan 16, 2011 6:30 pm
Has thanked: 57 times
Been thanked: 0 time

Re: Call a program in SORT.

Postby dick scherrer » Sun Oct 21, 2012 12:53 pm

Hello,

No, not difficult, but would take a few minutes to type. . . .

Maybe this could be done with a COBOL program using the REVERSE function if you are unwilling to do as suggested?
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6304
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 91 times

Re: Call a program in SORT.

Postby BillyBoyo » Mon Oct 22, 2012 2:42 pm

  INREC BUILD=(1,2,
               7,1,6,1,5,1,4,1,
               8,3)


  INREC BUILD=(1,2,
               35,1,34,1,33,1,32,1,31,1,30,1,
               29,1,28,1,27,1,27,1,26,1,25,1,24,1,23,1,22,1,21,1,20,1,
               29,1,28,1,27,1,27,1,26,1,25,1,24,1,23,1,22,1,21,1,20,1,
               29,1,28,1,27,1,27,1,26,1,25,1,24,1,23,1,
               36,whatever)


If you look, you need to change the remaining 2s in the second lot of "twenties" to 1s and zeros.

For extra clarity, consider symbols/SYMNAMES.

This "reverse" can be a good example of the difference between BUILD and OVERLAY. Once you have it working with BUILD, change it to OVERLAY and let us know what you make of it.

These users thanked the author BillyBoyo for the post:
Mehdi shri (Tue Oct 23, 2012 10:14 am)
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times

Re: Call a program in SORT.

Postby prino » Mon Oct 22, 2012 9:57 pm

Mehdi shri wrote:Is there a program to inverse the string form col4 to col7.(Or a control statement parameter to do this)
If isn't there how I can call my program (a load module that inverse an string) in sort control statment. And how my program must receieve input and send output to the SORT program.

Yes there is, it's called an exit. E15 for input, E35 for output, and the exit can be written in Cobol. Now go and RTFM.
Robert AH Prins
robert.ah.prins @ the.17+Gb.Google thingy
User avatar
prino
 
Posts: 536
Joined: Wed Mar 11, 2009 12:22 am
Location: Oostende, Belgium
Has thanked: 3 times
Been thanked: 21 times

Re: Call a program in SORT.

Postby skolusu » Mon Oct 22, 2012 11:05 pm

Mehdi shri,

You consider coding for 33 characters as a difficult task? Wow. Anyway here is an example of E15 exit which reverses the string for you and passes it back to SORT.

//STEP0100  EXEC PGM=IGYCRCTL                         
//SYSPRINT DD SYSOUT=*                               
//SYSTERM  DD SYSOUT=*                               
//SYSUT1   DD UNIT=SYSDA,SPACE=(CYL,(10,2),RLSE)     
//SYSUT2   DD UNIT=SYSDA,SPACE=(CYL,(10,2),RLSE)     
//SYSUT3   DD UNIT=SYSDA,SPACE=(CYL,(10,2),RLSE)     
//SYSUT4   DD UNIT=SYSDA,SPACE=(CYL,(10,2),RLSE)     
//SYSUT5   DD UNIT=SYSDA,SPACE=(CYL,(10,2),RLSE)     
//SYSUT6   DD UNIT=SYSDA,SPACE=(CYL,(10,2),RLSE)     
//SYSUT7   DD UNIT=SYSDA,SPACE=(CYL,(10,2),RLSE)     
//SYSLIN   DD DSN=&&LOADSET,                         
//            DISP=(MOD,PASS),                       
//            UNIT=SYSDA,                             
//            SPACE=(CYL,(1,1),RLSE)                 
//SYSIN    DD *                                       
        IDENTIFICATION DIVISION.                                 
        PROGRAM-ID. REVSTRNG.                                     
        ENVIRONMENT DIVISION.                                     
        DATA DIVISION.                                           
        WORKING-STORAGE SECTION.                                 
        LINKAGE SECTION.                                         
        01  RECORD-FLAGS               PIC 9(8) BINARY.           
            88  FIRST-REC              VALUE 00.                 
            88  MIDDLE-REC             VALUE 04.                 
            88  END-REC                VALUE 08.                 
                                                                 
        01 IP-RECORD                   PIC X(80).                 
        01 OP-RECORD                   PIC X(80).                 
                                                                 
        PROCEDURE DIVISION USING  RECORD-FLAGS                   
                                , IP-RECORD                       
                                , OP-RECORD.                     
                                                                 
           IF END-REC                                             
              MOVE 8 TO RETURN-CODE                               
           ELSE                                                   
              MOVE IP-RECORD  TO OP-RECORD                       
              MOVE FUNCTION REVERSE(IP-RECORD(1:30)) TO           
                            OP-RECORD (45:30)                     
              MOVE 20 TO RETURN-CODE                             
           END-IF                                                 
           GOBACK.                                               
//*                                                               
//STEP0200 EXEC PGM=IEWL,COND=(5,LT,STEP0100)           
//SYSLIB   DD DSN=CEE.SCEELKED,                         
//            DISP=SHR                                 
//SYSLIN   DD DSN=*.STEP0100.SYSLIN,DISP=(OLD,DELETE)   
//SYSLOUT  DD SYSOUT=*                                 
//SYSPRINT DD SYSOUT=*                                 
//SYSDBOUT DD SYSOUT=*                                 
//SYSUDUMP DD SYSOUT=*                                 
//SYSLMOD  DD DSN=Your.pgm.loadlib.pds(REVSTRNG),       
//            DISP=OLD                                 
//*                                                     
//STEP0300 EXEC PGM=SORT,COND=(5,LT,STEP0100)           
//STEPLIB  DD DSN=CEE.SCEERUN,DISP=SHR                 
//EXITC    DD DSN=Your.pgm.loadlib.pds,DISP=SHR         
//SYSOUT   DD SYSOUT=*                                 
//SORTIN   DD *                                         
I WANT TO REVERSE THIS STRING1                         
THIS IS VERY DIFFICULT TO CODE                           
//SORTOUT  DD SYSOUT=*                                 
//SYSIN    DD *                                         
  SORT FIELDS=COPY                                     
  MODS E15=(REVSTRNG,8000,EXITC,C)                     
//*


Check this link which explains in detail about writing your own exits with examples

http://publibz.boulder.ibm.com/cgi-bin/ ... E1CA60/5.0?
Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort

These users thanked the author skolusu for the post:
Mehdi shri (Tue Oct 23, 2012 11:05 am)
skolusu
 
Posts: 586
Joined: Wed Apr 02, 2008 10:38 pm
Has thanked: 0 time
Been thanked: 39 times

Re: Call a program in SORT.

Postby Mehdi shri » Tue Oct 23, 2012 11:15 am

Mr.Kolusu
Very thank you.
But when I run the JCL I give RC=12 and the following SYSPRINT:
20  IGYPS0086-I   "FUNCTION" was specified as an informational word in the current reserved word table.The eserved word table used may be different from the IBM-supplied default.               
20  IGYPS2121-S   "FUNCTION" was not defined as a data-name.  The statement was discarded.
20  IGYPS0088-S   The "MOVE" statement was invalid.  Expected "TO", but found "REVERSE".  The statement was discarded.         

Which statment I must to code?
Mehdi shri
 
Posts: 138
Joined: Sun Jan 16, 2011 6:30 pm
Has thanked: 57 times
Been thanked: 0 time

Re: Call a program in SORT.

Postby BillyBoyo » Tue Oct 23, 2012 11:48 am

Well, according to the IGYPS0086-I message, your site has updated the Cobol Reserved Word table to prevent the use of the intrinsic Functions. Must be a local standard. Confirm with your Team Leader/Trainer. Why are you asking this type of question of us, not them, first?
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times

Re: Call a program in SORT.

Postby skolusu » Tue Oct 23, 2012 9:04 pm

Mehdi shri wrote:Mr.Kolusu
Very thank you.
But when I run the JCL I give RC=12 and the following SYSPRINT:


Mehdi Shri,

The next time you have an error, make sure you post the version and release of the product you are using. The first few lines of most IBM products display the version and release of the product. Look at the version and release date of your Cobol compiler in sysprint which should be on the first line of your listing. I am guessing that you must be running VS COBOL II or OS/VS COBOL which are out of service atleast for 15 years which does NOT support the Intrinsic fucntions. Check this link for history of cobol compilers.

http://www.ibm.com/systems/z/os/zos/fea ... obmvs.html
Mehdi shri wrote:Which statment I must to code?


Start coding your own PERFORM Varying statement to mimic the functionality of moving 1 character at a time in the reverse order.
Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
skolusu
 
Posts: 586
Joined: Wed Apr 02, 2008 10:38 pm
Has thanked: 0 time
Been thanked: 39 times


Return to DFSORT/ICETOOL/ICEGENER

 


  • Related topics
    Replies
    Views
    Last post