I've one string with spaces ( I N D I A ). My question is I
want remove the spaces & combine in to single string without
space (INDIA).How we can write the cobol program & wich
options we need to use. Please let me know.
Answers were Sorted based on User's Feedback
Answer / mayank rastogi
Use following code: It'll work
MOVE 'I N D I A' TO WS-NAME.
UNSTRING WS-NAME DELIMITED BY ' '
INTO WS-CHAR1, WS-CHAR2, WS-CHAR3, WS-CHAR4, WS-CHAR5.
STRING WS-CHAR1, WS-CHAR2, WS-CHAR3, WS-CHAR4, WS-CHAR5
DELIMITED BY SIZE INTO WS-NAME1.
ws-name1 is the new variable that will contain INDIA
without any spaces
| Is This Answer Correct ? | 11 Yes | 1 No |
Answer / uday
Through reference modification we can acheive and it is the
best way.
In Working storage section
01 ws-india pic x(10) value ' I N D I A '
01 ws-india-f pic x(05).
In procedure division
Perform varying ws-i from 1 by 1 until wi-i > 20
If ws-india(ws-i:1) = spaces
continue
Else
move ws-india(ws-i:1)to ws-india-f
End-if
End-perform
| Is This Answer Correct ? | 3 Yes | 0 No |
Answer / wairagade
Can we do with referrence modication operator .. your
thoughts :)
| Is This Answer Correct ? | 2 Yes | 0 No |
Answer / jagan
Yes we can do it with reference modification too . But feel
the code will become a bit complex.
| Is This Answer Correct ? | 1 Yes | 0 No |
Answer / arpan
Probably you can write SPACES instead of ' ' in the
UNSTRING statement.
UNSTRING WS-NAME DELIMITED BY SPACES
INTO WS-CHAR1, WS-CHAR2, WS-CHAR3, WS-CHAR4, WS-CHAR5.
STRING WS-CHAR1, WS-CHAR2, WS-CHAR3, WS-CHAR4, WS-CHAR5
DELIMITED BY SIZE INTO WS-NAME1.
| Is This Answer Correct ? | 2 Yes | 1 No |
Answer / jagan
Thanks Mayank .... My answer was not correct. The code what
you mentioned is working properly .. But what in case we
don't know how many spaces (or) delimiters are there in the
string.....
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / sup
small modification to ans 9th,
If ws-india(ws-i:1) = spaces
continue
Else
move ws-india(ws-i:1)to ws-india-f(i:1)
i=i+1
End-if
| Is This Answer Correct ? | 3 Yes | 3 No |
Answer / karthik
STRING WS-NAME DELIMETED BY SPACES
INTO
OUT-VAB
| Is This Answer Correct ? | 0 Yes | 6 No |
Answer / ashwani
With the help of Unstring delimited by ' ' , you can do so
Please correct me if i am wrong............
| Is This Answer Correct ? | 0 Yes | 8 No |
what is redefines? where it can be effectively use for the purpose of memory utilization? give an example?
What is the problem of ordered sequential files access?
What are VS COBOL 11 special features?
IF I mention stop run in CICS what happens?
What is the maximum length of a field you can define using COMP-3?
4 Answers Complex System, Infosys,
Whats the difference between search & search ALL?
plz,could any one tell me? what about EBCDIC in cobol?briefly?
Why did you choose to work with ibm mainframe cobol programming?
i have two file, each file having : file1 is having 2 fields field1 field2 file2 is having 3 fields field1 field2 field3 my req is to make it one file like: field1 field2 field1 field2 field3 if anyone know please send me syntax, i tried this with DFSORT but could not succeed.
In INITIALIZE what is Repalcing Word will do
What are different file OPEN modes available in COBOL?
i have mainprogram and subgram...if i compile mainprogram without stop run..what will u get in compilation time?