View previous topic :: View next topic
|
Author |
Message |
raj4neo Warnings : 1 New User
Joined: 12 May 2006 Posts: 51 Location: India
|
|
|
|
Hi ,
I am getting a Infile with array data
Quote: |
IN-APPP-REC OCCURS 20 TIMES.
A5PPP-KIT-KEY.
***************
**************
A5PLCY-KIT-DATA
**********************
******************** |
This infile we are getting from external application and it was used by all others application too ..
My Requirements is I need to extract the First five array data of
IN-APPP-REC and write to the output file . from the array data of 20 infile
Thanks in Advance |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
And what problem are you having? |
|
Back to top |
|
|
Rohit Umarjikar
Global Moderator
Joined: 21 Sep 2010 Posts: 3051 Location: NYC,USA
|
|
|
|
then loop 5 times and write to the file instead of 20. |
|
Back to top |
|
|
hailashwin
New User
Joined: 16 Oct 2008 Posts: 74 Location: Boston
|
|
|
|
or simply use reference modification? |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
hailashwin wrote: |
or simply use reference modification? |
No. For someone who does not know what to do with a table in a record-layout, reference-modification or a group move is not a good suggestion.
If the data, of which we know nothing, is character-only (all PIC X or or all PIC A or any mixture of the two) then reference-modification or a group move would be OK.
However, with numerics the actual resultant data can be different between individual MOVEs and a group move or reference-modification, due to compiler options like TRUNC and NUMPROC and the simple fact that group moves and reference-modification don't take any account of how fields are defined. |
|
Back to top |
|
|
Rohit Umarjikar
Global Moderator
Joined: 21 Sep 2010 Posts: 3051 Location: NYC,USA
|
|
|
|
Ignore my last comment pls.
Quote: |
I need to extract the First five array data of IN-APPP-REC |
what size of first five elements? what is the layout of IN-APPP-REC ? What type of data present?
I would suggest you to read the file to array of 20 elements and then declare another 01 level record layout for writting the file from which only consist of 5 first five elements and then simply write 5 move statements before you write. |
|
Back to top |
|
|
RahulG31
Active User
Joined: 20 Dec 2014 Posts: 446 Location: USA
|
|
|
|
@Rohit Umarjikar and @hailashwin : You guys look like twins
I think there's no reason we should be bothered about this post when the questioner himself is not interested in telling what the problem is. |
|
Back to top |
|
|
hailashwin
New User
Joined: 16 Oct 2008 Posts: 74 Location: Boston
|
|
|
|
Quote: |
However, with numerics the actual resultant data can be different between individual MOVEs and a group move or reference-modification, due to compiler options like TRUNC and NUMPROC |
Wow, I never knew this. Thanks Bill for elobrating.
Quote: |
@Rohit Umarjikar and @hailashwin : You guys look like twins |
|
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Code: |
01 a-group.
05 some-data PIC S9.
05 some-other-data PIC 9.
01 b-group PIC XX.
01 c-group.
05 c-some-data PIC S9.
05 c-some-other-data PIC 9.
...
MOVE X'1F1C' TO a-group
MOVE a-group TO b-group
MOVE some-data TO c-some-data
MOVE some-other-data TO c-some-other-data
IF b-group NOT EQUAL TO c-group
DISPLAY "That's weird"
END-IF
|
If you run that code compiled with NUMPROC(NOPFD) or NUMPROC(MIG) you'll see "That's weird" in the sysout.
Note that I've put signs in the data which don't conform to the PICture. With NOPFD and MIG the signs will be "fixed" in the individual MOVEs and not in the group-MOVE.
If your data is known to be good, always, you'd be using NUMPROC(PFD). Using NUMPROC(PFD) with the above, not-so-good, data, does not produce the DISPLAY :-)
There is no problem doing group-MOVEs with character data. No problem with DISPLAY or PACKED-DECIMAL as long as the data conforms to PICture (including the number of digits represented). With binary data there is no problem with COMP-5 fields or if TRUNC(BIN) is being used, and potential problem with TRUNC(OPT) if data does not conform to PICture (since to use OPT you have to guarantee that data does conform to PICture) and TRUNC(STD).
The issues become a potential problem if the data is going to another Mainframe system which does not have the same settings for those compile options.
Always remember that with NUMPROC(PFD) data which does not conform to PICture will almost guarantee problems, within your own system. |
|
Back to top |
|
|
|