Hi Team
My requirement is to do the following:
1. Take one long sequential record from mainframe file..
2. Read one character at a time, if > ASCII 127, ignore, else keep.
3. Extract each sequence of contiguous ASCII characters as a separate word.
4. Reconstruct all the words into a sentence with spaces in between and write the output.
5. The final output will be a dataset of lines with only ASCII words.
Is it possible to achieve this using DFSORT?
Thank You
Regards
Prasanna G.
How to use ASCII condition in DFSORT
- Prasanna G
- Posts: 71
- Joined: Tue Apr 12, 2011 9:49 pm
- Skillset: JCL, Cobol, DB2
- Referer: Internet
- sergeyken
- Posts: 458
- Joined: Wed Jul 24, 2019 10:12 pm
- Skillset: Assembler, JCL, Utilities, PL/I, C/C++, DB2, SQL, REXX, COBOL, etc. etc. etc.
- Referer: Internet search
Re: How to use ASCII condition in DFSORT
IMHO, in that case REXX would be a better solution than any SORT tool.
SORT has very limited set of options to work with single bytes.
During the same time needed to build such sophisticated solution for SORT, one could create 5 to 10 similar solutions in REXX.
IMHO.
SORT has very limited set of options to work with single bytes.
During the same time needed to build such sophisticated solution for SORT, one could create 5 to 10 similar solutions in REXX.
IMHO.
Javas and Pythons come and go, but JCL and SORT stay forever.
- Prasanna G
- Posts: 71
- Joined: Tue Apr 12, 2011 9:49 pm
- Skillset: JCL, Cobol, DB2
- Referer: Internet
Re: How to use ASCII condition in DFSORT
sergeyken wrote:IMHO, in that case REXX would be a better solution than any SORT tool.
SORT has very limited set of options to work with single bytes.
During the same time needed to build such sophisticated solution for SORT, one could create 5 to 10 similar solutions in REXX.
IMHO.
Hi Sergeyken
The files that I am going to deal with will have million of records. Hence I thought processing them using REXX will be time consuming and will be inefficient.
Any REXX gurus or SORT gurus can please provide your valuable suggestions.
Thank You
Regards
Prasanna G.
- prino
- Posts: 641
- Joined: Wed Mar 11, 2009 12:22 am
- Skillset: PL/I - CICS - DB2 - IDMS - REXX - JCL, most in excess of three decades
- Referer: Google
- Location: Vilnius, Lithuania
- Contact:
Re: How to use ASCII condition in DFSORT
Prasanna G wrote:Any REXX gurus or SORT gurus can please provide your valuable suggestions.
Square pegs don't fit in round holes, use the right tools, write a program in PL/I (or if you're so inclined COBOL).
And by the way mainframe files are usually in EBCDIC, and they're called datasets!
Robert AH Prins
robert.ah.prins @ the.17+Gb.Google thingy
robert.ah.prins @ the.17+Gb.Google thingy
- sergeyken
- Posts: 458
- Joined: Wed Jul 24, 2019 10:12 pm
- Skillset: Assembler, JCL, Utilities, PL/I, C/C++, DB2, SQL, REXX, COBOL, etc. etc. etc.
- Referer: Internet search
Re: How to use ASCII condition in DFSORT
Prasanna G wrote:2. Read one character at a time, if > ASCII 127, ignore, else keep.
Is it possible to achieve this using DFSORT?
This is definitely impossible in SORT.
It works with records of datasets, and never - with characters in files.
Javas and Pythons come and go, but JCL and SORT stay forever.
- sergeyken
- Posts: 458
- Joined: Wed Jul 24, 2019 10:12 pm
- Skillset: Assembler, JCL, Utilities, PL/I, C/C++, DB2, SQL, REXX, COBOL, etc. etc. etc.
- Referer: Internet search
Re: How to use ASCII condition in DFSORT
Prasanna G wrote:The files that I am going to deal with will have million of records. Hence I thought processing them using REXX will be time consuming and will be inefficient.
If so, I would recommend either C/C++, or Assembler.
Javas and Pythons come and go, but JCL and SORT stay forever.
- sergeyken
- Posts: 458
- Joined: Wed Jul 24, 2019 10:12 pm
- Skillset: Assembler, JCL, Utilities, PL/I, C/C++, DB2, SQL, REXX, COBOL, etc. etc. etc.
- Referer: Internet search
Re: How to use ASCII condition in DFSORT
Something like this, without unimportant details
Code: Select all
#include <fstream>
#include <iostream>
#include <string>
using namespace std;
ifstream infile;
ofstream outfile;
string inline, outline;
. . . . . . . . . .
while ( getline( infile, inline) ) {
outline = "";
int len = inline.length();
for ( int i = 0, j = 0; i < len; ) {
while( i < len && inline[i] < 0x80 ) i++;
for (j = i; j < len && inline[j] >= 0x80; ) j++ ;
if (i < len)
outline += inline.substr( i, j - i + 1 ) + " " ;
}
if (outline.length() > 0)
outfile << outline << endl;
}
. . . . . . . . . .
Javas and Pythons come and go, but JCL and SORT stay forever.
- sergeyken
- Posts: 458
- Joined: Wed Jul 24, 2019 10:12 pm
- Skillset: Assembler, JCL, Utilities, PL/I, C/C++, DB2, SQL, REXX, COBOL, etc. etc. etc.
- Referer: Internet search
Re: How to use ASCII condition in DFSORT
1) My mistake - it should be
2) If performance is a real issue, I'd recommend to switch to pure C, without using C++ classes.
Code: Select all
outline += inline.substr( i, j - i ) + " " ;
2) If performance is a real issue, I'd recommend to switch to pure C, without using C++ classes.
Javas and Pythons come and go, but JCL and SORT stay forever.
- Prasanna G
- Posts: 71
- Joined: Tue Apr 12, 2011 9:49 pm
- Skillset: JCL, Cobol, DB2
- Referer: Internet
Re: How to use ASCII condition in DFSORT
Thanks Sergeyken.. I will try that out..
- sergeyken
- Posts: 458
- Joined: Wed Jul 24, 2019 10:12 pm
- Skillset: Assembler, JCL, Utilities, PL/I, C/C++, DB2, SQL, REXX, COBOL, etc. etc. etc.
- Referer: Internet search
Re: How to use ASCII condition in DFSORT
In C, it may be like this
Here, using the pointers char * instead of line indexes, or line-scanning functions like strlen(), strcat()... can significantly improve performance.
Code: Select all
#include <stdio.h>
#include <stdlib.h>
#define MAX_LINE 1000
FILE *infile, *outfile;
unsigned char inline[MAX_LINE], outline[MAX_LINE];
. . . . . . . . . .
if ( NULL == (infile = fopen( "........", "r" ) ) ) exit(100);
if ( NULL == (outfile = fopen( ".......", "w" )) ) exit(200);
do {
fgets( inline, sizeof(inline), infile );
outline[0] ='\0';
unsigned char *ichar, *jchar, *ochar;
for ( ichar = jchar = inline, ochar = outline; *ichar != '\0' ) {
while( *ichar != '\0' && *ichar < 0x80 ) ichar++;
for (jchar = ichar; *jchar >= 0x80; ) jchar++ ;
if (*ichar != '\0') {
int word_size = (jchar - ichar);
strncpy( ochar, ichar, word_size) ;
strcpy( (ochar += word_size), " " );
ochar++;
}
}
if ( outline[0] != '\0' ) {
fputs( outline, outfile );
fputc( '\n', outfile ); // because fputs() does not add EOL after the line...
}
} while ( !eof(infile) );
fclose(infile);
fclose(outfile);
. . . . . . . . . .
Here, using the pointers char * instead of line indexes, or line-scanning functions like strlen(), strcat()... can significantly improve performance.
Javas and Pythons come and go, but JCL and SORT stay forever.
-
- Similar Topics
- Replies
- Views
- Last post
-
-
Transfering ASCII files to z/OS USS using Connect Direct
by golemis » Sun Feb 21, 2021 2:24 pm » in All other Mainframe Topics - 1
- 6846
-
by golemis
View the latest post
Mon Feb 22, 2021 6:32 pm
-
-
- 1
- 1846
-
by sergeyken
View the latest post
Mon Nov 23, 2020 7:25 pm
-
- 2
- 1443
-
by willy jensen
View the latest post
Sun Nov 13, 2022 9:02 pm
-
- 5
- 3295
-
by knv09
View the latest post
Tue Jul 21, 2020 7:13 pm
-
- 0
- 5099
-
by mehi1353
View the latest post
Wed May 11, 2022 2:04 pm