How to write output file with concatenate the input fields



IBM's Command List programming language & Restructured Extended Executor

How to write output file with concatenate the input fields

Postby ritnihi » Fri Jan 13, 2012 4:46 pm

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.
ritnihi
 
Posts: 9
Joined: Wed Dec 28, 2011 5:24 pm
Has thanked: 0 time
Been thanked: 0 time

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

Postby MrSpock » Fri Jan 13, 2012 5:13 pm

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
User avatar
MrSpock
Global moderator
 
Posts: 809
Joined: Wed Jun 06, 2007 9:37 pm
Location: Raleigh NC USA
Has thanked: 0 time
Been thanked: 4 times

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

Postby ritnihi » Tue Jan 17, 2012 5:36 pm

Thanks a lot. It worked.
ritnihi
 
Posts: 9
Joined: Wed Dec 28, 2011 5:24 pm
Has thanked: 0 time
Been thanked: 0 time

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

Postby ritnihi » Tue Jan 17, 2012 5:50 pm

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 :-)
ritnihi
 
Posts: 9
Joined: Wed Dec 28, 2011 5:24 pm
Has thanked: 0 time
Been thanked: 0 time

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

Postby halfteck » Tue Jan 17, 2012 6:14 pm

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
halfteck
 
Posts: 42
Joined: Tue Nov 08, 2011 8:47 pm
Has thanked: 0 time
Been thanked: 0 time

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

Postby BillyBoyo » Tue Jan 17, 2012 6:25 pm

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.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

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

Postby ritnihi » Wed Jan 18, 2012 4:19 pm

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.
ritnihi
 
Posts: 9
Joined: Wed Dec 28, 2011 5:24 pm
Has thanked: 0 time
Been thanked: 0 time

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

Postby BillyBoyo » Wed Jan 18, 2012 4:27 pm

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.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

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

Postby prino » Wed Jan 18, 2012 5:33 pm

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?
Robert AH Prins
robert.ah.prins @ the.17+Gb.Google thingy
User avatar
prino
 
Posts: 641
Joined: Wed Mar 11, 2009 12:22 am
Location: Vilnius, Lithuania
Has thanked: 3 times
Been thanked: 29 times


Return to CLIST & REXX

 


  • Related topics
    Replies
    Views
    Last post