Retrieve Current Server JobNumber

chviaud

Active Member
For everybody looking for that (I was !), it will be possible for a batch to retrieve its own JobNumber without searching it hazardously in F986110...

Indeed, looking in F986110 doesn't work if the report was launched by another report (in the same process ID), because of "ReportInterConnect" insert the record just AFTER the second report is done...

However, the JobNumber exist in "lpBhvrCom" datastructure of Business Functions. It is hidden under the "lpReportSection" parameter.

"lpReportSection" seems to be an array of pointers, and the pointer #12 is a pointer to the "UBEVAR" structure used by "jdeLaunchUBEEx" to launch the batch.

At this point, I have to specify a very important information : I tested this on OneWorld Xe, SP21. It is working on our Server (AIX) and on Local (there is no JobNumber on Local, but there is a lot of other parameters in UBEVAR, such as LogFileName...)
It is possible that the structure of "lpReportSection" change between our E1 version and yours... You have to test it : if LogFileName is correctly retrieved, it's a win.

I would have preferred to find THE structure in standards .h E1 files, rather than to recreate it ("tagReportSection" in B5500201.h). But I didn't find it (if you find it : tell me please !)

I have implemented the possibility of activate the "cCreateCSV" flag by using the "2" value. Use it in "Initialize Report (future)" and the CSV file will be created. Useful to activate CSV by Processing Options for example...
You can only use this in "Report Level Event Rules" of your report. If you use it in another Event, report will crash (because - I suppose - it want to write to CSV file and this file is not open for output)

Thanks a lot for this forum !
Christophe

Special dedication to Google translate tool ;-). I hope everybody can understand my frenglish...

4 dec 2007 : added 2 missing DataStructures in the attached file.

17 may 2011 : added Unicode version of BSFN, added function "RetrieveUbeDataSelection" and UBE R55TEST1 for example of use
 

Attachments

  • 112397-B5500201_UBE Business Functions_v4.zip
    127.7 KB · Views: 1,628
Retrieve Current Server JobNumber & Control of CSV Output

I have updated the ZIP file...
Business Function has now 3 functions :

* GetCurrentUbeParameters
Some new parameters added...

* GetCurrentUbeOutputFiles
Rebuild LOG, PDF or CSV output file of current job.
Many thanks to Alex for its hint about 29 chars limitation of FNDFUF2 field.

* SetResetCurrentUbeCsvOutput
Switch on or switch off the standard CSV output.
If you want to switch on, you have to do it in "InitializeReport" Report Level Event. Otherwise UBE will crash because UBE engine open the CSV file just after "InitializeReport", regarding the "CreateCSV" flag. And if it doesn't open the file, it will crash when it will want to write it.


It's now easy to have a full control on CSV output file :
1) create "ReportHeader" and "ReportFooter" sections
2) in "InitializeReportHeader", retrieve the "CreateCSV" flag via "GetCurrentUbeParameters"
3) if flag is on :
a) switch off the flag via "SetResetCurrentUbeCsvOutput"
b) retrieve CSV FileName via "GetCurrentUbeOutputFiles"
c) open this CSV flat file for output via B34A1010.
d) optionally, write an header record in this flat file.
4) in "DoSection" of your main section, write each detail records in flat file (only if "CreateCSV" flag was on, of course !)
5) in "EndReportFooter", close flat file and switch on the "CreateCSV" flag (only if "CreateCSV" was on...)

>>> your own CSV file is accessible via WSJ !

(We have to use "ReportHeader" and "ReportFooter" sections instead of "InitializeReport" and "EndReport" report level events, because UBE engine decide how it will write F986110 AFTER "InitializeReport" and BEFORE "EndReport")

Christophe
 
Re: Retrieve Current Server JobNumber & Control of CSV Output

What a "canaille" this Christophe !
and what about the other little thing that is hidden somewhere else in the cache my friend ? You remember what thing
crazy.gif
?
Fred
 
Re: Retrieve Current Server JobNumber & Control of CSV Output

Hello everybody

I'm very chagrined... this does not work on OS/400 (However it's working on Windows and Unix !)

I suppose that I have misdeclared the undocumented "lpBhvrCom->lpReportSection" structure :

