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

fields truncated in csv file


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
sakrat

Active User


Joined: 05 Feb 2014
Posts: 164
Location: India

PostPosted: Thu May 14, 2015 11:06 pm
Reply with quote

vasanthz wrote:
Quote:
One last doubt can we format the record when sending as csv file like I want the header row to have different background color and in Bold.


It is 'un'possible to have formatting with ODS CSV.
Use something like ODS HTML while creating output file.

Code:
ODS LISTING CLOSE;
ODS HTML FILE='some VB PS file' style=sasweb rs=none;
proc print ...
..
run;
ODS HTML CLOSE;
ODS LISTING;

STYLE=SASWEB or MINIMAL or anything else
STYLE element gives a predefined style. If you need customized styles you may need to use PROC TEMPLATE to edit the styles.



Actually I have detailed records in one ps file and the header record in one ps file.

The PS file containing the detailed records is processed from the SAS code which I have shown earlier in the above link provided.

The header record is just a normal PS file written manually with comma separated format.

I use SORT fields=copy and merge the above two dataset, then use one more SAS code to send mail of the resultant dataset.

Can I use the formats which you have mentioned in the SAS code that which sends mail....?
Back to top
View user's profile Send private message
sakrat

Active User


Joined: 05 Feb 2014
Posts: 164
Location: India

PostPosted: Fri May 15, 2015 12:11 pm
Reply with quote

sakrat wrote:
vasanthz wrote:
Quote:
One last doubt can we format the record when sending as csv file like I want the header row to have different background color and in Bold.


It is 'un'possible to have formatting with ODS CSV.
Use something like ODS HTML while creating output file.

Code:
ODS LISTING CLOSE;
ODS HTML FILE='some VB PS file' style=sasweb rs=none;
proc print ...
..
run;
ODS HTML CLOSE;
ODS LISTING;

STYLE=SASWEB or MINIMAL or anything else
STYLE element gives a predefined style. If you need customized styles you may need to use PROC TEMPLATE to edit the styles.



Actually I have detailed records in one ps file and the header record in one ps file.

The PS file containing the detailed records is processed from the SAS code which I have shown earlier in the above link provided.

The header record is just a normal PS file written manually with comma separated format.

I use SORT fields=copy and merge the above two dataset, then use one more SAS code to send mail of the resultant dataset.

Can I use the formats which you have mentioned in the SAS code that which sends mail....?


So here is my code below where I have concatenated the detailed record and the Header record:

Code:


//FNDRPLCE EXEC PGM=SORT
//SORTIN   DD   DSN=***.CNTRLM.HEADER,DISP=SHR
//              DD   DSN=&&TEMP4,DISP=SHR
//SORTOUT  DD   DSN=***.***.FINAL.CNTRLM.RPT,
//          DISP=(NEW,CATLG,DELETE),
//          UNIT=PERMDA,
//          SPACE=(TRK,(7500,7500),RLSE),
//          DCB=(RECFM=FB,LRECL=1202,BLKSIZE=0)
//SYSPRINT DD   SYSOUT=*
//SYSOUT   DD   SYSOUT=*
//SYSIN    DD   *
  OPTION COPY
  OUTREC FINDREP=(INOUT=(C'Q07',C'PRE',C'TRE',C'PRE'))
