View previous topic :: View next topic
|
Author |
Message |
bnveena
New User
Joined: 29 May 2007 Posts: 50 Location: hyderabad
|
|
|
|
Hi,
in my cobol program i am have 3 variables as below
10 IN-PAT-LNAME PIC X(15).
10 IN-PAT-FNAME PIC X(10).
10 IN-PAT-MI PIC X(1).
01 WS-PATIENT PIC X(26) VALUE SPACES.
05 RPT-PATIENT PIC X(26).
I am sending the input from the in variables to WS-PATIENT and string it and sent to the RPT-PATIENT
the string statement goes like this
STRING IN-PAT-LNAME,WS-SPACE,IN-PAT-FNAME,
WS-SPACE,IN-PAT-MI
DELIMITED BY " "
INTO WS-PATIENT
END-STRING
MOVE WS-PATIENT TO RPT-PATIENT
for some names i am getting the out put correctly
but for some records i am getting an extra space in between the first name and middle name.
Code: |
for example
AMBRY CATHERINE M for this record
i am getting AMBRY CATHERINE M an extra space |
can any one help me in this regard |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
Check the names that appear to have one or more extra spaces to make sure there are no "unprintable" characters at the end of a name. Suggest you look at some of the values for some of the names that generate the incorrect result in hex to do this.
FWIW - You should also move spaces to ws-patient before the string. Unless there is some other use for ws-patient later in the code, you could string directly into rpt-patient. |
|
Back to top |
|
|
Terry Heinze
JCL Moderator
Joined: 14 Jul 2008 Posts: 1248 Location: Richfield, MN, USA
|
|
|
|
I don't have access to a mainframe, but try this untested code:
Code: |
string in-pat-lname delimited by space
' '
in-pat-fname delimited by space
' '
in-pat-mi delimited by size
into ws-patient
end-string |
|
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hi Terry,
Yup. Personally, i prefer your code style for this.
d |
|
Back to top |
|
|
bnveena
New User
Joined: 29 May 2007 Posts: 50 Location: hyderabad
|
|
|
|
hi terry...
i tried ur code but i m not getting the out put correctly for fname and lname the data is coming to gether and for middle name the 2 spaces are commig |
|
Back to top |
|
|
Terry Heinze
JCL Moderator
Joined: 14 Jul 2008 Posts: 1248 Location: Richfield, MN, USA
|
|
|
|
Are you saying that your result is
instead of
? Did you code it exactly as I did with the
between the lname and fname and between the fname and mi? As I said, without mainframe access all I can do is check the Language Reference Manual. Have you reviewed the syntax and example of the STRING statement there? |
|
Back to top |
|
|
bnveena
New User
Joined: 29 May 2007 Posts: 50 Location: hyderabad
|
|
|
|
Yes what code u have given i have given the same.
i am getting one space between the lname and mname but i am not getting a aingle space between the fname and laname.
i have tried vice versa also .... but still the problem is comming.
i have refered to the manul before i posted the query in the forum... but i could not get it..... |
|
Back to top |
|
|
Shashank.kapoor
New User
Joined: 14 Jan 2009 Posts: 24 Location: Mumbai
|
|
|
|
Hi Veena,
Can you please provide the screen shot of the syntax you are using in your code. Also please provide the output you are getting.
While providing the screen shot please do the HEX ON or you can confirm the HEX value of the position.
The code provided by Terry should work correctly.
string in-pat-lname delimited by ' '
' ' delimited by size
in-pat-fname delimited by ' '
' ' delimited by size
in-pat-mi delimited by size
into ws-patient
end-string
For the below example the above code should work perfectly.
10 IN-PAT-LNAME PIC X(15). Smith
10 IN-PAT-FNAME PIC X(10). John
10 IN-PAT-MI PIC X(1). M
Output => Smith John M
Thanks & Regards,
Shashank Kapoor |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
As i mentioned earlier, your data may contain some unprintable characters. You need to post some of the problem name data (in hex) so we can se what is the matter.
Did you change the code to move spaces to the target field before the string? The value could also be leftover from the prior string. |
|
Back to top |
|
|
bnveena
New User
Joined: 29 May 2007 Posts: 50 Location: hyderabad
|
|
|
|
hi , please find the attachment of the screen shot.
AMBRYDENNIS L
AMBRYCATHERINE M
AMBRYDANIELLE A
this is the output i got when i tried terry's code |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
It appears that the "extra" space has been resolved. To resolve the last and first name running together, try this slight modification:
Code: |
string in-pat-lname delimited by space
' ' delimited by '\'
in-pat-fname delimited by space
' ' delimited by '\'
in-pat-mi delimited by size
into ws-patient
end-string |
|
|
Back to top |
|
|
bnveena
New User
Joined: 29 May 2007 Posts: 50 Location: hyderabad
|
|
|
|
hi dick ...
i tried the syntax u have given...... but in the first name for example the name is
PAAPE JR JOHN H
JR in first name is not populating in the report |
|
Back to top |
|
|
Shashank.kapoor
New User
Joined: 14 Jan 2009 Posts: 24 Location: Mumbai
|
|
|
|
Hi Veena,
Just Curious regarding few things:
1) Did you check the HEX value of the particular position?
2) Did you initialize both your output variable?
As per your last post it seems that you are expecting space in input first name for eg.
10 IN-PAT-LNAME PIC X(15) value 'PAAPE JR'
If this is the case then definitely the below statement
' ' delimited by size
will remove the JR from output
Thanks & Regards,
Shashank |
|
Back to top |
|
|
bnveena
New User
Joined: 29 May 2007 Posts: 50 Location: hyderabad
|
|
|
|
hi ...
i have initialised all the output variables before moving the data....
i have checked all the values before moving also....
|
|
Back to top |
|
|
Shashank.kapoor
New User
Joined: 14 Jan 2009 Posts: 24 Location: Mumbai
|
|
|
|
Hi,
Please find below statements, it is working fine:
Code: |
01 WS-VALUES.
05 WS-LAST-NAME PIC X(15) VALUE 'SMITH '.
05 WS-FIRST-NAME PIC X(10) VALUE 'JOHN '.
05 WS-MIDDLE-NAME PIC X(01) VALUE 'M'.
05 WS-PATIENT PIC X(26) VALUE SPACES.
05 WS-RPT-PATIENT PIC X(26) VALUE SPACES. |
Code: |
STRING WS-LAST-NAME DELIMITED BY ' '
' ' DELIMITED BY SIZE
WS-FIRST-NAME DELIMITED BY ' '
' ' DELIMITED BY SIZE
WS-MIDDLE-NAME DELIMITED BY ' '
INTO WS-PATIENT.
DISPLAY 'WS-PATIENT : ' WS-PATIENT
MOVE WS-PATIENT TO WS-RPT-PATIENT.
DISPLAY 'WS-RPT-PATIENT : ' WS-RPT-PATIENT. |
Output =>
Code: |
WS-PATIENT : SMITH JOHN M
WS-RPT-PATIENT : SMITH JOHN M |
I have displayed the value in spool.
If your input can also have a space in input variable then you can use ' ' i.e. double spaces in the string function.
Hope this will help you.
-------------------
Shashank |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
Quote: |
i tried the syntax u have given...... but in the first name for example the name is
PAAPE JR JOHN H
JR in first name is not populating in the report
|
The syntax i posted will work - for your original requirement. . . The name that does not work does not match the format of the name you posted.
Before implementing some code, you need to completely define all of the name conditions that might arise and how they should be "strung". To work the code one discovery at a time is just a waste of time. |
|
Back to top |
|
|
bnveena
New User
Joined: 29 May 2007 Posts: 50 Location: hyderabad
|
|
|
|
hello dick.....
the program i m working .... its a very big input file and i cant put displays in my program when i am running a big file in my work place....
the string logic is working for some conditions and for some it is not working....
is there any other option for the program.
for example by taking the
PAPPE JR JOHN H and when implementing JR is not populating
if we are taking AMBRY CATHERINE M i am getting double space....
please help me in this regard |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hi Veenaq,
As i mentioned earlier, i believe a complete definition of the "rules" is needed befoer code is written. Suggest you gather a list of a few "standard" names (a first name a last name and an initial. To this list, add names that present a more complex rule - like PAPPE JR JOHN H, or VAN DER SCHOETTEN DR WILLIEM J, or others.
A study needs to be made to make sure that the same name components are stored in the same input fields. If the input arrives differently between records, this may cause inconsistencies.
Quote: |
the string logic is working for some conditions and for some it is not working.... |
This needs to be completely understood.
Your solution may be a combination of reference modification, data manipulation to remove unwanted components, and some string or move instructions to build the final output name field. |
|
Back to top |
|
|
bnveena
New User
Joined: 29 May 2007 Posts: 50 Location: hyderabad
|
|
|
|
hi ...
my problem got resolved .... firstly i have moved the length of the variables to another variable and i have printed according to that length......
one of my collegue has helped me in this regard....
thnks every one ... who has given me suggestions....
I have experimented a lot on string function |
|
Back to top |
|
|
Shashank.kapoor
New User
Joined: 14 Jan 2009 Posts: 24 Location: Mumbai
|
|
|
|
Good to see this that your problem got resolved.
Request you to share the logic you have used for this.
Just Curious, did you use the function reverse in your code?
------------
Shashank |
|
Back to top |
|
|
|