Creating a C or Pro*C Standalone Concurrent Program in Oracle Applications




Creating a C or Pro*C Standalone Concurrent Program in Oracle Applications
==========================================================================

This note describes the basic steps to set-up a Pro*C program as a Standalone concurrent program in Oracle Applications

This note has been used for Release 10.7 and Release 11 on Unix, any differences have been noted in the text.


Overview of the steps
=====================
1) Create custom application
2) Set-up concurrent program
3) Create and compile Pro*C program
4) Make the binary using adrelink
5) Run program and check results



1) Create custom application
============================
Customisations should of course be created in a seperate area in a custom application. If you have not yet created a custom application, you should follow the steps below:-

a) Modify the APPLSYS.env file

Add the following lines

PC_TOP=$APPL_TOP/pc
export PC_TOP

Add 'PC' to the APPLFULL variable for example:-
APPLFULL='PC FND AD ALR AX AK GL RG INV PO AP FA AR OE AS PA CN WH PER PAY SSP O
TA BOM MRP WIP ENG CRP RLA VEH QA CS CE EC ICX '


b) Create directories
Create the following directorys :-
$PC_TOP
$PC_TOP/$APPLLIB
$PC_TOP/bin
$PC_TOP/$APPLOUT
$PC_TOP/$APPLLOG


c) Application-->Register
Application Name = ProC Test
Short Name = PC
Basepath = PC_TOP
Abbreviation = PC (10.7 only)
Message = APP (10.7 only)
Description = ProC Test


d) Security-->Oracle-->register
Database User Name = PC
Password = PC
Privilege = Enabled
Name = STANDARD (10.7 only)
Install Group = 0
Description = ProC Test


e) Security-->Oracle-->DataGroup
Data Group = ProC
Application = ProC Test
Application User name = APPS
(You also must define AOL application against user APPS)


f) Create user in Database
Go into SQLPLUS, connect as system to the correct database and create PC user as below
create user pc identified by pc
default tablespace <data_tablespace_name>
temporary tablespace <temp_tablespace_name>
/
grant connect to pc
/


g) Security-->Responsibility-->Define
Group = ProC Test
Application = ProC Test
Code = <not entered>
Description = ProC Test
(You do not need to specify any requests in your Requests Group at this stage)


h) Application-->Menu
Menu = PROCMAINMENU
User Menu Name = ProC Main Menu
Description = ProC Main Menu
Seq = 1
Navigator Prompt = Requests
Submenu = Requests Menu - Other Responsibilities
Description = Requests


i) Security-->Responsibility-->Define
Responsibility = ProC Test
Application = ProC Test
Responsibility Key = PROCTEST (Rel 11 only)
Data Group = ProC
Application = ProC Test
Menu = ProC Main Menu
Request Group = ProC Test
Application = ProC Test


j) Security-->User-->Define
User Name = ProC
Password = <suitable password>
Responsibility = ProC Test

2) Set-up concurrent program
============================

As System Adminstrator do the following:-

a) Concurrent-->Program-->Executable
Executable = PCTEST
Application = ProC Test
Description = ProC Test
Execution Method = Spawned
Execution File Name = PCTEST
Subroutine Name = <not entered>


b) Concurrent-->Program-->Define
Program = ProC
Short name = PROC
Application = ProC Test
Description = ProC Test
Executable Name = PCTEST
Method = Spawned
(Leave all other settings as the default)


c) Security-->Responsibility-->Request
Group = ProC Test
Application = ProC Test
Code = <not entered>
Description = ProC Test
Requests Type = Program
Requests Name = ProC
Requests Application = ProC Test

3) Create C or Pro*C programs
=============================
From the Unix prompt change directory to the $PC_TOP/$APPLLIB directory.
Copy the following files from $FND_TOP/$APPLUSR:-
EX*.c
sample.mk

Rename EXMAIN.c as pctest.c
Rename EXPROG.c as pctestprog.c
Rename sample.mk as pc.mk

Modify pctest.c as below:-
#ifndef AFPUB
#include <afpub.h>
#endif
#ifndef AFCP
#include <afcp.h>
#endif
FDRCSID("$Header: pctest.c 1.0 99/05/24 09:30:00 porting ship $");
AFP_FUNCS pctest;
int main(argc, argv)
int argc;
char *argv[];
{
afsqlopt options;
return(afprcp(argc, argv, (afsqlopt *)NULL, (afpfcn *)pctest));
}

Modify pctestprog.c as below:-
#ifndef AFPUB
#include <afpub.h>
#endif
#ifndef AFCP
#include <afcp.h>
#endif
FDRCSID("$Header: pctestprog.c 1.0 99/05/24 09:30:00 porting ship $");
boolean pctest(argc, argv, reqinfo)
int argc;
text *argv[];
dvoid *reqinfo;
{
int i;
text buffer[241];
fdpwrt(AFWRT_LOG | AFWRT_NEWLINE, "Hello World.");
fdpwrt(AFWRT_LOG | AFWRT_NEWLINE, "Hello World.");
fdpwrt(AFWRT_OUT | AFWRT_NEWLINE, "This is a test! Take one.");
fdpwrt(AFWRT_OUT | AFWRT_NEWLINE, "-------------------------");
for ( i = 0; i < argc; i++ )
{
sprintf(buffer, "argv[%d]: %s", i, argv[i]);
fdpwrt(AFWRT_OUT | AFWRT_NEWLINE, buffer);
}
return(afpend(FDP_SUCCESS, reqinfo, "")); /* For successful completion */
}