/*



***.CNTRLM.HEADER is the dataset that contains header with comma separated format

&&TEMP4 contains the detailed records.

Both are concatenated and put in the =***.***.FINAL.CNTRLM.RPT dataset.

below is the next step which sends mail in CSV format :

Code:


//SENDMAIL EXEC  SAS,
//             WORK='500,500',
//             OPTIONS='SORTWKNO=3 SORT=500'
//MAILADDR DD  DSN=***.***.CNTRL.EMAIL,DISP=SHR
//SYSIN    DD  *
FILENAME EMAIL EMAIL LRECL=503 RECFM=VB;

DATA NAMES;
  INFILE MAILADDR;
  INPUT
     @001 NAME           $CHAR60.
  ;

    DATA _NULL_;
    FILE EMAIL;
    SET NAMES END=LAST;
    LENGTH FIRSTNAME $20;
 FIRSTNAME=SCAN(NAME,1,'.');
 RETAIN FROMNAME ***@***.COM';
 PUT '!EM_FROM!' FROMNAME;
 PUT '!EM_TO!' NAME;
 PUT '!EM_SUBJECT! sub name;
 PUT 'Hi,  ';
 PUT '     ';
 PUT 'PLEASE FIND ATTACHED.';
 PUT '!EM_ATTACH!' "(***.***.FINAL.CNTRLM.RPT'
 NAME='CONTROL-M DOCUMENT' CONTENT_TYPE='TEXT/CSV' EXT='CSV' )";
 PUT '   ';
 PUT '*************************************************************';
 PUT 'Note : Please do not respond to this mail. ';
 PUT 'It is automatically generated from an unattended Mailbox. ';
 PUT '*************************************************************';
 PUT '!EM_SEND!';
     PUT '!EM_NEWMSG!';
     IF LAST THEN PUT '!EM_ABORT!';
     ;
     RUN;
 /*



So where can I use the formatting in these two steps so that the header is highlighed.
Back to top
View user's profile Send private message
vasanthz

Global Moderator


Joined: 28 Aug 2007
Posts: 1742
Location: Tirupur, India

PostPosted: Fri May 15, 2015 1:47 pm
Reply with quote

Hello,
It all seems to make sense now..
Did not knew that the previous post was related to this one.

As I understand, now you are writing the required output to a dataset via the put statement: You are manually generating a CSV file.
Code:
PUT
@1  CHNGTYPE $3.
@4  C  $1.
@5     JBNAME   $8.
.
.
.


A better and easier solution would be, just comment out the PUT statement altogether & don't write the CSV file to a PS file.

Have this step after the DATA step. This code basically creates a XML formatted file similar to the PUT statement & writes it to a PS file WELLS.PS.FILE.LRECL-10000.RECFM-VB
Code:
ODS LISTING CLOSE;
ODS MSOFFICE2K FILE='WELLS.PS.FILE.LRECL-10000.RECFM-VB' STYLE=NORMAL RS=NONE;
PROC PRINT DATA = FILE2 NOOBS;
RUN;
ODS MSOFFICE2K CLOSE;
ODS LISTING;

After this step Have a SAS email step like the one below. This step emails the XML file WELLS.PS.FILE.LRECL-10000.RECFM-VB.
Code:
 
//emailstep    EXEC    SAS
//HTMLOUT    DD       DSN=WELLS.PS.FILE.LRECL-10000.RECFM-VB,DISP=SHR
//SYSIN   DD *
FILENAME EMAIL EMAIL
 FROM = ("wells@yolo.com")
 TO = ("wells@yolo.com"
       "wells2@yolo.com")
 REPLYTO=("wells@yolo.com")
 SUBJECT="This is a nice formatted instream email."
 TYPE='TEXT/HTML';
DATA _NULL_;
FILE EMAIL;
INFILE HTMLOUT;
INPUT;
PUT _INFILE_;
RUN;


The above email step sends the report as instream email.
If you want the report as attachment, then there are small tunings on the EMAIL step with ATTACH keyword.
Back to top
View user's profile Send private message
sakrat

Active User


Joined: 05 Feb 2014
Posts: 164
Location: India

PostPosted: Fri May 15, 2015 2:29 pm
Reply with quote

vasanthz wrote:
Hello,
It all seems to make sense now..
Did not knew that the previous post was related to this one.

As I understand, now you are writing the required output to a dataset via the put statement: You are manually generating a CSV file.
Code:
PUT
@1  CHNGTYPE $3.
@4  C  $1.
@5     JBNAME   $8.
.
.
.


A better and easier solution would be, just comment out the PUT statement altogether & don't write the CSV file to a PS file.

Have this step after the DATA step. This code basically creates a XML formatted file similar to the PUT statement & writes it to a PS file WELLS.PS.FILE.LRECL-10000.RECFM-VB
Code:
ODS LISTING CLOSE;
ODS MSOFFICE2K FILE='WELLS.PS.FILE.LRECL-10000.RECFM-VB' STYLE=NORMAL RS=NONE;
PROC PRINT DATA = FILE2 NOOBS;
RUN;
ODS MSOFFICE2K CLOSE;
ODS LISTING;

After this step Have a SAS email step like the one below. This step emails the XML file WELLS.PS.FILE.LRECL-10000.RECFM-VB.
Code:
 
//emailstep    EXEC    SAS
//HTMLOUT    DD       DSN=WELLS.PS.FILE.LRECL-10000.RECFM-VB,DISP=SHR
//SYSIN   DD *
FILENAME EMAIL EMAIL
 FROM = ("wells@yolo.com")
 TO = ("wells@yolo.com"
       "wells2@yolo.com")
 REPLYTO=("wells@yolo.com")
 SUBJECT="This is a nice formatted instream email."
 TYPE='TEXT/HTML';
DATA _NULL_;
FILE EMAIL;
INFILE HTMLOUT;
INPUT;
PUT _INFILE_;
RUN;


The above email step sends the report as instream email.
If you want the report as attachment, then there are small tunings on the EMAIL step with ATTACH keyword.


What does MSOFFICE2K in the below line mean:
Code:

ODS MSOFFICE2K FILE='WELLS.PS.FILE.LRECL-10000.RECFM-VB' STYLE=NORMAL RS=NONE;


Also in the Email step you have specified TYPE='TEXT/HTML' what does HTML mean here. is it relating to some webpage...? Also in the TO line can I specify a dataset containing the Email ID's obtained through REXX PANEL where the user specifies the email-id's to which the document has to be sent mail. can you show me how will the code in case of attachment.....
Back to top
View user's profile Send private message
sakrat

Active User


Joined: 05 Feb 2014
Posts: 164
Location: India

PostPosted: Fri May 15, 2015 2:44 pm
Reply with quote

vasanthz wrote:
Hello,
It all seems to make sense now..
Did not knew that the previous post was related to this one.

As I understand, now you are writing the required output to a dataset via the put statement: You are manually generating a CSV file.
Code:
PUT
@1  CHNGTYPE $3.
@4  C  $1.
@5     JBNAME   $8.
.
.
.


A better and easier solution would be, just comment out the PUT statement altogether & don't write the CSV file to a PS file.

Have this step after the DATA step. This code basically creates a XML formatted file similar to the PUT statement & writes it to a PS file WELLS.PS.FILE.LRECL-10000.RECFM-VB
Code:
ODS LISTING CLOSE;
ODS MSOFFICE2K FILE='WELLS.PS.FILE.LRECL-10000.RECFM-VB' STYLE=NORMAL RS=NONE;
PROC PRINT DATA = FILE2 NOOBS;
RUN;
ODS MSOFFICE2K CLOSE;
ODS LISTING;

After this step Have a SAS email step like the one below. This step emails the XML file WELLS.PS.FILE.LRECL-10000.RECFM-VB.
Code:
 
//emailstep    EXEC    SAS
//HTMLOUT    DD       DSN=WELLS.PS.FILE.LRECL-10000.RECFM-VB,DISP=SHR
//SYSIN   DD *
FILENAME EMAIL EMAIL
 FROM = ("wells@yolo.com")
 TO = ("wells@yolo.com"
       "wells2@yolo.com")
 REPLYTO=("wells@yolo.com")
 SUBJECT="This is a nice formatted instream email."
 TYPE='TEXT/HTML';
DATA _NULL_;
FILE EMAIL;
INFILE HTMLOUT;
INPUT;
PUT _INFILE_;
RUN;


The above email step sends the report as instream email.
If you want the report as attachment, then there are small tunings on the EMAIL step with ATTACH keyword.


Also if I add this below code instead of PUT in the SAS code how will give the length for each field and calculation made for each field using CATX....

Code:

ODS LISTING CLOSE;
ODS MSOFFICE2K FILE='WELLS.PS.FILE.LRECL-10000.RECFM-VB' STYLE=NORMAL RS=NONE;
PROC PRINT DATA = FILE2 NOOBS;
RUN;
ODS MSOFFICE2K CLOSE;
ODS LISTING;
Back to top
View user's profile Send private message
vasanthz

Global Moderator


Joined: 28 Aug 2007
Posts: 1742
Location: Tirupur, India

PostPosted: Fri May 15, 2015 3:04 pm
Reply with quote

You don't need the CATX steps as well.

In your original approach
1. You read some data from external file
2. Append some spaces using CATX.
3. Write the appended values into output ps file.
4. read the output file in email step


In the approach that I am suggesting,
1.Read the file
2. create XML file using ODS.
3. email the file.
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 -> JCL & VSAM Goto page Previous  1, 2

 


Similar Topics
Topic Forum Replies
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 8
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
Search our Forums:

Back to Top