fopen in Mainframe (C language) -
i'm working on opening file mainframe. currently, can't access input file wanted. don't know if there wrong c code or jcl. me out?
here code:
int main() { file *ifp, *ofp; printf("ctrace1\n"); ifp = fopen("dd:inputf", "rb, recfm=vb, lrecl=50"); printf("ctrace2\n"); ofp = fopen("dd:outputf","w"); printf("ctrace3\n"); fread( buffer, sizeof( char ), linesz, ifp ); printf( "number of characters read = %i\n", num ); printf( "buffer = %s\n", buffer ); dstr = (datastr*) buffer; printf("var_a = %.*s\n", sizeof(dstr->var_a), dstr->var_a); printf("var_b = %.*s\n", sizeof(dstr->var_b), dstr->var_b); printf("var_c = %.*s\n", sizeof(dstr->var_c), dstr->var_c); printf("ctrace4\n"); x[sizeof(x)+1]='\0'; y[sizeof(y)+1]='\0'; z[sizeof(z)+1]='\0'; printf("ctrace5\n"); memcpy(x, dstr->var_a,sizeof(dstr->var_a)); memcpy(y, dstr->var_b,sizeof(dstr->var_b)); memcpy(z, dstr->var_c,sizeof(dstr->var_c)); printf("ctrace6\n"); printf("%s,%s,%s",x,y,z); printf("ctrace7\n"); fwrite(buffer, sizeof(char), linesz, ofp); fprintf(ofp,"%s,%s,%s\n",x,y,z); fclose(ifp); fclose(ofp); return(0); }
here's jcl:
... //* typrun=scan //joblib dd dsn=x543863.loadlib1,disp=shr //step1 exec pgm=cccgrate //inputf dd dsn=x543863.sample.input01,disp=shr //outputf dd dsn=x543863.sample.output01, // disp=(new,catlg,delete), // space=(cyl,(1,1,45)), // dcb=(recfm=fb,lrecl=50) //sysout dd sysout=* //
without knowing output get, @ best difficult say.
are trying copy variable-length records fixed-length records?
two things. on fopen
input file not need specify dcb information - recfm=vb
, lrecl=50
not needed (the information if not specified, taken jcl (if present) or catalog (which correct)).
since not needed, have got them wrong :-)
take them off, , try program.
looking @ have there , have specified output, either vb wrong (you writing fb) or 50 wrong (if have 50 bytes of data, logically have fb definition, the lrecl vb should 54, because 4 bytes data needed include rdw (record descriptor word)).
the nothing wrong jcl, no way tell whether files , definitions of files correct.
down now. if still can't fix it, provide information.
Comments
Post a Comment