Code:
- /* */
- /* Out: 2/20/07 10:06 Ver: 3. 0 Level40 CHRISTEN, DUANE J. - IT&S */
- /* Ref: ANIN020701 ANI Inventory/Complex Product Attachment to Orders */
- /* DJC: Add conversion for Date and Time values with no editing Chars */
- /* */
- /* Out: 10/31/05 11:28 Ver: 2. 0 Level40 CHRISTEN, DUANE J. - IT&S */
- /* Ref: ANIN110502 ANI Inventory/CAS/Care Query Port to Provisioning Sys */
- /* DJC: Converted to Free Fromat and added VARCHAR as a valid type */
- /* for the convertCharToType procedure */
- /* */
- /* Out: 11/17/04 9:37 Ver: 1. 0 Level40 CHRISTEN, DUANE J. - IT&S */
- /* Ref: ANIN120403 ANI Inventory/Multiple Vendor E911 (Code) */
- /* DJC: The Scale value range for CHAR data types can be larger than 31 */
- /* */
- /* Out: 11/24/03 9:42 Ver: 0. 0 Level40 Duane J. Christen */
- /* Ref: ANIN010401 ANI Inventory/Migrate 911 to Provisioning System. */
- /* DJC: Initial program creation */
-
- /* Copyright McLeod, Inc., as an unpublished work created in
- /* 2003. This program is CONFIDENTIAL, unpublished work of
- /* authorship. IT IS A TRADE SECRET which is the property of
- /* McLeod, Inc. All use, disclosure, and/or reproduction not
- /* specifically authorized by McLeod, Inc., is prohibited.
- /* This program may also be protected under the copyright
- /* and/or trade secret laws of non-U.S. countries. All rights
- /* reserved.
-
- /*=============================================================================================
- /* Notes
- /*=============================================================================================
-
- /* Compile with ACTGRP(PVS9996)
-
- /*=============================================================================================
- /* Control Specifications
- /*=============================================================================================
-
- H NoMain
-
- /*=============================================================================================
- /* File Specifications
- /*=============================================================================================
-
-
- /*=============================================================================================
- /* Prototype Specifications
- /*=============================================================================================
-
- /Include QRpgCbSrc,XXCvt.H
- /Include QRpgCbSrc,String.H
- /Include QRpgCbSrc,StdLib.H
- /Include QRpgCbSrc,MI_CpyByte
- /Include QRpgCbSrc,PVS9996
-
- /*=============================================================================================
- /* Data Specifications
- /*=============================================================================================
-
- /Include QRPGCBSRC,DQUSEC
- /Include QRPGCBSRC,DQMHSNDPM
- /Include QRpgCBSrc,DUserCH
-
- /*---------------------------------------------------------------------------------------------
- /* Data Structure Specifications
- /*---------------------------------------------------------------------------------------------
-
-
- /*---------------------------------------------------------------------------------------------
- /* Array Specifications
- /*---------------------------------------------------------------------------------------------
-
-
- /*---------------------------------------------------------------------------------------------
- /* Indicator Specifications
- /*---------------------------------------------------------------------------------------------
-
- D globalInit S N
-
- /*---------------------------------------------------------------------------------------------
- /* Standalone Data Specifications
- /*---------------------------------------------------------------------------------------------
-
-
- /*---------------------------------------------------------------------------------------------
- /* Constant Specifications
- /*---------------------------------------------------------------------------------------------
-
-
- /*#############################################################################################
- /* Procedure Deleclaration - Convert Character Value to Type
- /*#############################################################################################
-
- P convertCharToType...
- P B Export
-
- /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- /* Procedure Interface
- /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-
- D convertCharToType...
- D PI
- D value * Value Value to convert
- D scale 10I 0 Value Scale of value
- D precision 10I 0 Value Precision of value
- D type 10A Value Convert to Type
- D returnValue * Value Converted Value
- D returnValueSize... Converted Value
- D 10I 0 Value Storage Size
- D errorStructure... Error Structure
- D * Value Options(*NOPASS)
-
- /*=============================================================================================
- /* Procedure Data Specifications
- /*=============================================================================================
-
- /*---------------------------------------------------------------------------------------------
- /* Procedure Data Structure Specifications
- /*---------------------------------------------------------------------------------------------
-
- D DS
- D stringLength 4B 0
- D binLength 2A OverLay(stringLength)
-
- /*---------------------------------------------------------------------------------------------
- /* Procedure Array Specifications
- /*---------------------------------------------------------------------------------------------
-
-
- /*---------------------------------------------------------------------------------------------
- /* Procedure Indicator Specifications
- /*---------------------------------------------------------------------------------------------
-
-
- /*---------------------------------------------------------------------------------------------
- /* Procedure Standalone Data Specifications
- /*---------------------------------------------------------------------------------------------
-
- D parmsPassed S 3P 0
-
- D precisionValues...
- D S 15A
-
- D stopString S *
- D stopStringAdr S * Inz(%Addr(stopString))
-
- D double S 8F
- D int S 10I 0
-
- D phone# S 10P 0
- D zipCode S 9P 0
-
- D charBase S *
- D char S 1A Based(charBase)
- D dateIso S 10A Based(charBase)
- D dateUsa S 10A Based(charBase)
-
- /*---------------------------------------------------------------------------------------------
- /* Procedure Constant Specifications
- /*---------------------------------------------------------------------------------------------
-
- /* Parameter count values
- D requiredParms C Const(6)
- D requiredErrorParms...
- D C Const(7)
-
- D scaleValues C Const('1 to 31')
-
- D typeValues C Const('CHAR, VARCHAR, DEC, +
- D TIMESTAMP, DATE, DATEISO0, +
- D DATEUSA, +
- D TIME, INT, BIN, NUMERIC, +
- D FLOAT, DOUBLE, TELEPHONE#, +
- D ZIPCODE9')
-
- /*---------------------------------------------------------------------------------------------
- /* Procedure Key Lists
- /*---------------------------------------------------------------------------------------------
-
-
- /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- /* Procedure Code
- /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-
- /Free
- Exsr initialize;
- Exsr validateParms;
-
- Select;
-
- When type = 'CHAR';
- cpyBytes(returnValue : value : returnValueSize);
-
- When type = 'DEC';
- ExSr decimalConversion;
- When type = 'TIMESTAMP';
- cpyBytes(returnValue : value : returnValueSize);
-
- When type = 'DATE';
- cpyBytes(returnValue : value : returnValueSize);
-
- When type = 'DATEISO0';
- If returnValueSize >= 10;
- charBase = value;
-
- If %Len(%Trim(dateIso)) = 8;
- Monitor;
- dateIso = %Char(%Date(%Trim(dateISO) : *ISO0) : *ISO);
-
- On-Error;
- dateIso = '0001-01-01';
- EndMon;
- EndIf;
- EndIf;
-
- cpyBytes(returnValue : value : returnValueSize);
-
- When type = 'DATEUSA';
- If returnValueSize >= 10;
- charBase = value;
-
- If %Len(%Trim(dateUsa)) = 10;
- Monitor;
- dateUsa = %Char(%Date(%Trim(dateUsa) : *USA) : *ISO);
-
- On-Error;
- dateUsa = '0001-01-01';
- EndMon;
- EndIf;
- EndIf;
-
- cpyBytes(returnValue : value : returnValueSize);
-
- When type = 'TIME';
- cpyBytes(returnValue : value : returnValueSize);
-
- When type = 'INT' or
- type = 'BIN';
- int = QxxZToI(value : scale : precision);
-
- cpyBytes(returnValue : %Addr(int) : returnValueSize);
-
- When type = 'NUMERIC';
- cpyBytes(returnValue : value : returnValueSize);
-
- When type = 'VARCHAR';
- For stringLength = scale downTo 1;
- charBase = value + stringLength;
-
- If char <> *BLANK or
- char <> x'00';
- Leave;
- EndIf;
- EndFor;
-
- cpyBytes(returnValue : %Addr(binLength) : 2);
-
- If stringLength > 0;
- cpyBytes(returnValue + 2 : value : stringLength);
- EndIf;
-
- When type = 'FLOAT' or
- type = 'DOUBLE';
- double = QxxZToD(value : scale : precision);
-
- cpyBytes(returnValue : %Addr(double) : returnValueSize);
-
- When type = 'TELEPHONE#';
- phone# = convertEditedPhonePacked(value : usec_Base);
- cpyBytes(returnValue : %Addr(phone#) : returnValueSize);
-
- When type = 'ZIPCODE9';
- zipCode = convertZipCodeToPacked9(value : usec_Base);
- cpyBytes(returnValue : %Addr(zipCode) : returnValueSize);
- EndSl;
-
- ExSr exitProcedure;
- Return;
-
- //===========================================================================================
- // Convert Charicter to Decimal
- //===========================================================================================
-
- BegSr decimalConversion;
-
- If precision = 0;
- QxxDtoP(returnValue : scale : precision :
- QxxZtoD(value : scale : precision));
-
- Else;
- QxxDtoP(returnValue : scale : precision :
- strToD(value : stopStringAdr));
-
- EndIf;
-
- EndSr;
-
- //===========================================================================================
- // Initialize Procedure
- //===========================================================================================
-
- BegSr initialize;
-
- If Not globalInit;
- globalInit = *ON;
- sndPM_Max_Data_Length = 500;
-
- /Include QRpgCBSrc,ZQmhSndPm
- EndIf;
-
- /Include QRpgCBSrc,ZUserCH
-
- If setJmp(jumpPoint) = 1;
- ExSr exitProcedure;
- EndIf;
-
- sndPM_Msg_Type = '*ESCAPE';
- userCHConditionHandler = %PAddr('PROVISIONERUSERCH003');
-
- registerConditionHandler(userCHConditionHandler :
- userCHBase :
- *OMIT);
- parmsPassed = %Parms;
-
- Select;
-
- When parmsPassed = requiredParms;
- userCH.errorBase = *NULL;
- usec_Base = *NULL;
-
- When parmsPassed = requiredErrorParms;
- userCH.errorBase = errorStructure;
- usec_Base = errorStructure;
-
- Other;
- sndPM_MsgF_File = 'QCPFMSG';
- sndPM_Msg_Id = 'CPF24B4';
- sndPm_Data_Length = 0;
- /Include QRPGCBSRC,CQMHSNDPM
-
- EndSl;
-
- If usec_Base <> *NULL;
- If usec_Provided >= usec_Avail_Static;
- usec_Msg_Id = *BLANKS;
- usec_Data_Length = usec_Provided - usec_Avail_Static;
-
- If usec_Data_Length > 0;
- usec_Data_Base = usec_Base + usec_Avail_Static;
- %Subst(usec_Data : 1 : usec_Data_Length) = *BLANKS;
- EndIf;
- EndIf;
- EndIf;
-
- EndSr;
-
- //===========================================================================================
- // Validate Parameters
- //===========================================================================================
-
- BegSr validateParms;
-
- //-------------------------------------------------------------------------------------------
- // Value
- If value = *NULL;
- SndPm_Msg_Id = 'PVM1001';
- %SubSt(SndPM_Data : 1 : 20) = 'Value';
- sndPm_Data_Length = 20;
- /Include QRPGCBSRC,CQMHSNDPM
- EndIf;
-
- //-------------------------------------------------------------------------------------------
- // Scale
- If type <> 'CHAR' and
- type <> 'VARCHAR';
- If scale < 1 or
- scale > 31;
- sndPM_Msg_Id = 'PVM1003';
- %SubSt(SndPM_Data : 1 : 35) = %Trim(%EditC(scale : 'Z'));
- %SubSt(SndPM_Data : 36 : 35) = 'Scale';
- stringLength = %Len(scaleValues);
- %SubSt(SndPM_Data : 71 : 2) = binLength;
- %SubSt(SndPM_Data : 73 : stringLength) = scaleValues;
- sndPm_Data_Length = 72 + stringLength;
- /Include QRPGCBSRC,CQMHSNDPM
- EndIf;
-
- ElseIf scale < 1;
- sndPM_Msg_Id = 'PVM1003';
- %SubSt(SndPM_Data : 1 : 35) = %Trim(%EditC(scale : 'Z'));
- %SubSt(SndPM_Data : 36 : 35) = 'Scale';
- stringLength = 3;
- %SubSt(SndPM_Data : 71 : 2) = binLength;
- %SubSt(SndPM_Data : 73 : stringLength) = '> 0';
- sndPm_Data_Length = 72 + stringLength;
- /Include QRPGCBSRC,CQMHSNDPM
- EndIf;
-
- //-------------------------------------------------------------------------------------------
- // Precision
- If precision < 0 or
- precision > scale;
- sndPM_Msg_Id = 'PVM1003';
- %SubSt(SndPM_Data : 1 : 35) = %Trim(%EditC(precision : 'Z'));
- %SubSt(SndPM_Data : 36 : 35) = 'Precision';
- precisionValues = '0 to ' + %Trim(%EditC(precision : 'Z'));
- stringLength = %Len(%Trim(precisionValues));
- %SubSt(SndPM_Data : 71 : 2) = binLength;
- %SubSt(SndPM_Data : 73 : stringLength) = %Trim(scaleValues);
- sndPm_Data_Length = 72 + stringLength;
- /Include QRPGCBSRC,CQMHSNDPM
- EndIf;
-
- //-------------------------------------------------------------------------------------------
- //Type
- If type <> 'CHAR' and
- type <> 'VARCHAR' and
- type <> 'DEC' and
- type <> 'TIMESTAMP' and
- type <> 'DATE' and
- type <> 'DATEISO0' and
- type <> 'DATEUSA' and
- type <> 'TIME' and
- type <> 'INT' and
- type <> 'BIN' and
- type <> 'NUMERIC' and
- type <> 'FLOAT' and
- type <> 'DOUBLE' and
- type <> 'TELEPHONE#' and
- type <> 'ZIPCODE9';
- sndPM_Msg_Id = 'PVM1003';
- %SubSt(SndPM_Data : 1 : 35) = type;
- %SubSt(SndPM_Data : 36 : 35) = 'Type';
- stringLength = %Len(typeValues);
- %SubSt(SndPM_Data : 71 : 2) = binLength;
- %SubSt(SndPM_Data : 73 : stringLength) = typeValues;
- sndPm_Data_Length = 72 + stringLength;
- /Include QRPGCBSRC,CQMHSNDPM
- EndIf;
-
- //-------------------------------------------------------------------------------------------
- // Return Value
- If returnValue = *NULL;
- SndPm_Msg_Id = 'PVM1001';
- %SubSt(SndPM_Data : 1 : 20) = 'Return Value';
- sndPm_Data_Length = 20;
- /Include QRPGCBSRC,CQMHSNDPM
- ExSr exitProcedure;
- EndIf;
-
- //-------------------------------------------------------------------------------------------
- // Return Value Size
- If returnValueSize < 1;
- sndPM_Msg_Id = 'PVM1002';
- %SubSt(SndPM_Data : 1 : 20) = 'Return Value Size';
- %SubSt(SndPM_Data : 21 : 10) = %EditC(returnValueSize : 'Z');
- sndPm_Data_Length = 30;
- /Include QRPGCBSRC,CQMHSNDPM
- ExSr exitProcedure;
- EndIf;
-
- memSet(returnValue : 0 : returnValueSize);
-
- EndSr;
-
- //===========================================================================================
- // Exit Program
- //===========================================================================================
-
- BegSr exitProcedure;
-
- unRegisterConditionHandler(userCHConditionHandler : *OMIT);
-
- Return;
-
- EndSr;
-
- /End-Free
-
- P convertCharToType...
- P E
-
- /*=============================================================================================
|
|