Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

When and why we use PLI Preprocessors?

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> PL/I & Assembler
View previous topic :: :: View next topic  
Author Message
subratarec

New User


Joined: 22 Dec 2007
Posts: 73
Location: Bangalore

PostPosted: Sun Mar 25, 2012 7:25 pm    Post subject: When and why we use PLI Preprocessors?
Reply with quote

Hi,

I have been working on PLI programming language for past 3 years but never used PLI Preprocessor much in our code (except %PAGE and %SKIP compiler listing statements).
But now there is a need to use preprocessor and I have been asked to go through this PLI Preprocessor thing. I have gone through few materials on PLI Preprocessor. I understood some of it and some is still unclear.

But my main question is WHEN or WHY we do need to use PLI Preprocessor. is there any advantage over normal PLI coding. I saw it has IF... ELSE or DO WHILE etc which are same what we use while writing normal PLI code (without using PLI Preprocessor)

Can someone please throw some light on this PLI Preprocessor concept ? (I tried to find some info on it but couldn't find much) I need to understand the concept of it before I can use it in program.

Thanks in advance
Back to top
View user's profile Send private message

Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1738
Location: Bloomington, IL

PostPosted: Sun Mar 25, 2012 8:17 pm    Post subject:
Reply with quote

I find it less necessary to use the pre-processor as the hardware gets more capable. Nonetheless, I do still use it (out of habit) to enhance readability:
Code:
%DCL (TRUE, FALSE) CHAR;
%TRUE  = '''1''B';
%FALSE = '''0''B';

DCL INFILE FILE RECORD INPUT;
DCL EOF_INFILE BIT INIT(FALSE);

ON ENDFILE (INFILE) EOF_INFILE = TRUE;

READ FILE (INFILE) INTO (INREC);

DO WHILE (EOF_INFILE=FALSE);
Back to top
View user's profile Send private message
subratarec

New User


Joined: 22 Dec 2007
Posts: 73
Location: Bangalore

PostPosted: Sun Mar 25, 2012 9:31 pm    Post subject:
Reply with quote

Hi Akatsukami,

Thanks! for your reply and your code. Actually I already have codes with me and I understood the logic also (how the code is flowing) BUT what I DON'T understand is WHY is this Preprocessor thing we actually use?? I know before the hard code gets compiled by the compiler all PLI preprocessor statements are converted into normal PLI source codes..

We are hard coding preprocessor statements then it is converting into normal PLI source codes and then it gets compiled and then object module gets created..
But Why all these things (I guess there must be some reason behind the scene) and When a programmer should consider using PLI Preprocessor over normal PLI code?

Actually I need to understand these 2 points (Why and When)

Thanks in advance!
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Mon Mar 26, 2012 7:04 am    Post subject:
Reply with quote

Hello,

I don't "do" PLI, but my guess is that When and Why to use the preprocessor is determined by local standards/conventions, rather than technical necessity.

Someone will correct this if i'm mistaken icon_wink.gif
Back to top
View user's profile Send private message
subratarec

New User


Joined: 22 Dec 2007
Posts: 73
Location: Bangalore

PostPosted: Mon Mar 26, 2012 11:13 am    Post subject:
Reply with quote

Hi Dick,

Thanks for your reply!. Yes I also never used Preprocessor! (Except those compiler directives %PAGE, %SKIP etc). So I am in dark. Without knowing the reason (is it advantageous to use preprocessor in some specific situation) I am not able to understand this concept fully!!

If someone knows please let me know. It would be of grt help.

Thanks in advance
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10202
Location: italy

PostPosted: Mon Mar 26, 2012 1:14 pm    Post subject: Reply to: When and why we use PLI Preprocessors?
Reply with quote

An application programmer has almost NEVER the need to be concerned with the preprocessor <stuff> apart the <semi> preprocessor directives,

Hi Dick,
the reason to use a preprocessor are mostly technical, and related to standards.

let' s make an example. ( might not fit the integrated db2 and cics preprocessors)

there are cases where it is awkward to put common <functions> in external subroutines and they must be inlined,
but since they are common the standards suggests that they fit better as <copy books> to be ++included

but if they contain sql or cics statements the old/standard db2/cics preprocessor
are unable to pick them up

in this case the proper sequence is
PL/I prepocessor just to resolve the ++ include statements,
DB2/CICS preprocesor
PL/I compiler

but this is explained in proper PL/I reference manuals ans IIRC also in the REDBOOKS

but the point is... if You need to ask about it, then You don' t need it
or better... a solution looking for a requirement
Back to top
View user's profile Send private message
prino

Active Member


Joined: 07 Feb 2009
Posts: 984
Location: Oostende, Belgium

PostPosted: Mon Mar 26, 2012 7:26 pm    Post subject:
Reply with quote

You know those wonderful "FILLER" fields in COBOL structures? With Enterprise PL/I you can now use an '*', but with this little preprocessor procedure

Code:
 %dcl filler entry;
 %filler: proc returns(char);
 dcl str char;

 dcl compiletime builtin;
 dcl counter     builtin;

 if substr(compiletime, 3, 1) = ' ' then
   str = 'Z' || counter;
 else
   str = '*     ';

 return(str);
 %end filler;

You can use FILLER fields in both OS PL/I and EPLI.

Or these three:

Code:
 /************************************************** %INCLUDE #ERCODEB *
 * Common abbreviated IDMS & SQL error codes for Batch                 *
 **********************************************************************/
 %dcl $$idms_err char;
 %dcl $$db2_err  char;
 %$$idms_err = 'signal error';
 %$$db2_err  = 'signal error';
 %include #ercodes;


Code:
 /************************************************** %INCLUDE #ERCODEC *
 * Common abbreviated IDMS & SQL error codes for CICS                  *
 **********************************************************************/
 %dcl $$idms_err char;
 %dcl $$db2_err  char;
 %$$idms_err = 'call er_idms(er_code)';
 %$$db2_err  = 'call er_db2(er_code)';
 %include #ercodes;


and

Code:
 /************************************************** %INCLUDE #ERCODES *
 * Common abbreviated IDMS & SQL error codes (Common code)             *
 **********************************************************************/
 %dcl $$non_0000      char;
 %dcl $$non_0307      char;
 %dcl $$non_0326      char;
 %dcl $$non_1601      char;
 %dcl $$non_0000_0307 char;
 %dcl $$non_0000_0326 char;
 %dcl $$non_0000_0716 char;
 %$$non_0000      = 'if error_status ^= ''0000'' then     ' ||
                    '                                      ' ||
                    $$idms_err;
 %$$non_0307      = 'if error_status ^= ''0307'' then     ' ||
                    '                                      ' ||
                    $$idms_err;

 %$$non_0326      = 'if error_status ^= ''0326'' then     ' ||
                    '                                      ' ||
                    $$idms_err;

 %$$non_1601      = 'if error_status ^= ''1601'' then     ' ||
                    '                                      ' ||
                    $$idms_err;

 %$$non_0000_0307 = 'if error_status ^= ''0000'' &        ' ||
                    '                                    ' ||
                    '   error_status ^= ''0307'' then     ' ||
                    '                                      ' ||
                    $$idms_err;

 %$$non_0000_0326 = 'if error_status ^= ''0000'' &        ' ||
                    '                                    ' ||
                    '   error_status ^= ''0326'' then     ' ||
                    '                                      ' ||
                    $$idms_err;

 %$$non_0000_0716 = 'if error_status ^= ''0000'' &        ' ||
                    '                                    ' ||
                    '   error_status ^= ''0716'' then     ' ||
                    '                                      ' ||
                    $$idms_err;

 %dcl $$non_00000       char;
 %dcl $$non_02000       char;
 %dcl $$non_00000_02000 char;
 %dcl $$non_00000_21000 char;
 %$$non_00000       = 'if sqlstate ^= ''00000'' then        ' ||
                      '                                      ' ||
                      $$db2_err;
 %$$non_02000       = 'if sqlstate ^= ''02000'' then        ' ||
                      '                                      ' ||
                      $$db2_err;
 %$$non_00000_02000 = 'if sqlstate ^= ''00000'' &           ' ||
                      '                                    ' ||
                      '   sqlstate ^= ''02000'' then        ' ||
                      '                                      ' ||
                      $$db2_err;
 %$$non_00000_21000 = 'if sqlstate ^= ''00000'' &           ' ||
                      '                                    ' ||
                      '   sqlstate ^= ''21000'' then        ' ||
                      '                                      ' ||
                      $$db2_err;


After all, typing $$non_00000; saves quite a few keystrokes over the full test, and it has the advantage that you only need to change two %includes if you want to change the error handling to something other than "SIGNAL ERROR" or the calls to those two procedures...

or how about making the DB2 SQLCA external?

Code:
%dcl sqlca char;                     
%deact sqlca;
%act sqlca norescan;
%sqlca = '%dcl sqlca char;
          %deact sqlca;
          %act sqlca norescan;
          %sqlca = ''SQLCA UNAL EXT'';
          EXEC SQL INCLUDE SQLCA;
          %deact sqlca;';
sqlca
%deact sqlca;
Back to top
View user's profile Send private message
subratarec

New User


Joined: 22 Dec 2007
Posts: 73
Location: Bangalore

PostPosted: Tue Mar 27, 2012 12:31 pm    Post subject:
Reply with quote

Hi Prino,

Thanks!! a such long code and explanation icon_smile.gif. But as I have never worked on PLI Preprocessor it is little bit tough for me to grasp the above mentioned code snippet (hopefully I will understand one day) but I just need to understand the basics of this preprocessor thing.. that is when programmer should think of applying this preprocessor.. is there any specific scenario for that or is it just it is local standards/conventions (as Dick have mentioned above)
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10202
Location: italy

PostPosted: Tue Mar 27, 2012 1:00 pm    Post subject: Reply to: When and why we use PLI Preprocessors?
Reply with quote

Quote:
that is when programmer should think of applying this preprocessor..


as I said before the programmer should NEVER, repeat NEVER, even think about using the preprocessor on his own without superior authorization.

using the preprocessor implies changes in the compile process, and these changes must be carried on by the support personnel.

topic is locked because it' s leading nowhere.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> PL/I & Assembler All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:



Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us