Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
How to insert a value on specific position based on conditio

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

New User


Joined: 31 Aug 2016
Posts: 17
Location: India

PostPosted: Sun Oct 01, 2017 3:04 am    Post subject: How to insert a value on specific position based on conditio
Reply with quote

Hi All,

I have a PS file which is 18 bytes long. Each record is exactly 18 byte long. I have to insert a 3-byte character on position 1 in the file based on some conditions. Below is the sort card i am currently using :

Code:
//SYSIN    DD *                                                       
 SORT FIELDS=COPY                                                     
 OUTREC IFTHEN=(WHEN=INIT,                                           
                  IFTHEN=(WHEN=(9,3,CH,EQ,'000'),OVERLAY=(1:C'GGA')),
                  IFTHEN=(WHEN=(9,3,CH,EQ,'IM1'),OVERLAY=(1:C'GGA')),
                  IFTHEN=(WHEN=(10,3,CH,EQ,'  4'),OVERLAY=(1:C'GGA')),
                  IFTHEN=(WHEN=(10,3,CH,EQ,'  3'),OVERLAY=(1:C'GGA')),
                  IFTHEN=(WHEN=(9,2,CH,EQ,'WG'),OVERLAY=(1:C'AFG')), 
                  IFTHEN=(WHEN=(9,3,CH,EQ,'IUL'),OVERLAY=(1:C'AFG')),
                  IFTHEN=(WHEN=(9,2,CH,EQ,'UL'),OVERLAY=(1:C'AFG')), 
                  IFTHEN=(WHEN=(7,3,CH,EQ,'  T'),OVERLAY=(1:C'AFG')),
                  IFTHEN=(WHEN=(9,2,CH,EQ,'23'),OVERLAY=(1:C'023'))),
