View previous topic :: View next topic
|
Author |
Message |
Pedro
Global Moderator
Joined: 01 Sep 2006 Posts: 2546 Location: Silicon Valley
|
|
|
|
Use the PARSE statement. |
|
Back to top |
|
|
Akatsukami
Global Moderator
Joined: 03 Oct 2009 Posts: 1788 Location: Bloomington, IL
|
|
|
|
Pedro wrote: |
Use the PARSE statement. |
"Use the parse, Luke!" |
|
Back to top |
|
|
sakrat
Active User
Joined: 05 Feb 2014 Posts: 164 Location: India
|
|
|
|
yes wrote a syntax with PARSE statement as below :
PARSE VALUE '"RES"' WITH PRE '(' POST ')'
SAY POST
POST1=SUBSTR(POST,2)
SAY POST1
IF DATATYPE(POST1) == NUM
ITERATE
END
dont know whether this will work or not...will try this tommorow and let you know people.....
in the above code i have taken POST variable if it is a GDG it will have wither + or - sign in first position so i removed that by using SUBSTR and the checking whether it is a NUMERIC or CHARACTER...if it is NUMERIC then it shows that it is GDG and so it will iterate through the loop.
But i tried with PARSE statement earlier today for the same issue if in case it is PS file then it would not have any open or close parenthesis... then in that case i should move my dataset to the stem variable....
here in above case it will just iterate through the loop if it is GDG but what if it is a PS file......what line should i add here in the code for that.... |
|
Back to top |
|
|
Pedro
Global Moderator
Joined: 01 Sep 2006 Posts: 2546 Location: Silicon Valley
|
|
|
|
I think you should use PARSE VAR instead of PARSE VALUE.
You discard the first character of the POST variable, but I think that first character is the most important part.
Your code will fail when it is PDS like this:
It will fail because it will proceed as though it was a GDG.
Quote: |
but what if it is a PS file......what line should i add here in the code for that.... |
What happens when you try it? What is in your POST variable when you have a sequential dataset? |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10872 Location: italy
|
|
|
|
installing on Your PC open object REXX available here
sourceforge.net/projects/oorexx/
will let You prototype ALL the computing logic of Your rexx scripts on Your PC |
|
Back to top |
|
|
sureshpathi10
Active User
Joined: 03 May 2010 Posts: 154 Location: Kuala Lumpur
|
|
|
|
Find all for ",CATLG,DELETE".
For each occurrence,
1. Get data from that line
2. check it matches to your string.
3. if match, the process or go for next. |
|
Back to top |
|
|
sakrat
Active User
Joined: 05 Feb 2014 Posts: 164 Location: India
|
|
|
|
Hi,
I tried my code with the below parse statement and it was working fine but now I am stuck with the error of UNEXPECTED THEN or ELSE...I couldnt find where i am going wrong......
DO WHILE COUNT > 0
IF RC=0 THEN DO
"ISREDIT (VAL) = LINENUM .ZCSR"
VAL1=VAL-1
SAY VAL1
"ISREDIT (LINE) = LINE " VAL1
INPUT.I = STRIP(LINE)
PARSE VALUE "'"INPUT.I"'" WITH PREC ','
OUT=POS('=',PREC)
RES=SUBSTR(PREC,OUT+1)
SAY RES
PARSE VALUE "'"RES"'" WITH PRE '(' POST ')'
SAY POST
IF POST = "" THEN DO
OUTPUT.I=RES
COUNT=COUNT-1
I=I+1
J=I
ELSE DO
IF DATATYPE(POST) == NUM THEN DO
NOP
ELSE DO
OUTPUT.I=RES
COUNT=COUNT-1
I=I+1
J=I
END
END
"ISREDIT FIND NEXT '"TEMP"' "
END
END |
|
Back to top |
|
|
sureshpathi10
Active User
Joined: 03 May 2010 Posts: 154 Location: Kuala Lumpur
|
|
|
|
Please use CODE tag for all program statements.
You are missing an 'END' for below statement
Code: |
IF POST = "" THEN DO
OUTPUT.I=RES
COUNT=COUNT-1
I=I+1
J=I |
|
|
Back to top |
|
|
sureshpathi10
Active User
Joined: 03 May 2010 Posts: 154 Location: Kuala Lumpur
|
|
|
|
Just for the thought,
You can code like below to simplify the process
Code: |
parse var INPUT.I '//' ddname 'DD' 'DSN=' dsname ',' others |
|
|
Back to top |
|
|
sakrat
Active User
Joined: 05 Feb 2014 Posts: 164 Location: India
|
|
|
|
sureshpathi10 wrote: |
Just for the thought,
You can code like below to simplify the process
Code: |
parse var INPUT.I '//' ddname 'DD' 'DSN=' dsname ',' others |
|
Hi,
I tried the syntax which you suggested but it says symbol expected..... |
|
Back to top |
|
|
sureshpathi10
Active User
Joined: 03 May 2010 Posts: 154 Location: Kuala Lumpur
|
|
|
|
Please post your Full code to help you further. |
|
Back to top |
|
|
sakrat
Active User
Joined: 05 Feb 2014 Posts: 164 Location: India
|
|
|
|
Hi All,
Thank you all for helping me in creating this tool....Finaaly I created a tool that which inserts the delete steps in a jcl.....
But this can be done only when the Dataset name is given properly. If in case the dataset is specified using Symbolic parameter using SET statement in JCL like DSN=&HLQ..&JOB.JCL
This delete step will not work....can someone please give me some idea of how do i achieve that and insert the delete step in this case..... |
|
Back to top |
|
|
sureshpathi10
Active User
Joined: 03 May 2010 Posts: 154 Location: Kuala Lumpur
|
|
|
|
If you use IEFBR14 utility to delete your dataset, you don't need to worry about Symbolic parameter as its part of your JCL.
Code: |
//stepname EXEC PGM=IEFBR14
//SYSPRINT DD SYSOUT=*
//ddname DD DSN=dsname,
// DISP=(OLD,DELETE,DELETE)
/* |
|
|
Back to top |
|
|
sakrat
Active User
Joined: 05 Feb 2014 Posts: 164 Location: India
|
|
|
|
sureshpathi10 wrote: |
If you use IEFBR14 utility to delete your dataset, you don't need to worry about Symbolic parameter as its part of your JCL.
Code: |
//stepname EXEC PGM=IEFBR14
//SYSPRINT DD SYSOUT=*
//ddname DD DSN=dsname,
// DISP=(OLD,DELETE,DELETE)
/* |
|
But I cannot use IEFBR14 as i want to have the delete all the file used in JCL at once so that i will IDCAMS like this...
//stepname EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SYSIN DD *
DELETE dsname1
DELETE dsname2
DELETE dsname3
SET MAXCC=0
/*
I will insert the above step using my rexx tool by finding the DSNAME in the JCL....if in this case my DSNAME has using symbolic parameter what should i do...... |
|
Back to top |
|
|
sakrat
Active User
Joined: 05 Feb 2014 Posts: 164 Location: India
|
|
|
|
Hi,
I have dataset name &HLQ..&SS&ENV..&JOB..JCL in my stem variable OUTPUT.I now i wanna change all HLQ to some name similarly SS and ENV....how do i achieve this using CHANGE ALL syntax of ISREDIT MACROS can some one give me some idea.....please.... |
|
Back to top |
|
|
Pedro
Global Moderator
Joined: 01 Sep 2006 Posts: 2546 Location: Silicon Valley
|
|
|
|
Please use a different forum thread when you ask a different question. |
|
Back to top |
|
|
Pedro
Global Moderator
Joined: 01 Sep 2006 Posts: 2546 Location: Silicon Valley
|
|
|
|
Please provide a sample of your data. |
|
Back to top |
|
|
sureshpathi10
Active User
Joined: 03 May 2010 Posts: 154 Location: Kuala Lumpur
|
|
|
|
You may use Translate built-in function to achieve your desire output.
You can find Here how to use Translate. |
|
Back to top |
|
|
sakrat
Active User
Joined: 05 Feb 2014 Posts: 164 Location: India
|
|
|
|
sureshpathi10 wrote: |
You may use Translate built-in function to achieve your desire output.
You can find Here how to use Translate. |
Hi,
I will explain you clearly with an example:
Take for example my JCL is as below at first :
Code: |
//USERID JOB CLASS=B,MSGCLASS=X,NOTIFY=USERID
//*
//*
// SET HLQ=TRE
// SET SS=I
// SET ENV=DTH
//*
//*
//************************************************
//* THIS STEP IS USED TO COPY THE INPUT FILE TO
//* OUTPUT FILE
//************************************************
//STEP1 EXEC PGM=SORT
//SORTIN DD DSN=&HLQ..&SS&ENV..CODEIN.JCL,DISP=SHR
//SORTOUT DD DSN=&HLQ..&SS&ENV..CODE1.JCL,
// DISP=(NEW,CATLG,DELETE),
// SPACE=(TRK,(1,2),RLSE)
//SYSIN DD *
SORT FIELDS=COPY
/*
//
|
and now when i insert the delete step using my rexx tool i want my jcl to look like this shown below:
Code: |
//USERID JOB CLASS=B,MSGCLASS=X,NOTIFY=USERID
//*
//*
// SET HLQ=TRE
// SET SS=I
// SET ENV=DTH
//*
//JS0010 EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SYSIN DD *
DELETE TRE.IDTH.CODE1.JCL
SET MAXCC=0
/*
//*
//************************************************
//* THIS STEP IS USED TO COPY THE INPUT FILE TO
//* OUTPUT FILE
//************************************************
//STEP1 EXEC PGM=SORT
//SORTIN DD DSN=&HLQ..&SS&ENV..CODEIN.JCL,DISP=SHR
//SORTOUT DD DSN=&HLQ..&SS&ENV..CODE1.JCL,
// DISP=(NEW,CATLG,DELETE),
// SPACE=(TRK,(1,2),RLSE)
//SYSIN DD *
SORT FIELDS=COPY
/*
//
|
How do i change the symbolic parameters in the DSN to normal one so that the actual dataset name is used in inserting into the delete step....my rexx tool now inserts the delete step properly if there is no symbolic parameter is specified in the DSN in JCL....please help me in achieving this..... |
|
Back to top |
|
|
TheMFKid
New User
Joined: 20 Nov 2013 Posts: 91 Location: India
|
|
Back to top |
|
|
sakrat
Active User
Joined: 05 Feb 2014 Posts: 164 Location: India
|
|
|
|
yes before starting this new post i was asking my doubt over there....i had got a reply for that from sureshpathi so just replied for that post also..... |
|
Back to top |
|
|
sureshpathi10
Active User
Joined: 03 May 2010 Posts: 154 Location: Kuala Lumpur
|
|
|
|
If you really want to proceed with IDCAMS instead of IEFBR14, here is your logic.
1. Gather all the "SET" variables and values from JCL. (it will be difficult when PROC's are involved).
2. Before writing IDCAMS step, Use TRANSLATE function to change the value from SET variables to SET values. (I mean, &VAR1. to VALUE1). |
|
Back to top |
|
|
sakrat
Active User
Joined: 05 Feb 2014 Posts: 164 Location: India
|
|
|
|
sureshpathi10 wrote: |
If you really want to proceed with IDCAMS instead of IEFBR14, here is your logic.
1. Gather all the "SET" variables and values from JCL. (it will be difficult when PROC's are involved).
2. Before writing IDCAMS step, Use TRANSLATE function to change the value from SET variables to SET values. (I mean, &VAR1. to VALUE1). |
Do you mean to say that I should put all the SET variable lines in a stem variable (Eg: stem1.I) and take the Variable and its value in a separate stem varaible (Eg stem2.I and stem3.I) , then i shall use the TRANSLATE function like TRANSLATE(OUTPUT.I,stem2.I,stem3.I) so that the OUTPUT.I stem variable containing the symbolic parameter qualifier present in stem2.I will be replaced into normal qualifier which is present in stem3.I
Am I right....????? |
|
Back to top |
|
|
sureshpathi10
Active User
Joined: 03 May 2010 Posts: 154 Location: Kuala Lumpur
|
|
|
|
Yes. Exactly...
You have to do TRANSLATE function for all SET variables (put loop) for all the line you are going to write (nested loop).
don't forget to include '&' and '.'(dot) while do TRANSLATE. |
|
Back to top |
|
|
sakrat
Active User
Joined: 05 Feb 2014 Posts: 164 Location: India
|
|
|
|
sureshpathi10 wrote: |
Yes. Exactly...
You have to do TRANSLATE function for all SET variables (put loop) for all the line you are going to write (nested loop).
don't forget to include '&' and '.'(dot) while do TRANSLATE. |
Yeah ok.....will try this and let you know....hope I am able to create the tool with this idea..... |
|
Back to top |
|
|
|