View previous topic :: View next topic
|
Author |
Message |
kksbabu05
New User
Joined: 03 May 2007 Posts: 3 Location: chennai
|
|
|
|
There is a file, which has a account number field of 7 characters, need to convert the 7 character field to 11 character field by padding zeroes in the front and write to a new file using cobol program. |
|
Back to top |
|
|
murmohk1
Senior Member
Joined: 29 Jun 2006 Posts: 1436 Location: Bangalore,India
|
|
|
|
kksbabu05,
Plese post the variable declarations. |
|
Back to top |
|
|
IQofaGerbil
Active User
Joined: 05 May 2006 Posts: 183 Location: Scotland
|
|
|
|
Does your file look something like this?
Code: |
01 INFILE.
02 IN-1 PIC X(10).
02 IN-ACC PIC X(7).
02 IN-2 PIC X(33).
|
and do you want it to look something like this?
Code: |
01 OUTFILE.
02 OUT-1 PIC X(10).
02 NEW-ACC.
03 FILLER PIC X(4) VALUE ZEROS.
03 OUT-ACC PIC X(7).
02 OUT-2 PIC X(33).
|
or something else?
or do you need to pad the original 7 char field with zeros as well
e.g. is it already held as
or
please give examples. |
|
Back to top |
|
|
kksbabu05
New User
Joined: 03 May 2007 Posts: 3 Location: chennai
|
|
|
|
IQofaGerbil wrote: |
Does your file look something like this?
Code: |
01 INFILE.
02 IN-1 PIC X(10).
02 IN-ACC PIC X(7).
02 IN-2 PIC X(33).
|
and do you want it to look something like this?
Code: |
01 OUTFILE.
02 OUT-1 PIC X(10).
02 NEW-ACC.
03 FILLER PIC X(4) VALUE ZEROS.
03 OUT-ACC PIC X(7).
02 OUT-2 PIC X(33).
|
or something else?
or do you need to pad the original 7 char field with zeros as well
e.g. is it already held as
or
please give examples. |
Hi IQofaGerbil,
Whatever file layout you have mentioned is same
The program should be a subroutine
The subroutine is called using below Linkage variables
Old Static File Layout
New Static File Layout
File Processing Indicator
EOF Indicator
If the file processing indicator = Open, the static file is opened and the control is returned back to the main program
If the File processing indicator = Read, next record in the file is read and the account number field is converted from length of 7 to 11 and the values of the record are moved to the new record layout and the data is passed back to the main program
If the EOF is reached the EOF Indicator is set to true such that the main program will stop calling the adapter to read further record |
|
Back to top |
|
|
kksbabu05
New User
Joined: 03 May 2007 Posts: 3 Location: chennai
|
|
|
|
Hi IQofaGerbil,
Whatever file layout you have mentioned is same
The program should be a subroutine
The subroutine is called using below Linkage variables
Old Static File Layout
New Static File Layout
File Processing Indicator
EOF Indicator
If the file processing indicator = Open, the static file is opened and the control is returned back to the main program
If the File processing indicator = Read, next record in the file is read and the account number field is converted from length of 7 to 11 and the values of the record are moved to the new record layout and the data is passed back to the main program
If the EOF is reached the EOF Indicator is set to true such that the main program will stop calling the adapter to read further record
Please let me know the code |
|
Back to top |
|
|
IQofaGerbil
Active User
Joined: 05 May 2006 Posts: 183 Location: Scotland
|
|
|
|
Quote: |
If the file processing indicator = Open, the static file is opened and the control is returned back to the main program
If the File processing indicator = Read, next record in the file is read and the account number field is converted from length of 7 to 11 and the values of the record are moved to the new record layout and the data is passed back to the main program
If the EOF is reached the EOF Indicator is set to true such that the main program will stop calling the adapter to read further record
|
...errrmmm I think that you have practically all but coded it yourself have you not?
Just ad a few IFs and ELSEs thow in a MOVE an OPEN maybe a READ and a GOBACK
place them all strategically in your spec and you are away!
Unless of course that this is your first Cobol program - ever? |
|
Back to top |
|
|
|