/*                 


After several hit and trials i am still getting the error. I am missing something here. Can anyone please help me to complete this.

Input File : (Each record is exactly 18 bytes long. Every record has variable number of spaces in the beginning. Spaces may not be visible after posting this.)

Code:
----+----1----+---

        0000L01762
             4875851
        IM10000929
             3400009
      WG10004785
        IUL1000016
        UL10000006
        T700000011
        2307900026


Expected Output : (Output file will also have length of 18 bytes)

Code:
CGA     0000L01762       
CGA        4875851       
CGA     IM10000929       
CGA        3400009       
LFG     WG10004785       
LFG     IUL1000016       
LFG     UL10000006       
LFG     T700000011       
023     2307900026       


Thanks a lot in advance !!
Back to top
View user's profile Send private message

Poha Eater

New User


Joined: 31 Aug 2016
Posts: 17
Location: India

PostPosted: Sun Oct 01, 2017 3:40 am    Post subject:
Reply with quote

This is the expected output. By mistake i wrote the wrong expected output in my topic. Below is the correct expected output :

Code:

GGA 0000L01762
GGA 4875851
GGA IM10000929
GGA 3400009
AFG WG10004785
AFG IUL1000016
AFG UL10000006
AFG T700000011
023 2307900026

Back to top
View user's profile Send private message
Poha Eater

New User


Joined: 31 Aug 2016
Posts: 17
Location: India

PostPosted: Sun Oct 01, 2017 3:42 am    Post subject:
Reply with quote

Thanks Magesh. I will keep this in mind going forward.
Back to top
View user's profile Send private message
magesh23586

Active User


Joined: 06 Jul 2009
Posts: 211
Location: Chennai

PostPosted: Sun Oct 01, 2017 8:23 am    Post subject: Reply to: How to insert a value on specific position based on conditio
Reply with quote

All your conditions are matching with 1,3(offset,length) or 1,2 or 1,1 why are you handling at 9th byte or 10th byte ?

Instead of
Code:

IFTHEN=(WHEN=(9,3,CH,EQ,'000'),OVERLAY=(1:C'GGA')),


you should have ?

Code:

IFTHEN=(WHEN=(1,3,CH,EQ,C'000'),OVERLAY=(1:C'GGA',4:1,15)),


May be you can try below code, untested
Code:

  SORT FIELDS=COPY

  OUTREC IFTHEN=(WHEN=(1,3,CH,EQ,C'000'),
                 OVERLAY=(1:C'GGA',4:1,15)),
         
         IFTHEN=(WHEN=(1,3,CH,EQ,C'IM1'),
                 OVERLAY=(1:C'GGA',4:1,15)),

         IFTHEN=(WHEN=(1,1,CH,EQ,C'4'),
                 OVERLAY=(1:C'GGA',4:1,15)),
 
         IFTHEN=(WHEN=(1,1,CH,EQ,C'3'),
                 OVERLAY=(1:C'GGA',4:1,15)),

         IFTHEN=(WHEN=(1,2,CH,EQ,C'WG'),
                 OVERLAY=(1:C'AFG',4:1,15)),

         IFTHEN=(WHEN=(1,3,CH,EQ,C'IUL'),
                 OVERLAY=(1:C'AFG',4:1,15)),

         IFTHEN=(WHEN=(1,2,CH,EQ,C'UL'),
                 OVERLAY=(1:C'AFG',4:1,15)),

         IFTHEN=(WHEN=(1,1,CH,EQ,C'T'),
                 OVERLAY=(1:C'AFG',4:1,15)),

         IFTHEN=(WHEN=(1,2,CH,EQ,C'23'),
                 OVERLAY=(1:C'023',4:1,15)),

         IFTHEN=(WHEN=NONE,
                 OVERLAY=(1:3X,4:1,15)))   
Back to top
View user's profile Send private message
Poha Eater

New User


Joined: 31 Aug 2016
Posts: 17
Location: India

PostPosted: Sun Oct 01, 2017 2:05 pm    Post subject:
Reply with quote

Hi Magesh,

Thanks for the quick reply. I have tried your code but getting some errors. The input file was created after FTP a notepad file to Mainframe.

The data in the input is starting from 9th or 10th byte. When the post was pasted here, it somehow removed the leading spaces from all the records that is why it is showing that the data is starting from 1st byte. I am pasting the input file below :

Code:

        0000L01762
           4875851
        IM10000929
           3400009
        WG10004785
        IUL1000016
        UL10000006
        T700000011
        2307900026


Error i am getting :

Code:

           SORT FIELDS=COPY                                                   
           OUTREC IFTHEN=(WHEN=(9,3,ZD,EQ,000),OVERLAY=(1:C'GGA',4:4,15)),     
                  IFTHEN=(WHEN=(9,3,CH,EQ,'IM1'),OVERLAY=(1:C'GGA',4:4,15)),   
                                          $                                   
ICE113A E COMPARISON FIELD ERROR                                               
                  IFTHEN=(WHEN=(10,3,ZD,CH,'  4'),OVERLAY=(1:C'GGA',4:4,15)), 
                  $                                                           
ICE005A 0 BLANK NEEDED IN COLUMN 1 OR OPERATION NOT DEFINED CORRECTLY         
                  IFTHEN=(WHEN=(10,3,CH,EQ,'  3'),OVERLAY=(1:C'GGA',4:4,15)), 
                  $                                                           
ICE005A 0 BLANK NEEDED IN COLUMN 1 OR OPERATION NOT DEFINED CORRECTLY         
                  IFTHEN=(WHEN=(9,2,CH,EQ,'WG'),OVERLAY=(1:C'AFG',4:4,15)),   
                  $                                                           
ICE005A 0 BLANK NEEDED IN COLUMN 1 OR OPERATION NOT DEFINED CORRECTLY         
                  IFTHEN=(WHEN=(9,3,CH,EQ,'IUL'),OVERLAY=(1:C'AFG',4:4,15)),   
                  $


I can really use some guidance here because i need to deliver this tomorrow anyhow. As of now i am testing this on a sample data. Once it works here then i need to run same conditions on a file which contains more than 600,000 records so Please help !!

Thanks a lot in advance.
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10375
Location: italy

PostPosted: Sun Oct 01, 2017 2:20 pm    Post subject:
Reply with quote

Quote:
I can really use some guidance here because i need to deliver this tomorrow anyhow.


You should remember that people answer
ON THEIR OWN TIME
FREE OF CHARGE

if You have time constraints a forum is not the place to ask for help
a paid consultant - for the proper fee - will be happy to provide assistance according to your plans
Back to top
View user's profile Send private message
Poha Eater

New User


Joined: 31 Aug 2016
Posts: 17
Location: India

PostPosted: Sun Oct 01, 2017 2:41 pm    Post subject:
Reply with quote

Hi Enrico,

You are right, my bad !


Thanks !
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10375
Location: italy

PostPosted: Sun Oct 01, 2017 2:55 pm    Post subject:
Reply with quote

the DFSORT manuals, or a simple search of the forums will certainly tell
the proper format of the comparison statement
if You had done the due diligence You should not have had the need to ask

and ... why in &heaven didn' t You follow the syntax of Magesh suggestion ?
Back to top
View user's profile Send private message
Poha Eater

New User


Joined: 31 Aug 2016
Posts: 17
Location: India

PostPosted: Sun Oct 01, 2017 3:12 pm    Post subject:
Reply with quote

Hi Enrico,

The data in the file is starting from 9th byte instead of 1st byte. In each data there are leading spaces that is why i wrote the SORT card starting from 9th byte instead of 1st byte as Magesh suggested.

The input file was created after FTP a Notepad file. This is why i am confused about the data type which i need to mentioned in SORT card.

Code:

                  IFTHEN=(WHEN=(9,3,CH,EQ,'IM1'),OVERLAY=(1:C'GGA',4:4,15)),   
                                          $                                   
ICE113A E COMPARISON FIELD ERROR                                               


'IM1' seems to be a character format and that is why i have given CH here but it is giving comparison field error. I am not sure what else i can give here to make it work.

(Mod: corrected cut'n'paste in this post. Cleaned up earlier posts)
Back to top
View user's profile Send private message
Poha Eater

New User


Joined: 31 Aug 2016
Posts: 17
Location: India

PostPosted: Sun Oct 01, 2017 3:41 pm    Post subject:
Reply with quote

Hi Enrico,

I get your point when you said :
Quote:
and ... why in &heaven didn' t You follow the syntax of Magesh suggestion ?


I have realized now where i was missing and corrected the syntax as per Magesh.

I am getting the expected output.

Thanks a lot Magesh and Enrico. icon_biggrin.gif
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 Split files upto certain limit based ... bubbu75 DFSORT/ICETOOL 5 Tue Nov 14, 2017 11:11 pm
No new posts sort records based on length exceeds ... maxsubrat DFSORT/ICETOOL 7 Wed Oct 04, 2017 4:48 pm
No new posts Execute JCL step based on the content... sprikitik JCL & VSAM 2 Tue Oct 03, 2017 10:03 am
No new posts Insert a Row_number into table useit DB2 2 Tue Sep 19, 2017 1:07 pm
No new posts BUILD OUTFIL based on condition other... balaji81_k DFSORT/ICETOOL 13 Fri Sep 08, 2017 11:06 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us