F4076 Calculate Algebraic Expression

Total Page:16

File Type:pdf, Size:1020Kb

F4076 Calculate Algebraic Expression

F4076CalculateAlgebraicExpresn F4076 Calculate Algebraic Expression

Minor Business Rule

Object Name: B4500130

Parent DLL: CDIST

Location: Client/Server

Language: C

Functional Description

Purpose

This business function calculates the algebraic expression in an alphanumeric string and returns a mathnumeric value, otherwise return error message ID.

Setup Notes and Prerequisites

The Input string format:

• May or may not contain parentheses to establish precedence. • May or may not contain blank(s)

• May interpret to a character string value or to numeric va lue.

• All arithmetic function characters must be in upper case,

The input string is a 160-upper-case-character string.

• May or may not contain variables

Here are some examples of valid input text strings:

((2+3)-4))*(5/6) ; &VAR1*5 ; ((1.4 * 10)-1500) %EA

((2500 * 1.15)-(?SDUORG*10)) !USD ; (((99 * 88) + 77) %TN) + 15000

10*5/2500 ; ?SDAEXP*?SDUORG/&VAR2

Is very important to consider that exist 4 different types of variables, these variables are always defined with a special character in the first position of the variable. The special characters are into the file F4009 and these can be changed, alphabetic, numeric, and mathematical function (for example, A,1,(,+,-,*,/) values are not valid in this field. The second character of the variable must be in the range A to Z or 0-9.

When you are using variables type Unit of Measure and Currency Code, always you must put a specific mathematical operator, example:

• Unit of Measure %EA = " / 1.1111", the Division sign must p recede each variable of Unit of

Measure defined , if you enter this expression "+ %EA" , the result will be wrong because the interpretation will be " + / 1.1111".

• Currency Code !USD = " * 1.1111", the Multiplication sign must precede each variable of Currency

Code defined , if you enter this expression "+ !USD" , the re sult will be wrong because the interpretation will be " + * 1.1111".

Special Logic

A.Operators: The following operators are prioritized as:

1)')'Right parentheses 2)'/'Division 3)'*'Multiplication 4)'-'Minus 5)'+'Addition 6)'('Left parentheses

Technical Specification

Related Tables

Table Table Description

F4075Price Variable Table

Related Business Functions

Source NameFunction Name

X0005GetUDC B0000033GetExchRate B1100001IsColInCurrencyCodeTable B0000500AlgebraicExpressionCalculate B400520GetItemUoMConversionFactor B0000500AlgebraicExpressionCalculate

Processing

Retrieve CPCP02, CPCP03, CPCP04, and CPCP05 from F4009.

List A

CPCP02Symbol to identify Variable table CPCP03Symbol to identify Unit of Measure CPCP04Symbol to identify Currency CPCP05Symbol to identify Database Fields

List B

CPCP02Symbol to identify Variable table CPCP03Symbol to identify Unit of Measure CPCP04Symbol to identify Currency CPCP05Symbol to identify Database Fields ')'Right parentheses '/'Division '*'Multiplication '-'Minus '+'Addition '('Left parentheses ' 'Blank character

Compare each character in the string one at a time against the four symbols retrieved from F4009

(List A).

If you encounter any character between A-Z and a-z or any spec ial characters that is not proceeded by one of the four symbols, then issue the error code.

There should not be any character or string other than function names that defined in section 1.2.

If there is any invalid character or string, skip all steps be low and return Error Code.

Take the first character of the input string and validate

Detach the special character of the variable and take rest of the variable until find character blank or mathematical function, defined section 1.3

If DS CP02 was found into the string

If the variable = blanks

return Error Code, assign DS Error ID '3958' else

If variable is greater that ten characters

return Error Code, assign DS Error ID '3958'

else

Retrieve record from the file F4075 with the fields DS DT EJ and Variable Name

If unsuccessful fetch

return Error Code, assign DS Error ID '3958'

else

If DS Mode Call = 1

change the variable string for value "1"

else

Use field UOM from F4075 for calculate conversion fa ctor if UOMs are different If DS UOM is not equal to F4075-UOM

Retrieve UOM conversion factor with the Business F unction B40000520

DS MCU->MCU F4075-UOM->UOM DS UOM->UOM "1"->QTY DS IVI->IVI DS ITM->ITM DS TFLA->TFLA Work Field<-CONV F4075-UPRC= F4075-UPRC / Work Filed (Conversion Fa ctor)