<font class="small">Code:</font><hr /><pre>
typedef struct tagReportSection
{
void *pPtr01;
void *pPtr02;
void *pPtr03;
void *pPtr04;
void *pPtr05;
void *pPtr06;
void *pPtr07;
void *pPtr08;
void *pPtr09;
void *pPtr10;
void *pPtr11;
PUBEVAR pUBEVar; /* tagUBEVAR declared in jdekstrt.h */
} ReportSection, *LPReportSection;
</pre><hr />
Perhaps I have to declare the 11 firsts pointer differently ?

I don't know enough the AS/400 and, moreover, I do not have any more an access to this system to make tests...

Is there an AS/400 & C expert to suggest a solution ?

Thanks
Christophe
 
Re: Retrieve Current Server JobNumber & Control of CSV Output

Hi Christophe,

I am using the custom BSFN on E812 to retrieve the current server Job Number. I found only one data structure parameters are included in the ZIP file. Can you please include the other 2 data structure parameters (D5500201B & D5500201C).I want to use the Same alias that you have used.

Thanks in Advance
 
Re: Retrieve Current Server JobNumber & Control of CSV Output

Hi Gov,

Sorry if I'm comming so late... too late...
I can't update the attached file in the main post... So I attach the updated version to my response...

5 dec 2007 : I had to change the name of the file to attach it to the main post... it is done now...
 
Re: Retrieve Current Server JobNumber on ALL system ???

Hello everybody,

I would like the fonction "GetCurrentUbeParameters" work on all system...

Attached to this message is a ZIP file with a JDE Report and 2 Functions. These allow to "see" the portion of memory where is the undocumented structure "ReportSection".
Somewhere in this structure is a pointer to "UbeVar" structure.

Run the batch : the objective is to locate all pointers which are "near" to ReportSection pointer.
Now you can run the batch with the processing option populate with each offset located.

If the report found the good "server job number", you win : you have to replace the 11 pointers declared in "tagReportSection" in b5500201.c by an array of chars with the length equal to the offset found.

On Windows and AIX system, there is 7 pointers and an empty buffer of 16 chars before the UbeVar pointer.
A pointer is 4 chars (Windows and AIX !) : 7x4 + 16 = 44
>>> The pointer is at offset 44 of ReportSection Structure !
(look at the PDF stored in the attached ZIP file)
<font class="small">Code:</font><hr /><pre>
typedef struct tagReportSection
{
char buf[44];
PUBEVAR pUBEVar; /* tagUBEVAR declared in jdekstrt.h */
} ReportSection, *LPReportSection;
</pre><hr />
I think you could locate 7 pointers and a buffer on others systems... the differences should be on a pointer size (depending on the system) and on the length of the empty buffer...

I'm very sorry for all English people : I think they can't understand my franglich...
tongue.gif


Thanks for your participation !
(I hope it will be working !!!)
Christophe



Post edited on 2011/05/12 :

There is an issue when scanning memory : it is not possible to know if a pointer is valid before to use it.
So, I modified BSFN and UBE to avoid "BSFN has caused a memory violation"...
I also translate BSFN to Unicode
Now, you have to run the batch a first time with Processing Option = 0, to have a PDF with memory dump (no memory scan at this time)
With the dump, locate one or pointers
Then, run the batch with PO = offset of pointer >>> If PDF prints "Pointer to Data Structure "pUBEVar" possibly found at "lpReportSection" offset :", you found it !

Locating a pointer on the dump :
- on Windows and Unix, pointers are "reversed" >>> pointer 0x3813F22F displays as "2F F2 13 38"
- on AS-400... I don't know...

Known at this time
- Xe-Win, Xe-Unix, E9-Win : offset = 44 (tested)
- Win (all jde versions) : offset = 44 (not tested, but possible...)
- Unix (all jde versions) : offset = 44 (not tested, but possible...)
- AS/400 ????
- Windows 64bits ????
... to be continued...

If you have a value for the offset for an unknown system, please add a message to this post and attach your PDF
 

Attachments

  • 132196-LookForUbevar2.zip
    77.3 KB · Views: 753
Re: Retrieve Current Server JobNumber on ALL system ???

Hi

Iam not able to access the attacment // Woull you please attach the file again.

Thanks
Prasant
 
Re: Retrieve Current Server JobNumber on ALL system ???

For E8.11.1/SP 8.98/Unix the offset is at 44. Thanks Christophe for your help!!
 
