Last active
February 16, 2020 01:46
-
-
Save phpdave/a8c2c3128c1afd1aaecc to your computer and use it in GitHub Desktop.
IBMi convert file members to stream files for git 1) Create Physical File triggers on the libraries you want to monitor 2) Triggers run ConvertAllMembersToStreamFiles.PGM which runs 3) CopyMembersToStreamFiles.php which is a PHP script that runs through an array of file members to run through CPYTOSTMF
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CALL PGM(QP2SHELL) PARM('/usr/local/zendsvr/bin/php-cli batchphp/CopyMembersToStreamFiles.php') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
$lib = "MYLIB"; //The library the file members are in | |
$file = "QRPLESRC"; // The file the file members are in | |
$outfile = "$lib/ALLMEMBERS"; // The output file that contains all the members of $lib/$file after the DSPFD command is ran | |
$membersArray = array(); | |
//Comment line below if you want to hardcorde the members you want to pull | |
//$membersArray = array('MyMember1','MyMember2','MyMember3'); | |
//Below will take all members under $lib/$file and put it into the output file $lib/$outfile | |
//::Alternative:: user OVRDBF or Create Alias over every member file http://www-01.ibm.com/support/docview.wss?uid=nas8N1018261 | |
$toolkit->runCL("DSPFD FILE( $lib/$file ) TYPE( *MBR ) OUTPUT(*OUTFILE) OUTFILE( $lib/$outfile )"); | |
//read the outputfile to get the file members | |
$outfilecontent = readfile("$lib/$outfile"); | |
//parse $outfilecontent to get all the members in $file | |
foreach($outfilecontent as $line) { | |
$membersArray[] = $line ; | |
} | |
//PHP IBMi toolkit that lets you call CL | |
$toolkit = new IBMiToolkit(); | |
//loop through each file member and copy it to a stream file using CPYTOSTMF | |
foreach($membersArray as $srcmember) | |
{ | |
$toolkit->runCL("CPYTOSTMF FROMMBR('/QSYS.LIB/$lib.LIB/$file.FILE/$srcmember.MBR') TOSTMF('$srcmember.TXT') STMFCCSID(1208)"); | |
} | |
// Ending message that the process has worked and completed. | |
echo "I'm done copying Source Members to stream files"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ADDPFTRG FILE(MYLIB/QRPLESRC) TRGTIME(*AFTER) TRGEVENT(*INSERT) PGM(MYLIB/ConvertAllMembersToStreamFiles) | |
ADDPFTRG FILE(MYLIB/QRPLESRC) TRGTIME(*AFTER) TRGEVENT(*UPDATE) PGM(MYLIB/ConvertAllMembersToStreamFiles) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This may copy files to disk when a program is saved. But how do you push the program back to IBMi when it is changed on the disk (e.g. after merging someone else's changes with yours)