Endif

Use field CRCD from F4075 for calculate conversion f actor if CRCDs are different

If F4075-CRCD is not equal to DS CRCD

Retrieve the exchange rate using Business Function B0000033

F4075-CRCD->CRCD DS CRCD->CRDC DS AN8->AN8 DS DTEJ->EFT Work field<-CRR F4075-UPRC=F4075-UPRC * Work Field (Currency conve rsion factor )

Endif

Change the variable string for the field F4075-UPRC into the formula

Endif Endif

Endif

Endif else

If DS CP03 was found

If variable is greater that two characters

return Error Code, assign DS Error ID '4335'

else

Verify if the variable exist into the file F0005 with the Business Function X0005

"UOM"->DTAI "00"->SY "UM"->RT Variable name ->KY "2"->AS If Error message ID DTAI in not blank

return Error Code, assign DS Error ID '4335'

else

If Mode Call = 1

edit this filed, the Division sign must precede this value, example: "/ 1" else

If variable is not equal to DS UOM

Retrieve record from the file F4211 with the field s DS DOCO ,DCTO ,LNID ,SFXO , MCU

Keep the fields SDITM,SDMCU to be used in the busi ness function B400520

Retrieve record from the file F4101 with the key S DITM and keep the field IMTFLA to be

used in the business function B400520

Retrieve record from the file F40205 with the key DS LNID and keep the field LFIVI to

be used in the business function B400520

Retrieve UOM conversion factor with the Business F unction B400520

SDMCU->MCU DS UOM->UOM Variable Name->UOM "1"->QTY LFIVI->IVI SDITM->ITM IMTFLA->TFLA Work Field<-CONV change the variable string for the value of the wo rk field returned

edit this field, the Division sign must precede t he numeric value, example:

If the return value was 99.9999 you must put this character "/"before the field , and

the result is "/ 99.9999". else

change the variable string for value "1"

edit this filed, the Division sign must precede th is value, example: " / 1"

Endif

Endif

Endif

Endif else

If DS CP04 was found

If DS CRYR = "N"

return Error Code, assign DS Error ID '4336'

else

If the variable = Blanks

return Error Code, assign DS Error ID '2110'

else

If variable is greater that three characters

return Error Code, assign DS Error ID '2110' else

Validate the variable Currency Code with the Business Function B1100001

EV01<-bhvrerrid DS Variable->CRCD If EV01 is not blank

return Error Code, assign DS Error ID '2110'

else

If Mode Call = 1

edit this filed, the Multiplication sign must p recede this value, example: "* 1"

else

If Variable Currency Code is not equal to DS CR CD

If DS CR CDCR = Blanks

return Error Code, assign DS Error ID '433 8'

else

Retrieve the exchange rate using Business Function B0000033

DS CRCD->CRCD Variable name->CRDC DS AN8->AN8 DS DTEJ->EFT Work field<-CRR change the variable string for the value of the work field returned

edit this field, the Multiplication sign must precede the numeric value,

example:

If the return value was 99.9999 you must p ut this character "*"before the

field , and the result is "* 99.9999".

Endif

else

edit this filed, the Multiplication sign must precede this value, example: " *

1"

Endif

Endif Endif

Endif

Endif

Endif else

If DS CP05 was found If the variable does not a name of the fields of file F4211

return Error Code, assign DS Error ID '4337'

else

If DS Mode Call = 1

change the variable string for value "1"

else

Retrieve record from the file F4211 with the fields DS DOCO,DCTO,LNID,SFXO,MCU

change the variable string for the value of the name of variable, example:

SDUPRC, is the name of the variable

F4211, field SDUPRC has value 999.9999

change SDUPRC for 999.9999 into the formula

Endif

Endif else

If the first character >= "A" and <= "Z"

return Error Code, assign DS Error ID '4771' Endif

Endif

Endif

Endif

A.Evaluation:

Use the Business Function B0000500 for evaluate the string f ormula, remind that

you must send a new string formula only with numeric values .

String Formula->CALCIT DS MATH01<-MN29D9 Math numeric result DTAI<-DTAI Error Message

If DTAI is not blank return Error Code, assign DS Error ID '0416'

Endif

Data Structure

D4500130 - F4076 Calculate Algebraic Expression

Special Input Expected

