Copying the VB file to VB file



IBM's flagship sort product DFSORT for sorting, merging, copying, data manipulation and reporting. Includes ICETOOL and ICEGENER

Copying the VB file to VB file

Postby Dhanu0009 » Tue Sep 17, 2019 6:27 pm

Hi Team,
I have a requirement to copy the VB file of rec-length:4580 to VB file based on Delimitor count upto 95 only from each record even if input record has more that delimitor fields only.Each field is associated with the | delimitor.need to truncate the fields after 95th delimitor.Can you please help

Infile:
1|2|3|...………..|95|96|...…|9999

Output:
1|2|3|...….|95
Dhanu0009
 
Posts: 7
Joined: Tue Sep 17, 2019 6:20 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Copying the VB file to VB file

 

Re: Copying the VB file to VB file

Postby NicC » Tue Sep 17, 2019 6:49 pm

Why Easytrieve? If I understand you through all the mud of your description then this is simple in DFSort/Syncsort - simply parse out the first 95 fields and build your output using those 95 fields.
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 3004
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisies (almost)
Has thanked: 4 times
Been thanked: 136 times

Re: Copying the VB file to VB file

Postby Dhanu0009 » Tue Sep 17, 2019 7:01 pm

Thank you for quick reply...By using the Parse, we are building the fixed record legth w.r.to field length. let say field-1in input file has X(06) but content as ABC|DEF|..... etc. But with the parse the output will be ABC |CDF |...etc ...how we can exclude the spaces in outrec.I tried with Parse but not getting how to remove those spaces after building the field length fields

Input file:
LG|LG||065065042|20190613|20190613|10600|DWTF|101||103K40B00001GD|

Parse-Output:

LG |LG | |065065042 |20190613|20190613|

Expected-Output:
LG|LG||065065042|20190613|20190613|10600|DWTF|101||103K40B00001GD|..upto 95 | dleimitors only.
Dhanu0009
 
Posts: 7
Joined: Tue Sep 17, 2019 6:20 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Copying the VB file to VB file

Postby NicC » Tue Sep 17, 2019 8:39 pm

Show your control cards - and use the code tags when posting data - especially when there are multiple spaces.
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 3004
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisies (almost)
Has thanked: 4 times
Been thanked: 136 times

Re: Copying the VB file to VB file

Postby sergeyken » Tue Sep 17, 2019 9:31 pm

Dhanu0009 wrote:By using the Parse, we are building the fixed record legth w.r.to field length. let say field-1in input file has X(06) but content as ABC|DEF|..... etc. But with the parse the output will be ABC |CDF |...etc ...how we can exclude the spaces in outrec.

 OUTREC BUILD=(%1... %95)...
 OUTFIL FTOV,                           change RECFM to VB
       BUILD=(1,length,SQZ=(SHIFT=LEFT)), remove all intermediate spaces
       VLTRIM=C' '                     truncate tail spaces as well    

Alternatively, parameter SQZ can be applied to each of 95 parsed fields (OMG!)
sergeyken
 
Posts: 100
Joined: Wed Jul 24, 2019 10:12 pm
Has thanked: 2 times
Been thanked: 10 times

Re: Copying the VB file to VB file

Postby sergeyken » Tue Sep 17, 2019 9:53 pm

REXX can be used as straightforward solution, too
//* REXX */                                                          
/* . . . . . . . . . . . . . . . */                                  
                                                                     
"NEWSTACK"                                                          
                                                                     
Do iRec = 1 By 1                                                    
   "EXECIO 1 DISKR INFILE"                                          
   If RC = 2 Then                                                    
      Leave iRec                                                    
                                                                     
   Parse Pull OldRecord                                              
   NextPos = 1                                                      
   Do iField = 1 To 95         /* jump over up to 95 fields */                                            
      SkipTo = Index( OldRecord, '|', NextPos )                      
      If SkipTo = 0 Then Do      /* less than 95 separators? */      
         NextPos = Length(OldRecord) + 1  /* use full record */      
         Leave iField            /* break search */                  
      End                                                            
      NextPos = SkipTo + 1   /* continue after next separator */    
   End iField                                                        
   GoodSize = NextPos - 1                                            
   NewRecord = Left( OldRecord, GoodSize )                          
   Push NewRecord                                                    
   "EXECIO 1 DISKW OUTFILE"                                          
