rosy
Member
Hi,
I am new in developing C business function. I have some knowledge in C/C++ programming. In JDE, i would like to develop a C business function and test it.
I tried some coding. The function should pass the parameter as the workorder number and retrieves its corresponding record from table F00165.
like, SELECT GDCRTU FROM F00165 WHERE GDOBNM='GT00092' AND GDTXKY='somevalue';
'somevalue' is passed as a parameter and retrieve its corresponding GDCRTU.
Here is my code,
I also created the data structure and paste it on the header file.
Please help me how do i need to check if it is connected with the table and print some message it is connected with the JDEDB. I am testing this code in DV7333.
My Question is:
1. how do i need to call/use the API. JDB_OpenTable,.....
2. how do i need to connect to the DB - coding.
3. how to check if it is connected with the DB or not.
4. Select a column based on the input.
5. How i can view the result.
Please help.
Thanks,
Rosy
I am new in developing C business function. I have some knowledge in C/C++ programming. In JDE, i would like to develop a C business function and test it.
I tried some coding. The function should pass the parameter as the workorder number and retrieves its corresponding record from table F00165.
like, SELECT GDCRTU FROM F00165 WHERE GDOBNM='GT00092' AND GDTXKY='somevalue';
'somevalue' is passed as a parameter and retrieve its corresponding GDCRTU.
Here is my code,
Code:
/************************************************************************
* Variable declarations
************************************************************************/
HUSER hUser;
JDEDB_RESULT eJDBReturn;
JDEDB_RESULT eReturn;
HREQUEST hRequestF00165 = (HREQUEST) NULL;
int i;
char *p;
typedef struct
{
char gdobnm[11]; /* 0 to 10 */
char gdtxky[255]; /* 11 to 265 */
char gdcrtu[11]; /* 266 to 278 */
} F00165, FAR *LPF00165;
F00165 dsF00165 = {0};
eJDBReturn = JDB_InitBhvr (lpBhvrCom, &hUser, (char *) NULL,
JDEDB_COMMIT_AUTO);
if (eJDBReturn != JDEDB_PASSED)
{
return (ER_ERROR);
}
/* Open File */
eJDBReturn = JDB_OpenTable(hUser,
NID_F00165,
ID_F00165_I00165,
NULL,
(ushort) 0,
NULL,
&hRequestF00165);
/* Check Open Table success */
if (eJDBReturn == JDEDB_PASSED)
{
/*strncpy(dsF00165.gdobnm, lpDS->szNameObject,
sizeof(dsF00165.gdobnm) );
strncpy(dsF00165.gdtxky, lpDS->GenericTextKey,
sizeof(dsF00165.gdtxky) );
p = dsF00165.gdtxky;
printf(p);
printf("JDEDB PASSED.");
if (eJDBReturn == JDEDB_FAILED)
{
JDB_FreeBhvr(hUser);
JDB_CloseTable(hRequestF00165);
printf("JDEDB FAILED.");
return (ER_ERROR);
}
} /* endif */
else
{
printf("JDEDB.");
JDB_CloseTable(hRequestF00165);
JDB_FreeBhvr(hUser);
return (ER_ERROR);
}
/************************************************************************
* Function Clean Up
************************************************************************/
JDB_CloseTable(hRequestF00165);
JDB_FreeBhvr(hUser);
return (ER_SUCCESS);
}
Code:
#ifndef DATASTRUCTURE_D55MEDI
#define DATASTRUCTURE_D55MEDI
typedef struct tagDSD55MEDI
{
char szNameObject[11];
char GenericTextKey[255];
char szCreatedByUser[11];
} DSD55MEDI, *LPDSD55MEDI;
#define IDERRszNameObject_1 1L
#define IDERRGenericTextKey_2 2L
#define IDERRszCreatedByUser_3 3L
#endif
My Question is:
1. how do i need to call/use the API. JDB_OpenTable,.....
2. how do i need to connect to the DB - coding.
3. how to check if it is connected with the DB or not.
4. Select a column based on the input.
5. How i can view the result.
Please help.
Thanks,
Rosy