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

Move corresponding for a group item


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

New User


Joined: 25 Nov 2010
Posts: 7
Location: UK

PostPosted: Sat Dec 04, 2010 8:54 pm
Reply with quote

Hi ,

I want move a group/occur item to output file in a delimited format.

For example , I want to create output file in a delimited format .every field should be followed by a delimiter '@@'

Input file :-
01 Fxxxx-ORECORD.
05 Fxxxx-KEY.
10 Fxxxx-CLASS PIC XX.
10 Fxxxx-COVER PIC X.
10 Fxxxx-PROFILE PIC X.
05 Fxxxx-DESCRIPTION PIC X(30).
05 Fxxxx-XS-DETAILS OCCURS 6.
10 Fxxxx-EFF-DATE-CC PIC -9(7).
10 Fxxxx-XS-CODES.
15 Fxxxx-XS-CODE PIC 999 OCCURS 20.
05 FILLER PIC X(2).

Should be converted to below format file(with delimiter!!)

01 Fyyyy-ORECORD.
05 Fyyyy-KEY.
10 Fyyyy-CLASS PIC XX.
10 FILLER PIC XX VALUE '//'.
10 Fyyyy-COVER PIC X.
10 FILLER PIC XX VALUE '//'.
10 Fyyyy-PROFILE PIC X.
10 FILLER PIC XX VALUE '//'.
05 Fyyyy-DESCRIPTION PIC X(30).
05 FILLER PIC XX VALUE '//'.
05 Fyyyy-XS-DETAILS OCCURS 6.
10 Fyyyy-EFF-DATE-CC PIC -9(7).
10 FILLER PIC XX VALUE '//'.
10 Fyyyy-XS-CODES.
15 Fyyyy-XS-CODE PIC 999 OCCURS 20.
05 FILLER PIC XX VALUE '//'.
05 FILLER PIC X(2).


I have used a move corresponding verb but it is not working for the group variable and occurs clause. I donot want to use 'sort' because some of the copy books for other files are really big.


Please could see how it can be achieved?
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Sat Dec 04, 2010 10:50 pm
Reply with quote

Quote:
I have used a move corresponding verb but it is not working for the group variable and occurs clause.
What does this mean? Did the MOVE CORR give a syntax error in the compile? Did it compile correctly but not produce the desired results? Something else entirely? Saying something "is not working" is telling us nothing at all.

And a MOVE CORR will work if -- and only if -- xxxx and yyyy in your variables are the same for each subordinate variable. MOVE CORR works by moving items with the same name. Call the variable different names in the two structures and MOVE CORR will move nothing.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Sun Dec 05, 2010 6:05 am
Reply with quote

Hello,

You are looking for an "effortless" way of getting form the input the the desired output.

It is not going to happen with a MOVE or MOVE CORR. . .

Suggest you build a loop within a loop and using STRING and/or Reference Modification build the output you want.
Back to top
View user's profile Send private message
PRAKMAIN

New User


Joined: 25 Nov 2010
Posts: 7
Location: UK

PostPosted: Sun Dec 05, 2010 6:50 pm
Reply with quote

Hi

@Robert,

During compile , I am getting a error saying 'trying to move a group item'
For rest of the copybooks without any table or group variables, Move corresponding verb work fine.

@Dick,

Please could you provide an example for the suggestion?

Cheers
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Sun Dec 05, 2010 11:10 pm
Reply with quote

Hello,

Quote:
During compile , I am getting a error saying 'trying to move a group item'
Because what you atr trying to do is not supported. . . Or said differently, you cannot do that (as we mentioned before).. . .

I don't have a sample but you can write one and ask us for guidance when you have questions. Suggest you write pseudo code and post this so we can see that you are on the right track before writing the "real" code. If the output is going to be exactly as you posted, you can do what you want with a neested loops and simple MOVEs.
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6250
Location: Mumbai, India

PostPosted: Mon Dec 06, 2010 4:22 pm
Reply with quote

Well, start from here: 2.8.7.1 CORRESPONDING Phrase.
Back to top
View user's profile Send private message
Phrzby Phil

Senior Member


Joined: 31 Oct 2006
Posts: 1042
Location: Richmond, Virginia

PostPosted: Mon Dec 06, 2010 6:26 pm
Reply with quote

Quote:
MOVE CORR works by moving items with the same name.


But does not handle OCCURSes.
Back to top
View user's profile Send private message
PRAKMAIN

New User


Joined: 25 Nov 2010
Posts: 7
Location: UK

PostPosted: Mon Dec 06, 2010 7:32 pm
Reply with quote

01 monthidx pic 99.

05 Fxxxx-XS-DETAILS OCCURS 6.
10 Fxxxx-EFF-DATE-CC PIC S9(7) COMP-3.
10 Fxxxx-XS-CODES.
15 Fxxxx-XS-CODE PIC 999 OCCURS 20.

