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 S04E error in jcl?
11 Answers IBM, L&T,
How to delete a front spaces in a data-name/variable in cobol Example:- 01 data-name-1 PIC x(20) value " cobol language". 01 data-name-2 PIC x(20). MOVE data-name-1 to data-name-2. would like the value of data-name-2 is "cobol language".
In A cobol program , we can use COPY Statement in FILE- SECTION / WORKING-STORAGE SECTION / ENVIRONMENT DIVIION basically what is the difference
01 a pic 9(6) value is 123456 01 b pic 9(3) move a to b wht will be the value ?
TO abend the data sholud open in which mode? 1.new 2.old 3.mod 4.shr
WE HAVE 2 FILES IN COBOL. ONE IS FIXED LENGTH RECORDS ANOTHER ONE IS VARIABLE LENGTH. IF I DECLEAR LRECL OF FIXED ONE AS 80 AND 2ND RECORD AS 132. WHAT WE NEED TO DECLEAR LRECL FOR THOSE 2 FILES IN JCL?
What are various search techniques in cobol? Explain.
subscript and index r not coded in u r application program what will happen?
Can we use redefine clause in occurs clause?
i have a file which contains records like 10,30,90,50,20,40,80,60,70 i want to display these records in reverse order like 70,60,80,40,20,50,90,30,10 please give me the cobol code (do not sort the records)
3 Answers Cap Gemini, Mind Tree,
how can you identify wheather the program is using search or search all in the cobol program?
In CICS/VSAM every file that is accessed should be defined in FCT. we have CICS READ, WRITE, BROWSE commands for VSAM files. How does it work with DB2 tables. It know it has to do with the plan. Please expain with examples.