Get Data Selection on a section (quite working)

sviardot

sviardot

Reputable Poster
Here is a code for a BSFN than allow to retrieve and pront dataselection for a section only.
I have jsut a problem : i dont have time to finish that and it's only a bug : i don't display the correct value if the parameter is a numeric.

If someone have time to finish, it could be a pretty one tools for all of us.

Thanks
 
Hi Serge,

Please, attach the code, if you do not want for somebody volunter to start from scratch.
cool.gif


Regards,

Zoltán
 
sorry for the convenience. I did atached the file and dont understand why it's not on my message.
At not at office for today night but i will send it tomorrow morgin as soon i arrive.
 
Here is the code.
And if the attachement doesn"t work :

#include <jde.h>

#define b5500430_c


/*****************************************************************************
* Source File: b5500430
*
* Description: SPhere Retreive Data Selection Source File
*
* History:
* Date Programmer SAR# - Description
* ---------- ---------- -------------------------------------------
* Author 5/11/2009 Unkno Unknown - Created
*
* Copyright (c) J.D. Edwards World Source Company, 1996
*
* This unpublished material is proprietary to J.D. Edwards World Source Company.
* All rights reserved. The methods and techniques described herein are
* considered trade secrets and/or confidential. Reproduction or
* distribution, in whole or in part, is forbidden except by express
* written permission of J.D. Edwards World Source Company.
****************************************************************************/
/**************************************************************************
* Notes:
*
**************************************************************************/

#include <b5500430.h>


/**************************************************************************
* Business Function: SphereRetreiveDataSelection
*
* Description: SPhere Retreive Data Selection for a section
*
* Parameters:
* LPBHVRCOM lpBhvrCom Business Function Communications
* LPVOID lpVoid Void Parameter - DO NOT USE!
* LPDSD550 lpDS Parameter Data Structure Pointer
*
*************************************************************************/

JDEBFRTN (ID) JDEBFWINAPI SphereRetreiveDataSelection (LPBHVRCOM lpBhvrCom, LPVOID lpVoid, LPDSD5500430 lpDS)

