IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

COBOL Program to Read Array data


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
raj4neo
Warnings : 1

New User


Joined: 12 May 2006
Posts: 51
Location: India

PostPosted: Sat Aug 15, 2015 12:28 am
Reply with quote

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
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Sat Aug 15, 2015 12:31 am
Reply with quote

And what problem are you having?
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3051
Location: NYC,USA

PostPosted: Tue Aug 18, 2015 1:45 am
Reply with quote

then loop 5 times and write to the file instead of 20.
Back to top
View user's profile Send private message
hailashwin

New User


Joined: 16 Oct 2008
Posts: 74
Location: Boston

PostPosted: Tue Aug 18, 2015 2:59 pm
Reply with quote

Quote:
then loop 5 times

or simply use reference modification? icon_smile.gif
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Tue Aug 18, 2015 5:05 pm
Reply with quote

hailashwin wrote:

or simply use reference modification? icon_smile.gif


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
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3051
Location: NYC,USA

PostPosted: Tue Aug 18, 2015 8:36 pm
Reply with quote

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
View user's profile Send private message
RahulG31

Active User


Joined: 20 Dec 2014
Posts: 446
Location: USA

PostPosted: Tue Aug 18, 2015 10:43 pm
Reply with quote

@Rohit Umarjikar and @hailashwin : You guys look like twins icon_wink.gif

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
View user's profile Send private message
hailashwin

New User


Joined: 16 Oct 2008
Posts: 74
Location: Boston

PostPosted: Wed Aug 19, 2015 1:58 pm
Reply with quote

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
icon_lol.gif
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed Aug 19, 2015 3:37 pm
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Store the data for fixed length COBOL Programming 1
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts Using API Gateway from CICS program CICS 0
No new posts Error to read log with rexx CLIST & REXX 11
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
Search our Forums:

Back to Top