How To create an CSV file in Mainframe (from Object star database)?

40 pts.
Tags:
CSV
z/OS
I have to create some extract from Object star tables, in CSV format.Please let me know if any utility or programe can be used.

Software/Hardware used:
Z/OS

Answer Wiki

Thanks. We'll let you know when a new response is added.

Please find below a screenprint of a rule that puts the content of a table in a dataset in a CSV-format.
The first record in the dataset contains the names of the fields of the table. This is a quite generic way to do what is asked. The table in question has only one parameter (but this can be easily adjusted as needed…)

<pre>
RULE EDITOR ===> SCROLL: P
KPDOWNLOAD(P_TAB, P_PARM, P_FILE_NAME);
_ LOCAL L_RECORD;
_ —————————————————————————
_ ————————————————————+————–
_ CALL @OPENDSN(P_FILE_NAME); ¦ 1
_ FORALL FIELDS(P_TAB) : ¦ 2
_ L_RECORD = L_RECORD || FIELDS.NAME ||’,'; ¦
_ END; ¦
_ CALL @WRITEDSN(HEADSTRING(L_RECORD, LENGTH(L_RECORD) – 1)) ¦ 3
_ ; ¦
_ FORALL P_TAB(P_PARM) : ¦ 4
_ L_RECORD = ”; ¦
_ FORALL FIELDS(P_TAB) : ¦
_ L_RECORD = L_RECORD ||(P_TAB).(FIELDS.NAME) ||’,'; ¦
_ END; ¦
_ CALL @WRITEDSN(HEADSTRING(L_RECORD, LENGTH(L_RECORD) – ¦
_ 1)); ¦
_ END; ¦
_ CALL @CLOSEDSN; ¦ 5
_ —————————————————————————</pre>

Maybe copy the part above to a fixed width lettertype to view what is actually the screenprint.

The P_FILE_NAME has to be a fully qualified dataset-name (may be a member in a PDS). This rule is to be called from batch preferably, but from within a TSO-execution-environment it should work also. Be aware that it is best to have the PDS defined before use.

Experiment, and you will learn.

That’s All Folks,
Harald.

Discuss This Question: 3  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • Ari2009
    Hi, is there any way to keep the length fixed for the table fields ? in present code, if for a table field length is 10 , and the field value is of length 3, then the next fied value is starting from the 4th position in the file. if we need to do a file compare on field by field , current code is not helpful for that. I need to hold the even the spaces for a field .. e.g field f1 of length 6 and f2 length 4. value for f1 in record 1 - 333 and for f2 4666 value for f1 in record 2 - 22 and for f2 3366 expectation in the file format is - record 1 : 333 4666 record2 : 22 3366 if any one can solve this ,will be a great help.
    40 pointsBadges:
    report
  • Ari2009
    I have to requirements, 1) I need to extract data present in column A from a O* table, which is of of two columns 'A' and 'B'. The field value can be between 14 to 19 in length and numeric and the file should have a comma at the end of each record ( e.g - the file extract should look like below rec1 - 1234567891011121, rec2 - 34567891011121, rec3 - 1234567891011121111, 2) again, I need to read the same file after processing and load data in Column 'B' of the same table. the input file will look like - rec1 - 1234567891011121,1234567891011120 rec2 - 34567891011121,34567891011120 rec3 - 1234567891011121111,1234567891011121110 can any one suggest any solution to this , it will be a great help. regards, Ad
    40 pointsBadges:
    report
  • Ebieg
    Hi Define an export table with the exact field names and lengths as the current table with the data. Then copy the data to the export table. When defining the export table you can specify the name of the csv file, dont forget to specify the .csv extension at the end of the file name when defining the export table. Hope this helps.
    25 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following