View previous topic :: View next topic
|
Author |
Message |
suneelv
New User
Joined: 26 Aug 2008 Posts: 52 Location: inida
|
|
|
|
Hi,
I have PS file of length 500 and when ever "~" operator present i breaking the fields into sub strings but its not working.
I have given W-OUT DELIMITED BY "~" INTO VENDOR,LOCATION.
W-OUT is of length X(500) and VENDOR is of length X(20) and LOCATION is of length X(50).
But after the statement executed it copies first 20 characters of data
W-OUT into VENDOR and next 50 characters of data into LOCATION.
Why "~" is not recognizing in the UNSTRING.
Could any one help on this.
Regards
Suneel |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
We both know that if the code is correct and the data contains characters that we expect, the UNSTRING will work.
so, if it does not work, then possibly the "~" you are providing as a literal is not really the character in the string.
how are you determining that W-OUT contains a string with "~"? |
|
Back to top |
|
|
suneelv
New User
Joined: 26 Aug 2008 Posts: 52 Location: inida
|
|
|
|
Hi,
Below is the example of the record
abcdefghi ~.ABC #111 - bbbbbbbbbbbb~.12/11/01 8:04:13 AM.~
i want EXample in to one field
ABC #111 - bbbbbbbbbbbb in to another field
12/11/01 8:04:13 AM. into another field.
Thanks
Suneel |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
It may help if you post the variable definitions and the complete unstring statement. . . |
|
Back to top |
|
|
suneelv
New User
Joined: 26 Aug 2008 Posts: 52 Location: inida
|
|
|
|
Hi,
Here is the varible declaration and UNSTRING statement
01 W-OUTPUT-REC.
05 VENDOR PIC X(20).
05 LOCATION PIC X(50).
UNSTRING W-OUTPUT-REC DELIMITED BY "~"
INTO VENDOR,
LOCATION,
I am reading the file and writing the each record into W-OUTPU-REC and executing unstring command.
In the above just i gave 2 fields only but it contains more than 10 fields.
Thanks
Suneel |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Unless other than the code used has been posted, the process is trying to unstring into itself. You need to unstring from one area to another, not the same one. Assuming the vendor, locaton, etc remain in the W-OUTPUT-REC, something like the following should work.
Code: |
UNSTRING MY-NEW-WORK-REC DELIMITED BY "~"
INTO VENDOR,
LOCATION,
|
|
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
This is the last time I will assume the OP has any knowledge of COBOL.
waste of time to provide an answer without knowing what chaos is going on.
feeling sorry for myself. I apologize. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
this should have been posted in the rookies forum. |
|
Back to top |
|
|
suneelv
New User
Joined: 26 Aug 2008 Posts: 52 Location: inida
|
|
|
|
Hi,
I didn't get.
Regards
suneel |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
Quote: |
Below is the example of the record
abcdefghi ~.ABC #111 - bbbbbbbbbbbb~.12/11/01 8:04:13 AM.~
i want EXample in to one field
ABC #111 - bbbbbbbbbbbb in to another field
12/11/01 8:04:13 AM. into another field.
|
it seems as if you will have 4 output fields.
abcdefghi ~ <will become> abcdefghi (the ~ will be dropped by the unstring
.ABC #111 - bbbbbbbbbbbb~ <will become> .ABC #111 - bbbbbbbbbbbb
.12/11/01 8:04:13 AM.~ <will become> .12/11/01 8:04:13 AM.
and whatever follows as the fourth.
you need a minimum of 4 output fields in your UNSTRING command.
as Mr. Scherrer explained: you are unstringing a area and using the area as a receiver of the UNSTRING output. Designate output fields that are not part of the input, otherwise you are destroying your input. |
|
Back to top |
|
|
suneelv
New User
Joined: 26 Aug 2008 Posts: 52 Location: inida
|
|
|
|
hI,
As per your suggesion i modified all variables as elementary data items
77 W-OUTPUT-REC PIC X(500).
77 VENDOR PIC X(20).
77 LOCATION PIC X(50).
UNSTRING W-OUTPUT-REC DELIMITED BY "~"
INTO VENDOR,
LOCATION,
I am reading the file and writing the each record into W-OUTPU-REC and unstringing the W-OUTPUT-REC into VENDOR and LOCATION.
At this time i got VENDOR and LOCATION are spaces.
Regards
Suneel |
|
Back to top |
|
|
suneelv
New User
Joined: 26 Aug 2008 Posts: 52 Location: inida
|
|
|
|
Hi,
Here is the details of the variables and UNSTRING command and example of record also.
#WS
77 VENDOR PIC X(20).
77 LOCATION PIC X(50).
77 ACTIVITY-DT PIC X(19).
77 W-OUTPUT-REC PIC X(500).
#PD
UNSTRING W-OUTPUT-REC DELIMITED BY "~"
INTO VENDOR,
LOCATION,
ACTIVITY-DT,
example of record:
SECCONDDATA~.ARC #523 - LIMITED ACCESS~.12/01/08 8:04:13 AM.~
total of 3 fields and delimeter is "~"
when i execute above untstring command by using the above record
all the above 3 fields contains spaces.
Could you please tell me why it is happening.
Regards
Suneel |
|
Back to top |
|
|
suneelv
New User
Joined: 26 Aug 2008 Posts: 52 Location: inida
|
|
|
|
Hi,
Its working now. i have missed "." after end of the UNSTRING.
Thanks for all your help.
Regards
Suneel |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Good to hear it is working - thank you for letting us know
At the top of the page is a link to "IBM Manuals" and the COBOL manuals are available there. It will be to your advantage to become familiar and comfortable with those manuals. They are invaluable
d |
|
Back to top |
|
|
|