BSSV mapping MathNumeric to Integer and Dates etc out of E1

johndanter

Legendary Poster
Hi folks,

I've had to write a heap of BSSVs lately to help expose some of our custom BSFNs and I'm running into the old MathNumeric to Int issues (and dates)

Does anyone have a good clear example of how they convert these 2 fields back and forth please?

I've nailed the Math to Int, but I'd still like to see how you do it.

confirmVO.setMnDocumentOrderInvoiceE_DOCO (internalVO.getMnDocumentOrderInvoiceE_DOCO().intValue ());

Next fields are the dates :)

Thanks

John
 

saikiran

Active Member
Hi John,

Even i had the same query...

As of now, i am replacing the "integer" datatype with "MathNumeric" and then generating the accessors.
This doesn't require any back & forth conversion.
 

Jitendra P

Member
Hi John,

I always use the concept of typecasting for this purpose.
Type casting is nothing but assigning a value of one type to a variable of another type.

In your case, I would go forward with following code to convert the two fields:

When converting from MathNumeric to Interger:
confirmVO.setnDocumentOrderInvoiceE_DOCO (new Integer(internalVO.getMnDocumentOrderInvoiceE_DOCO().intValue()));


When converting from Interger to MathNumeric:
confirmVO.setMnDocumentOrderInvoiceE_DOCO (new MathNumeric(internalVO.getnDocumentOrderInvoiceE_DOCO()));


Moreover Java specific datatypes should always be used in Published Value Objects classes as the data coming from the external sources needs to be handled by the Published VO. Whereas JDE specific datatypes should be used in Internal Value Object classes as this values are manipulated from/to JDE tables.


Hope this addresses your issue.


Regards,
Jitendra
 

nkuebelbeck

VIP Member
I personally take all values in as string's. Then in the constructor of the internal value object convert the values to jde types. From my experience bssv will just error if you have an int data type in your published value object. At least this way I have some control. the called bsfn takes care of validation.

try{
this.mnAddressNumber = new MathNumeric(Integer.parseInt(vo.getSzAddressNumber()));
}catch(Exception e){
this.mnAddressNumber = new MathNumeric(0);
}
 
Discover how to build no-code data integrations and business process automations.

johndanter

Legendary Poster
Thanks guys, I think I've nailed it. But my java is pants.
What I did was look at an existing record on F98603 and looked how they did with a toothcomb
So I looked at the VO the 2 published VOs (in/out) and worked out what they do

Basically they declare both MathNumeric and Integer in the accessors. (Is that typecasting?)
So.....

I try and use the names of the E1 DSTR elements throughout (even in the published VOs). I also use excel to help me map the assignments on mass.
The Getters and setters are all pasted in automatically when you right click

Then I scroll down through the accessors and ensure Date – Calender / Math – Int is handled
Declare MathNumerics as Integers/BigDecimals and Dates as Calendar by adding the green text below
(replace Integer with BigDecimal when needed)

public void setGTS_mnCobyQtyCompleted_TRQT(MathNumeric GTS_mnCobyQtyCompleted_TRQT) {
this.GTS_mnCobyQtyCompleted_TRQT = GTS_mnCobyQtyCompleted_TRQT;
}
I add this------------------------
public void setGTS_mnCobyQtyCompleted_TRQT(Integer gTS_mnCobyQtyCompleted_TRQT)
{ if ( gTS_mnCobyQtyCompleted_TRQT == null )
{ this.GTS_mnCobyQtyCompleted_TRQT = null; }
else
{ setGTS_mnCobyQtyCompleted_TRQT( new MathNumeric(gTS_mnCobyQtyCompleted_TRQT) ); }
}
To here------------------------

public MathNumeric getGTS_mnCobyQtyCompleted_TRQT() {
return GTS_mnCobyQtyCompleted_TRQT;
}

public void setJdSLIssueLotEffectiveDate_DLEJ(Date jdSLIssueLotEffectiveDate_DLEJ) {
this.jdSLIssueLotEffectiveDate_DLEJ = jdSLIssueLotEffectiveDate_DLEJ;
}
same here too--------------
public void setJdSLIssueLotEffectiveDate_DLEJ (Calendar calDate)
{ if ( calDate == null )
{ this.jdSLIssueLotEffectiveDate_DLEJ = null; }
else
{ setJdSLIssueLotEffectiveDate_DLEJ ( calDate.getTime() ); }
}
To here----------------------

public Date getJdSLIssueLotEffectiveDate_DLEJ() {
return jdSLIssueLotEffectiveDate_DLEJ;
}
 
Last edited:

Jitendra P

Member
Hi John,

Yes you did the right thing going forward with your logic to assign values between Math-Int.

Also following code snippet from your code can be called as Typecasting.

******************************************************************

if ( gTS_mnCobyQtyCompleted_TRQT == null )
{
this.GTS_mnCobyQtyCompleted_TRQT = null;
}
else
{
/*This is called as Typecasting*/
/*Where You assign a Interger type variable to a MathNumeric type variable*/
/*Using "new MathNumeric()" generic class*/
setGTS_mnCobyQtyCompleted_TRQT( new MathNumeric(gTS_mnCobyQtyCompleted_TRQT) );
}
}

******************************************************************


Regards,
Jitendra
 
Top