Concurrent C and PRO C Program Tutorial (Doc ID 113428.1)
Concurrent C and PRO C Program Tutorial (Doc ID 113428.1)
Concurrent C and PRO C Program Tutorial (Doc ID 113428.1)
1)
1. Introduction
------------
You will find that the article layout is broken down into the twelve
major areas, each identified by a number. The areas are listed below
in a table of contents and span general coding concepts, paradigms
in Oracle Applications and known issues linked to writing C and Pro*C
code. All code examples have been grouped together in Section 10 and
they are referred to in the article as program sample [10.1] et cetera.
Also, references are in Section 12 and they are referred to in the
article as reference [12.1] et cetera for Oracle documentation and
as reference [G.1] et cetera for general references to the C programming
language and "vi" text editor. For clarity, the English notational
style of placing commas and periods outside of the quotes is adopted
in this paper to avoid any syntatical confusion.
Table of Contents
-----------------
# Section Heading
-- ---------------
1 Introduction
2 Definition of Process
3 Creating Concurrent C Programs
4 Creating Concurrent Pro*C Programs
5 Compiling Objects
6 Archiving Subroutines into Product Libraries
7 File and Version Control Suggestions
8 Linking Objects (through "adrelink")
9 Registering Programs
10 Sample Code Repository
11 Known Issues
12 References
#include <stdio.h>
main()
{
printf("Hello World.\n");
}
cc -o hello hello.c
2. Definition of Process
---------------------
The process for compiling and linking your code modules is covered
in Appendix B of the Oracle Applications Installation Manual [12.6]
[12.11] and Oracle Applications Developer's Manual [12.11]. The
approach taken in the article is to follow this standard. Therefore,
there are two programs for each executable, a main program and a
subroutine program. The combination of the two program components
make an executable program when linked by using the "adrelink" tool.
Once the two are linked, you have an executable program in your
product top's executable directory - $CUS_TOP/bin Note.115016.1.
These executables can then be made accessible by registering them
within the standard Oracle Applications forms from either the System
Administration or Application Developer responsibilities, see
Section 9 below. The two executables for this article are:
1. The first executable is a slightly modified form of the
EXMAIN.c and EXPROG.c programs and simply prints a set of
test lines to the log and report files. The subroutine
program [10.1] manages the printing of the file and the
main program [10.2] becomes the executable that calls
the library function, which is the compiled and archived
subroutine program [10.1], within the "libfnd.a" archive.
* NOTE
----
If the concept of a custom product top is unfamiliar please
check Chapter 2 of the Oracle Applications Installation Manual
[12.3] and [12.7] or Note.115016.1.
5. Compiling Objects
-----------------
In the example case, you should create a directory for source code
in your $FND_TOP directory. Oracle Applications standards would
name that the $FND_TOP/src directory. (NOTE: For the sake of a
simplified test case, we are using an existing library and part of
the standard directory tree; however, you should delete these after
completing your test. Please note the discussion in Section 7 if
you are unsure about directory structures within the context of
Oracle Applications.
Example 10.1
------------
$ make -f $FND_TOP/usrxit/Makefile hello.o
Example 10.2
------------
$ make -f $FND_TOP/usrxit/Makefile hello_main.o
Example 10.3
------------
$ make -f $FND_TOP/usrxit/Makefile submit_hello.o
Example 10.4
------------
$ make -f $FND_TOP/usrxit/Makefile sample_main.o
If we assume the test case of this article, you will execute the
following commands to move the files.
Example 10.1
------------
$ mv $FND_TOP/src/hello.o $FND_TOP/lib/.
Example 10.2
------------
$ mv $FND_TOP/src/hello_main.o $FND_TOP/lib/.
Example 10.3
------------
$ mv $FND_TOP/src/submit_hello.o $FND_TOP/lib/.
Example 10.4
------------
$ mv $FND_TOP/src/sample_main.o $FND_TOP/lib/.
Then, confirm that you have successfully moved the files by changing to
the $FND_TOP/lib directory and listing the files (e.g., with the "ls"
utility). When you have confirmed that the files are where they should
be in the $FND_TOP/lib directory, you will need to archive the subroutine
objects into the libfnd.a library file.
General Syntax
--------------
$ ar ruvs <library_name> <subroutine_name.o>
* NOTE
----
Please remember you should remove these objects from the libfnd.a
library after testing. The syntax for removing them is noted below.
General Syntax
--------------
$ ar d <library_name> <subroutine_name.o>
If you follow the guidelines for Oracle Applications, you will have
a custom top directory structure as a child directory from your
$APPL_TOP directory. For example, if your customer directory is "CUS",
then you will have an $APPL_TOP/cus directory. You will define an
environment variable for $CUS_TOP for your custom directory.
(Naturally, the "CUS" will be whatever is meaningful in your
environment.)
Within your $CUS_TOP, you will have the following directories. However,
you may exclude some of these if you define a common log repository
under an $APPLCSF environment variable or choose not to develop SQL
reports et cetera. You should check the Oracle Application Installation
Manual for Unix for reference to the directory structure noted [12.3].
$CUS_TOP Directories
--------------------
admin include mesg patchsc reports sql
bin lib out resource src
forms log patch rpt srw
You need to link your executable files now that your subroutines are
archived as objects within the libfnd.a library. You do this by
running the "adrelink" utility to link the executables. (Please check
the Oracle Applications Installation Manual [12.3][12.7], if you have
any questions about running the "adrelink" utility.) Please remember
that you should edit the $FND_TOP/lib/fnd.mk file to include your
custom program as qualified below in Section 11.5 Note.113490.1.
General Syntax
--------------
9. Registering Programs
--------------------
=> Navigate => Security => Responsibility => Report => Groups
General Syntax
--------------
PROGRAM orauser/pwd 0 Y [parameter1] [parameter2] ...
Example Syntax
--------------
$FND_TOP/bin/hello APPS/APPS 0 Y
You will find four sample programs in this article; however, more
examples of Concurrent Manager C and Pro*C code may be found in
the Oracle Application Object Library Reference Manual [12.2] and
Note.115016.1. Equivalents to the sample programs section do not
exist in the Oracle Applications Developer's Guide.
/*
|| This is a concurrent program that uses the example
|| code provided in the $FND_TOP/usrxit/EXPROG.c
|| program.
||
|| Modified: Michael McLaughlin
|| Date: 06/07/2000
*/
#ifndef AFPUB
#include <afpub.h>
#endif
#ifndef AFCP
#include <afcp.h>
#endif
/*
|| This is the beginning of an example program.
*/
int i;
text buffer[241];
/*
|| For successful completion.
*/
/*
|| This is a concurrent program that uses the example
|| code provided in the $FND_TOP/usrxit/EXMAIN.c
|| program.
||
|| Modified: Michael McLaughlin
|| Date: 06/07/2000
*/
#ifndef AFPUB
#include <afpub.h>
#endif
#ifndef AFCP
#include <afcp.h>
#endif
AFP_FUNCS hello;
{
afsqlopt options;
return(afprcp(argc, argv, (afsqlopt *)NULL, (afpfcn *)hello));
}
/*
|| This is a concurrent program that uses the example
|| code provided in the $FND_TOP/usrxit/EXPROG.c
|| program and modified pursuant to the example code
|| found in the Oracle Application Object Library
|| Reference Manual, Concurrent Processing, pages
|| 9-46 through 9-47 (A12534-6).
||
|| Modified: Michael McLaughlin
|| Date: 06/07/2000
*/
#ifndef AFPUB
#include <afpub.h>
#endif
#ifndef AFCP
#include <afcp.h>
#endif
/*
|| Even though this does not appear on page 9-46 of
|| Manual, it should. Please check documentation
|| Bug:1338680 for any questions.
*/
#include <sqlca.h>
char note[1024];
/*
|| This is the beginning of an example program.
*/
reqstart.arr[reqstart.len] = '\0';
sprintf(command,"CONCURRENT FND HELLO_MAIN START=\"%s\" ",reqstart.arr);
fdpwrt(AFWRT_LOG | AFWRT_NEWLINE,command);
if(!fdpscr(command,request_id,errbuf))
{
sprintf(note,"Request ID * value * = * %s * ", request_id);
fdpwrt(AFWRT_LOG | AFWRT_NEWLINE,note);
fdpwrt(AFWRT_LOG | AFWRT_NEWLINE,"Failed to submit concurrent request");
fdpwrt(AFWRT_LOG | AFWRT_NEWLINE,errbuf);
return(afpend(FDP_ERROR,reqinfo,"Failed to submit concurrent request"));
}
else
{
EXEC SQL COMMIT WORK;
sprintf(note,"Request ID * value * = * %s * ", request_id);
fdpwrt(AFWRT_LOG | AFWRT_NEWLINE,note);
return(afpend(FDP_SUCCESS,reqinfo,"Submitted Successfully"));
}
}
/*
|| This is a concurrent program that uses the example
|| code provided in the $FND_TOP/usrxit/EXMAIN.c
|| program.
||
|| Modified: Michael McLaughlin
|| Date: 06/07/2000
*/
#ifndef AFPUB
#include <afpub.h>
#endif
#ifndef AFCP
#include <afcp.h>
#endif
AFP_FUNCS submit_hello;
12. References
----------
Oracle References
-----------------
Version 10.7
------------
[12.1] Oracle Application Object Library Reference Manual, Release 10,
Volume 1 (A12532-6)
[12.2] Oracle Application Object Library Reference Manual, Release 10,
Volume 2 (A12534-6)
[12.3] Oracle Applications Installation Manual, Release 10.7 for Unix,
Appendix B (A47542-1)
[12.4] Oracle Call Interface, Release 7.3, Programmer's Guide
(A32546-1)
[12.5] Programmer's Guide to the Oracle Precompilers, Release 1.8
(A42526-1)
Version 11.x
------------
[12.6] Oracle Applications Developer's Guide, Release 11 (A58187-01)
[12.7] Oracle Applications Installation, Release 11 for Unix,
Appendix B (A57983-02)
[12.8] Programmer's Guide to the Oracle Call Interface, Release 8,
Volume I: OCI Concepts (A54657-1)
[12.9] Programmer's Guide to the Oracle Call Interface, Release 8,
Volume II: OCI Reference (A54655-01)
[12.10] Programmer's Guide to the Pro*C/C++ Precompiler, Release 8
(A54661-01)
Version 11i*
-----------
[12.11] Oracle Applications Developer's Guide, Release 11i (A83705-02)
[12.12] Oracle Call Interface, Programmer's Guide, Volume 1, Release 8.1.6,
(A76977-01)
[12.13] Oracle Call Interface, Programmer's Guide, Volume 2, Release 8.1.6,
(A76978-01)
[12.14] Pro*C/C++ Precompiler, Programmer's Guide, Volume 1, Release 8.1.6,
(A76943-01)
[12.15] Pro*C/C++ Precompiler, Programmer's Guide, Volume 2, Release 8.1.6,
(A76944-01)
* NOTE: Documentation on compiling and linking Concurrent C and Pro*C
programs found in Appendix B of [12.2] and [12.6] is now only
covered in Chapter 19 of [12.10].
General References
------------------
[G.6] UNIX Systems Programming for SVR4, 1996, David A. Curry, O'Reilly,
ISBN 1565921631.
[G.8] Learning the vi Editor, 6th Ed., 1998, Linda Lamb and Arnold
Robbins, ISBN 1565924266.