Home      Mainframe Forum      Mainfarme Tutorials      IBM Manuals      Mainframe Interview Questions      Mainframe Books      IT News     SiteMap     Downloads


     
 
MAINFRAME - TIP OF THE DAY : All available storage is assigned to the job or jobstep, If REGION is coded 0K or 0M

Google
 
Web mainframegurukul.com

OUTREC with a searched value?

 
Post new topic   Reply to topic    mainframegurukul.com Forum Index -> DFSORT , ICETOOL & Utilities
  View previous topic :: View next topic  
Author Message
sidhe
Member


Joined: 12 Aug 2015
Posts: 5
Location: Milan (ITALY)

Answer was approved by Question owner.
Useful Post
1 votes
Not an useful post
Greate Post!! Salute Author
0 salutes

PostPosted: Thu Aug 13, 2015 12:47 pm    Post subject: OUTREC with a searched value? Reply with quote

Hi All,
my INPUT is a fixed lenght file. The records contain a table occurs 4 times:
code pic 9(3)
myvalue pic x(2)

in OUTPUT if the code = 001 i need the text value, when other i need zero. I know the position of the table into the record, but I don't know the position of the 001 code into the table.

Example of input file:
..001AA007BB003DD009AA...
..008CC002CC001BB007DD...
..003DD005AA002CC006BB...

Example of the output that i want:
...AA..
...BB..
...00..

Question1: in your opinion, how can I do it?
Question2: in my sort I already have an OUTREC to format the other part of the output record, may I do all this at once in the same step of my outrec or i must create a new step?

Please, help me, thank you Rolling Eyes
Back to top
View user's profile Send private message
Click here, If this post answer your question. <-- Click on right mark icon. If this post answer your question.

William Collins
Active Member


Joined: 24 May 2012
Posts: 714

Answer was approved by Question owner.
Useful Post
0 votes
Not an useful post
Greate Post!! Salute Author
0 salutes

PostPosted: Thu Aug 13, 2015 9:34 pm    Post subject: Reply with quote

You only have four possibilities, so you can use OR on an INCLUDE= on OUTFIL.

INREC/OUTREC and OUTFIL can be extended to multiple statements easily with various flavours of IFTHEN.

Start with the DFSORT Getting Started manual.
Back to top
View user's profile Send private message
Click here, If this post answer your question. <-- Click on right mark icon. If this post answer your question.
sidhe
Member


Joined: 12 Aug 2015
Posts: 5
Location: Milan (ITALY)

Answer was approved by Question owner.
Useful Post
0 votes
Not an useful post
Greate Post!! Salute Author
0 salutes

PostPosted: Thu Aug 13, 2015 10:44 pm    Post subject: Reply with quote

William Collins wrote:
you can use OR on an INCLUDE= on OUTFIL

Thanks for your answer, but I don't think so.
I don't need to filter the input removing unnecessary records, my output must have the same number of record of my input, so I think that OMIT/INCLUDE cannot resolve my problem.

Quote:
Start with the DFSORT Getting Started manual.

Before asking for help here, I already checked DFSORT/ICETOOL manuals, but i can't find a simple and optimized solution Smile

Now I've done with an OUTREC to format the other part of the record, and after it an OUTFIL with multiple IFTHEN to test the code in all the possible position.
It works, but I don't like it...
Adding to my OUTREC the OUTFIL can extend the statement, but does it read again all the file?

I was hoping to find an easiest solution...
any other ideas?
Back to top
View user's profile Send private message
Click here, If this post answer your question. <-- Click on right mark icon. If this post answer your question.
William Collins
Active Member


Joined: 24 May 2012
Posts: 714

Answer was approved by Question owner.
Useful Post
0 votes
Not an useful post
Greate Post!! Salute Author
0 salutes

PostPosted: Thu Aug 13, 2015 11:38 pm    Post subject: Reply with quote

Sorry, I misread your question.

So if a certain position contains 001, you need a certain other position to be left as it is (need the text value)? Else blank? Can there be more than one 001 on the same record?

