Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


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?

Answers were Sorted based on User's Feedback



here is my requirement A1 is alphanumeric with value 'A1B2C3D4' as defined below 05 A1..

Answer / rajkanya

DATA DIVISION.
WORKING-STORAGE SECTION.
01 GROUP1.
05 A1 PIC X(08)
VALUE 'A1B2C3D4'.
05 ARRAY1 REDEFINES A1 OCCURS 8 TIMES
PIC X(01).
01 ARRAY2.
05 A2 OCCURS 4 TIMES PIC X(01).
01 ARRAY3.
05 A3 OCCURS 4 TIMES PIC X(01).
01 WS-COUNT PIC 9(02)
VALUE 01.


PROCEDURE DIVISION.

PERFORM MOVE-LETTERS-PARA VARYING ODD FROM 1 BY 2
UNTIL ODD > 8
* INITIALIZE THE COUNTER FOR SECOND LOOP
MOVE 01 TO WS-COUNT
*
PERFORM MOVE-NUMBERS-PARA VARYING EVEN FROM 2 BY 2
UNTIL EVEN > 8
.
.
.
MOVE-LETTERS-PARA.
MOVE ARRAY (ODD) TO ARRAY2 (WS-COUNT)
ADD 1 TO WS-COUNT
.
.
MOVE-NUMBERS-PARA.
MOVE ARRAY (EVEN) TO ARRAY3 (WS-COUNT)
ADD 1 TO WS-COUNT
.
.
.

Is This Answer Correct ?    2 Yes 0 No

here is my requirement A1 is alphanumeric with value 'A1B2C3D4' as defined below 05 A1..

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

More COBOL Interview Questions

Can we call a CICS program from a batch program or viceversa?If so, how?

3 Answers  


What is the difference between PIC 9.99 and 9v99?

7 Answers  


What is difference between static and dynamic call in cobol?

0 Answers  


Hi All, how is sign is stored in S9(17) comp-3 variable. Answer with an Example will be of great help.

5 Answers   EDS,


what if any ,is the syntex error in the following piece of code 01 B PIC A(7) 02 C PIC 9(4) ........ IF(B NUMERIC) ADD 10 TO C a.the condition in the if statement is wrong b.noting is wrong c.because C is initialised.ADD 10 TO C is wrong d.both B and C shoud have same size.

5 Answers   TCS,


when SE37 SB37 and sd37 occurs how to increase the volume , primary quantity and secondary quantity?

1 Answers   Hewitt,


What are the ways you can generate a copybook?

2 Answers  


what is soc7 abend?how u can trace it?

4 Answers   Accenture,


Hi Guys, I have faced one interview question if I have requirement to add 5 new columns to existing table what are prerequisite do i need to take.

1 Answers  


how we sort two input files based on a common column and giving one o/p file please send me the coding logic?

0 Answers   Valtech,


what is MSGLEVEL?

1 Answers   IBM,


A cobol program to read a file , match it with other if. If match occurs then write it to an output file. If no match then no need to write it.Error log created by program to track any error.

1 Answers  


Categories