MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Getting File from Unix(SAP) to mainframe and parse thru Sort

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
Suchay
Beginner


Joined: 29 Jun 2017
Posts: 43
Topics: 9

PostPosted: Fri Feb 16, 2018 12:08 pm    Post subject: Getting File from Unix(SAP) to mainframe and parse thru Sort Reply with quote

We are receiving the file from SAP (Unix server). It is a report in a.TXT file. When we received the file to mainframes, it could not recognize the End of Line character (X’25’) from unix.

FTP command to receive the file:
Code:

cd /out/                                                         
locsite wrap                                   (After using this command we were able to get all the data but it was wrapped)
get TST00005-001.20180215.062850.1.txt 'Host file’ (REPLACE
QUIT                                                                   


Problem:
The data in the file is wrapped. We want it to be fixed 132 bytes like shown in Expected output.
Input:

Code:

Sample:
RPT00005                                    ABCD XYZ Accept.Corp           TS-040                                  Page:      1X’25’
XXX_FI                                             Sample Report                                                02/16/2018 X’25’005 
                                                                                                                    04:43:18 X’25’--------   
--------------------------------------------------------------------------------------------------------------------x’25’


Expected Output:

Code:


RPT00005                                    ABCD XYZ Accept.Corp           TS-040                                  Page:      1x’25’
XXX_FI                                             Sample Report                                                    02/16/2018  x’25’
005                                                                                                                    04:43:18    x’25’
-----------------------------------------------------------------------------------------------------------------------------------



We tried to parse the record using the below sort but only the first record was right. Rest of the records were still wrapped. I am not sure how we could use the REPEAT command, since we do not know how many Line Feed characters are available in this file.

Code:


OPTION COPY                                                           
INREC PARSE=(%00=(ABSPOS=1,STARTAFT=X'25',ENDBEFR=X'25',FIXLEN=131)),
BUILD=(1:%00)                                                         


Please advise
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Fri Feb 16, 2018 12:54 pm    Post subject: Reply with quote

Suchay,

What is the type of transfer you used in FTP? BINARY or ASCII ? Looks like you are transferring it as byte stream.

And you should use ENDAT instead of STARTAFT and ENDBEFR as you need to distinguish the records split across lines.
Code:

