Page 1 of 1

How to write output file with concatenate the input fields

PostPosted: Fri Jan 13, 2012 4:46 pm
by ritnihi
Hi,

I have one input file and I need to concatenate the input fields with ';' and write to output file.

Input File layout:

07 A1 PIC S9(09)
07 A2 PIC S9(09)
07 A3 PIC S9(09)
07 A4 PIC X(003)
07 A5 PIC X(085)

Output file layout should be :

07;A1;PIC S9(09)
07;A2;PIC S9(09)
07;A3;PIC S9(09)
07;A4;PIC X(003)
07;A5;PIC X(085)

Could you please help me out with REXX code.

Thanks,
ritnihi.

Re: How to write output file with concatenate the input fiel

PostPosted: Fri Jan 13, 2012 5:13 pm
by MrSpock
I'm thinking the easiest way is to parse the string into tokens:

Parse Var rec v1 v2 v3

then concatenate them together:

rec = v1';'v2';'v3

Re: How to write output file with concatenate the input fiel

PostPosted: Tue Jan 17, 2012 5:36 pm
by ritnihi
Thanks a lot. It worked.

Re: How to write output file with concatenate the input fiel

PostPosted: Tue Jan 17, 2012 5:50 pm
by ritnihi
Hi,

Can you please tell me whether we can able to get the length of A1,A2,A3,A4 and A5 fields? Is their any function for this?

Example: For A4, it's 3 and for A5 it's 85

Appreciates your help :-)

Re: How to write output file with concatenate the input fiel

PostPosted: Tue Jan 17, 2012 6:14 pm
by halfteck
REXX is full of built in functions, providing just that sort of info. Suggest you search REXX info for a function called LENGTH. However you are already quoting the field lengths

Re: How to write output file with concatenate the input fiel

PostPosted: Tue Jan 17, 2012 6:25 pm
by BillyBoyo
What are you trying to achieve? If you are trying to do something fancy with a Cobol record-layout, you have a lot of work ahead of you.

How long are these?
01  A-RECORD.
    05  A-CHARACTER PIC X.
    05  A-BINARY-EX1 COMP PIC 9.
    05  A-BINARY-EX2 COMP PIC 9(5).
    05  A-COMP3-EX1 COMP-3 PIC 9(5).
    05  A-COMP3-EX2 COMP-3 PIC 9(4).
    05  A-COMP3-EX3 COMP-3 PIC 9(5)V9(4).
    05  A-FLOAT COMP-1
    05  A-BIGGER-FLOAT COMP-2
    05  A-FIELD-WHICH-IS-EDITED PIC X(8)BX(8).
   


And how long is the record?

That is without 66s, 77s, 88s, OCCURS, REDEFINES (including the possibility of redefining longer than the original field), indexes etc.

If you can get your answer from a Compile listing, the Compiler will have done the hard work for you.

Re: How to write output file with concatenate the input fiel

PostPosted: Wed Jan 18, 2012 4:19 pm
by ritnihi
Thanks for your reply.

But I need to consider all the record length type as per above mentioned including OCCURS,77 and 88 levels.
I can't take any value from compile listing as my program is a REXX program.So i believe I will not be having any compile listing.

Let me clear with the requirement:
----------------------------------------
If this is my input file,

A1;PIC 9(09) COMP
A2;PIC 9(02)
A3;PIC X(003)
A4;PIC X(05)

Then the output should be like ,

field;length;starting position;end position

A1;PIC 9(09) COMP;1;4
A2;PIC 9(02);5;6
A3;PIC X(003);7;9
A4;PIC X(05);10;14

Please help me with the code how to find the starting and ending position for the above fields.

Please let me for any confusion

Thanks,
Rita.

Re: How to write output file with concatenate the input fiel

PostPosted: Wed Jan 18, 2012 4:27 pm
by BillyBoyo
But what are you trying to do with the information?

If you get your rexx to read a compile listing, you'd have the compile listing. Your rexx is reading something else.

If you are going to "parse" Cobol pictures and usage, and you don't know enough rexx to get the number from within the brackets, then you have a huge task ahead of you.

Re: How to write output file with concatenate the input fiel

PostPosted: Wed Jan 18, 2012 5:33 pm
by prino
And before we waste any more time on an ever moving target, can you please tell us which clueless idiot/dimwit/moron set this requirement and the rationale behind it?