End iRec                                                            
                                                                     
"DELSTACK"                                                          
                                                                     
"EXECIO 0 DISKR INFILE (FINIS"                                      
"EXECIO 0 DISKW OUTFILE (FINIS"                                      
/* . . . . . . . . . . . . . . . */                                  
 
sergeyken
 
Posts: 100
Joined: Wed Jul 24, 2019 10:12 pm
Has thanked: 2 times
Been thanked: 10 times

Re: Copying the VB file to VB file

Postby sergeyken » Tue Sep 17, 2019 10:02 pm

If dataset is not expected to be a huge one then REXX code can be simplified, and I/O optimized
/* REXX */                                                          
/* . . . . . . . . . . . . . . . */                                  
                                                                     
"NEWSTACK"                                                          
                                                                     
"EXECIO * DISKR INFILE (FINIS"                                      
TotalLines = Queued()                                                
Do iRec = 1 To TotalLines                                            
   Parse Pull OldRecord                                              
   NextPos = 1                                                      
   Do iField = 1 To 95                                              
      SkipTo = Index( OldRecord, '|', NextPos )                      
      If SkipTo = 0 Then Do      /* less than 95 separators? */      
         NextPos = Length(OldRecord) + 1  /* use full record */      
         Leave iField            /* break search */                  
      End                                                            
      NextPos = SkipTo + 1   /* continue after next separator */    
   End iField                                                        
   GoodSize = NextPos - 1                                            
   NewRecord = Left( OldRecord, GoodSize )                          
   Queue NewRecord                                                  
End iRec                                                            
"EXECIO" Queued() "DISKW OUTFILE (FINIS"                            
                                                                     
"DELSTACK"                                                          
                                                                     
/* . . . . . . . . . . . . . . . */                                  
 
sergeyken
 
Posts: 100
Joined: Wed Jul 24, 2019 10:12 pm
Has thanked: 2 times
Been thanked: 10 times

Re: Copying the VB file to VB file

Postby Dhanu0009 » Wed Sep 18, 2019 10:46 am

@ sergeyken, Can you please help to elaborate the SORT ccard w.r.to one field with SQZ and VLTRIM

Input:
HR|20190613|GD|1|1|
LG|LG||065065042|20190613|20190613|.....
LG|LG||065065042|20190613|20190613|.....
TR|2|20190613|0|202|0|2|

Output With Parse:
HR |201906|GD |1 |1 | |
LG |LG | |065065042 |20190613|20190613|
LG |LG | |065065042 |20190613|20190613|
TR |2 |20190613 |0 |202 |0 |

Sort CCard:

