0

Can anybody show me examples on how to pass to a c program the parameters from SYSIN DD * in JCL.

I used to have my JCL program pass the parameter to a c program using the PARM option, but the PARM option has a 100 character limit, thus, requiring me to use the SYSIN DD * option in JCL instead. However, my old c program uses the argv paramater passing style and I don't know if this would still apply when using SYSIN DD *.


This is what my old JCL code looks like:

/ SET P1='RBR1 FIRBS.AIC_REHBFG_FDG.BM '                                        
// SET P2='BGM.LOL_FDSG '                                                       
// SET P3='"" '                                                                 
// SET P4='X F GMHKD'                                                           
//ST01    EXEC PGM=VCMBGJF,                                                     
//PARM='&P1.&P2.&P3.&P4' 

This is what my new JCL code looks like:

//ST01    EXEC PGM=VCMBGJF
//SYSIN    DD *    
RBR1 FIRBS.AIC_REHBFG_FDG.BM                                       
BGM.LOL_FDSG                                                      
""                                                               
X F GMHKD
/* 
Pierre-Luc Pineault
  • 8,993
  • 6
  • 40
  • 55
ineedhelp
  • 59
  • 1
  • 9

2 Answers2

1

Have you tried reading STDIN and if so does it return data from SYSIN, or try opening SYSIN, as fp = fopen("SYSIN", "r");

Alternatively, try changing the DD name of SYSIN to STDIN. The DD * says to pull the data from the text lines that follow. It does NOT have to be named SYSIN.

Finally, if all else fails read the C/Mainframe user guide. (I don't have one and it was a long time ago when I wrote on a mainframe, so I forget the particulars.)

Lastly, the first example seems to have a few errors:

// SET P1='RBR1 FIRBS.AIC_REHBFG_FDG.BM '                                        
// SET P2='BGM.LOL_FDSG '                                                       
// SET P3='"" '                                                                 
// SET P4='X F GMHKD'                                                           
//ST01    EXEC PGM=VCMBGJF,PARM='&P1.&P2.&P3.&P4'
//* there should be a space between // and PARM 

I mention this because the parm data you listed is < 100 chars, so fixing the PARM statement might fix the running of your code.

JackCColeman
  • 3,777
  • 1
  • 15
  • 21
  • @user2718969, `SYSIN DD *` should allow an unlimited number of text lines. From the zOs point of view SYSIN is just a file. – JackCColeman Aug 27 '13 at 00:13
  • thank you, but say that the lines following SYSIN DD * have more than 100 characters per line and that each line have spaces between them, so the PARM option of passing the parameters would not be really possible. Also, you mentioned that I can try opening SYSIN using the fpopen function of c, would I start parsing at the line after SYSINN DD *? and parse for each new line with the '\n' delimeter and test if its not the end of the file with '!=EOF'? Can you provide examples please.. sorry had to write this again, didnt know you can only edit within 5 minutes – ineedhelp Aug 27 '13 at 00:22
  • @user2718969, you should have code that reads the parms as a string of text, probably using sscanf? The same code should work when reading a file only use fscanf(for a file) or scanf (for stdin). scanf handles new lines as white space, so from a parsing point you are parsing one long string. if things get too complicated for scanf then open and read SYSIN as a text file and write code to parse it. Remember, the lines that follow `SYSIN DD *` are considered to be a file, so you never really "read" the `//SYSIN DD *` line. Also, consider defining keyword parms, X=3, etc. this is much easy. – JackCColeman Aug 27 '13 at 00:31
  • @user2718969, this is much easier to parse using scanf. it is something line `scanf("X = %d Y = %d C = %s ", etc.)` and scanf finds the X = Y = and C = text strings (in that order). – JackCColeman Aug 27 '13 at 00:33
  • my old code did not use fopen or fscanf, it uses the argv referencing as the JCL code passes it as // PARM='&P1.&P2.&P3.&P4' thus my c code reads gets the paramters passed in argv and assigns it to char arrays: strncpy(arrayname1, argv[1], length); will i just rewrite my code then to use fopen() ? or is there an easier way? by the way, testing of end of file would still be done with '!=EOF'? right? again, thank you very much.. this is very great help.. – ineedhelp Aug 27 '13 at 00:50
  • @user2718969, not a problem. The argv[n] is really a pointer to a string n, delimited by spaces. So, a `scanf("%s %s etc. ", &arrayname1, &arrayname2, etc.)` will provide a similar function. The EOF for scanf is more implicit. scanf returns the number of fields that matched its format. So, each field is a contiguous string of characters, P4 is really 3 fields!! So, your code needs to handle this or parse SYSIN with something else. By the way scanf is good for well defined input when stuff gets ambiguous it is time to use `gets` or similar. – JackCColeman Aug 27 '13 at 02:09
  • @user2718969, you will get an EOF (-10 if you issue a scanf("%etc.) and there is no data to read. If scanf finds 2 fields then it returns a 2, 1 field returns a 1, etc. – JackCColeman Aug 27 '13 at 02:17
0

You could use the CEE3PR2 Language Environment callable service. Its purpose is to return parm strings of greater than 80 bytes [sic] to invoking programs. I believe this is new to z/OS 1.13. Note that this is not portable to non-mainframe systems. Of course, neither is JCL.

cschneid
  • 10,237
  • 1
  • 28
  • 39