Gen Inline code Statements for 'C' Code for Group View Processing
search cancel

Gen Inline code Statements for 'C' Code for Group View Processing

book

Article ID: 368854

calendar_today

Updated On:

Products

Gen Gen - Host Encyclopedia Gen - Run Time Distributed Gen - Workstation Toolset

Issue/Introduction

Trying to use an Inline Code control (C code) to populate an explicit group view.  It doesn't seem to be populating the group as expected.

Environment

Release:  8.6

Component:  Gen Workstation Toolset

Resolution

Inline Code has many benefits over EABs, especially since the code is kept with the model.  It is recommended that all new "external" logic to be done with Inline Code instead of EABs, where possible.
 
Here are links that might be useful pertaining to Inline Code:

Add an Inline Code Statement
 

Add Inline Code Statements Containing ODBC, JDBC, or ADO.NET Statements

 

Suggested method

INLINE CODE Language: C Operating System: WINDOWS TP Monitor: WINDOWS
         
##GROUP_OUT.Subscript##=0;
      
while (##GROUP_OUT.Subscript## < ##GROUP_OUT.Max##)
      {

      //Use all members of the array (don't skip the .[0] position)
      ##GROUP_OUT.R_EXP.IEF_SUPPLIED.COUNT##(##GROUP_OUT.Subscript##)=##GROUP_OUT.Subscript##;
      ##GROUP_OUT.Subscript##=##GROUP_OUT.Subscript##+1;
        
      }
      //Set the LAST to the highest subscript used or else the data will be lost when the RGV is passed back to the GEN runtimes
      ##GROUP_OUT.Last##=##GROUP_OUT.Subscript##;


Method that closely emulates GEN generated code 

INLINE CODE Language: C Operating System: WINDOWS TP Monitor: WINDOWS

     //Gen initializes the subscript to 1
     ##GROUP_OUT.Subscript##=1;

     //Since we are starting at 1 we should go all the way to the MAX and not stop short
     while (##GROUP_OUT.Subscript## <= ##GROUP_OUT.Max##)
     {

     //Since we started at one(1) but to keep from missing the .[0] we reference the
     // current value minus 1.
     ##GROUP_OUT.R_EXP.IEF_SUPPLIED.COUNT##(##GROUP_OUT.Subscript##-1)=##GROUP_OUT.Subscript##;
     // Set the last as we go along or the data will be lost when the RGV is passed back to the GEN runtimes
     ##GROUP_OUT.Last##=##GROUP_OUT.Subscript##;
     ##GROUP_OUT.Subscript##=##GROUP_OUT.Subscript##+1;

     }