{
/************************************************************************
* Variable declarations
************************************************************************/
MATH_NUMERIC mnSectionID = {0};
int nSection = 0;
unsigned short uCount = (unsigned short)0;
ID idJDBReturn = JDEDB_PASSED;
int i = 0 ;
/*int j = 0 ;*/
JCHAR jnValue[10];
MATH_NUMERIC mnValue;
long lValue;
/************************************************************************
* Declare structures
************************************************************************/

/************************************************************************
* Declare pointers
************************************************************************/
HUSER hUser = (HUSER)NULL;
JCHAR* pszRptName = (JCHAR*)NULL;
JCHAR* pszVersionName = (JCHAR*)NULL;
LPGLOBALAPP pGlblApp = (LPGLOBALAPP)NULL;
LPJDEAPP lpObj = (LPJDEAPP)NULL;
LPNEWSELECTSTRUCT lpSelect = (LPNEWSELECTSTRUCT)NULL;
/* LPNEWSELECTSTRUCT lpNewSelect = (LPNEWSELECTSTRUCT)NULL; */
PJSTR lpSelectType = (PJSTR)NULL;
/* HREQUEST hRequest = NULL; */
/************************************************************************
* Check for NULL pointers
************************************************************************/
if ((lpBhvrCom == (LPBHVRCOM) NULL) ||
(lpVoid == (LPVOID) NULL) ||
(lpDS == (LPDSD5500430) NULL))
{
jdeErrorSet (lpBhvrCom, lpVoid, (ID) 0, _J("4363"), (LPVOID) NULL);
return ER_ERROR;
}

idJDBReturn = JDB_InitBhvr(lpBhvrCom, &hUser, (JCHAR *)NULL, JDEDB_COMMIT_AUTO);

if (idJDBReturn == JDEDB_FAILED)
{
jdeErrorSet(lpBhvrCom, lpVoid, (ID)0, _J("4363"), (LPVOID)NULL);
return ER_ERROR;
}

/************************************************************************
* Set pointers
************************************************************************/

/************************************************************************
* Main Processing
************************************************************************/

lpDS->cErrorCode = _J('0');

if (lpDS->cMode == _J('0'))
{
/* Get Report Name */
jdeStrcpy(lpDS->szProgramId, ubeReport_GetName(lpBhvrCom));
pszRptName = ubeReport_GetName(lpBhvrCom);

/* Get Report Version */
lpObj = lpBhvrCom->lpObj;
pGlblApp = lpObj->lpGlobalApp;
jdeStrcpy(lpDS->szVersion, pGlblApp->szVersion);
pszVersionName = pGlblApp->szVersion;

/* Get Report Section ID */
ubeSection_GetID(lpBhvrCom, &mnSectionID);
MathNumericToInt(&mnSectionID, &nSection);
lpDS->idSection = (ID)nSection;


idJDBReturn = ubeSection_GetDataSelection(lpBhvrCom, NULL, NULL, lpDS->idSection, &lpSelect,
&lpSelectType, &uCount);
if (lpSelect)
{
for(i = 0; i < (int) uCount; i++)
{
/*jdeStrcpy(lpDS->szAdditionalText , lpSelectType );*/
jdeStrncat(lpDS->szAdditionalText,lpSelect.Item1.szTable,DIM(lpDS->szAdditionalText));
jdeStrncat(lpDS->szAdditionalText,_J("."),DIM(lpDS->szAdditionalText));
jdeStrncat(lpDS->szAdditionalText,lpSelect.Item1.szDict,DIM(lpDS->szAdditionalText));
jdeStrncat(lpDS->szAdditionalText,_J("."),DIM(lpDS->szAdditionalText));
if (lpSelect .nCmp == JDEDB_CMP_EQ)
{
jdeStrncat(lpDS->szAdditionalText,_J("="),DIM(lpDS->szAdditionalText));
}
else
{
if (lpSelect .nCmp == JDEDB_CMP_GT)
{
jdeStrncat(lpDS->szAdditionalText,_J(">"),DIM(lpDS->szAdditionalText));
}
else
{
if (lpSelect .nCmp == JDEDB_CMP_LT)
{
jdeStrncat(lpDS->szAdditionalText,_J("<"),DIM(lpDS->szAdditionalText));
}
else
{
if (lpSelect .nCmp == JDEDB_CMP_GE)
{
jdeStrncat(lpDS->szAdditionalText,_J(">="),DIM(lpDS->szAdditionalText));
}
else
{
if (lpSelect .nCmp == JDEDB_CMP_LE)
{
jdeStrncat(lpDS->szAdditionalText,_J("<="),DIM(lpDS->szAdditionalText));
}
else
{
jdeStrncat(lpDS->szAdditionalText,_J("!="),DIM(lpDS->szAdditionalText));
};
};
};
};
};
jdeStrncat(lpDS->szAdditionalText,_J(" "),DIM(lpDS->szAdditionalText));
/*memset((void *)(&jnValue),(int)(lpSelect.lpValue),sizeof(jnValue));*/
jdeStrncat(lpDS->szAdditionalText,lpSelect.lpValue ,DIM(lpDS->szAdditionalText));
jdeStrncat(lpDS->szAdditionalText,_J(" "),DIM(lpDS->szAdditionalText));
jdeStrncat(lpDS->szAdditionalText,_J(" "),DIM(lpDS->szAdditionalText));
if (lpSelect.nAndOr == JDEDB_ANDOR_AND)
{
jdeStrncat(lpDS->szAdditionalText,_J(" AND"),DIM(lpDS->szAdditionalText));
}
else
{
jdeStrncat(lpDS->szAdditionalText,_J(" OR"),DIM(lpDS->szAdditionalText));
};
jdeStrncat(lpDS->szAdditionalText,_J("\n"),DIM(lpDS->szAdditionalText));
};
};

ubeSection_FreeDataSelection(lpBhvrCom, &lpSelect, &lpSelectType, uCount);
}

/************************************************************************
* Function Clean Up
************************************************************************/

JDB_FreeBhvr(hUser);
return (ER_SUCCESS);
}

/* Internal function comment block */
/**************************************************************************
* Function: Ixxxxxxx_a // Replace "xxxxxxx" with source file number
* // and "a" with the function name
* Notes:
*
* Returns:
*
* Parameters:
**************************************************************************/
 

Attachments

  • 145876-b5500430.TXT
    7.9 KB · Views: 143
Hi Serge,

I tested the code for the scenario where the right operand is Alphanumeric & as well for a Number. It worked fine with me.

Check the PDF attached.

Thanks for the nice code!!
 

Attachments

  • 145881-RDATASEL_TEST01_D090514_T140224233.pdf
    47.4 KB · Views: 188
Thanks

But i still have a problem. On my client, we have