INREC PARSE=(%01=(ENDBEFR=C'|',FIXLEN=06),
%02=(ENDBEFR=C'|',FIXLEN=06),
%03=(ENDBEFR=C'|',FIXLEN=10),
%04=(ENDBEFR=C'|',FIXLEN=34),
%05=(ENDBEFR=C'|',FIXLEN=08),
%06=(ENDBEFR=C'|',FIXLEN=08),
%07=(ENDBEFR=C'|',FIXLEN=06),
%08=(ENDBEFR=C'|',FIXLEN=04),
%09=(ENDBEFR=C'|',FIXLEN=19),
%10=(ENDBEFR=C'|',FIXLEN=19),
%11=(ENDBEFR=C'|',FIXLEN=30),
%12=(ENDBEFR=C'|',FIXLEN=10),
%13=(ENDBEFR=C'|',FIXLEN=10),
%14=(ENDBEFR=C'|',FIXLEN=10),
%15=(ENDBEFR=C'|',FIXLEN=03),
%16=(ENDBEFR=C'|',FIXLEN=01),
%17=(ENDBEFR=C'|',FIXLEN=19),
%18=(ENDBEFR=C'|',FIXLEN=19),
%19=(ENDBEFR=C'|',FIXLEN=03),
%20=(ENDBEFR=C'|',FIXLEN=15),
%21=(ENDBEFR=C'|',FIXLEN=01),
%22=(ENDBEFR=C'|',FIXLEN=34),
%23=(ENDBEFR=C'|',FIXLEN=50),
%24=(ENDBEFR=C'|',FIXLEN=70),
%25=(ENDBEFR=C'|',FIXLEN=01),
%26=(ENDBEFR=C'|',FIXLEN=210),
%27=(ENDBEFR=C'|',FIXLEN=01),
%28=(ENDBEFR=C'|',FIXLEN=210),
%29=(ENDBEFR=C'|',FIXLEN=01),
%30=(ENDBEFR=C'|',FIXLEN=210),
%31=(ENDBEFR=C'|',FIXLEN=01),
%32=(ENDBEFR=C'|',FIXLEN=210),
%33=(ENDBEFR=C'|',FIXLEN=01),
%34=(ENDBEFR=C'|',FIXLEN=210),
%35=(ENDBEFR=C'|',FIXLEN=01),
%36=(ENDBEFR=C'|',FIXLEN=210),
%37=(ENDBEFR=C'|',FIXLEN=01),
%38=(ENDBEFR=C'|',FIXLEN=210),
%39=(ENDBEFR=C'|',FIXLEN=01),
%40=(ENDBEFR=C'|',FIXLEN=210),
%41=(ENDBEFR=C'|',FIXLEN=01),
%42=(ENDBEFR=C'|',FIXLEN=210),
%43=(ENDBEFR=C'|',FIXLEN=05),
%44=(ENDBEFR=C'|',FIXLEN=01),
%45=(ENDBEFR=C'|',FIXLEN=1000),
%46=(ENDBEFR=C'|',FIXLEN=02),
%47=(ENDBEFR=C'|',FIXLEN=02),
%48=(ENDBEFR=C'|',FIXLEN=02),
%49=(ENDBEFR=C'|',FIXLEN=02),
%50=(ENDBEFR=C'|',FIXLEN=02),
%51=(ENDBEFR=C'|',FIXLEN=02),
%52=(ENDBEFR=C'|',FIXLEN=01),
%53=(ENDBEFR=C'|',FIXLEN=02),
%54=(ENDBEFR=C'|',FIXLEN=02),
%55=(ENDBEFR=C'|',FIXLEN=02),
%56=(ENDBEFR=C'|',FIXLEN=02),
%57=(ENDBEFR=C'|',FIXLEN=60),
%58=(ENDBEFR=C'|',FIXLEN=20),
%59=(ENDBEFR=C'|',FIXLEN=20),
%60=(ENDBEFR=C'|',FIXLEN=60),
%61=(ENDBEFR=C'|',FIXLEN=20),
%62=(ENDBEFR=C'|',FIXLEN=20),
%63=(ENDBEFR=C'|',FIXLEN=60),
%64=(ENDBEFR=C'|',FIXLEN=20),
%65=(ENDBEFR=C'|',FIXLEN=20),
%66=(ENDBEFR=C'|',FIXLEN=60),
%67=(ENDBEFR=C'|',FIXLEN=20),
%68=(ENDBEFR=C'|',FIXLEN=20),
%69=(ENDBEFR=C'|',FIXLEN=60),
%70=(ENDBEFR=C'|',FIXLEN=20),
%71=(ENDBEFR=C'|',FIXLEN=20),
%72=(ENDBEFR=C'|',FIXLEN=60),
%73=(ENDBEFR=C'|',FIXLEN=20),
%74=(ENDBEFR=C'|',FIXLEN=20),
%75=(ENDBEFR=C'|',FIXLEN=60),
%76=(ENDBEFR=C'|',FIXLEN=20),
%77=(ENDBEFR=C'|',FIXLEN=20),
%78=(ENDBEFR=C'|',FIXLEN=60),
%79=(ENDBEFR=C'|',FIXLEN=20),
%80=(ENDBEFR=C'|',FIXLEN=20),
%81=(ENDBEFR=C'|',FIXLEN=60),
%82=(ENDBEFR=C'|',FIXLEN=20),
%83=(ENDBEFR=C'|',FIXLEN=20),
%84=(ENDBEFR=C'|',FIXLEN=60),
%85=(ENDBEFR=C'|',FIXLEN=20),
%86=(ENDBEFR=C'|',FIXLEN=20),
%87=(ENDBEFR=C'|',FIXLEN=16),
%88=(ENDBEFR=C'|',FIXLEN=16),
%89=(ENDBEFR=C'|',FIXLEN=75),
%90=(ENDBEFR=C'|',FIXLEN=01),
%91=(ENDBEFR=C'|',FIXLEN=30),
%92=(ENDBEFR=C'|',FIXLEN=30),
%93=(ENDBEFR=C'|',FIXLEN=30),
%94=(ENDBEFR=C'|',FIXLEN=13),
%95=(ENDBEFR=C'|',FIXLEN=13),
%96=(ENDBEFR=C'|',FIXLEN=13)),
BUILD=(1,4,%01,C'|',%02,C'|',%03,C'|',%04,C'|',%05,C'|',%06,C'|',
%07,C'|',%08,C'|',%09,C'|',%10,C'|',%11,C'|',%12,C'|',
%13,C'|',%14,C'|',%15,C'|',%16,C'|',%17,C'|',%18,C'|',
%19,C'|',%20,C'|',%21,C'|',%22,C'|',%23,C'|',%24,C'|',
%25,C'|',%26,C'|',%27,C'|',%28,C'|',%29,C'|',%30,C'|',
%31,C'|',%32,C'|',%33,C'|',%34,C'|',%35,C'|',%36,C'|',
%37,C'|',%38,C'|',%39,C'|',%40,C'|',%41,C'|',%42,C'|',
%43,C'|',%44,C'|',%45,C'|',%46,C'|',%47,C'|',%48,C'|',
%49,C'|',%50,C'|',%51,C'|',%52,C'|',%53,C'|',%54,C'|',
%55,C'|',%56,C'|',%57,C'|',%58,C'|',%59,C'|',%60,C'|',
%61,C'|',%62,C'|',%63,C'|',%64,C'|',%65,C'|',%66,C'|',
%67,C'|',%68,C'|',%69,C'|',%70,C'|',%71,C'|',%72,C'|',
%73,C'|',%74,C'|',%75,C'|',%76,C'|',%77,C'|',%78,C'|',
%79,C'|',%80,C'|',%81,C'|',%82,C'|',%83,C'|',%84,C'|',
%85,C'|',%86,C'|',%87,C'|',%88,C'|',%89,C'|',%90,C'|',
%91,C'|',%92,C'|',%93,C'|',%94,C'|',%95,C'|',%96)
OUTFIL FTOV,
BUILD=(1,6,SQZ=(SHIFT=LEFT)),VLTRIM=C' '
OPTION COPY
ALTSEQ CODE=(40F0)
Dhanu0009
 
Posts: 7
Joined: Tue Sep 17, 2019 6:20 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Copying the VB file to VB file

Postby NicC » Wed Sep 18, 2019 1:32 pm

What do you need to elaborate that is not in the manual? Why are you making your fields fixed length?
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 3004
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisies (almost)
Has thanked: 4 times
Been thanked: 136 times

Re: Copying the VB file to VB file

Postby Dhanu0009 » Wed Sep 18, 2019 2:18 pm

Why are you making your fields fixed length?--> Is there any other option not to use FIXLEN parameter through PARSE
Dhanu0009
 
Posts: 7
Joined: Tue Sep 17, 2019 6:20 pm
Has thanked: 0 time
Been thanked: 0 time

Next

Return to DFSORT/ICETOOL/ICEGENER

 


  • Related topics
    Replies
    Views
    Last post