Modify pc.mk as below:-

# start of makefile
PCTEST_BIN = $(PC_TOP)/$(APPLBIN)/PCTEST
PCTEST_OBJ = $(PC_TOP)/$(APPLLIB)/pctest.o
MODULES = $(PCTEST_BIN)
all: $(MODULES)
$(PCTEST_BIN): $(PCTEST_OBJ) $(LFNDLIB) $(LPCLIB)
$(CC) $(LDFLAGS) -o $@ $(PCTEST_OBJ) \
$(LPCLIB) $(LFNDLIB) $(ORACLE_LINK)
$(CHMOD) 755 $@
$(MCS) $@
# end of makefile


4) Compile programs and make the binary using adrelink
======================================================
Ensure you are in the $PC_TOP/$APPLLIB directory

a) Set up ProC generation file and process Pro*C file (if applicable)
I am sure there is a better way of doing this, but the following works for me....

Create a shell script called pcrun with contents as below:-

proc include=. include=$FND_TOP/include include=$ORACLE_HOME/rdbms/demo include=
$ORACLE_HOME/precomp/public ireclen=161 sqlcheck=none dbms=v6 $1 | tee pcrun.log

When you want to process your ProC file, you type in 'pcrun <filename>' If any messages on screen are lost, the screen output is echoed into the file called 'pcrun.log'


b) Make the C files

Run the following commands to compile the example programs
make -f pc.mk pctest.o
make -f pc.mk pctestprog.o

Check the files pctest.o and pctestprog.o exist. If there is a file called n=Read_only_strings, then there is a problem with the CFLAGS environment file. This is set-up in the $FND_TOP/$APPLUSR/devenv file and depends on the $PLATFORM environment variable being correct. Check $PLATFORM is the correct value for your system, if not change this setting in your APPLSYS.env (or equivilent) file.


c) Generate library file

We need to create a library file for the PC module as below:-
ar rv libpc.a pctestprog.o

NOTE - the file libpc.a MUST exist for adrelink to complete. If the file does not have any object files in it then Release 10.7 adrelink will fail, whereas Release 11 will just give you a warning. This step ensures there will not be any such problems.


d) Link binaries using adrelink

Now try to relink the binaries using the following command:-
adrelink force=y ranlib=y "PC PCTEST"

Check the adrelink.log file for errors, and that PCTEST exists in the $PC_TOP/bin directory.

NOTE - If you get an error similar to "UX:make: ERROR: Must be a separator on rules line 1303 (bu39)" this is usually caused by corrupt / misaligned makefile.
Are you using tabs in the makefile ?
IE :-
$(PCTEST_BIN): $(PCTEST_OBJ) $(LFNDLIB) $(LPCLIB)
<tab>$(CC) $(LDFLAGS) -o $@ $(PCTEST_OBJ) \
If you put in spaces where <tab> should be, you will get this error.


5) Test program
===============
Login to applications as the PROC username.
Run the Concurrent Program called 'ProC'
Assuming it completes succesfully, you should see the following output:-

Log file
--------

ProC Test: Version : UNKNOWN - Development
PROC module: ProC
+---------------------------------------------------------------------------+
Current system time is xx
+---------------------------------------------------------------------------+
Hello World.
Hello World.
+---------------------------------------------------------------------------+
Concurrent request completed successfully
Current system time is xx


Report file
-----------
This is a test! Take one.
This is a test! Take two.
-------------------------
argv[0]: PROC



References
==========

Manuals
-------
A57983 - Release 11 Installation Manual (Unix) - page B-8
A58187 - Release 11 Developers Guide - Chapter 19
A47542 - Release 10 Installation Manual (Unix) - page B-12
A12535 - AOL Reference manual - Chapter 9


Notes
-----
Bug 758459 - Release 11 - afcall.h missing see contents of this file below:-

Contents of afcall.h
--------------------
/*$Header: afcall.h 110.0 98/07/20 15:32:44 porting ship $*/
/*======================================================================+
| Copyright (c) 1998 Oracle Corporation Belmont, California, USA |
| All rights reserved. |
| Application Division |
+======================================================================+
| FILENAME |
| afcall.h |
| |
| DESCRIPTION |
| HISTORY |
| 07/20/98 Jin Liu Created. |
*----------------------------------------------------------------------*/
#ifndef AFCALL
#define AFCALL
#ifdef WIN32COMMON
#ifdef FNDPUBSTD
#define AF_CALL _stdcall
#else
#define AF_CALL _cdecl
#endif
#else
#define AF_CALL
#endif
#endif /* AFCALL */ 







No comments:

ORA-01552: cannot use system rollback segment for non-system tablespace 'TEMP'

 ORA-01552: cannot use system rollback segment for non-system tablespace "string" Cause: Used the system rollback segment for non...