If you post what you have, it can probably all be done on INREC (unless you have a significant SORT as well).

It'll also make it clearer what you are having problems with.

SORT is not a general-purpose language as such. The aim is optimisation of processing, not short-hand in coding, but we can make it as clear as possible. It has no looping constructs, so you have to code things out if you process something in an "occurs".
Back to top
View user's profile Send private message
Click here, If this post answer your question. <-- Click on right mark icon. If this post answer your question.
sidhe
Member


Joined: 12 Aug 2015
Posts: 5
Location: Milan (ITALY)

Answer was approved by Question owner.
Useful Post
0 votes
Not an useful post
Greate Post!! Salute Author
0 salutes

PostPosted: Fri Aug 14, 2015 12:53 am    Post subject: Reply with quote

I have to extract from a large file only parts of strings (i've used OUTREC BUILD), changing some values (i've used CHANGE command into the same OUTREC), totalizing some values (i've used ADD command into the same OUTREC), formatting numeric fields (i've used EDIT into the same OUTREC), etc...

My problem is that I'd like to string (with the same OUTREC) the value after the position of the code 001.
I know only the range of position where 001 can be (from xx to yy), but I don't know exactly where the 001 starts, because the 001 doesn't start always in the same position, and in some record the 001 there isn't.
So i need something like this:
- evaluate only from position xx and pos yy of the record
- into this, find the position of the C'001'
- when find it, take out the value that start after the C'001' (need the 2 bytes after the C'001')
- when other (if not find the C'001' from xx to yy) take the default fixed value C'00'

In the first message above, I had written a simplified example of my input and the output I would like to have.

Example of input file:
..001AA007BB003DD009AA...
..008CC002CC001BB007DD...
..003DD005AA002CC006BB...

Example of the output that i want:
...AA..
...BB..
...00..

Thanks for your attention Rolling Eyes Smile
Back to top
View user's profile Send private message
Click here, If this post answer your question. <-- Click on right mark icon. If this post answer your question.
William Collins
Active Member


Joined: 24 May 2012
Posts: 714

Answer was approved by Question owner.
Useful Post
0 votes
Not an useful post
Greate Post!! Salute Author
0 salutes

PostPosted: Fri Aug 14, 2015 1:11 am    Post subject: Reply with quote

Still no code from you Smile

To find the data, in what looks like four different fixed positions, and if you can guarantee no false hits, you can use PARSE. Tell PARSE where to start and end, and use STARTAFT=C'001' with FIXLEN=2. If the 001 exists in one of the four places on that record (remember, you have to guarantee no false hits) then the PARSEd item will contain the two bytes you want, else it will be two spaces.

You can use PARSE and BUILD on the same statement.