PARSE=(%01=(ENDAT=X'25'

_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
tsharsri
Beginner


Joined: 16 Feb 2018
Posts: 3
Topics: 0

PostPosted: Mon Feb 19, 2018 6:45 am    Post subject: Reply with quote

Hi Kolusu,
Thanks for the suggestion. And, sorry I think I gave the sample input incorrectly. The requirement is to move any characters after X'25' to next line. When I used, ENDAT, it truncated the data after X'25'. I tried removing FIXLEN and just using ENDAT, but I get syntax error.

Updated Requirement:
Input file length 133 bytes (Include X'25')


Code:

OPTION COPY                                 
INREC PARSE=(%00=(ENDAT=X'25',FIXLEN=133)), 
     BUILD=(1:%00)                           



Code:

Input:

----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2----+----3---
********************************* Top of Data **************************************** Top of Data **********************************
ABC00005                                     xxxxx xxxxx Accept.Corp           GL-040                                  Page:   43071.
A000291                                       Sample Journals Report                                                   02/15/2018.005
                                                                                                                    05:36:56.--------
-----------------------------------------------------------------------------------------------------------------------------..Company
Code:      xxxx                     Document Type:   XX                Entry Date:       07/25/2017.Document Number:   999999999   



Code:

Output:

----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2----+----3---
ABC00005                                    xxxxx xxxxx Accept.Corp           GL-040                                  Page:   43071.
A000291                                      Sample Journals Report                                                   02/15/2018.
005                                                                                                                   05:36:56.
------------------------------------------------------------------------------------------------------------------------------------.
Company Code:      xxxx                     Document Type:   XX                Entry Date:       07/25/2017.
Document Number:   999999999                                                   Entry Time:       09:20:43.


_________________
Thanks
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Mon Feb 19, 2018 10:32 am    Post subject: Reply with quote

tsharsri wrote:
Hi Kolusu,
Thanks for the suggestion. And, sorry I think I gave the sample input incorrectly. The requirement is to move any characters after X'25' to next line. When I used, ENDAT, it truncated the data after X'25'. I tried removing FIXLEN and just using ENDAT, but I get syntax error.

Updated Requirement:
Input file length 133 bytes (Include X'25')



tshasri,

The first rule of seeking help is to pay attention to the questions asked and answer them. I asked you a question about transfer method and you did not even bother to answer that.

Secondly, you do need to use ENDAT but your Parse should have the maximum number to account for each record. For example if your input is LRECL 1340 (10 records + 10 delimiters) then you need a max of 10 parsed fields. The reason You need to have ENDAT is because you need to distinguish the records which are split across records. The record that does not have the delimiter is the one that is split across records, so you need to join that record. You need 2 passes to reconstruct the file.

So pay attention to what is being asked and suggested and then you work on it.

What is the Input LRECL and RECFM?
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
tsharsri
Beginner


Joined: 16 Feb 2018
Posts: 3
Topics: 0

PostPosted: Mon Feb 19, 2018 11:02 am    Post subject: Reply with quote

Sorry I missed to pay attention to your questions.

We used ASCII mode of transfer to recieve the file and used LOCSITE WRAP. The LRECL of the file is 133 bytes.

Code:

cd /out/                                                         
ASCII                                                                   
locsite wrap                                                           
get ABC00005-006.20180215.063242.6.txt 'ABC.ABC00005.RPT006.REC133' (REPLACE


Some records have 1 delimiter and some have 2. Whenever there is an empty line between two records, we are getting 2 delimiters. Otherwise, its one delimiter per record.

We are requesting the source team to add carriage return character along with the line feed to the file but not sure if they will be able to add it.
_________________
Thanks
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Mon Feb 19, 2018 11:32 am    Post subject: Reply with quote

tsharsri wrote:
Sorry I missed to pay attention to your questions.

We used ASCII mode of transfer to recieve the file and used LOCSITE WRAP. The LRECL of the file is 133 bytes.


It is LOCSITE WRAPRECORD.

tsharsri wrote:

Some records have 1 delimiter and some have 2. Whenever there is an empty line between two records, we are getting 2 delimiters. Otherwise, its one delimiter per record.

We are requesting the source team to add carriage return character along with the line feed to the file but not sure if they will be able to add it.


If your records only have a maximum of 2 delimiters then you use the following control cards. I assumed that your 2 delimiter records are always an all spaces line.

Code:

//SYSIN    DD *                                                   
  OPTION COPY                                                     
  OUTREC PARSE=(%01=(ENDAT=X'25',FIXLEN=133),                     
                %02=(ENDAT=X'25',FIXLEN=133)),                     
         BUILD=(%01,%02)                                           
                                                                   
  OUTFIL IFOUTLEN=132,                                             
         IFTHEN=(WHEN=(001,2,CH,NE,X'2540',AND,                   
                       134,2,CH,EQ,X'4025'),                       
         BUILD=(1,132,/,X)),                                       
         IFTHEN=(WHEN=(001,2,CH,EQ,X'2540',AND,                   
                       134,2,CH,EQ,X'4025'),                       
         BUILD=(X))                                           
//*

_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Tue Feb 20, 2018 10:43 am    Post subject: Reply with quote

kolusu,

I realized that I have not removed the X'25' from the records.

add the following
Code:

ALTSEQ CODE=(2540)

and change

Code:

BUILD=(1,132,/,X)),


to

Code:

BUILD=(1,132,TRAN=ALTSEQ,/,X)),

_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
tsharsri
Beginner


Joined: 16 Feb 2018
Posts: 3
Topics: 0

PostPosted: Tue Feb 20, 2018 1:32 pm    Post subject: Reply with quote

Thanks a lot. I tried both these solutions. In some lines, the strings after the x'25' got trimmed.
The source team has finally agreed to write file with CRLF character and so the file is fixed at it's source.
Thank you again.
_________________
Thanks
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> 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


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group