Add to a value read into a JCL - jcl

I am working on writing a JCL which will read an option card containing a date. I need the date that is read in +1 and +2. Is there a way for me to do this in my JCL?
For example, my option card might contain: 20150923
I, for other pieces of my JCL, need: 20150924 and 20150925

Best here is to use REXX to either generate a job or have a written template that you modify and submit.
With REXX you would have to open the file/dataset that you obtain the 'option card' , save that to a variable and later on pass it to the edited JCL.
At the end You can submit the job or do it later manually.
Regards,
Jarek.
Here is a nice example. Bit of a long read but it's Using a batch REXX procedure to generate a unique output data set name

Related

Talend - Extract FileName from tLogRow/tSort

I am new to Talend and just trying to work my way through it.
Problem Statement
I need to process a positional file, from a list of files. Need to identify the latest file first and then process only that file. I was able to identify the most updated file. And then I was able to create another flow which processes the positional file. The problem is combining these two flows so that I am able to identify the most recent file and have just that one processed.
Tried so far
Have been trying to extract the most recent file from a list within a directory. Iterated through all the files, retained their properties in a buffer. Post completion of this sub-task, read through the buffer, sorted with descending mime, extracted the top record and was able to print it using tLogRow.
All seems to be fine except I don't know how to use the filename now for next task.
I am certain this is very rudimentary but I'll be honest, I've been scourging the internet/help from quite some time now, with no success.
Any pointers would help.
The job flow is attached for your reference.
First of all, you can simplify your job by using tFileList's capabilities. It can sort files by their modified date:
Next, use tIterateToFlow to convert each iteration to a row:
(String)globalMap.get("tFileList_1_CURRENT_FILEPATH")
and tSampleRow with a range of "1", to get the most recent file.
Then store the result in a global variable. In the next subjob, just use that global variable as your filename in tFileInputPositional.

How to save some variable values in a file

I want at the end of my program to get the values stored at certain variables and append them to a file let's say "result". I am going to run it several times (for different parameters) at night and then check results in the morning.
Basically, I am looking for something similar to redirection in linux (>>) for matlab.
I am using the diary function to store the whole messages from my program and i want to keep those for verifying later.
But here what I want is just some specific values. So how to do it?
It does not necessary have to be in the same file. If I can get each result in a separate file, that is ok too.
You can use a combination of diary and any function which can append data to a text file, but you have to turn off diary before writing. A short example using save
f='example.txt'
diary(f);
for ix=1:10
disp(ix);
diary off %diary off to flush
save(f,'ix','-append','-ascii')
diary(f);
end
Instead of save you can also use fprntf or dlmwrite

How to pass values from rexx to jcl

i've jcl which accepts date and pass value to rexx to get next date and previous date.
and then jcl prints that next and previous dates.
please tell how to take value back from rexx to jcl and use that values in jcl
If it's to print the date, then JCL doesn't actually do that. Rather JCL invokes a program that writes data that can be printed.
If it's printing of the dates, then that could be achieved using EXECIO.
If your requirement is to modify JCL AND that JCL is not the current JCL, then Rexx can be used to submit a modified job or jobs (system authority permitting). If I recall correctly you'd use INTRDR.
blvdeer kind of explained how JCL works above in the comment but you can start to work of something like this.
Use REXX to invoke its DATE (reference here - z/OS TSO/E REXX DATE) and put this into a variable to do whatever you want with it (in this case current and previous dates) and use EXECIO as per MikeT answer to write this to a dateset.
Later you can run a JCL to do whatever with this newly created dataset as an input.
Regards,
Jarek.

Importing Flat file dynamically using %MACRO and dataset values SAS

I have a folder with various flat files. There will be new files added every month and I need to import this raw data using an automated job. I have managed everything except for the final little piece.
Here's my logic:
1) I Scan the folder and get all the file names that fit a certain description
2) I store all these file names and Routes in a Dataset
3) A macro has been created to check whether the file has been imported already. If it has, nothing will happen. If it has not yet been imported, it will be imported.
The final part that I need to get right, is I need to loop through all the records in the dataset created in step 2 and execute the macro from step 3 against all file names.
What is the best way to do this?
Look into call execute for executing a macro from a data step.
The method I most often use, is to write the macro statements to a file and use %include to submit it. I guess call execute as Reeza suggested is better, but I feel more in control when I do it like this:
filename s temp;
data _null_;
set table;
file s;
put '%macrocall(' variable ');';
run;
%inc s;

How to generate new numbers if i run the program everytime from the begining?

I am working on CATScript in optimization of a part.
When I run the script everytime it shoud provide numbers in ascending order.
For example if I run the program for the first time it should provide the output as " 1 "
and if I run the program again it shoud provide the output as " 2 " and so on.
I am stuck with this and I could not figure out th logic that we have to use here.
Looking forward for your help.
Thank you!!
An option (matlab based) could be to save a counter variable to a .mat-file at the end of the script, which is then loaded again at the beginning of the script.
That would allow you to keep track of how many times the script have been run.
In CATIA if it is being run multiple times on the same part/product, you could add a hidden, integer parameter to the specification tree and increment it each time the macro is run.
Another, more generic way would be to create a text file on the user's local and update the number in the text file.