Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

COBOL Program to Read Array data

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
raj4neo
Warnings : 1

New User


Joined: 12 May 2006
Posts: 49
Location: India

PostPosted: Sat Aug 15, 2015 12:28 am    Post subject: COBOL Program to Read Array data
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7225

PostPosted: Sat Aug 15, 2015 12:31 am    Post subject: Reply to: COBOL Program to Read Array data
Reply with quote

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

Senior Member


Joined: 21 Sep 2010
Posts: 1609
Location: NY,USA

PostPosted: Tue Aug 18, 2015 1:45 am    Post subject:
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: 73
Location: Boston

PostPosted: Tue Aug 18, 2015 2:59 pm    Post subject:
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7225

PostPosted: Tue Aug 18, 2015 5:05 pm    Post subject:
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

Senior Member


Joined: 21 Sep 2010
Posts: 1609
Location: NY,USA

PostPosted: Tue Aug 18, 2015 8:36 pm    Post subject:
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: 331
Location: USA

PostPosted: Tue Aug 18, 2015 10:43 pm    Post subject: Reply to: COBOL Program to Read Array data
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: 73
Location: Boston

PostPosted: Wed Aug 19, 2015 1:58 pm    Post subject:
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7225

PostPosted: Wed Aug 19, 2015 3:37 pm    Post subject: Reply to: COBOL Program to Read Array data
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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts How to move a long alphanumeric data ... lind sh COBOL Programming 2 Mon Dec 05, 2016 7:51 pm
No new posts IMS BMP program causes 878 system abend Artemk IMS DB/DC 7 Tue Nov 22, 2016 8:26 pm
This topic is locked: you cannot edit posts or make replies. RANDOM Function in COBOL swapnil781 COBOL Programming 2 Tue Nov 15, 2016 6:17 pm
No new posts ODPP(Optim Data privacy Provider) Iss... Rama kishore IBM Tools 1 Mon Nov 07, 2016 5:46 pm
No new posts Regarding COBOL Stored Procedure opti... selvamsrinivasan85 DB2 4 Fri Nov 04, 2016 8:57 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us