Skip to Content

SAP IS – Oil : ASTM 2004 Routines Compilation on Windows

What is QCI  – Introduction:



      1. The API/ASTM standards and the implementation rules are issued by the American Petroleum Institute (API), the American Society for Testing and Materials (ASTM) and the Institute of Petroleum (IP).


    Initially Tables were introduced that contained the conversion factors based on Density , Pressure & Temperature ranges. With the advent of IT, we now have C Routines / ABAP Implementations which now compute the Volume Conversion Factor   


        1. On behalf of the SAP ERP System, we have a Quantity Conversion Interface which talks to the external routines and gets back a Volume Conversion Factor which is used to determine the standardized quantity within SAP.


      Currently SAP IS-Oil customers could choose to interface with C Routines provided by FlowCal [ API initially sold these routines directly, but later on they decided to partner with FlowCal to sell & support these routines – Visit  for more information ] or ABAP Implementation from QuantityWare [ [ |] ] or their own ABAP implementations based on the global standards  .


         This Blog is specifically written for all customer who have decided to go ahead implementing their QCI with API provided C Routines from FlowCal.

        h3. How to get Started:                  

        Pre-Requisites for Windows Compilation of ASTM 2004 C Routines provided by FlowCal

        Procure the ASTM 2004 Routines from API [ Contact FlowCal  @  ]


          Download & Install Microsoft Visual Studio Professional Edition 2008 on the Server. . You could download this from the link mentioned here,  The Trial version works for 90 days free .


              1. Download the ASTM_2004.c file from the SAP Note 970603 and extract the file as shown here, 




            <u>Detailed Steps for Compiling the C Routines using Microsoft Visual Studio 2008:</u>


            Step 1: Please perform the following steps to compile. Open the FlowCal CD and you would see the contents as shown below in the screenshot.




            Step 2 : Select the Unix Folder  !|height=21|alt=image|width=55|src=|border=0!and open the contents.



            Step 3 : Copy the APIVCFBA file.




            Step 4 : Unzip file APIVCFBA.TGZ to any folder. In this example, ASTM_2004_COMPILE







            Step 5 : All the source files will be available




            Step 6 : Create new project using MS Visual Studio of type “Win32 Console Application”














            Step 7: Provide name of the project and the path. Click Next






            Step 8 : After clicking on finish you would see the following in your Solution Explorer




            Also the following Project Folders are now created:




            Step 9 : Copy Folders include, SRC and RES from Step 5 to the newly created folder for the project.




            Your project folder would now have the following contents




            Step 10 : And also copy file ApiVCFBase.rc from root folder of unzipped folder to Res folder of the project.




            Step 11 : Copy WindowsExportTable.h file to the root of the newly created folder.




            Step 12 : Include header files, source files and resource files in the project.




            *Step 13 : After adding all the files your solution explorer should look as shown below,</p><p style=”margin: 0in 0in 10pt” class=”MsoNormal”>!|height=448|alt=image|width=154|src=|border=0!</p><p style=”margin: 0in 0in 10pt” class=”MsoNormal”> </p><p style=”margin: 0in 0in 10pt” class=”MsoNormal”>You could choose to remove the ExampleProgram.c and TestCases.c from the compilation list as they are redundant.</p><p style=”margin: 0in 0in 10pt” class=”MsoNormal”> </p><p style=”margin: 0in 0in 10pt” class=”MsoNormal”>Step 14 :* Now open the newly created project file Step 15 : Paste the coding of astm_2004.c to the above mentioned file keeping all include files intact.


            Changes that are needed to be made in the ASTM_2004.cpp file would be the following:


            *Change 1: Alter the Buffer size from Len to 5000 by default.</p><p style=”margin: 0in 0in 10pt; text-indent: 0.5in” class=”MsoNormal”> </p><p style=”margin: 0in 0in 10pt; text-indent: 0.5in” class=”MsoNormal”>!|height=393|alt=image|width=661|src=|border=0!</p><p style=”margin: 0in 0in 10pt 0.5in” class=”MsoNormal”> </p><p style=”margin: 0in 0in 10pt 0.5in” class=”MsoNormal”>Change 2:* Alter the Output Parameters by initializing this to zero for r_altVol & r_baseVol. 



            *Change 3: Open the ApiVCFBase.rc file and delete the Statement highlighted  below,</p><p style=”margin: 0in 0in 10pt; text-indent: 0.5in” class=”MsoNormal”> </p><p style=”margin: 0in 0in 10pt; text-indent: 0.5in” class=”MsoNormal”>!|height=238|alt=image|width=648|src=|border=0!</p><p style=”margin: 0in 0in 10pt; text-indent: 0.5in” class=”MsoNormal”> </p>  <p style=”margin: 0in 0in 10pt” class=”MsoNormal”> </p><p style=”margin: 0in 0in 10pt” class=”MsoNormal”>Step 16:* For compilation the Microsoft Visual Studio settings that are needed are the following:






            Add the Include Folder to the list of the Include Files mentioned below,




            Change the Pre-Compiled Header settings to the one mentioned below;





            *Step 17: Final Compilation – Select the ASTM_2004_WIN.CPP file and select compile </p><p style=”margin: 0in 0in 10pt” class=”MsoNormal”> </p><p style=”margin: 0in 0in 10pt” class=”MsoNormal”>!|height=448|alt=image|width=156|src=|border=0!</p><p style=”margin: 0in 0in 10pt” class=”MsoNormal”> </p><p> <strong>Expected Output:</strong></p><p>!|height=242|alt=image|width=633|src=|border=0!<strong> </strong> *


            *Step 18: Building the Solution</p><p style=”margin: 0in 0in 10pt” class=”MsoNormal”> </p><p>!|height=291|alt=image|width=692|src=|border=0!</p><p> Expected Output:</strong></p><p> </p><p>!|height=272|alt=image|width=364|src=|border=0!*


            *Step 19: Testing of the Executable</p><p style=”margin: 0in 0in 10pt” class=”MsoNormal”> </p><p style=”margin: 0in 0in 10pt” class=”MsoNormal”>Based on the Output Files Directory mentioned the Executable is created in the Debug Folder</p><p style=”margin: 0in 0in 10pt” class=”MsoNormal”> </p><p>!|height=209|alt=image|width=650|src=|border=0!*


            The Executable is listed below,


            image * *


            Open Command Prompt and go to the Destination of the Compiled Executable and do the following,



            *Type <strong>in the following:</strong></p><p>C:\Documents and Settings\i054570\Desktop\QCI Compilation – Documentation\ASTM_2004_COMPILE\ASTM_2004_WIN\Debug>astm_2004_win F_111_71 1.500000000000000E01 1.400000000000000E-03 0.000000000000000E00 0.000000000000000E00 0.000000000000000E00 1.555555533333336E01 0.000000000000000E00 0.000000000000000E00 0.000000000000000E00 0.000000000000000E00 9.990000000000000E02 -1 TEMPERATURE_C ? THERMAL_EXP_REV_C ? ? ? TEMPERATURE_C PRESSURE_PSI ? ? ? ? DENSITY_KGM3 </p><p style=”margin: 0in 0in 10pt” class=”MsoNormal”>The above set of parameters are the one that is passed as test parameters to the QCI Executable</p><p style=”margin: 0in 0in 10pt” class=”MsoNormal”>Expected Output From the Executable is Shown Below:* 


            <u>After Compilation Process:</u>

            Set Up Customizing in SPRO for QCI Conversion Groups



            * O3QCITEST Sample Run</p><p>!|height=487|alt=image|width=619|src=|border=0!</p><p> </p><p> </p><p>Hope you find the above information helpful for you to go ahead with compiling ASTM 2004 Routines on your Windows Machine. Please drop in your comments / feedback / Suggestions / Issues on the above process in the Comments Section of this Blog or write in directly to me at .</p><p>Also, if you have compiled these routines on other Operating Systems & Servers [SUN , HP , IBM ], please upload the steps for the benefit of all Oil and Gas Customers.</p><p>Note: After completing the above steps, please apply the SAP Note: 1510931 – ” QCI for Windows : Handling of Float Truncation Issue “. Without applying this Note, all Results from the Executable are skewed owing to a Float Truncation Issue.*



            You must be Logged on to comment or reply to a post.
            • This was fairly easy to follow.<br/><br/>I did have to add the following include to ASTM_2004_WIN.cpp:  #include <string.h><br/><br/>This was because of compiler errors that where 'strcmp' was not found.<br/><br/>And ... the change to add the entry with the include directory is actually not under "Properties", but Tools ==> Options.  (This is was not a big deal as it was fairly easy to figure out, but just thought I would mention it.)<br/><br/>I will let you know how the testing goes tomorrow, but the command line test really makes me smile.  I ran it and now I am going to server testing with a lot more confidence.<br/><br/><br/><br/>

            • I can follow this entire set of instructions with the exception of what I noted in my previous comment to this blog.

              However, when I attempt to run the O3QCITEST transaction as shown in the last step, I receive the following error: "QCI: RFC-Error: 17-Observed Density out of Range".

              Any info related to this error would be of interest to me as well.

              • The Error that you have mentioned is more of an Issue with the Density Input to the Compiled Routines. As known each Conversion Group might have a Density Range that it could standardize. You might consider checking the range of Densities allowed for the Conversion Group.
                • Well, it looks to me ... when I compare the "15DA API_4  15 °C CRUDE OIL IN DENSITY" conversion group to the "534A 53&54A 15 °C CRUDE OIL IN DENSITY" that they are identical.  However when I go to run the test, the Base Relative Density parameter for the 2004 version 15DA is being set to 0.0 while in the old 1980 astm 534A is being set to 821.0.  Perhaps this is the problem, but I cannot find where to set the Base Relative Density for conversion groups. 15DA and 534A look to be configured identically with the exception of the external function call type.

                  Any elaboration on this situation may prove helpful.

                  • The Base Relative Density is defaulted from the Test Relative Density for the 15DA Conversion Group. What are the parameters that you are entering in the O3QCITEST ?
                    An Example that is in range is listed below,

                    Material temperature     20,00     CEL
                    Test temperature     15,00     CEL
                    Test relative density     900,0
                    Air buoyancy indicator                     
                    Air buoyancy factor     0,000000
                    Hydrometer correction indic.     X
                    BSW fraction     0,500000
                    Meter correction factor     1,000000
                    Base relative density     900,0 - This is Read Only in the Calculator as this is derived directly from the Test Relative Density

                    • Thanks for your reply on this.

                      I am following your examples exactly as you have indicated.

                      For example when I use the Example you provide above, the Base relative density does not derive. It remains zero.

                      Base relative density 0,0

                      Yet for the old 1980 conversion group 534A it derives correctly to a Base relative density of 900,0 as you indicate.

                      This leads me to believe my issue is in the build of the new ASTM_2004_WIN.exe

                      As I am looking back over your build instructions, I realize that there was one other difference in the code that I actually had to make.  You instructed to add the output parameter r_ctplBaseToAlt.

                      That parameter r_ctplBaseToAlt was actually already in my output list, but the parameter below it r_ctplB was missing in my astm_2004.c file.  So, to make my output list match yours, I added r_ctplB instead.

                      Perhaps I should not have added r_ctplB to the output parameter list?

                      Would you recommend removing the r_ctplB output parameter?

                    • I had a detailed look into this. I agree on removing the r_ctplB Output. This is not needed and was put in for Test Purposes. Thanks so much for testing this out in detail. I would update the Blog with the Updated Screenshot. Please let me know if you face any further issues on this.
                    • r_ctplB was put in for testing purposes. We could safely remove this. I have updated the Blog with this change. Thanks so much for pointing this out to me. Please let me know if you have any other Suggestions on the same.
            • Hi,

              Its very useful.

              Unfortunately, I cannot jump to your blogs...

              Can you advise me where I can see those contents or send me a mail.

              Best Regards,

              Kiichiro Okajima

            • Dear Navneet,

              The links that are provided are no longer working. Could you please help in updating the right paths for the pictures.