How to delete leading spaces/blank in COBOL ?
Example:- 01 data-name-1 pic x(220) " English is a
language".
I would like to delete leading spaces.
Answers were Sorted based on User's Feedback
Answer / varun v
Yes, we can use "Inspect Tallying" for the same.
Wroking storage Variable:
01 WS-VAR PIC X(15) VALUE ' COBOL'.
01 WS-VAR-FINAL PIC X(15).
01 WS-TALLY1 PIC 9(02) VALUE ZERO.
Procedure Dvision:
Inspect WS-VAR Tallying WS-TALLY1 for leading spaces
Move WS-VAR(WS-TALLY1+1 : 15-WS-TALLY1) to
WS-VAR-FINAL.
Now WS-INSPECT-FINAL should have
Value 'COBOL'.
Is This Answer Correct ? | 50 Yes | 12 No |
Answer / xyz
USe the Inspect Clause , get the number of the leading
spaces in the Count variable. Use the reference move then.
Is This Answer Correct ? | 32 Yes | 5 No |
Answer / naveen
You have many options.
1. Use Reference modification if you want a COBOL program.
2. INSPECT will also do.
3. Use SORT, OUTREC option, it will also work.
Is This Answer Correct ? | 8 Yes | 1 No |
Answer / varun v
I agree with Ans # 1 also.
But I think "Inspect Tallying" is the effective one as
there is no manual calculation is required for finding the
exact length of the second variable field(CHR6 in Ans #1)
is required.
Is This Answer Correct ? | 7 Yes | 3 No |
Answer / arne royce tiangson
I CAN FIND THE WRITE OUTPUT.. PLEASE EXPLAIN THIS CODE
'MOVE WS-USERID-TEMP(WS-TALLY + 1 : ) TO WS-LS-USERID'
THNX
Is This Answer Correct ? | 1 Yes | 2 No |
Answer / prasanth
Wroking storage Variable:
01 WS-VAR PIC X(15) VALUE ' COBOL'.
01 WS-VAR-FINAL PIC X(15).
01 WS-TALLY1 PIC 9(02) VALUE ZERO.
Procedure division
INITIALIZE WS-TALLY
MOVE ID-TBL-IMMS OF TBL TO WS-USERID-TEMP
INSPECT WS-USERID-TEMP TALLYING WS-TALLY
FOR LEADING SPACE
MOVE WS-TALLY TO WS-TEMP
IF WS-TALLY IS NOT ZERO
MOVE WS-USERID-TEMP(WS-TALLY + 1 : ) TO WS-LS-USERID
Is This Answer Correct ? | 6 Yes | 10 No |
Answer / minarul
you can do this by defining another varible with JUSTIFIED
RIGHT clause. then move the value from data-name-1 to that
varible. You have to define the picture clause of that
varible with proper length : below code will exactly do
that:
01 data-name-1 pic x(220) " English is a language".
01 CHR6 PIC X(217) JUSTIFIED RIGHT.
now do a move from data-name-1 to CHR6 and then disolay
the content of CHR6
Is This Answer Correct ? | 20 Yes | 33 No |
How do you submit JCL via a Cobol program?
The hierarchy of the execution of logical operators is (a) NOT AND OR (b) AND OR NOT (c) OR AND NOT (d) OR NOT AND
10 Answers Huawei, IBM, TCS,
INREC AND OUTREC? HOW TO SPLIT 5K RECORDS TO DIFFERENT FILES IN A FILE IN COBOL? RESTART IN COBOL-DB2? ISOLATION LEVELS?
What are the ways you can generate a copybook?
ID DIVISION. PROGRAM-ID. PLO. DATA DIVISION. WORKING-STORAGE SECTION. 01 VAR1 PIC 9(2). 01 VAR2 PIC X(2). PROCEDURE DIVISION. ACCEPT VAR2. MOVE VAR2 TO VAR1. STOP RUN. if i give 'PI' in var2 then what will b output of progr. any abend?????
How can I tell if a module is being called DYNAMICALLY or STATICALLY?
01 a pic x(6) value is abcdef 01 b pic x(3) move a to b wht will be the value in b ?
we can use set true for condition names.. similarly can we code set to false in cobol pgm? will it work?
where did you see the information regarding abend codes in jcl?
what is call by value and call by reference ?
3 Answers Infosys, ITC Indian Tobacco Company,
What is the difference between a subscript and an index in a table definition?
wirte a pgm in using files in which we hav 10 ,20,30 40...100 records in inputfile and i want them to be send to outputfile in reverse order. PLZ HELP ME OUT .........THIS IS A RECENT QUESTION IN IGATE..