R014021 SPhere 5/14/2009 11:00:08
One Line Per Address Page - 1
Address
Number
Alpha
Name
Area
Code
Phone
Number
Mailing
Name
Address
Line 1 City State
Postal
Code Country
2000435 HALDIA PETROCHIMICALS
LTD
HALDIA PETROCHIMICALS LTD 1 AUCKLAND PLACE KOLKATA 700017 India
F0101.MCU.= SP AND
F0101.AN8.>= &#56256;&#56320;&#56256;&#56320;0 AND
Address Total - 1

Instead of F0101.MCU.= SP AND
F0101.AN8.>= 80000 AND

Any idea ?
 
I believe the problem is you are expecting lpValue to be a char array for all items. lpValue is generic pointer that will point to a char array for string data items, but will point to a MATH_NUMERIC or JDEDATE etc for others. AN8, of course, is a MATH_NUMERIC and why the strcat gets undesired results. You'll need to determine the data type of the DD item and convert lpValue to a string based on the type.
 
Hi craig. If i understood well what you said, i have to cast lpValue before to call a bsfn to convert ?
 
Serge,

Rather than casting, you actually have to convert lpValue to a string. In the case of a MATH_NUMERIC (AN8), you can use the API FormatMathNumeric( JCHAR*, LPMATH_NUMERIC). Create a temporary char array and this code:

JCHAR szTemp[64];
...
FormatMathNumeric(szTemp, (LPMATH_NUMERIC)lpValue);

This will convert the MATH_NUMERIC to a string and store it in szTemp. Then concat szTemp to your output string.

For JDEDATE you can use the FormatDate API.
 
I guess as per Craig, lpValue needs to be converted into String before you do concat.

I guess it is OK to call in Advanced section, if you could make call to BSFN only once
 
Thanks for all comments.

I'll have to find time to complete. Send the complete code as soon as possible.
 
Hi, ALL!
I had time for free coding and tried to revise Serge's code.
smile.gif
. I added the possibility to set parameters szProgramId, szVersion and mnSectionID. Also added printing list and range values and join constraint (i.e. F4101.ITM = F4102.ITM).
 

Attachments

  • 153930-GetUBEDataSelection.zip
    3.9 KB · Views: 122
Hi, All!
I have some rework. First of all I added BF Y56RetrieveUBEDataSelectionLine for work with Data Selection line by line. This may be helpful if you want to print DS by line (e.g. in CSV) or if you have to localize your print. BF uses memory for store retrieved Data Selection and this requires additional BF call for delete allocated memory (with Mode = 9).
Any other suggestion would be appreciated.

Some example of using this BF:

=======================================================================
SECTION: Page Header [PAGE HEADER] (S3)
=======================================================================
OBJECT: SECTION
EVENT: After Last Object Printed
-----------------------------------------------------------------------
evt_LineNumber_INT01
evt_LineCount_INT01
OPT: Using Defaults
0001 //
0002 VA evt_LineNumber_INT01 = "0"
0003 Retrieve UBE Data Selection Line
<Zero> -> BF cMode
VA rpt_GenericLong <> BF idDataPtr
"1" -> BF idSection
VA rpt_ErrorCode_DTAI <- BF szErrorCode
RV Message Text <- BF szSelectionLine
VA evt_LineCount_INT01 <- BF nLineCount
VA evt_LineNumber_INT01 -> BF nLineNumber
"1" -> BF nLineIncrement
VA evt_LineNumber_INT01 <- BF nNextLineNumber
0004 While VA evt_LineNumber_INT01 is less than or equal to VA evt_LineCount_INT01 And VA rpt_ErrorCode_DTAI is equal to <Blank>
0005 Do Custom Section(RS Print Message)
0006 Retrieve UBE Data Selection Line
<Zero> -> BF cMode
VA rpt_GenericLong <> BF idDataPtr
"1" -> BF idSection
VA rpt_ErrorCode_DTAI <- BF szErrorCode
RV Message Text <- BF szSelectionLine
VA evt_LineNumber_INT01 -> BF nLineNumber
"1" -> BF nLineIncrement
VA evt_LineNumber_INT01 <- BF nNextLineNumber
0007 End While
0008 Retrieve UBE Data Selection Line
"9" -> BF cMode
VA rpt_GenericLong <> BF idDataPtr
 

Attachments

  • 155118-GetUBEDataSelection.zip
    7.1 KB · Views: 165
Back
Top