Parameters for B4500130 business function:

Data Item Data Structure DescriptionI/ORequiredNotes

EV01 Mode Call I Y Call = '1', c alled on ly for testing

pr ocess Call = '2',

ca lled for return

re sult numeric FML Calculation Formula I Y 160 upper-case- ch aracter input

st ring.

DTEJ Pricing Date I Y Required only if Mode = 2, use for Pricing

Da te.

CRYR Currency Conversion I Y A code that spe cifies wh ether to use multi-

cu rrency accounting,

mu st be Y or Z when is

ac tive

CRCD Currency Code I Y Use if multi- currency is active, all amounts

wi ll be converted to

th is common currency co de.

UOM Unit of Measure I Y Use for convert all am ounts to this common

un it of measure.

KCOO Order Number Document Company I Y Sales Order Required on ly if Mode = 2

GENLNG Pointer to Order Detail (F4211)I N Required only if Mode = 2

TFLA Standard UOM Conversion I Y Required on ly if Mode = 2, use in UOM

co nversion item

sp ecific UOM

co nversion, from

F4 101.

EV02 Suppress Error Messages I N 1 = Suppres s, 0 = Not suppress

Special Output Returned

Parameters for B4500130 business function:

Data Item Data Structure DescriptionI/ORequiredNotes

MATH01Numeric Return Value O N Math Numeric Resul t EV01 Error Code O 1 = Error found, 0 = Error not found

DTAI Error Message ID O N

Parameter Name Data Item Data Type Req/Opt I/O/Both cCallingMode MODE char NONE NONE The processing mode used in Purchase Order Consolidator to signify when specific orders are being processed. szCalculationFormula FML char NONE NONE An algebraic expression the system uses to calculate the adjustment to which the formula is attached. When you define formulas, use standard arithmetic symbols to indicate addition (+), subtraction (-), multiplication (*), and division (/). In the formula you can also include units of measure and currency codes, and references to fields in the Sales Order Detail table (F4211) and to variable tables. You identify each of these with a symbol. You define these symbols in the pricing constants, which you access from the branch/plant constants. The following is an example of a pricing formula that refers to a variable table. (.90 * PROPANE) + 2 The ampersand identifies PROPANE as a variable table. mnNumericReturnValue MATH01 MATH_NUMERIC NONE NONE Results in a calculation. jdPricingDate DTEJ JDEDATE NONE NONE The Julian Date szCurrencyCode CRCD char NONE NONE A code that indicates the currency of a customer's or a supplier's transactions. szUom UOM char NONE NONE A user defined code (00/UM) that indicates the quantity in which to express an inventory item, for example, CS (case) or BX (box). idF4211Pointer GENLNG ID NONE NONE szStandardUOMConv TFLA char NONE NONE cErrorCode EV01 char NONE NONE

1 = Error found

0 = Error not found

cSuppressErrorMsg EV02 char NONE NONE

1 = Suppress

0 = Not suppress szErrorMsgId DTAI char NONE NONE For World, the RPG data name. This data field has been set up as a 10-byte field for future use. Currently, it is restricted to 4 bytes so that, when preceded by a 2- byte table prefix, the RPG data name will not exceed 6 bytes. Within the Data Dictionary, all data items are referenced by this 4-byte data name. As they are used in database tables, a 2- character prefix is added to create unique data names in each table specification (DDS). If you are adding an error message, this field must be left blank. The system assigns the error message number using next numbers. The name appears on a successful add. You should assign error message numbers greater than 5000. Special characters are not allowed as part of the data item name, with the exception of #, @, $. You can create protected data names by using $xxx and @xxx, where you define xxx. For OneWorld, a code that identifies and defines a unit of information. It is an 8- character, alphabetical code that does not allow blanks or special characters such as: % , . +. Create new data items using system codes 55-59. The alias cannot be changed. szUnitOfMeasureVariable UOM4 char NONE NONE A user defined code (00/UM) that indicates the unit of measure in which you usually price the item.

Related Functions

B0000033 Get Exchange Rate B0000500 Algebraic Expression Calculate B1100001 Is Column In Currency Code Table B4000260 Line Type - Activity Rules B4000520 Get Item UoM Conversion Factor B4500040 F4075GetPriceVariableTableRow X0005 Get User Defined Codes

Related Tables

F4075 Price Variable Table F4211 Sales Order Detail File

Recommended publications