Issue while reading format S370FPD9 from mainframe

Accepted Solution Solved
Reply
Contributor
Posts: 60
Accepted Solution

Issue while reading format S370FPD9 from mainframe

Hi,


I am reading a file from mainframe enviroment but getting an error while reading S370FPD9 format. This is something I am doing first time.


DATA READIN;

INFILE IN1 LRECL=3D220 RECFM=3DF LENGTH=3DLEN MISSOVER OBS=3D20;

INPUT

@1 B_SYS_ID S370FIB4.

@5 C_TCN_NUM S370FPD9.

@14 C_HDR_SVC_FST_DT YYMMDD10.

@24 C_HDR_SVC_LST_DT YYMMDD10.

@34 C_HDR_TY_CD $1.

@35 C_HDR_ID_CD $2.

@37 A_ID $11.

@48 A_TY_CD $1.

@49 B_ALT_ID 14.

;

FORMAT C_HDR_SVC_FST_DT C_HDR_SVC_LST_DT MMDDYY10.;

RUN;

All but the 2nd variable readin correctly. For=20

C_TCN_NUM, I get an "invalid data" message like=20

this (I converted the ID variables to 0's for sharing/privacy purposes):

NOTE: The infile IN1 is:

File Name=3DF:\Samhsa\Data\MSRAW\DO04001639\CHMAINTB.DA T,

RECFM=3DF,LRECL=3D220

NOTE: Invalid data for C_TCN_NUM in line 1 5-13.

RULE:=20

----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+-=

---8----+----9----+----0=20

1 CHAR ..=A9}..=84.m=F8=B9.@2003-01-182003-01-18P60=20

0000035089883209014729A01

ZONE=20

00A700816FB043333233233333323323353322222222222233 33333333333333333333433222=

222222222222222222222222

NUMR=20

009D3243D89102003D01D182003D01D1806000000000000000 00035089883209014729101000=

000000000000000000000000

101 0C030243339490220173085M05=20

0001-01-010001-01-01.......................=E2..N.=EF.=DAa~2003-01-2

ZONE=20

22222234333333333333333333333433222222333323323333 33233233000000000000000000=

00000E0040E0D67333323323

NUMR=20

00000003030243339490220173085D050000000001D01D0100 01D01D010000000C00000C0000=

0C00020CE0F0A1E2003D01D2

201 52003-01-27......NP.

ZONE 33333233233000011450

NUMR 52003D01D2700020CE0A

LEN=3D220 B_SYS_ID=3D00000 C_TCN_NUM=3D.=20

C_HDR_SVC_FST_DT=3D01/18/2003=20

C_HDR_SVC_LST_DT=3D01/18/2003 C_HDR_TY_CD=3DP C_HDR_ID_CD=3D60 A_ID=3D

A_TY_CD=3D B_ALT_ID=3D000000000 _ERROR_=3D1 _N_=3D1

NOTE: Invalid data for C_TCN_NUM in line 2 5-13.



Let me know if any other info is required.


Accepted Solutions
Solution
‎10-09-2014 12:51 PM
Super Contributor
Posts: 358

Re: Issue while reading format S370FPD9 from mainframe

Posted in reply to PravinMishra

It looks like you are downloading a file from a mainframe and then processing it on a local server.   You can't just download pack fields from the mainframe because of the conversion from EBCDIC to ACSII.  The download process screws up the hex value of the packed fields which is causing the problem.

Your best solution is to unpack the field on the mainframe before you download it to your local system.

View solution in original post


All Replies
Solution
‎10-09-2014 12:51 PM
Super Contributor
Posts: 358

Re: Issue while reading format S370FPD9 from mainframe

Posted in reply to PravinMishra

It looks like you are downloading a file from a mainframe and then processing it on a local server.   You can't just download pack fields from the mainframe because of the conversion from EBCDIC to ACSII.  The download process screws up the hex value of the packed fields which is causing the problem.

Your best solution is to unpack the field on the mainframe before you download it to your local system.

Trusted Advisor
Posts: 3,215

Re: Issue while reading format S370FPD9 from mainframe

OS2rules your are correct.  Downloading  with ebcdic ascii translation and then reading binary data is fail  form start.

There are 2 options.

1/ Convert all data on the mainframe to something readable. eliminating all binary data.

2/ Download the file binary including the RDW. Process it in SAS (windows/Unix) using the mainframe types.

The question is who doing the work and thinking. 

---->-- ja karman --<-----
New Contributor
Posts: 2

Re: Issue while reading format S370FPD9 from mainframe

Posted in reply to PravinMishra

I disagree on manipulating the mainframe file on the mainframe - that sounds like more work than jsut handling it in SAS directly. You absolutely need to download the file as binary rather than as ASCII. If you've got a command-line FTP at your disposal you might just want to try typing 'binary' in the command line.

From there, the EBCDIC formats are easy enough - to get a nice date out of it you'll need to use an input statement though. My mainframe formats are a bit rusty, but something like  :

DATA READIN;

INFILE IN1 LRECL=3D220 RECFM=3DF LENGTH=3DLEN MISSOVER OBS=3D20;

INPUT

   @1 B_SYS_ID S370FIB4.

   @5 C_TCN_NUM S370FPD9.

   @14 _XC_HDR_SVC_FST_DT $EBCDIC10.

   @24 _XC_HDR_SVC_LST_DT $EBCDIC10.

   @34 C_HDR_TY_CD $EBCDIC1.

   @35 C_HDR_ID_CD $EBCDIC2.

   @37 A_ID $EBCDIC11.

   @48 A_TY_CD $EBCDIC1.

   @49 B_ALT_ID S370FZD14.

;

FORMAT C_HDR_SVC_FST_DT C_HDR_SVC_LST_DT MMDDYY10.;

C_HDR_SVC_FST_DT = INPUT(_XC_HDR_SVC_FST_DT,MMDDYY10.);

C_HDR_SVC_LST_DT = INPUT(_XC_HDR_SVC_LST_DT,MMDDYY10.);

DROP _X:;

RUN;

Should do the trick.

Super User
Posts: 10,044

Re: Issue while reading format S370FPD9 from mainframe

Posted in reply to PravinMishra

INFILE IN1 encoding=EBCDIC037 recfm=s370v termstr=nl   ;

Trusted Advisor
Posts: 3,215

Re: Issue while reading format S370FPD9 from mainframe

Posted in reply to PravinMishra

Do not use the termstr when having downloaded the file really binary. There should be no newlines being inserted

Mainframe are having a better designed record orientation as the common known dedicated byte approach. They are:

- Fixed  Used that length

- Variable with a preceding with a rdw (record descriptor word).

The block length is dedicated hardware oriented not visible after download

see: TS-DOC: TS-642 - Reading EBCDIC Files on ASCII Systems

---->-- ja karman --<-----
🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 5 replies
  • 385 views
  • 0 likes
  • 5 in conversation