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



I've one string with spaces ( I N D I A ). My question is I want remove the spaces & comb..

Answer / jagan

Inspect string1 replacing all spaces by ''

Is This Answer Correct ?    13 Yes 2 No

I've one string with spaces ( I N D I A ). My question is I want remove the spaces & comb..

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

I've one string with spaces ( I N D I A ). My question is I want remove the spaces & comb..

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

I've one string with spaces ( I N D I A ). My question is I want remove the spaces & comb..

Answer / wairagade

Can we do with referrence modication operator .. your
thoughts :)

Is This Answer Correct ?    2 Yes 0 No

I've one string with spaces ( I N D I A ). My question is I want remove the spaces & comb..

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

I've one string with spaces ( I N D I A ). My question is I want remove the spaces & comb..

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

I've one string with spaces ( I N D I A ). My question is I want remove the spaces & comb..

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

I've one string with spaces ( I N D I A ). My question is I want remove the spaces & comb..

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

I've one string with spaces ( I N D I A ). My question is I want remove the spaces & comb..

Answer / karthik

STRING WS-NAME DELIMETED BY SPACES
INTO
OUT-VAB

Is This Answer Correct ?    0 Yes 6 No

I've one string with spaces ( I N D I A ). My question is I want remove the spaces & comb..

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

Post New Answer

More COBOL Interview Questions

wht is packed decimal in cobol

2 Answers  


How do you code cobol to access a parameter that has been defined in jcl? And do you code the parm parameter on the exec line in jcl?

0 Answers  


Read a flat file and write last but one (I have n records in a file I have to write n-1th) record in another flat file. Could you please provide me the code in COBOL?

1 Answers  


if a>b continue display x. dispaly y. end-if display 1 display 2. display 3. what should be my output ?

3 Answers  


Consider the following code: 77 A PIC 99V99 VALUE 55.35 77 B PIC 99V999 VALUE 32.754 ADD B TO A ON SIZE ERROR DISPLAY "ERROR!!!" What will be the result ? (a) A=88.10, B=32.754 (b) A=87.00 B=32.754 (c) A=87.10 B=32.754 (d) ERROR!!! will be DISPLAYed on the screen.

3 Answers   TCS,






Following questions were asked in Capegemini on 8th sep,2012 mainframe test 1.)Condition code for dul recors in VSAM- 2.) Is NULL or =NULL in Select statement 3.)max size of CI 4.)What happens after CI is full 5.)Ques on COND parameter 6.)which among following can not be rolled back a)delete table b.)droptable c)Update d.)insert 7.)groupby and orderby sql querries 8.)Max extents in VSAM file 9.)quesn on DPRTY=(1,10) 10.)range of condition codes in COBOL 11.)occurs clase can not be used at which level? 12.)delimiter in jcl 13.)sort card for file in PGM=SORT 14.)PIC(6) value 120056 possible? 15)question on BLKSIZE Is (20,20) and (20,10) possible? 16.)number of bytes in RDF 17.)Can we use index in WS-section or LK-section 18.)Verify command in IDCAMS used for? 19.)question on Alternate Index 20.)Return code of file attribute mismatch 21.)In which format COBOL variables stored? 22.)what is Alternate of HANDLE? 23.)can SUM,AVG,MIN,ROUND used in numeric and char variable data types? 24.)What is the datatype of FILE STATUS codes in WS-section?

2 Answers   Cap Gemini,


EXPLAIN MAIN FRAME TESTING PROCESS...HOW TO FIX THE MAINFRAME BUGS?

0 Answers   Accenture,


Hi pls anybody tell me about " ANALYSIS DOCUMENT PREPARATION AND ESTIMATION OF TASK " (in real time project)."I want to update a sequential file in my project" for that purpose i need both structures i mean analysis document and estimation of task.

0 Answers  


if a dataset is already created with fixed length but after that i want to change fixed length to variable length then how is it possible

3 Answers   IBM,


Can we put move statement in COBOL copybook

3 Answers   Global Logic,


Extract only those records from a PS file which are having word 'TEXT' in the records using COBOL? The word TEXT is not present in a particular position in all the records.

2 Answers   RBS,


What is different between variable length and fixed length?

2 Answers   TCS,


Categories