View previous topic :: View next topic
|
Author |
Message |
suneelv
New User
Joined: 26 Aug 2008 Posts: 52 Location: inida
|
|
|
|
Hi,
I am stringing the below 2 fields into W-OUTPUT-REC.
77 VENDOR PIC X(20).
77 LOCATION PIC X(20).
77 W-OUTPUT-REC PIC X(60).
If VENDOR and LOCATION has contains the data as below
VENDOR: FIRST DATA
LOCATION: BOMBAY
After i execute
STRING VENDOR DELIMITED BY SIZE
LOCATION DELIMITED BY SIZE
INTO W-OUTPUT-REC.
o/p : FIRST DATA BOMBAY
after BOMBY i am getting 20 dots, i want to remove the dots also
I want o/p should be FIRST DATABOMBAY
Could any one help in this.
Regards
Suneel |
|
Back to top |
|
|
technut
New User
Joined: 27 Dec 2007 Posts: 73 Location: India
|
|
|
|
Hi,
You can try this..
MOVE SPACES TO ERROR-RECORD.
STRING VENDOR DELIMITED BY SIZE
LOCATION DELIMITED BY SIZE
INTO ERROR-RECORD
OR .............
01 ERROR-RECORD.
05 ERROR-REC1 PIC X(40).
05 FILLER PIC X(20) VALUE SPACES.
STRING WS-VENDOR DELIMITED BY SIZE
WS-LOCATION DELIMITED BY SIZE
INTO ERROR-REC1
Let me know if this works for you. |
|
Back to top |
|
|
suneelv
New User
Joined: 26 Aug 2008 Posts: 52 Location: inida
|
|
|
|
Hi,
Its not working.
Regards
Suneel |
|
Back to top |
|
|
technut
New User
Joined: 27 Dec 2007 Posts: 73 Location: India
|
|
|
|
It had worked for me when I did a test. Are you getting null values now also at the end of the file?
Which option you tried of both? More details would help! |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
The dots are probably LOW-VALUES from not initializing the output field before you use it. Move spaces to it before the STRING or add VALUE SPACES to its definition.
As far as what you want,
Code: |
05 VENDOR PIC X(20) VALUE 'FIRST DATA'.
05 SEP PIC X(01) VALUE SPACE.
05 LOCATION PIC X(20) VALUE 'BOMBAY'.
05 WS-VAR-OUT PIC X(60).
LINKAGE SECTION.
/
PROCEDURE DIVISION.
S1000-MAIN SECTION.
MOVE SPACES TO WS-VAR-OUT.
STRING VENDOR DELIMITED BY ' '
SEP DELIMITED BY SIZE
LOCATION DELIMITED BY SPACE
INTO WS-VAR-OUT.
DISPLAY 'VENDOR: ' VENDOR.
DISPLAY 'LOCATION: ' LOCATION.
DISPLAY 'COMBINED: ' WS-VAR-OUT. |
gives me this output:
Code: |
VENDOR: FIRST DATA
LOCATION: BOMBAY
COMBINED: FIRST DATA BOMBAY |
However if the vendor field has 19 characters in it there's an extra space between the fields. This could be checked for via reference modification; it depends on how critical the spacing is for you. |
|
Back to top |
|
|
suneelv
New User
Joined: 26 Aug 2008 Posts: 52 Location: inida
|
|
|
|
Hi,
But after FIRST DATA iam getting 10 spaces and since VENDOR is of length 20
After BOMBAY also there are 14 bytes of space since LOCATION is of length 20
I want to remove the spaces after FIRST DATA and BOMBAY
Regards
Suneel |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
If you use DELIMITED BY SIZE the entire field is moved via STRING. SIZE refers to the variable PIC, not the actual number of non-blank characters in the variable. |
|
Back to top |
|
|
suneelv
New User
Joined: 26 Aug 2008 Posts: 52 Location: inida
|
|
|
|
Hi,
But i want o/p should be FIRST DATA without spaces after FIRST DATA
same should be for LOCATION
without spaces after BOMBAY
Regards
Suneel |
|
Back to top |
|
|
CICS Guy
Senior Member
Joined: 18 Jul 2007 Posts: 2146 Location: At my coffee table
|
|
|
|
How about:
Code: |
STRING VENDOR DELIMITED BY x'4040'
LOCATION DELIMITED BY x'4040'
INTO W-OUTPUT-REC. |
or:
Code: |
STRING VENDOR DELIMITED BY x'4040'
x'40' DELIMITED BY SIZE
LOCATION DELIMITED BY x'4040'
INTO W-OUTPUT-REC. |
|
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
Your recent post:
Quote: |
But i want o/p should be FIRST DATA without spaces after FIRST DATA
same should be for LOCATION
without spaces after BOMBAY |
conflicts with your original request, where you wanted a space after the vendor before the location. Furthermore, you need to be aware that you are stringing 2 20-bytes fields into a 60-byte field. A minimum of 20 bytes and a maximum of 57 bytes of the output variable will not be coming from the STRING variables. What do you want these 20 to 57 bytes to be? They are going to be something -- spaces, LOW-VALUES, HIGH-VALUES, periods, or anything else in the collating sequence. You can pick the character but you cannot opt for them not to exist as they will exist, period.
The code I provided you has output that matches precisely what your last post says you want -- so what's the problem with it? |
|
Back to top |
|
|
suneelv
New User
Joined: 26 Aug 2008 Posts: 52 Location: inida
|
|
|
|
Hi,
Each field is of 20 bytes each and stringing into 60 bytes.
If the fields VENDOR or LOCATION contains less than 20 bytes the remaing are filled with spaces but i want to remove the spaces.
After 40 bytes stringing into 60 bytes ,still 20 bytes left they are filled with
dots.
I want to remove the dots in last 20 bytes from 41 to 60.
This is my requirement.
I tried the below code:
STRING VENDOR DELIMITED BY x'4040'
x'40' DELIMITED BY SIZE
LOCATION DELIMITED BY x'4040'
INTO W-OUTPUT-REC
but still 1 space is coming after VENDOR.
why 1 space is coming i am looking into this one.
Could any one help on this.
Regards
Suneel |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
Remove the dots by
Code: |
MOVE SPACES TO W-OUTPUT-REC |
before your STRING statement. Have you tried the
instead of SIZE as I specified? |
|
Back to top |
|
|
Terry Heinze
JCL Moderator
Joined: 14 Jul 2008 Posts: 1249 Location: Richfield, MN, USA
|
|
|
|
Reread Robert's reply. He just explained the situation in detail. |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
Quote: |
why 1 space is coming i am looking into this one. |
x'40' DELIMITED BY SIZE! |
|
Back to top |
|
|
suneelv
New User
Joined: 26 Aug 2008 Posts: 52 Location: inida
|
|
|
|
Hi,
I moved spaces to W-OUPUT-REC before string statement but one space is removed after VENDOR and LOCATION.
Regards
Suneel |
|
Back to top |
|
|
suneelv
New User
Joined: 26 Aug 2008 Posts: 52 Location: inida
|
|
|
|
Hi,
But dots are not removed after stringing vendor,location into W-output-rec. Dots are present from 41 to 60.
Regards
Suneel |
|
Back to top |
|
|
Terry Heinze
JCL Moderator
Joined: 14 Jul 2008 Posts: 1249 Location: Richfield, MN, USA
|
|
|
|
Suneel,
I repeat: Reread Robert's post of 12:25 PM. |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
Post exactly what your code looks like (with BBCode) and the output as it is generated by this code, and also post what you want done differently. |
|
Back to top |
|
|
suneelv
New User
Joined: 26 Aug 2008 Posts: 52 Location: inida
|
|
|
|
Hi,
WS varibles:
77 VENDOR PIC X(20).
77 LOCATION PIC X(20).
77 W-OUTPUT-REC PIC X(60).
Code:
MOVE SPACES TO W-OUTPUT-REC.
STRING C-QUOTE DELIMITED BY SIZE
VENDOR DELIMITED BY X'4040'
X'40' DELIMITED BY " "
INTO W-OUTPUT-REC.
O/P generated by above code
FIRST DATABOMBAY..........................................
o/p should be : FIRST DATABOMBAY
Regards
Suneel |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Did you copy/paste the generated output or did you type it? Have you ensured that BOMBAY is actually followed by spaces, not some strange hex value?
What is in this field (C-QUOTE)? Make sure it is not blank and run again. When doing this, also display the individual input fields in hex and post that.
As requested earlier, use the "Code" tag for readability (do not use screenshots). |
|
Back to top |
|
|
Shashank.kapoor
New User
Joined: 14 Jan 2009 Posts: 24 Location: Mumbai
|
|
|
|
Hi,
Please find below one solution for your query.
I have not considered the C-QUOTE in the below code.
Below code is for the values:
VENDOR : FIRST DATA
LOCATION : BOMBAY
STRING VENDOR DELIMITED BY X'4040'
LOCATION DELIMITED BY X'4040'
INTO W-OUTPUT-REC.
Inspect W-OUTPUT-REC REPLACING all LOW-VALUES by SPACES.
OUTPUT:FIRST DATABOMBAY
Second inspect will remove all the low values from the string.
I hope this will help you out from the problem.
If possible, also confirm to the post of Dick whether the code you have provided was the copy paste or you type it? |
|
Back to top |
|
|
|