View previous topic :: View next topic
|
Author |
Message |
PRAKMAIN
New User
Joined: 25 Nov 2010 Posts: 7 Location: UK
|
|
|
|
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 |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8697 Location: Dubuque, Iowa, USA
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
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 |
|
|
PRAKMAIN
New User
Joined: 25 Nov 2010 Posts: 7 Location: UK
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
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 |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
Back to top |
|
|
Phrzby Phil
Senior Member
Joined: 31 Oct 2006 Posts: 1042 Location: Richmond, Virginia
|
|
|
|
Quote: |
MOVE CORR works by moving items with the same name.
|
But does not handle OCCURSes. |
|
Back to top |
|
|
PRAKMAIN
New User
Joined: 25 Nov 2010 Posts: 7 Location: UK
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
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 |
|
|
Shamsudeen
New User
Joined: 16 Jan 2006 Posts: 4
|
|
|
|
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 |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
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 |
|
|
PRAKMAIN
New User
Joined: 25 Nov 2010 Posts: 7 Location: UK
|
|
|
|
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 |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8697 Location: Dubuque, Iowa, USA
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
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 |
|
|
PRAKMAIN
New User
Joined: 25 Nov 2010 Posts: 7 Location: UK
|
|
|
|
@ 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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
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 |
|
|
|