here is my requirement
A1 is alphanumeric with value 'A1B2C3D4' as defined below
05 A1 PIC X(8) VALUE IS 'A1B2C3D4'
but i need to have A2,A3 as ABCD & 1234 repectively......
A2 = ABCD
A3 = 1234
Can you please explain me what are the different ways to do it?
Answer Posted / mainframe guy
You can also do it this way:
DATA DIVISION
01 A1 VALUE 'A1B2C3D4'
05 A1-CHAR PIC X(01) OCCURS 8.
01 A2 PIC X(04) VALUE SPACES.
01 A3 PIC X(04) VALUE SPACES.
01 I PIC 9(02) VALUE ZEROS.
01 J PIC 9(02) VALUE ZER0S.
01 K PIC 9(02) VALUE ZEROS.
PROCEDURE DIVISION.
MOVE 1 TO I J K
PERFORM VARYING I FROM 1 BY 1 UNTIL WS-I > 8
IF A-CHAR(I) IS NUMERIC
MOVE A-CHAR(I) TO A3(K:1)
ADD 1 TO K
ELSE
MOVE A-CHAR(I) TO A2(J:1)
ADD 1 TO J
END-IF
END-PERFORM
Now you will have A2 = ABCD and A3 = 1234
This method can be used only if you want to seperate numbers
from alphabets. Otherwise, the previous solution has to be used.
| Is This Answer Correct ? | 2 Yes | 0 No |
Post New Answer View All Answers
I have File 1 occurs 5 times with Employee-ID,Employee-Name,Employee-Dept (EEE and MECH). I have File 2 occurs 10 times with Employee-ID,Employee-Name,Employee-Dept (EEE,CIVIL,CHEMICAL and MECH). In FIle 1 and FIle 2 , for matching Employee-DEPT (Only MECH) , we need to move entire records from file1 to file 2. We should not use 2D array. Your help is needed here.
If you are current on the owner of a set, what is the difference between an obtain next and obtain first? Actually in which topic will we use dis???Plz explain it clearly
What is amode(24), amode(31), rmode(24) and rmode(any) (applicable to only mvsesa enterprise server) ?
IF I mention stop run in CICS what happens?
What are the different rules of SORT operation?
what is difference bt COND, REGION & TIME parameters at JOB & EXEC. give an exp.
What is static and dynamic call in cobol?
Explain how you can characterize tables in cobol?
Give some examples of command terminators?
Why do we code s9 (4) comp. Inspite of knowing comp-3 will occupy less space?
What is difference between static and dynamic call in cobol?
What is report-item in COBOL?
In which area will you utilize 88 level items in cobol?
What is a scope terminator give example?
how we sort two input files based on a common column and giving one o/p file please send me the coding logic?