View previous topic :: View next topic |
Author |
Message |
arvibala Beginner
Joined: 12 Feb 2008 Posts: 142 Topics: 67
|
Posted: Thu Aug 28, 2008 9:41 am Post subject: Dynamic Field to be appended in a File |
|
|
Hi all,
I have a series of Fields that needs to be filled in and sent(FTP) to a system. That system will be loading this data in Oracle apps.
My problem is that they want each field to end with a delimiter (~).
For example, if these are the fields.
INDICATOR (3)
VENDOR_ID (7)
VENDOR_NAME (25)
VENDOR_ADD (50)
If the values are
VEN
V223
XXXXYYYY
23 AAAAAA
the output should be
VEN~V223~XXXXYYYY~23 AAAAAA
To make this simple, irrespective of the data length, we need to add the delimiter at the end of each data. So I cant use filler to have this delimiter defined in my Working Storage.
How can this be acheived? Pls advice
Thanks _________________ Arvind
"You can make a difference with your smile. Have that with you always" |
|
Back to top |
|
|
jsharon1248 Intermediate
Joined: 08 Aug 2007 Posts: 291 Topics: 2 Location: Chicago
|
Posted: Thu Aug 28, 2008 10:24 am Post subject: |
|
|
You can do this in a number of ways. The COBOL string verb can be used. If your data has no embedded spaces, just add a DELIMITED BY SPACE clause for each field. If there's any chance of embedded spaces, you need to code something to determine the actual length of the data in a field. If you're selecting VARCHAR fields from a DB2 table, you already have the length in the 49 level length field. You can also use REXX which is a little friendlier with string manipulations. I've also coded this type of routine using VBS on the Windows platform. |
|
Back to top |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12375 Topics: 75 Location: San Jose
|
Posted: Thu Aug 28, 2008 12:31 pm Post subject: |
|
|
arvibala,
Where are you getting the data from? Is it from a DB2 table ? If so there are many utilities which unload the data with delimiters. |
|
Back to top |
|
|
arvibala Beginner
Joined: 12 Feb 2008 Posts: 142 Topics: 67
|
Posted: Thu Aug 28, 2008 2:42 pm Post subject: |
|
|
No Kolusu,
I am getting this from 2 FLAT Files. I can use STRING verb, but it has some Numeric manupulation too before forming the Final Output file. I want something similar to STRING, but should work for both CHARACTER as well as NUMERIC.
Thanks
Arvind B _________________ Arvind
"You can make a difference with your smile. Have that with you always" |
|
Back to top |
|
|
dbzTHEdinosauer Supermod
Joined: 20 Oct 2006 Posts: 1411 Topics: 26 Location: germany
|
Posted: Fri Aug 29, 2008 2:27 am Post subject: |
|
|
as mentioned in the other board where you posted this question, move the numerics to numeric edited and then string that. _________________ Dick Brenholtz
American living in Varel, Germany |
|
Back to top |
|
|
arvibala Beginner
Joined: 12 Feb 2008 Posts: 142 Topics: 67
|
Posted: Fri Aug 29, 2008 11:08 am Post subject: |
|
|
Thanks Brenholtz,
But the problem is since Numeric Edited variable is Right aligned we will still get spaces.
Code: |
INDICATOR (3)
VENDOR_ID (7)
VENDOR_NAME (25)
VENDOR_ADD (50)
NUMBER3-EDIT PIC Z(10)
|
If the values are
Code: |
VEN~
V223~
XXXXYYYY~
23 AAAAAA~
90
|
If we STRING these we will get
Code: |
VEN~V223~XXXXYYYY~23 AAAAAA~ 90
|
But I need Code: |
VEN~V223~XXXXYYYY~23 AAAAAA~90 |
_________________ Arvind
"You can make a difference with your smile. Have that with you always" |
|
Back to top |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12375 Topics: 75 Location: San Jose
|
Posted: Fri Aug 29, 2008 12:59 pm Post subject: |
|
|
arvibala,
Code: |
INSPECT FUNCTION REVERSE(WS-NUMBER3-EDIT)
TALLYING WS-TALLY FOR LEADING SPACE
STRING WS-INDICATOR DELIMITED BY size
WS-VENDOR-ID DELIMITED BY size
WS-VENDOR-NAME DELIMITED BY size
WS-VENDOR-ADD DELIMITED BY SIZE
WS-NUMBER3-EDIT (WS-TALLY + 1 : )
DELIMITED BY SIZE
INTO WS-FINAL-STRING
|
|
|
Back to top |
|
|
|
|