If you can't guarantee no false hits, you'll need four IFTHEN=(WHEN=(logicalexpression) to test the four locations and OVERLAY the value you want (or possibly BUILD).
Back to top
View user's profile Send private message
Click here, If this post answer your question. <-- Click on right mark icon. If this post answer your question.
sidhe
Member


Joined: 12 Aug 2015
Posts: 5
Location: Milan (ITALY)

Answer was approved by Question owner.
Useful Post
0 votes
Not an useful post
Greate Post!! Salute Author
0 salutes

PostPosted: Fri Aug 14, 2015 7:37 pm    Post subject: Reply with quote

ok, thank you!
I've tried with PARSE command (my first time that I use it Very Happy ), but I have some questions... Rolling Eyes

Solution 1 - only PARSE: it doesn't work when there is not the C'001' in my range, but there is the same string C'001' in other part of the file
Question 1: with parameter ABSPOS, I can specify the position where start the evaluation, but HOW can I tell him the position where to STOP evaluation? because I haven't a delimiter like point or semicolon or space for the ENDBEFR/ENDAT...
Code:
OUTREC          PARSE=(%01=(STARTAFT=C'001',FIXLEN=02)),
                BUILD=(1:C'MY OUT IS: ',%01,C';')       

Example of input :
..001AA007BB003DD009AA...other data....0000001XXXX0055001
..008CC002CC001BB007DD...other data....0000022XXXX0063541
..003DD005AA002CC006BB...other data....0000001XXXX0001777
output:
MY OUT IS: AA;
MY OUT IS: BB;
MY OUT IS: XX; <== ko, it takes string out of range to evaluate


Solution 2 - IFTHEN + PARSE : it doesn't work because no action done when there is not the C'001' in my range
Question 2: is it possible to give him a default value (C'00') to use when not found the C'001' in the range?
Code:
OUTREC IFOUTLEN=50,                                     
         IFTHEN=(WHEN=(3,20,SS,EQ,C'001'),               
                 PARSE=(%01=(STARTAFT=C'001',FIXLEN=02)),
                 BUILD=(1:C'MY OUT IS: ',%01,C';'))     

Example of input :
..001AA007BB003DD009AA...other data....0000001XXXX0055001
..008CC002CC001BB007DD...other data....0000022XXXX0063541
..003DD005AA002CC006BB...other data....0000001XXXX0001777
output:
MY OUT IS: AA;
MY OUT IS: BB;
..003DD005AA002CC006BB...other data....0000001XXXX <== ko


Solution 3 - IFTHEN + PARSE+ IFTHEN: it works BUT I repeated 2 times the command BUILD
Question 3: this is a simplified example but my real case is more complicated, and my BUILD actually contains many more parameters.. so: is it possible to write only 1 BUILD instead of 1 for each IFTHEN? (how?)
Code:
OUTREC IFOUTLEN=50,                                       
         IFTHEN=(WHEN=(3,20,SS,EQ,C'001'),               
                 PARSE=(%01=(STARTAFT=C'001',FIXLEN=02)),
                 BUILD=(1:C'MY OUT IS: ',%01,C';')),     
         IFTHEN=(WHEN=(3,20,SS,NE,C'001'),               
                 BUILD=(1:C'MY OUT IS: ',C'00',C';'))     

output (OK) :
MY OUT IS: AA;
MY OUT IS: BB;
MY OUT IS: 00;
Back to top
View user's profile Send private message
Click here, If this post answer your question. <-- Click on right mark icon. If this post answer your question.
William Collins
Active Member


Joined: 24 May 2012
Posts: 714

Answer was approved by Question owner.
Useful Post
0 votes
Not an useful post
Greate Post!! Salute Author
0 salutes

PostPosted: Fri Aug 14, 2015 8:54 pm    Post subject: Reply with quote

Your data turned out to be longer than I thought, I didn't realise the dots (.) represented other-data-of-some-value.

PARSE is going to stop at the end of the record. You have other data, with different values per record, so you can't ENDBEFR.

You can copy the data to the end of the record (temporarily) and PARSE there. With fixed-position data, PARSE is usually not necessary, but for finding one occurrence amongst eight it may be worth it.

With Solution 2, you have used SS, but again you have to be certain about the possibility or not of false hits. The problem is not the default value for the PARSEd field so much as their has not been a BUILD, so your input record is unchanged.

With Solution 3, WHEN=INIT to establish the other data with BUILD and then OVERLAY in your IFTHEN=(WHEN=(logicalexpression) just for the PARSEd field. In your example you could keep the structure the same, except use WHEN=NONE instead of reversing the condition. Because there are no "procedures" of any type, sometimes there is repetition that you'd prefer there not to be.

Reducing the impact of repetition is one of the uses of SORT symbols/SYMNAMES.

BUILD defaults to starting at the first byte of data, so no need for the column on the BUILD.
Back to top
View user's profile Send private message
Click here, If this post answer your question. <-- Click on right mark icon. If this post answer your question.
sidhe
Member


Joined: 12 Aug 2015
Posts: 5
Location: Milan (ITALY)

Answer was approved by Question owner.
Useful Post
0 votes
Not an useful post
Greate Post!! Salute Author
0 salutes

PostPosted: Mon Aug 17, 2015 9:20 pm    Post subject: Reply with quote

Thank you very much for your help and tips, I've modified my sort code, and now it works fine Wink
Back to top
View user's profile Send private message
Click here, If this post answer your question. <-- Click on right mark icon. If this post answer your question.
academyindia4
Guest





Answer was approved by Question owner.
Useful Post
0 votes
Not an useful post
Greate Post!! Salute Author
0 salutes

PostPosted: Mon Jan 25, 2016 9:29 pm    Post subject: Topic deleted by Admin Reply with quote

<< Content deleted By Admin >>
Back to top
Click here, If this post answer your question. <-- Click on right mark icon. If this post answer your question.
Display posts from previous:   
Post new topic   Reply to topic    mainframegurukul.com Forum Index -> DFSORT , ICETOOL & Utilities All times are GMT + 5 Hours
Page 1 of 1



 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Related topics
 Topics   Replies   Author   Views   Last Post 
No new posts Search Batch file-aid help 14 frenchman 31561 Mon Feb 01, 2016 10:23 pm
academyindia4 View latest post
No new posts File-Aid Help 3 Nicholas 21374 Mon Feb 01, 2016 10:22 pm
academyindia4 View latest post
No new posts Hi plz help me out 7 Guest 21197 Mon Feb 01, 2016 10:14 pm
academyindia4 View latest post
This topic is locked: you cannot edit posts or make replies. executing java program thru JCL 6 Guest 24809 Tue Feb 12, 2013 1:56 pm
Anuj Dhawan View latest post
No new posts Many JCL statements contain specific values designed to dire 1 Krishna 4873 Tue May 12, 2009 5:39 pm
Krishna View latest post
 


Cobol Tutorial
This cobol tutorial covers most of the important topics like STRING, UNSTRING, COMP, COMP-3.....
DB2 Tutorial
DB2 Tutorial focuses on DB2 COBOL Programming. Explains in simple language. Some Chapters are locked, Forum members have free access to these chapters
CICS Tutorial
This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming...
JCL Tutorial
This is most popular JCL tutorial from mainframegurukul. It does contain important jcl ....
SORT Tutorial
This Tutorial covers all important aspects of DFSORT. Has more SORT examples
INTERVIEW Questions
This page covers important interview questions
Mainframe Jobs
Mainframe Jobs posted by members of mainframegurukul forum
FaceBook Page
MainframeGurukul FaceBook Page
LinkedIn Page
MainframeGurkul Linkedin Page

This widget requires Flash Player 9 or better







Go to top of the page
 

Online ABEND Reference ||  JCL References ||  COBOL References ||  VSAM References ||  Tutorials by Drona Series ||  SQL tutorial ||  BOOKS  ||  DB2 INTERVIEW QUESTIONS ||  COBOL INTERVIEW QUESTIONS  ||  JCL INTERVIEW QUESTIONS ||  JCL2 INTERVIEW QUESTIONS ||  VSAM INTERVIEW QUESTIONS ||  CICS INTERVIEW QUESTIONS  ||  Online tutorials ||  Online ABEND Reference ||  JCL References ||  COBOL References ||  VSAM References ||  Tutorials by Drona Series ||  SQL tutorial ||  BOOKS  ||  SiteMap  ||  Expeditor Tutorial  ||  FILE-AID Tutorial  ||  Changeman Tutorial  ||  COBOL   ||  DB2   ||  JCL  ||  CICS  ||  VSAM  ||  DB2 Interview Questions ( 110 )   || Simple JCL Tutorials  || JCL Tutorial from MainframeGurukul.com   || Simple JCL Tutorial - Chapter1 ;|| Mainframe Forum - Tutorials  || Mainframe Tutorials || Mainframe CICS tutorial|| Mainframe COBOL Tutorial

Drona Educational Forums - Mainframe Cobol DB2 CICS Board
Powered by phpBB

mainframetopic-7912.html