I am making a payslip project using IBM mainframes and I am asked to create a payslip report for an employee every month. This payslip is supposed to be stored into a VSAM file in a format as follows as follows:
The data can be fetched from DB2 via a COBOL program but the problem is that I don't know the method to write contents into the file in such a user formatted style.
So can anyone please send me a COBOL code to help me out because when I searched on the internet, all I could find was how to store data in a key-sequenced record format.
Also please tell as to what type of VSAM I should use.
Id division.
Program-id. VSAMSEQW.
Environment division.
Input-output section.
File-control.
Select F1
Assign to AS-DD1
Organization is sequential
File status is FS FS2.
Data division.
File section.
FD F1.
1 R1 pic X(133).
Working-storage section.
1 fs pic 99.
1 fs2.
2 rc pic s9(4) binary.
2 fc pic s9(4) binary.
2 fb pic s9(4) binary.
1 X pic X(10).
Procedure division.
Declaratives.
F1-error section.
Use after standard error procedure on F1.
1. Display "Error declarative entered"
Display " File status: " fs
Display " VSAM return code: " rc
Display " VSAM function code: " fc
Display " VSAM feedback code: " fb
Display "Testcase VSAMSEQW failed!"
Move 16 to return-code
Stop run
.
End declaratives.
MainPgm section.
Display "Entering VSAMSEQW"
Open output F1
* Do whatever you need to get data and update R1
Move "Line 1" to R1
Write R1
* 2nd output line
Move "Line 2" to R1
Write R1
Close F1
Display "Exiting VSAMSEQW"
Goback.
Related
I have a table with about 500 variables and 2000 cases. The type of these variables varies. My supervisor has asked me to produce a table listing all the numeric variables, along with their maximums and minimums. I am supposed to use SPSS because R apparently messes up the value labels.
I've only done very basic things in SPSS before this, like finding statistics for single variables, and I'm not sure how to do this. I think I should probably do something like:
*Create new table*
DATASET DECLARE maxAndMin.
*Loop through all variables: Use conditional statement to identify numeric variables*
DO REPEAT R=var1 TO varN.
FREQUENCIES VARIABLES /STATISTICS=MINIMUM
END REPEAT
*Find max and minimum*
I'm not sure how to go about this though. Any suggestions would be appreciated.
The following code will first make a list of all numeric variables in the dataset (and store it in a macro called !nums) and then it will run an analysis of those variables to tell you the mean, maximum and minimum of each:
SPSSINC SELECT VARIABLES MACRONAME="!nums" /PROPERTIES TYPE= NUMERIC.
DESCRIPTIVES !nums /STATISTICS=MEAN MIN MAX.
You can use the following code to create a tiny dataset to test the above code on:
data list list/n1 (f1) t1(a1) n2(f1) t2(a1).
begin data
1 "a" 34 "b"
2 "a" 23 "b"
3 "a" 52 "b"
4 "a" 71 "b"
end data.
If SUMMARIZE produces a nice enough table for you, here is a "non-extension" way of doing it.
file handle mydata /name="<whatever/wherever>".
data list free /x (f1) y (a5) z (F4.2).
begin data.
1 yes 45.67
2 no 32.00
3 maybe .
4 yes 22.02
5 no 12.79
end data.
oms select tables
/destination format=sav outfile=mydata
/if subtypes="Descriptive Statistics" /tag="x".
des var all.
omsend tag="x".
get file mydata.
summarize Var1 Mean Minimum Maximum /format list nocasenum nototal
/cells none /statistics none /title "Numeric Variables Only".
or use a DATASET command instead of file handle if you don't need the file on disk.
I need perform 50 Abaqus simulations, each simulation analyses a certain material property and each differs by changing one parameter. So the idea is to write a Matlab script that:
opens the .inp file
edits the material parameter of interest
prints it into a new file which will be the new .inp file
runs it to perform the simulation
This is what I accomplished so far in a very simplified version:
f= fopen('PRD8_30s.inp');
c = textscan(f,'%s %s %s %s %s ','delimiter',',');
fclose(f) ;
S = [c{1}];
A = {'5e-08'} ;
S(12496) = A ;
fid = fopen('file.inp','w') ;
fprintf(fid,'%s \n',S{:} );
fclose(fid) ;
PRD_8_30s.inp
I manually found out the position of the parameter of interest (A at 12496 hence below the line *Viscoelastic). The code actually changes the parameter I need but there are major problems: it prints a new file with additional lines with respect to the original .inp (12552 vs 8737) and it doesn't print the entire .inp but only the first column.
How can I edit the .inp changing the parameter and obtaining a new .inp with the edited parameter that can be used to run the new simulation?
Thank you in advance for your help!
If your input file is not multiple Gb in size, The following might help.
create a template input and mark the parameter you want to change as, for example para_xxxx
Use the following script:
text=fileread('template.inp');
newtext=replace(text,'para_xxxx',newParameter);
fid=fopen('newcase.inp','w');
fprintf(fid,newtext);
fclose(fid);
The file name 'newcase.inp' should be updated each time in the loop.
To start from the beginning I had a long memo line that I needed to strip down to only show me a specific name in the string. Here is an example of the original memo line my report was giving me:
Ex. PLUMBERS-ACH distribution from share suffix 9 [2] 19.00 01DEC2017
I created three different formulas to strip down the memo line to only show me text before the "-". Here are those formulas:
Formula 1:
Left({SH_HIST.trn_memo}, instr(1,{SH_HIST.trn_memo},"-")-1)
Formula 2:
replace({Formula 1}, "-", " ")
Formula 3:
If instr({SH_HIST.trn_memo}, "-")>0 then {#Formula 2} else {SH_HIST.trn_memo}
I then placed Formula 3 into the report to give me the desired output from the memo line (this returns output successfully). Now I need to sort by that field because I need to be able to group all like items and sum them. When I click on "Insert Group" and select Formula 3 then try to preview the report I get the following message:
string length is less than 0 or not an integer
Can anyone lead me in the right direction to fix this, please? I've googled my heart out.
Instead of 3 formulas why don't you try this:
Split(Column,"-")[1] //Provided the format you gave applies for all records
Now group by this formula
How does one write or print multiple variable outputs with headers, line by line per tick to command center in netlogo? the idea is to print out ticking results of more than one variable (reported by procedures) so that it appears in they appear as follows in the command center output window:
length weight height area
24.2 23.1 22.0 25.1
18.7 19.2 10.4 22.0
and so on, updating per tick in columnar form.
I eventually want to be able to use the export-output command to transport the output to a csv file at the end of the simulation run. I know there are other ways of doing this but I want it this way specifically for a reason.
You need the type and print commands. Your heading would need to be printed during initialisation and the variable values would need to be printed each tick. Assuming your procedures are named cal-length etc, code would look something like this. Note that there is no spacing control or other formatting.
to setup
...
print "length weight height area"
...
end
to go
...
dump-to-screen
...
end
to dump-to-screen
type calc-length type " " type calc-weight type " "
type calc-height type " " print calc-area
end
I'm trying to import data to matlab from txt file which is length is about 1e6 lines.
the text is as follows :
[04 05 11 12] jiffies=100
[04 06 15 09] jiffies=3455
.
.
.
[00 02 07 07] jiffies=111200
I've managed to extract the first two numbers (which I need) without using a loop;
now I want to read only the number after the "jiffies=#" , If I am trying to use the same method
textscan(fid,'%s','delimiter', 'jiffies=')
but it's not working , any method without using loops ?
You can skip values by using a star *.
The complete formatting string for all data in your file is
'[%d %d %d %d] jiffies=%d'
To skip all the numbers in the front, simply put a star between % and d.
C = textscan(fid,'[%*d %*d %*d %*d] jiffies=%d');
which returns
C{1}
ans =
100
3455
111200
If you want to import all of the data at once, you can open this file in the Import Tool:
uiimport(filename);
This will correctly remove the brackets and 'jiffies=' text, and can return you a numeric array of all the numbers. You can also generate code from the Import Tool (click on the Import Selection dropdown/Generate script or function). This may prove to handle any errors in the file better than using textscan directly.