View previous topic :: View next topic
|
Author |
Message |
rohanthengal
Active User
Joined: 19 Mar 2009 Posts: 206 Location: Globe, India
|
|
|
|
I want to copy multiple PDS content into single output PDS. When I use LMCOPY in loop, it does not work for next iteration with same DATAID or DDNAME.
Any trick to crack this issue ? |
|
Back to top |
|
|
Akatsukami
Global Moderator
Joined: 03 Oct 2009 Posts: 1788 Location: Bloomington, IL
|
|
|
|
Yes; explain how it "doesn't work". |
|
Back to top |
|
|
rohanthengal
Active User
Joined: 19 Mar 2009 Posts: 206 Location: Globe, India
|
|
|
|
Code: |
DO I =1 to 5
"LMINIT DATAID("INDD1") DATASET("PDSNAME") ENQ(SHRW)" <<--- i am populating new pdsname in every new iteration but my OUTPDS is always same, since i want to merge members from multiple PDS and replace if already exists
"LMINIT DATAID("OUTDD1") DATASET("OUTPDS") ENQ(SHRW)"
"LMCOPY FROMID("INDD1") FROMMEM(*) TODATAID("OUTDD1") REPLACE TRUNC"
"LMFREE DATAID("INDD1")"
"LMFREE DATAID("OUTDD1")"
"LMCLOSE DATAID("INDD1")"
"LMCLOSE DATAID("OUTDD1")"
end |
But second iteration onwards my LMCOPY is failing. if i try using different DATAID i.e. INDD2 and OUTDD2 then it starts working. |
|
Back to top |
|
|
rohanthengal
Active User
Joined: 19 Mar 2009 Posts: 206 Location: Globe, India
|
|
|
|
I need help since i have 398 libraries from which i want to copy. |
|
Back to top |
|
|
Akatsukami
Global Moderator
Joined: 03 Oct 2009 Posts: 1788 Location: Bloomington, IL
|
|
|
|
Check the return codes from the LMINIT and LMCOPY services. I can already tell you that the LMCLOSE is useless, both because it comes after the LMFREE and because the data set was never opened. |
|
Back to top |
|
|
rohanthengal
Active User
Joined: 19 Mar 2009 Posts: 206 Location: Globe, India
|
|
|
|
perfect i have removved LMCLOSE.
If i see at LMINIT & LMCOPY Return codes, at first iteration it says 0 and at second iteration onwards LMINIT return code is 0 for both indd1 and outdd1 but LMCOPY is giving 10 means dataset is not associated with my DATAID. but i am unable to understand WHY ? Is there any limitation to use DATAID only for one copy iteration and start using different DATAIDs for further iterations e.g. INDD1 and OUTDD1 DATAIDs for first iteration, INDD2 and OUTDD2c DATAID for second iteration, INDD3 and OUTDD3 DATAID in third iteration and so on... but i am helpless since i cant use array as well and i have around 400 libraries from which members need to be copied.. |
|
Back to top |
|
|
Pedro
Global Moderator
Joined: 01 Sep 2006 Posts: 2547 Location: Silicon Valley
|
|
|
|
In the LMINIT, the DATAID(abc) parameter uses the name of the variable. In the LMCOPY and LMFREE, it is the value of the variable (rather than the name of the variable).
In your sample code segment, the LMINIT and LMFREE for the output file should be outside of the loop. |
|
Back to top |
|
|
rohanthengal
Active User
Joined: 19 Mar 2009 Posts: 206 Location: Globe, India
|
|
|
|
But i need to populate new PDSNAME in every iteration so that i would be able to copy members from that PDS. |
|
Back to top |
|
|
Pedro
Global Moderator
Joined: 01 Sep 2006 Posts: 2547 Location: Silicon Valley
|
|
|
|
In the first iteration,
as input to LMINIT. It uses 'DATAID' as the name of the variable to put the token in. After LMINIT,
Code: |
DATAID = 'ISR0001' /* for example*/ |
and it works because LMCOPY and LMFREE use ISR0001.
But on the second iteration,
as input to LMINIT. It uses 'ISR0001' as the name of the variable to put the token in. After LMINIT:
Code: |
ISR0001 = 'ISR0002' /* for example*/ |
|
|
Back to top |
|
|
Marso
REXX Moderator
Joined: 13 Mar 2006 Posts: 1353 Location: Israel
|
|
|
|
In other words, do:
Code: |
"LMINIT DATAID(INDD1) DATASET("PDSNAME") ENQ(SHRW)" |
(No quotes around INDD1, but only in the LMINIT)
In the sample you gave, you will copy the same file to the same place 5 times.
I hope your code is different. |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
|
|
Quote: |
I want to copy multiple PDS content into single output PDS. |
why waste time for a poor performing approach?
what is wrong in using the good old plain IEBCOPY in batch ??? |
|
Back to top |
|
|
rohanthengal
Active User
Joined: 19 Mar 2009 Posts: 206 Location: Globe, India
|
|
|
|
Thanks a lot Marso and Pedro. It worked out.. Many Many Thanks.
Taken dump of 400 libraries in one go.... COOL
I would have prepared job as well with IEBCOPY through REXX, thanks for other option Enrico.
There is one doubt, if same members are present in multiple source libraries then it should get replaced with last source, so i used REPLACE option in LMCOPY with PACK option. But i see there is one more option as TRUNC.
Whats the difference between PACK and TRUNC ?? |
|
Back to top |
|
|
prino
Senior Member
Joined: 07 Feb 2009 Posts: 1306 Location: Vilnius, Lithuania
|
|
|
|
rohanthengal wrote: |
Whats the difference between PACK and TRUNC ?? |
What's wrong with reading the manual, or giving the "MODEL" command and reading the generated NOTE lines it inserts? |
|
Back to top |
|
|
Pedro
Global Moderator
Joined: 01 Sep 2006 Posts: 2547 Location: Silicon Valley
|
|
|
|
Quote: |
Taken dump of 400 libraries in one go |
It is not totally clear what you are trying to accomplish... how about using ADRDSSU? or just issue HBACK command? |
|
Back to top |
|
|
|