Gracias, funciona también AIX (Offset ia at 44).

Saludos,
David León
Developer
 
RE: unable to retrieve Server Job Number

while running above any project the DLL files error is occurring therefore report does not show desired parameter like Server Job Number and other

Thanks
Prasant[/QUOTE]
 
I am using the custom BSFN on E812 to retrieve the current server Job Number. I found only one data structure parameters are included in the ZIP file.
 
Has anyone successfully used this function on an AS/400? The server package build is ending in error. It built fine locally.

Thanks,
Shannon
 
We migrated from JDE 32 bit to 64 bit & this BSFN stopped working on there. But your second UBE helped us to find out the offset for 64 bit.

Windows 64 bit - Offset Value is 88
 
We have migrated from 9.2 JDE 32 bit to 64 bit. Report which uses this business function is going in error. Please let me know if anyone has idea on this.
 
Hi
I know: this post is very old now...
But I finally tested it on AS/400 (JDEx32)... and it's working:
1696604527218.png

The right definition of the non-documented structure is:
typedef struct tagDSD5500201_ReportSection
{
void *pPtr01;
void *pPtr02;
void *pPtr03;
void *pPtr04;
void *pPtr05;
void *pPtr06;
void *pPtr07;
void *pPtr08;
void *pPtr09;
void *pPtr10;
void *pPtr11;
PUBEVAR pUBEVar; /* tagUBEVAR declared in jdekstrt.h */
} DSD5500201_ReportSection, *LPDSD5500201_ReportSection;
... like it was in my first version... I don't know why I declared it was not working on AS400 on 2007... I did not have time to test enough.

As of today, I successfully tested it myself on:
- JDEx32 : Fat Client (Win), Servers (Win, Unix/Linux, AS/400)
- JDEx64 : Fat Client (Win), Servers (Unix/Linux)
I'm pretty sure it's working too on x64 Win and AS/400... and in all architectures

regards,
 
... and here is the updated attachment
I removed AS/400 specific code which was causing server package to fail
 

Attachments

  • 112397-B5500201_UBE Business Functions_v5.zip
    126.9 KB · Views: 10
Starting in 9.2.7, there is now a BSFN from the Tools Rollup ESU (which calls a system API, also documented) that can get this (and other useful additional information) without hacking on the data structures. If on pre-TR9.2.7 it doesn't do anything. The DDICT aliases are provided on what to use to get the results, and you only pass in what you need.

From the Report Design Guide, read about BSFN GetRuntimeInfo:

The information includes (from the doc):
  1. Report Name
  2. Version Name
  3. User Name (short)
  4. EnterpriseOne Environment Name
  5. Time stamp when the spec load completed and Execution begins, in UTC (no timezone applied)
  6. Job Queue – This value is blank on a Dev Client.
  7. Execution Host Name – This is either the Virtual Host name of a VBQ configuration, or the Actual Hostname. It is always “WinClient” on a Dev Client.
  8. Actual Host Name – This is the actual Enterprise Server host name.
  9. Job Number (as a math numeric) – The current job number. Always 0 on dev clients.
  10. Parent Job Number (as a math numeric) – This is the value is 0 if called in top-level UBE, otherwise this is the job number of UBE which called this function. Always 0 on dev clients.
  11. Oldest Parent Job Number (as a math numeric) – This is the value is 0 if called in top-level UBE, otherwise this is the job number of topmost UBE of synchronous job chain. Always 0 on dev clients.
  12. Job Number (as a string) – The current job number. Always “0” on dev clients.
  13. Parent Job Number (as a string) – This is the value is “0” if called in top-level UBE, otherwise this is the job number of UBE which called this function. Always “0” on dev clients.
  14. Oldest Parent Job Number (as a string) – This is the value is “0” if called in top-level UBE, otherwise this is the job number of topmost UBE of synchronous job chain. Always “0” on dev clients.
  15. Printer Name
  16. PDF File Name – This name is assigned only at completion of End Report Event. BI Publisher reports do not have a valid PDF name.
  17. CSV File Name – This name is assigned only at completion of End Report Event, and is only valid for reports that have CSV output activated.
  18. OSA filename – This name is assigned only at completion of End Report Event, and is only valid for reports that have an OSA output stream activated.
 
Thanks. But just to clarify, you mean B986110R right? Get UBE Runtime Info???
 
Back
Top