Monday, 4 July 2011

SQL using native AS/400 timestamp fields and SQL, qsys2/systables qsys2/sysindexes

I was struggling to find out how many tables were being generated as part of my upgrade audit scripts.  I like to report on the number of tables and indexes that are created during various stages of the JDE upgrade process, so that it’s uber repeatable…  The environment workbench creates and bunch, and the initial tasks workbench, etc etc.

The SQL below allows you to show the date / time as a long string – ‘YYYYMMSSHHMMSS’, so you can then see how many tables / indexes were created bwtween certain hours, before some hours and after others!

Indexes:

select * from qsys2.sysindexes where created_timestamp > timestamp('20110621114100' ) and table_schema = 'CRPDTA';

Tables:


select * from qsys2.systables where last_altered_timestamp > timestamp('20110614114100' ) and table_schema = 'CRPDTA';

I commonly do lots of SQL over these catalogs, as you would for oracle all_tables and all_indexes.

Monday, 27 June 2011

OVS host preparation

As oracle puts more time and money into it’s virtual servers, it’s going to become more common.  I’ve been dabbling with OVS at a client that is going to be using it in their live environment.  We were having some problems with multipathing, but seemingly because nobody filled out the multipath.conf file with an vendor settings – so everything was vanilla out of the box and would not work.

Once this was rectified, a bit of an audit was performed.  I was doing some research and found references to an RPM (vmpinfo-2.2-3.noarch.rpm), which is available on https://support.oracle.com.  This is an awesome script which does a post installation battery of tests and checks and creates a pretty cool (nerdy cool) HTML based report.

install is trivial:  rpm -i vmpinfo-2.2-3.noarch.rpm

Then just run it, vmpinfo.

There are a couple of example outputs on https://sites.google.com/site/cncninja/file-cabinet, as well as the installation rpm.

This could be used for any generic host checking I think - but is specific for OVS and looks for specific OVS problems.

Thursday, 9 June 2011

Load testing, stress testing performance testing JDE

Myriad have uncovered an inexpensive and simple method for load testing web versions of JDE.  It’s always been difficult to find a cost effective method of loading up JDE for stress testing, we think we have the perfect solution.

We’ve been able to perform application load testing down to transactional detail, ensuring that the 2400 sales orders (for example) that were entered in by the load testing scripts actually hit the database.  We are able to ensure that all of the batch jobs were executed. 

We are able to quickly record your core transactions and user interactions with the system and then multiple this load across your EnterpriseOne suite.  This level of testing can stress your batch, interactive and web servers as much or as little as you like.  Myriad can then monitor for any bottlenecks, make recommendations and retest.

Have you ever wondered if OAS is faster than WebLogic?  Should you use weblogic instead of WebSphere?  Myriad can easily create a virtual test environment for you and run load testing over it – so you can compare apples with apples.

What is the average bandwidth use for a modern E1 client?  How many turns are being generated for logging in.  You can quickly get these answers and more with some load testing.

Myriad can VPN into your system and complete all testing remotely and then send you a comprehensive report at the end!

image

Simple graphs like the above can highlight your latency issues and also tell you when your network is going to be saturated.

Did you know that 2400 users logging into your system and running basic queries for < 10 minutes can generate more than 3.4GB of traffic?  You need to ensure that everything is tuned correctly to ensure your JDE environment is as efficient as possible.

Myriad are leading the way for stress and load testing JDE software.

Tuesday, 7 June 2011

replace function with SQL, forgotten gem

Oracle/PLSQL: Replace Function


In Oracle/PLSQL, the replace function replaces a sequence of characters in a string with another set of characters.

The syntax for the replace function is:

replace( string1, string_to_replace, [ replacement_string ] )

string1 is the string to replace a sequence of characters with another set of characters.

string_to_replace is the string that will be searched for in string1.

replacement_string is optional. All occurrences of string_to_replace will be replaced with replacement_string in string1. If the replacement_string parameter is omitted, the replace function simply removes all occurrences of string_to_replace, and returns the resulting string.

 

How cool is this for renaming a server and your update statements over the F986101 and the F98611.  Just use:

Note that the AS/400 and oracle have the exact syntax for this string operator (amazing?)

update JDEPLAN900.f986101
set omdatp = replace(omdatp, 'SVR003', 'SVR703')
where omdatp like '%SVR003%'

This will get the – Logic, –XAPI etc etc.

That just made my machine rename scripts MUCH more simple.

Friday, 27 May 2011

Awesome problem… UBE ending early on AS/400 not completing all records in main select