05 Fyyyy-XS-DETAIL OCCURS 6.
10 Fyyyy-EFF-DATE-CC PIC -9(7).
10 FILLER PIC XX VALUE '//'.
10 Fyyyy-XS-CODES.
15 Fyyyy-XS-COD PIC 999 OCCURS 20.
05 FILLER PIC XX VALUE '//'.

PERFORM VARYING MonthIdx FROM 1 BY 1 UNTIL MonthIdx > 6
MOVE corresponding Fxxxx-xs-details(MONTHIDX) of fxxxx-record
of fxxxx-record TO
Fyyyy-xs-detail(monthidx)
END-PERFORM

Please find the pesudo code , I have developed and tested but this also didnot work..
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Mon Dec 06, 2010 8:50 pm
Reply with quote

Hello,

Quote:
but this also didnot work..
As we explain to many people - posting "it didn't work" simply wastes everyone's time (especially yours).

What didn't work? Some compiler error(s). Some abend? Undesired results?

If you don't explain what has happened, we cannot help much. . .

For starters, you used MOVE CORR again after being repeatedly told you cannot. . . So, take our the CORR and replace with the necessary MOVEs.
Back to top
View user's profile Send private message
Shamsudeen

New User


Joined: 16 Jan 2006
Posts: 4

PostPosted: Tue Dec 07, 2010 7:03 pm
Reply with quote

Hey PRAKMAIN

The following items will not work for MOVE CORR
- 66 RENAMES
- 77 ELEMENTARY
- 88 Condition
- INDEX
- ARRAY

Your code uses an array
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Tue Dec 07, 2010 7:53 pm
Reply with quote

you will never be able to populate

10 Fyyyy-EFF-DATE-CC PIC -9(7)

with

10 Fxxxx-EFF-DATE-CC PIC S9(7) COMP-3

in a move corresponding.

they have to be the same reference name.
(as everybody has said, over, and over, and over again.
Back to top
View user's profile Send private message
PRAKMAIN

New User


Joined: 25 Nov 2010
Posts: 7
Location: UK

PostPosted: Tue Dec 07, 2010 8:44 pm
Reply with quote

PERFORM VARYING MonthIdx FROM 1 BY 1 UNTIL MonthIdx > 6
MOVE CORRESPONDING Fxxxx-XS-DETAILS(MONTHIDX)
TO
F0513-xs-detail(monthidx)
END-PERFORM

This peace code is completing without any errors but values on the table is empty.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Tue Dec 07, 2010 9:03 pm
Reply with quote

PRAKMAIN, MOVE CORRESPONDING is not a panacea -- it works for certain operations and only for certain operations. As you have discovered, it does not work for what you want to do. You can change your MOVE statements, find another way to accomplish what you want, or find another career as IT does not seem very well suited to you. You have been told -- repeatedly -- that what you want to do is not allowed under the rules of COBOL as specified in section 6.1.8.1 of the COBOL Language Reference manual (link at the top of the page). Your insistence on doing the MOVE your way and ignoring the advice of your seniors indicates communication is not one of your skills -- yet communication is incredibly important to an IT career, hence my recommendation you reconsider IT as a career choice.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Tue Dec 07, 2010 9:23 pm
Reply with quote

Hello,

Quote:
This peace code is completing without any errors but values on the table is empty.
Which part of NO has not been clear?

There is a major difference between being persistent and merely being obstinate. . .

If you cannot understand why what you insist on doing is wrong, we need to close this topic. . . The documentation, senior people here, and your senior co-workers (if you would speak with them) all have the same "rules". You (for whatever reason) refuse to follow them.

Also, for what it is worth, many organizations do not even permit the use of MOVE CORRESPONDING in any code on their systems.
Back to top
View user's profile Send private message
PRAKMAIN

New User


Joined: 25 Nov 2010
Posts: 7
Location: UK

PostPosted: Tue Dec 07, 2010 10:10 pm
Reply with quote

@ Dick,

Data for Fxxxx-XS-COD is empty.

I am not adament in using 'corresponding' verb.I know it will not work.I have stopped using it.
I am trying some other ways to populate the required data now.

-
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Tue Dec 07, 2010 10:19 pm
Reply with quote

Hello,

Quote:
I am trying some other ways to populate the required data now.
Use a MOVE from one field to the other. . .

Possibly it will help if you show what you coded (variables and procedure code for the problem field(s)) and explain what happens in more detail.
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 COBOL - Move S9(11)v9(7) COMP-3 to -(... COBOL Programming 5
No new posts How to move the first field of each r... DFSORT/ICETOOL 5
No new posts Compare latest 2 rows of a table usin... DB2 1
No new posts Problem with IFTHEN=(WHEN=GROUP,BEGIN... DFSORT/ICETOOL 5
No new posts Splitting group records based on deta... DFSORT/ICETOOL 8
Search our Forums:

Back to Top