View previous topic :: View next topic
|
Author |
Message |
apandey
New User
Joined: 31 Aug 2009 Posts: 73 Location: Mumbai
|
|
|
|
Hi ALL
I have a record in my input file as :-
'VEH001|VEH2|PART1234|LASTPART..'
Last 2 dots (..) are X'02D5' i.e. for representing end of line.
Now I am using Unstring to split these 4 fields as :
UNSTRING INPUT-FILE-RECORD
DELIMITED BY '|'
INTO
LR-FIELD1
LR-FIELD2
LR-FIELD3
LR-FIELD4
END-UNSTRING.
Now LR-FIELD1,2 and 3 is containing proper values in it. But LR-FIELD4 is containing 'LASTPART..' i.e. X'02D5' value also.
I want to remove this. I tried giving DELIMITED BY '|' OR 'X02D5'
but again LR-FIELD is containing those 2 bytes of data. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
try DELIMITED BY 'X02D5' OR '|' |
|
Back to top |
|
|
apandey
New User
Joined: 31 Aug 2009 Posts: 73 Location: Mumbai
|
|
|
|
Forgot to mention the length of given variables:
LR-FIELD1 PIC X(10)
LR-FIELD2 PIC X(10)
LR-FIELD3 PIC X(10)
LR-FIELD4 PIC X(20).
So LR-FIELD4 may contain spaces as well which i need to remove tht too.
Like 'LASTPART.. '
So I want only value 'LASTPART' in LR-FIELD4 variable. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
You'll have to explain what you mean by "removing" spaces from LR4. You've been through that before. If the field is 20, it is going to hold 20 bytes of "whatever". If you "remove" space it will have to be something else.
So, describe more accurately what you want, please. |
|
Back to top |
|
|
apandey
New User
Joined: 31 Aug 2009 Posts: 73 Location: Mumbai
|
|
|
|
Hi Dick
I tried that just now but again its coming in tht variable. |
|
Back to top |
|
|
apandey
New User
Joined: 31 Aug 2009 Posts: 73 Location: Mumbai
|
|
|
|
Hi Bill
LR-FIELD4 is of 20 bytes. but it may contain actual data of 10 bytes and
remaining spaces.
Like above it contains actual data 'LASTPART' of 8 bytes + 2 bytes of 'X02D5' but what abt remaining 10 bytes.
I am not able to show spaces here.
So I want to truncate all values after 2 dots (..) X'02D5' including this too. |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8700 Location: Dubuque, Iowa, USA
|
|
|
|
Dick's code change works for me:
Code: |
77 INPUT-FILE-RECORD PIC X(50) VALUE
'VEH001|VEH2|PART1234|LASTPART N' .
77 LR-FIELD1 PIC X(10).
77 LR-FIELD2 PIC X(10).
77 LR-FIELD3 PIC X(10).
77 LR-FIELD4 PIC X(20).
/
PROCEDURE DIVISION.
S1000-MAIN SECTION.
UNSTRING INPUT-FILE-RECORD
DELIMITED BY X'02D5' OR '|'
INTO LR-FIELD1
LR-FIELD2
LR-FIELD3
LR-FIELD4
END-UNSTRING.
DISPLAY 'INPUT-FILE-RECORD <' INPUT-FILE-RECORD '>'.
DISPLAY 'LR-FIELD1 <' LR-FIELD1 '>'.
DISPLAY 'LR-FIELD2 <' LR-FIELD2 '>'.
DISPLAY 'LR-FIELD3 <' LR-FIELD3 '>'.
DISPLAY 'LR-FIELD4 <' LR-FIELD4 '>'. |
produces expected output of
Code: |
INPUT-FILE-RECORD <VEH001|VEH2|PART1234|LASTPART.N >
LR-FIELD1 <VEH001 >
LR-FIELD2 <VEH2 >
LR-FIELD3 <PART1234 >
LR-FIELD4 <LASTPART > |
So what are you expecting to be different in this output? |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
apandey wrote: |
Hi Bill
LR-FIELD4 is of 20 bytes. but it may contain actual data of 10 bytes and
remaining spaces.
Like above it contains actual data 'LASTPART' of 8 bytes + 2 bytes of 'X02D5' but what abt remaining 10 bytes.
I am not able to show spaces here.
So I want to truncate all values after 2 dots (..) X'02D5' including this too. |
OK, so make up your mind about how it is valid to define a hexadecimal literal. Try that as part of your solution.
If UNSTRING does not fill a field, the remaining bytes are the value which was in the field at the time the UNSTRING stared. So, it is always "excellent practice" to set your fields which are the target of your UNSTRING to some initial value. I like "MOVE SPACE TO ...." but I'm sure there are less rigorous ways to attempt it. |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10888 Location: italy
|
|
|
|
seems that there is a consistent tpyogarphical error here
'x02D5' instead of x'02D5' |
|
Back to top |
|
|
apandey
New User
Joined: 31 Aug 2009 Posts: 73 Location: Mumbai
|
|
|
|
Hi Robert/Dick,
I tried same but its not working. Pls see actual code below.
Code: |
2000-PROCESS-LR951.
-------------------------------------------------------------
INITIALIZE INCOMING-EMAIL
MOVE WS-TIMESTAMP TO LR-KEY OF INCOMING-EMAIL
UNSTRING WS-INPUT-RECORD
DELIMITED BY X'02D5' OR '|'
INTO
LR-TO-FIELD-TEXT
LR-CC-FIELD-TEXT
LR-SUB-FIELD
LR-SUB1-FIELD-TEXT
LR-TEXT-FIELD-TEXT
LR-USER-DATE-TEXT
LR-USRTXT1-FIELD-TEXT
LR-USRTXT2-FIELD-TEXT
LR-USRTXT3-FIELD-TEXT
LR-USRTXT4-FIELD-TEXT
END-UNSTRING.
DISPLAY 'LR-USRTXT4-FIELD-TEXT: ' LR-USRTXT4-FIELD-TEXT |
Sysout is:
Code: |
-------------------------------------------------
LR-USRTXT4-FIELD-TEXT: HELLO BOSS THIS IS TEXT4::
DD6EEDEEEF6CCCDC6ECEE74CCDDD4CDEE4ECCE4CE4ECEEF020
390429373406953403573A0853360262203892092035734D50 |
|
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
You are, finally, showing us X'02D5'. Now you show the data, and it is x'0D25'. |
|
Back to top |
|
|
apandey
New User
Joined: 31 Aug 2009 Posts: 73 Location: Mumbai
|
|
|
|
Bill,
I didnt get you
You mean to say there is difference between X'02D5' and x'02D5'. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
It looks like what I mean is that you are not reading the hex display properly.
Code: |
-------------------------------------------------
LR-USRTXT4-FIELD-TEXT: HELLO BOSS THIS IS TEXT4::
DD6EEDEEEF6CCCDC6ECEE74CCDDD4CDEE4ECCE4CE4ECEEF020
390429373406953403573A0853360262203892092035734D50 |
Have a look at the first letter of your display. L. Find the EBCDIC code for L. Look at the hex values in your example. Where does x'D3' occur? Vertically, underneath the L.
So, what value are the last three bytes X'0D2500'.
If you correct your delimeter to X'0D25' it should work, including not piicking up that X'00'.
I knew you'd use INITIALIZE, even with me steering you from it :-)
Did you ever go back and let us know about that SORT question you had the other day... after all that talk about feedback.. |
|
Back to top |
|
|
apandey
New User
Joined: 31 Aug 2009 Posts: 73 Location: Mumbai
|
|
|
|
Bill ..Extremely sorry abt this. Earlier I was using X'02D5' thats why it was not working. Very silly mistake
Now I tried with X'0D25', so now its working well ..!
Thanks everyone for all ur effort. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Usually when I see hex at the end of something, I check with yellow/green card. Because the X was first part of the literal itsef, I didn't :-)
X'0D25' is Carriage-Return, Line-Feed. A common combination for the "end" of a text line.
You might want to look at how to remove it from the transfer from the server. It can usually be done, then your Cobol program wouldn't even have to know about it... |
|
Back to top |
|
|
|