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.

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

what happens if parmparameter passes zero bytes to the program

1648


Explain about different table spaces.

636


What is the default value(s) for an initialize and what keyword allows for an override of the default?

681


Write a program to explain size error.

665


I need to compare 3 variables(dates) and do some processing based on the earliest date. There could be more then 1 date record in any of the 3 fields. What is the best way to code this?

1794






if we display var1 then what will b displayed in below condition. 77 var1 pic s9(2) value -10. 77 var1 pic s9(2) value -11. " " " -12. " " " -13. -14 ... ... -19.

5651


Write some characteristics of cobol as means of business language.

608


How do u write test cases?

1629


Why did you choose to work with ibm mainframe cobol programming?

619


How many sections are there in data division in COBOL?

667


How can i load all the data from a file to Table (array) in cobol.How i manage the occurs clause with out reading the file.Any options avilable ? Please can any one help me it is urgent?

2087


Why is it necessary that file needs to be opened in I-O mode for REWRITE?

730


how do you reference the variable unblock file formats from cobol programs

731


Difference between cobol and cobol-ii?

695


which is Best IBM Mainframe Training and Placement Institute in Ameerpet Hyderabad

1011