The benefits of ODBC trace are still there when debugging UBEs especially.

So this was the problem.  There was a main section with a SQL statement that was based on a VIEW (this is important) and should have processed 20000 rows.  The SQL was good and tidy, but the batch job would stop after 10 rows on the 400 and 271 on the client.  Yep, that is weird.  The problem was kind of intermittent, but consistent…  (Even that is a bad description).

The developers were saying the server was rubbish and fix it.  This is a tough situation, as CNC is generally at the bottom of these types of problems that are in the nether regions of peoples responsibilities.

So we ran it with logging, nothing really. 

Mar 21 13:31:36.701864 dbdrvsql.c1362  - 1087/139 MAIN_THREAD                          >>>Start - FetchSQLRow QxdaProcessExtDynEDRS

Mar 21 13:31:36.805392 dbdrvsql.c1373  - 1087/139 MAIN_THREAD                          >>>End - FetchSQLRow QxdaProcessExtDynEDRS

Mar 21 13:31:36.805432 dbdrvag.c1143   - 1087/139 MAIN_THREAD                          Exiting PerformRequest, result=-1

Mar 21 13:31:36.805448 jdb_exef.c4618 - 1087/139 MAIN_THREAD                          No More Data found

--UBE--[2]-- End of Records for the section with Return Code (-2147483648) after fetching 0 records.

The above message is a funny one, as this is 2^31 negative.  I think this is the return of an unsigned int if it gets a negative.

Good info, but not helpful enough.

Next level of logging was tracing the job on the 400 and ODBC trace.

ODBC trace turn out to solve the problem quickly.  The ODBC trace has great information about warnings and things that JDE logs ignore.  The ODBC trace shows you accurate handle associates and cursors etc.

What actually was occurring was that there was an update to a parent table in the parent child relationship that the view was based upon. 

So the main loop had a cursor open and that value had been updated with a separate table i/o to the parent record.

This eventually caught up with the code and the report crapped out.  The ODBC trace shows the handles that the errors are reported on.  The different colours show the continuity of the handles.

activConsole    13cc-1e0 EXIT  SQLPrepareW  with return code 0 (SQL_SUCCESS)

                                HSTMT               03AC92F0

                                WCHAR *             0x1BD95F80 [     766] "SELECT T0.AFEDBT, T0.AFEDTN, T0.AFEDLN, T0.AFEDSP, T0.AF57PRID, T0.AF57PRDESC, T0.AFITM, T0.AF57STCD, T0.AFLITM, T0.AF57STDESC, T0.AFAN8, T0.AFALKY, T0.AFTRDJ, T0.AF57ACD, T0.AF57ACOOP, T0.AFAID, T0.AFAID2, T0.AFAID3, T0.AFAID4, T0.AFUSER, T0.AFPID, T0.AFJOBN, T0.AFUPMJ, T0.AFUPMT, T1.BHEDBT, T1.BH57INTF, T1.BHEDCT, T1.BH57SEQ, T1.BH57BSTS, T1.BH57RECC, T1.BH57TOT1, T1.BH57TOT2, T1.BH57TOT3, T1.BH57TOT4, T1.BH57SUM1, T1.BH57SUM2, T1.BH57FDAT, T1.BH57FTIM, T1.BH57TDAT, T1.BH57TTIM, T1.BH57CDAT, T1.BH57CTIM, T1.BH57MDAT, T1.BHUSER, T1.BHPID, T1.BHJOBN, T1.BHUPMJ, T1.BHUPMT, T1.BH57MTIM, T1.BH57EDBT FROM UADTA/F570911F T0,UADTA/F570001 T1 WHERE  (  ( T1.BH57INTF = ? AND T1.BH57BSTS = ? )  )  AND  ( T0.AFEDBT=T1.BHEDBT )  ORDER BY T0.AFEDBT ASC,T0.AF57PRID ASC"

                                SDWORD                   766

activConsole    13cc-1e0 ENTER SQLExecute

                                HSTMT               03AC92F0

activConsole    13cc-1e0 EXIT  SQLExecute  with return code 0 (SQL_SUCCESS)

                                HSTMT               03AC92F0

activConsole    13cc-1e0 ENTER SQLFetch

                                HSTMT               03AC92F0

activConsole    13cc-1e0 ENTER SQLPrepareW

                                HSTMT               03ACAC40

                                WCHAR *             0x2665CF90 [      59] "UPDATE UADTA/F570001  SET BH57BSTS=? WHERE  ( BHEDBT = ? ) "

                                SDWORD                    59

