How to Write a C Business Function to Return a Special Character

Purpose of Document

To manipulate string or text values you need to make use of special characters available, which can be accomplished only by C programming. This document is a simple example of how a C business function can be written to return a special character. 

NOTE:  The following example is provided as is, Oracle does not provide warranty and is not responsible for any issues with using this example.  This information is provided as an example only. 

User must be proficient in C++ programming in order to use the information in this document. 

 

In C library, the standard "string" library contains many useful functions to manipulate strings (referenced by K & R C Programming Language). Some of the most useful functions are:

(s and t are char*, cs and ct are const char*, c is an char converted to type int, and n is an int.)

Refer to the attachment "Unicode Cookbook Documentation.doc" from <Document 626598.1> - E1: BSFN: Unicode and C Business Functions to get a list of JDE APIs which makes use of the standard "string" library functions.

This document mainly cover concatenation as below:

FunctionStandard
Library
Used for
JCHAR *jdeStrcat(JCHAR *d, const JCHAR *s) Strcat Concatenate one Unicode string with another
JCHAR *jdeStrncat(JCHAR *d, const JCHAR *s, int n) Strncat Concatenate one Unicode string with another, stopping after n characters (Note, this is characters not bytes).



C representation of special characters,

NOTE: 


To implement this,
1. Create a data structure with a data dictionary item with data type character (e.g., EV01)

#ifndef DATASTRUCTURE_D55SC001A
#define DATASTRUCTURE_D55SC001A

typedef struct tagDSD55SC001A
{
   JCHAR cReturnType;
   JCHAR cCharacter;
} DSD55SC001A, *LPDSD55SC001A;

#define IDERRcReturnType_1 1L
#define IDERRcCharacter_2 2L

#endif



2. Create a C function (this is an important step because currently system function concat() only accepts string argument. For example, f(s) concat ("string", "string") so if we assign parameter '\r' for example the output will be 'string\r'. That is, '\r' is recognized as "\r".)


switch(lpDS->cReturnType)
{
   case _J('1'): lpDS->cCharacter = _J('\t'); /* Horizontal tab */
      break;
   case _J('2'): lpDS->cCharacter = _J('\f'); /* form feed */
      break;
   case _J('3'): lpDS->cCharacter = _J('\v'); /* Vertical tab */
      break;
   case _J('4'): lpDS->cCharacter = _J('\n'); /* New-Line Character */
     break;
   case _J('5'): lpDS->cCharacter = _J('\a'); /* Alert Tone */
     break;
   case _J('6'): lpDS->cCharacter = _J('\b'); /* Backspace */
     break;
   case _J('7'): lpDS->cCharacter = _J('\r'); /* Carriage Return */
     break;
   case _J('8'): lpDS->cCharacter = _J('\0'); /* NULL Character */
     break;
}


3. Compile it
4. If needed call it from Report Design Aid (RDA), Form Design Aid (FDA) or Named Event Rule (NER)

NOTE: