IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Format Last Record differently from rest of records


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Learncoholic

New User


Joined: 20 Sep 2007
Posts: 93
Location: India

PostPosted: Tue Oct 24, 2017 12:01 pm
Reply with quote

Hi,
I have a I/P file that reads:
Code:

            AAA
          AAAAA
         123145
      SCNCASHCJ


I want to have the O/P as:
Code:
'            AAA',
'          AAAAA',
'         123145',
'      SCNCASHCJ');


The No of records in the file may vary on a daily basis.

I did this is 2 SORT Steps. I would prefer to have it in 1 step.

I tried to do it in 1 step by using:
INREC - to provide Sequence Number
SORT - descending based on the Sequence No
OUTFIL IFTHEN - to build ');' in case Sequence No is 1 otherwise build ','.
This arrangement actually flips the records.

Can this be done without flipping using a single SORT Step?

Thanks
Back to top
View user's profile Send private message
sergeyken

Active Member


Joined: 29 Apr 2008
Posts: 931
Location: Maryland

PostPosted: Tue Oct 24, 2017 5:53 pm
Reply with quote

At the first step, no info can be available in advance: what is following next to the current record?
This is fundamental principle; it is not related neither to SORT, nor to anything else.
Any possible trick would simulate the second scan of records, either explicitly, or in hidden manner.
Back to top
View user's profile Send private message
daveporcelan

Active Member


Joined: 01 Dec 2006
Posts: 747
Location: Pennsylvania

PostPosted: Tue Oct 24, 2017 8:01 pm
Reply with quote

Additional information would be helpful.

When the scope of the problem is too narrow, the possible solutions are limited.

The desired output appears to be part of SYSIN DD for some sort of SQL.

Please show the next step of the Job where this is to run.

I have a thought that could be helpful, but can not properly express without additional information.
Back to top
View user's profile Send private message
RahulG31

Active User


Joined: 20 Dec 2014
Posts: 446
Location: USA

PostPosted: Wed Oct 25, 2017 3:20 am
Reply with quote

As daveporcelan mentioned, if it is indeed a part of SQL query where you are doing something like a 'WHERE values IN' and trying to build the list of values then, you could possibly make use of a 'Dummy' record:
Code:
 OUTFIL BUILD=(1:X'7D',2:1,16,18:X'7D6B',X),
 TRAILER1=(1:X'7D',2:C'           DUMMY',18:X'7D5D5E')
 OPTION COPY


the output will be:
Code:
'             AAA',
'           AAAAA',
'          123145',
'       SCNCASHCJ',
'           DUMMY');

The 'Dummy' value won't make a difference to the output if chose carefully.

.
Back to top
View user's profile Send private message
Learncoholic

New User


Joined: 20 Sep 2007
Posts: 93
Location: India

PostPosted: Wed Oct 25, 2017 8:29 pm
Reply with quote

Hi Rahul & daveporcelan,

Both of you are correct. This O/P of the SORT is an I/P to a SQL Query.
I get what Rahul is suggesting & putting a Dummy record will work perfectly fine in my case.

Thanks
Back to top
View user's profile Send private message
daveporcelan

Active Member


Joined: 01 Dec 2006
Posts: 747
Location: Pennsylvania

PostPosted: Wed Oct 25, 2017 10:37 pm
Reply with quote

That is what I was going to suggest, but was waiting for you to provide more information.

Since you are 'learnaholic', learn this: providing some background information (do not go overboard), would greatly help get solutions to the problem.

Lucky for you, both Rahul and I have enough experience to work with the sparse information provided.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Converting a file from PD to display ... SYNCSORT 4
No new posts Merging more than two records DFSORT/ICETOOL 15
No new posts Matching and non matching records usi... DFSORT/ICETOOL 11
No new posts Record count of RECFM=U tape file DFSORT/ICETOOL 17
No new posts REMOVE DUPLICATE RECORDS BASED ON A S... DFSORT/ICETOOL 4
Search our Forums:

Back to Top