activConsole    13cc-1e0 EXIT  SQLPrepareW  with return code 0 (SQL_SUCCESS)

                                HSTMT               03ACAC40

                                WCHAR *             0x2665CF90 [      59] "UPDATE UADTA/F570001  SET BH57BSTS=? WHERE  ( BHEDBT = ? ) "

                                SDWORD                    59

activConsole    13cc-1e0 ENTER SQLExecute

                                HSTMT               03ACAC40

activConsole    13cc-1e0 EXIT  SQLExecute  with return code 0 (SQL_SUCCESS)

                                HSTMT               03ACAC40

...

activConsole    13cc-1e0 EXIT  SQLFetch  with return code 100 (SQL_NO_DATA_FOUND)

                                HSTMT               03AC92F0

activConsole    13cc-1e0 ENTER SQLCloseCursor

                                SQLHSTMT            03ACB078

activConsole    13cc-1e0 EXIT  SQLCloseCursor  with return code 0 (SQL_SUCCESS)

                                SQLHSTMT            03ACB078

activConsole    13cc-1e0 ENTER SQLCloseCursor

                                SQLHSTMT            03AC92F0

activConsole    13cc-1e0 EXIT  SQLCloseCursor  with return code 0 (SQL_SUCCESS)

                                SQLHSTMT            03AC92F0

activConsole    13cc-1e0 ENTER SQLCloseCursor

                                SQLHSTMT            03ACA3D0

activConsole    13cc-1e0 EXIT  SQLCloseCursor  with return code 0 (SQL_SUCCESS)

                                SQLHSTMT            03ACA3D0

activConsole    13cc-1e0 ENTER SQLCloseCursor

                                SQLHSTMT            03ACA808

activConsole    13cc-1e0 EXIT  SQLCloseCursor  with return code 0 (SQL_SUCCESS)

                                SQLHSTMT            03ACA808

activConsole    13cc-1e0 ENTER SQLCloseCursor

                                SQLHSTMT            03ACAC40

activConsole    13cc-1e0 EXIT  SQLCloseCursor  with return code -1 (SQL_ERROR)

                                SQLHSTMT            03ACAC40

                                DIAG [24000] [IBM][System i Access ODBC Driver]Invalid cursor state. (30022)

activConsole    13cc-1e0 ENTER SQLGetDiagRecW

                                SQLSMALLINT                  1

                                SQLHANDLE           03AB1540

                                SQLSMALLINT                  1

                                SQLWCHAR *          0x2657EEF0 (NYI)

                                SQLINTEGER *        0x2657EEFC

                                SQLWCHAR *          0x2657EF00 (NYI)

                                SQLSMALLINT                256

                                SQLSMALLINT *       0x2657EEE8

Wednesday, 25 May 2011

2005 script for change object owner

Of course the exact purpose is change object owner, but the framework can be used for any repetitive operations.

-- Change the object owner from
-- PRODDTA to CRPDTA
USE PS_CRP

DECLARE @Object_Name AS varchar(60)

DECLARE curChange_Owner CURSOR READ_ONLY FORWARD_ONLY FOR
    SELECT
        sysusers.name + '.' + sysobjects.name
    FROM
        sysobjects , sysusers
    WHERE
        sysobjects.uid = sysusers.uid
            AND
        sysusers.name = 'PRODDTA'
            AND
        xtype = 'u'

OPEN curChange_Owner

FETCH NEXT FROM curChange_Owner INTO
    @Object_Name

WHILE @@FETCH_STATUS = 0
BEGIN
    EXEC sp_changeobjectowner @Object_Name, 'CRPDTA'

    FETCH NEXT FROM curChange_Owner INTO
        @Object_Name
END
 
CLOSE curChange_Owner
DEALLOCATE curChange_Owner

Allowing input tray selection with PCL printing in JDE

Allowing input tray selection with PCL printing in JDE

It is a known issue that you cannot do tray selecting in JDE when your printers are PCL...  Or can you???

Introduction

PCL printing is different to PS, where PCL is all embedded in the file that is sent to the printer, there are no “command line” options as such.  This is why JDE does not give the same flexibility in the PCL printing options as they do for PS.

Dumpbin to find the which DLL has the function you want, and include files.

I’m using the above to find functions with PCL in their text and locating their address:

        950  3B5 00195260 _SetupClientSecurityAPI@4

        951  3B6 00195B40 _SetupClientSecuritySilentAPI@4

       1131  46A 0020C020 _convertPDFToPCL@2524

2164  868 0020C060 _prtFilter_ConvertToPCL@20

So the function that I want has 5 parameters, it’s the last one with  @20.  @4 means one parameter, @8 two etc.

I can find the include files to see the parameters, but that is not important.

KRNL_RTN( int             ) JDEWINAPI prtFilter_ConvertToPCL              (  HUSER                hUser,

JCHAR*               szInPDF,

JCHAR*               szOutLP,

PPRT_PRINTER_INFO    pPRTPrinterInfo,

BOOL                 OutNativeCS             );

Note that the PPRT_PRINTER_INFO has a tray member, but this does not get passed to the final PCF document.

Remember that the JDE “printer definition language” string tells you what DLL and what function is being used to massage your PDF stream into PS or PCL.  I was able to tell the DLL and function name from there also.

Jdekrnl.dll and function _prtFilter_ConvertToPCL@20

PCL background

As stated before,  there is a PCL string at the beginning of a print file that tells the printer what it should do with the stream that is coming at it.  I was able to refer to the following excellent website to find the kind of PCL commands I’d be looking for. http://pcl.to/reference/

I’m expecting that there is a string in my file that specifies which tray the print job needs to go to (Ec&l#H), I want to modify this.  I’m guessing that I will find a complete PCL string somewhere in the function space.

Note that escape is Hex 1B 26 6C (30 39) 48

This sequence could not be found, but I did find all of the other strings, see below:

clip_image002

From above you can see that it’s building the various codes in this block of executable.  You cannot just add code here, you need to be careful what you change.  There are all sort od checks and boundaries that need to be maintained.

The actual output

To see what JDE was doing with the output, I opened the .spl file.  Windows printing (for a print server) writes all of the print files to %SystemRoot%\SYSTEM32\SPOOL\PRINTERS.  So if you pause your printer, you can intercept the output files and see what the heck JDE is putting at the front if the PDF.

The actual PCL file looks like this: C:\winnt\system32\spooler\printer\*.SHD (printer info) and .SPL (file from JDE)

image Note this is it in colour.

%-12345XE&l1X&u300D&l26A&l1O&l0E&l0L*p0x0Y*c8418x5952Y*c0T&k2G

*r3U

(s1p7.00v0s3b16602T*p2445.208x136.458Y(19U24/

So it is sending:

Reset

Copies

DPI

Paper Type

Orientation

Define Top Margin at # Lines

Define Left Margin at Column #

PCL absolute positioning

Unsure

PCL Line termnialtion

It is not sending TRAY information, so why isn’t the printer using the tray that we have defined?

So now what can we do, the tray info is not being sent!.

The solution:

So, I tried hacking the paper type, but had no real control on how to ensure that the correct tray was being passed into the command string.  What I did determine what that the default # of copies was 1 – so this was not needed.

When I say hack the paper type, Change the A in &l26A to H and then try different paper types.  This did not work for a number of reasons.  Firstly the PDF’s were getting generated based upon the papersize and secondly you can’t print a letter based report to an A4 printer – JDE still embeds the printer paper type that the report was run against.

Therefore I hacked the jdekrnl.dll file (well a copy) to change the command for # of copies to tray selection.  I changed the X in &l1X to a H.  Therefore when you passed in a 1 for number of copies, this would use tray 1.  Pass in a 2 for copies, this will use tray 2 but only print 1 copy.  

So, when you choose my printer, which uses my custom “printer definition language” which uses the hacked jdekrnl2.dll file.  This swaps copies for output tray.

clip_image003

clip_image004

clip_image005

I used a hex editor to change the PCL commands embedded into the PCL file that is send to the printer.

So the code now interprets the count of prints to fill out what goes into the tray selection value.

Note that this is the server version of jdekrnl.dll.  I’ve called it jdekrnl2.dll and have located a master version of it in \\xxx\E811\DLL_HACK

So this is a safe mod, what are the net effects.

· Jdekrnl2.dll is ONLY used for printing with tray selection

· You cannot choose “number of copies” for the T2 printer, it must be 1 to choose the green paper.  It seems that the RICOH tray selection codes, which are not the same as HP standard ones.  102 is second tray etc, a little weird.

Therefore any job that goes to \\xxx\PROPSRIC7001T2 from JDE will print on green paper if you choose 1 copy.  Choosing 2 or 3 blocks the printer...  I think that you need to choose 102 or 202 based upon the following table:

clip_image007

If there is a tools release, this file should stay (the way new tools releases currently work).

clip_image002[1]

Hex view of the code in the DLL, this is where the printf are defined for the PCL codes.  Note also that they bytes are little endian, so you need to be a little careful about which ones to change.