File creation in IFS using RPGLE Program - IBMi / AS400
How to create a file in IFS using RPGLE program:-
**Free
* Program to write data in IFS
Ctl-opt DftActGrp(*no) ActGrp(*new);
* Procedure for opening file
Dcl-pr open int(10) ExtProc('open');
*n pointer Value options(*string); //File Path
*n int(10) value; //File Option
*n uns(10) value options(*nopass); //Permission
*n uns(10) value options(*nopass); //Codepage
End-pr;
* Procedure for writing data into file
Dcl-pr write int(10) ExtProc('write');
*n int(10) value; //File pointer
*n pointer value; //Pointer to data
*n uns(10) value; //Length of data
End-pr;
* Procedure for closing file
Dcl-pr close int(10) ExtProc('close');
*n int(10) value; //File Pointer
End-pr;
* Constant declartaion
Dcl-C WriteFile 2;
Dcl-C CreateFile 8;
Dcl-C AppendFile 256;
Dcl-C ClearFile 64;
* Variable declaration
Dcl-S Output int(10);
Dcl-S Content char(30);
* File Opening
Output = open('/home/SHARMIT/TechSharmit/Data.xml'
:CreateFile+WriteFile+ClearFile
:(6*64)+(6*8)+(4));
if Output < 0;
Dsply 'Error';
else;
Content = 'Rpgle programming concepts';
* File Writing
callp write(Output:%addr(Content):30);
* File Closing
callp close(Output);
endif;
*inlr = *on;
Subscribe Tech Sharmit for more videos on IBMi / AS400
Please refer to the below video for the same topic.
Comments
Post a Comment