View previous topic :: View next topic
|
Author |
Message |
k_kirru Currently Banned New User
Joined: 14 Sep 2005 Posts: 16
|
|
|
|
Hi,
I have to strip the values and should cancatenate them.
The Problem is :
I have the two fields
ws-fullname pic x(32)
ws-lastname pic x(32)
Resultant field:
ws-name pix x(64).
Here the Values in the fileds are
ws-fullname = 'A FULLNAME'
ws-lastname = 'LASTNAME'
here the resulatnat value should be 'A FULLNAME LASTNAME'
Here i need to strip the values and then concatenate like what we will do in feching the fields from db2 tru strip function, but in COBOL i couldnt able to use this.
So any one can suggest me how to strip the fileds and concatenate.
It would be grate if you provide some piece of code.
Thanks in Advance.
Regards,
Kiran. |
|
Back to top |
|
|
tdsvamsidhar
New User
Joined: 03 Oct 2005 Posts: 7
|
|
|
|
Try doing the following.
Iniitalize your variables with some character which you think does not come in the ws-firstname or secondname.
WS-FIRSTNAME pic X(32) value '////////////////////////'
WS-SECONDNAME pic X(32) value '////////////////////////'
move 'A FIRSTNAME' to WS-FIRSTNAME
move 'SECONDNAME' to WS-SECONDNAME
INSPECT WS-FIRSTNAME TALLYING WS-COUNT FOR CHARACTERS AFTER
INITIAL '/'.
COMPUTE WS-COUNT1 = 32 - WS-COUNT
MOVE ws-firstname(1:WS-COUNT1) to NEWVAR(1:WS-COUNT1)
Do the same for the second variable..
Hope this helps..Please somebdoy correct me if I am wrong. |
|
Back to top |
|
|
k_kirru Currently Banned New User
Joined: 14 Sep 2005 Posts: 16
|
|
|
|
Hi, Thanks....
What you have told is correct, but the filed names are coming from file, so when we move from the file to initialzed variables (/), here in the file itselef there might be some spaces so it over writes the initialized variables, hence its not working in my case. can you suggest me in any way.. |
|
Back to top |
|
|
tdsvamsidhar
New User
Joined: 03 Oct 2005 Posts: 7
|
|
|
|
You can declare two other temp variables which receives the values from file variables and you can inspect the temp variables like I said earlier. Is that OK. Let me know. |
|
Back to top |
|
|
ikumar
New User
Joined: 02 Aug 2005 Posts: 81
|
|
|
|
Hi,
check the below solution, you can implement it if you like the same...
1) using inspect fill all the SPACES in your first field to some delimiter that you would not face in your data, for example, '~'
2) Reverse the string using FUNCTION
for ex, MOVE FUNCTION REVERSE(WS-STRING) TO WS-STRING
3) using inspect fill all the leading delimiter '~' with spaces.
4) Do the reverse of the string again and
5) STRING WS-FIRSTNAME DELIMITED By ws-space and one space and WS-LASTNAME.
INSPECT WS-FIRSTNAME REPLACING ALL " " BY "~"
MOVE FUNCTION REVERSE(WS-FIRSTNAME) TO WS-FIRSTNAME
INSPECT WS-FIRSTNAME REPLACING ALL LEADING "~" BY " "
MOVE FUNCTION REVERSE(WS-FIRSTNAME) TO WS-FIRSTNAME
STRING WS-FIRSTNAME DELIMITED By ws-space
SPACE
WS-LASTNAME
just correct yourself if any syntax errors are there in the above code...and please let me know whether it has worked or not...
Hope this helps...
Cheers,
Kumar. |
|
Back to top |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
Hi Kiran,
You can try something like this (untested):
Code: |
MOVE ZERO TO L
INSPECT FUNCTION REVERSE(ws-fullname) TALLYING L FOR LEADING SPACES
COMPUTE L1 = LENGTH OF ws-fullname - L
MOVE ZERO TO L
INSPECT FUNCTION REVERSE(ws-lastname) TALLYING L FOR LEADING SPACES
COMPUTE L2 = LENGTH OF ws-lastname - L
STRING ws-fullname(1:L1) ' ' ws-lastname(1:L2) DELIMITED BY SIZE
INTO ws-name
END-STRING |
|
|
Back to top |
|
|
ss.vijaysb1984
New User
Joined: 25 Jul 2008 Posts: 2 Location: India-Chennai
|
|
|
|
Thisi is Very usefull for me... |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
|
|
Now that's the adventure of Forums..you find something very handy. And thanks for letting us know that yeah..some one is using the "Search" facility of this site.
-Ad |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
|
|
Mcmillian,
Can't we get a count of "how many times the search button was hit" for a given day.. |
|
Back to top |
|
|
mcmillan
Site Admin
Joined: 18 May 2003 Posts: 1210 Location: India
|
|
|
|
Quote: |
Can't we get a count of "how many times the search button was hit" for a given day.. |
Yes, we can get it from the server access_log, if needed |
|
Back to top |
|
|
|