Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Help in arriving at a logic

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
karthik3883

New User


Joined: 19 Oct 2007
Posts: 37
Location: chennai

PostPosted: Wed Jun 19, 2013 9:05 am    Post subject: Help in arriving at a logic
Reply with quote

Hi,

I require a help in arriving at a logic. my input file contains list like below and number of items is not fixed

BBRM
UB
UK
LCB

and i want to make this as ('BBRM','UB','UK','LCB") where condition.

I can able to do this in sort and i want to know how can we conclude it is a last record and finish with close paranthesis ')'

Regards
Karthik
Back to top
View user's profile Send private message

Pandora-Box

Moderator


Joined: 07 Sep 2006
Posts: 1529
Location: Andromeda Galaxy

PostPosted: Wed Jun 19, 2013 9:23 am    Post subject:
Reply with quote

You always want them as single record?

or is Multiple record ok for you ?
Back to top
View user's profile Send private message
karthik3883

New User


Joined: 19 Oct 2007
Posts: 37
Location: chennai

PostPosted: Wed Jun 19, 2013 9:47 am    Post subject:
Reply with quote

Hi I want them as a single record so that it can be used in where condition
Back to top
View user's profile Send private message
Pandora-Box

Moderator


Joined: 07 Sep 2006
Posts: 1529
Location: Andromeda Galaxy

PostPosted: Wed Jun 19, 2013 10:05 am    Post subject:
Reply with quote

ok on a regular basis how many records do you expect in Input file
What is the Maximum and minimum length of records?

FYI query also works if where clause is in multiple records

And sort product is?
Back to top
View user's profile Send private message
karthik3883

New User


Joined: 19 Oct 2007
Posts: 37
Location: chennai

PostPosted: Wed Jun 19, 2013 11:22 am    Post subject:
Reply with quote

the number of records is not fixed ,it may vary from month to month
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2158
Location: @my desk

PostPosted: Wed Jun 19, 2013 11:53 am    Post subject: Re: Need a help
Reply with quote

karthik3883 wrote:
I can able to do this in sort and i want to know how can we conclude it is a last record and finish with close paranthesis ')'

Regards
Karthik
Karthik,

One way of doing it would be to have a dummy value using TRAILER1 at the end like this, which is never expected in the data.
Code:
( --> HEADER1
'BBRM',
'UB',
'UK',
'LCB',
'dummy-end') --> TRAILER1
Back to top
View user's profile Send private message
karthik3883

New User


Joined: 19 Oct 2007
Posts: 37
Location: chennai

PostPosted: Wed Jun 19, 2013 12:30 pm    Post subject:
Reply with quote

Hi Arun,

Thank you ,

Actually we are doing a FTP from a file,normally a .txt which contains details like

aaaa
vvvv
ccccc

and wont contain trailer

i have to convert this to ('aaaa','vvv','ccccc);

please help me if there is any way to achieve this
Back to top
View user's profile Send private message
Pandora-Box

Moderator


Joined: 07 Sep 2006
Posts: 1529
Location: Andromeda Galaxy

PostPosted: Wed Jun 19, 2013 12:52 pm    Post subject:
Reply with quote

karthik,

I would strictly suggest you to read the manuals so that you could understand Arun's hints or pointers
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2158
Location: @my desk

PostPosted: Wed Jun 19, 2013 2:36 pm    Post subject:
Reply with quote

karthik3883,

If you are to use your output to build a "dynamic" SQL WHERE condition, it does not matter if you have the values in a single record or in multiple records. In fact it is pretty much easier to write it in multiple records.

My suggestion was to use the OUTFIL BUILD to format your data records which in turn will write the actual search values in your WHERE clause. And use the HEADER1 and TRAILER1 parameters in the OUTFIL to write the open and close parantheses respectively, but the last value in the WHERE should not have a comma suffixed to it and hence the trick with the TRAILER1 with dummy-end value.
Back to top
View user's profile Send private message
mistah kurtz

Active User


Joined: 28 Jan 2012
Posts: 268
Location: Room: TREE(3). Hilbert's Hotel

PostPosted: Wed Jun 19, 2013 5:47 pm    Post subject:
Reply with quote

Hi karthik3883,

You can achieve what Arun has suggested using this SORT job, assuming that you have DFSORT and maximum length of data is 10.
Code:
//SORTIN  DD *                                         
AAAA                                                   
VVVV                                                   
CCCCC                                                 
//SORTOUT DD SYSOUT=*                                 
//SYSIN DD *                                           
 OPTION COPY                                           
 INREC  IFTHEN=(WHEN=INIT,BUILD=(C'''',2:1,10,         
                SQZ(SHIFT=LEFT,TRAIL=C''',')))         
 OUTFIL REMOVECC,HEADER1=('('),TRAILER1=('''DUMMY'');')

Output:
Code:
(       
'AAAA', 
'VVVV', 
'CCCCC',
'DUMMY');
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Wed Jun 19, 2013 7:03 pm    Post subject:
Reply with quote

Hello,

Need a help
may be the least useful subject posted in a long time . . .

Pretty much everyone who starts a topic is looking for some kind of help . . .

Please use meaningful topic/subject.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Thu Jun 20, 2013 4:19 am    Post subject: Reply to: Need a help
Reply with quote

As has been pointed out already, this is much more sensible to do over several lines.

Borrowing a Smart Trick, here is a DATASORT solution.

Yes, then does mean sorting the file, but since it is values for a WHERE clause, I'm assuming there aren't going to be hundreds of thousands of input records.

DATASORT allows you to specify "header records" (FIRST(n)) and "trailer records" (LAST(n)) which retain their original relative positions in the file whilst everything in between is sorted.

With DATASORT you get OPTION EQUALS for nothing. So the "data" can be sorted on the first byte (which by that time is always a single-quote) and the records even stay in the same order. The "non-trailer" records get a comma after the closing quote, the "trailer" record does not.

Code:
//MKWHEN   EXEC PGM=ICETOOL
//SYMNAMES DD *
DATA-AREA,1,71,CH
DATA-BYTE-ONE,1,1,CH
SINGLE-QUOTE,C''''
QUOTE-COMMA,C''','
OPENING-BRACKET,C'('
CLOSING-BRACKET,C')'
INDENT-BRACKETS,5
//SYMNOUT DD SYSOUT=*
//TOOLIN DD *
DATASORT FROM(IN) TO(OUT)  LAST USING(WHEN)
                                                       
//WHENCNTL DD *
 INREC OVERLAY=(DATA-BYTE-ONE:DATA-AREA,
                JFY=(SHIFT=LEFT,
                     LEAD=SINGLE-QUOTE,
                     TRAIL=QUOTE-COMMA))
                                                       
 SORT FIELDS=(DATA-BYTE-ONE,A)
                                                       
 OUTFIL FNAMES=OUT,REMOVECC,
        HEADER1=(INDENT-BRACKETS:OPENING-BRACKET),
        TRAILER1=(INDENT-BRACKETS:CLOSING-BRACKET),
        IFTHEN=(WHEN=(DATA-BYTE-ONE,NE,SINGLE-QUOTE),
                 OVERLAY=(DATA-BYTE-ONE:DATA-AREA,
                          JFY=(SHIFT=LEFT,
                               LEAD=SINGLE-QUOTE,
                               TRAIL=SINGLE-QUOTE)))
                                                       
//TOOLMSG  DD SYSOUT=*
//DFSMSG   DD SYSOUT=*
//IN       DD *
BBRM
UB
UK
LCB
//OUT      DD SYSOUT=*


Output is:

Code:
    ( 
'BBRM',
'UB', 
'UK', 
'LCB' 
    )
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Wildcard logic in COBOL dudenithy COBOL Programming 13 Thu Sep 01, 2016 7:36 pm
No new posts Sort Logic to extract data scorp_rahul23 DFSORT/ICETOOL 13 Tue Mar 01, 2016 1:22 am
No new posts Need a logic to validate the data in ... sandeep kumar302 COBOL Programming 17 Mon Feb 01, 2016 3:30 pm
No new posts Tricky sort logic required pgopi92 DFSORT/ICETOOL 3 Mon Jan 25, 2016 3:29 pm
No new posts DB2 - CURRENT DATE + 2 YRS logic balaji81_k DB2 3 Thu Nov 26, 2015 3:07 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us