PDA

View Full Version : [CLOSED]debugging the backend RPG


dlstrawn
04-08-2010, 10:19 AM
What is the easiest and quickest way to debug my back end RPG? In particular, I would like to see the constructed SQL statement.

sean.lanktree
04-08-2010, 10:36 AM
http://www.cnxforum.com/showthread.php?t=30

The above post outlines how to debug through RDI.

Otherwise, do a STRSRVJOB on a CGI job for your server instance, followed by a STRDBG on your program. Normally, you can just select the first CGI job. However, you cannot always be sure that the first CGI job will be the one to answer your request.

Additionally, if your SQL statement is not running AND you are using one of the Valence procedures to execute it, check the Errors program as it should show your constructed SQL statement.

dlstrawn
04-08-2010, 01:42 PM
I tried to add an output file to an autocode generated program and write a record to it for debugging purposes. It would not write anything to this file, nor was my new SQL statements working. So, I tried changing the environment settings by unchecking "override job user" and "reset job user", thinking they might have an impact on the process, and it worked. My new SQL statements started working, as well as, writing records to my output file for debugging. What is the reasoning behind this?

By the way, I could not get the STRSRVJOB process to work.

sean.lanktree
04-08-2010, 01:54 PM
Did you check the job log previously to changing the settings? It sounds like an authority issue.

dlstrawn
04-08-2010, 04:25 PM
I did not see anything related to security in the job log, but I still think you are right. I changed the settings back and it works on my new procedure. I think there is a problem with WDSCi giving you all the info you need when compiling a program.

On another note, I am now getting a record count of 0 when I click on the "download as PDF" button in my new procedure. When you enter the dow sqlcod=0 section in LoadRecordsToArray from SendBackAsGrid, sqlcod is 0, however when you enter from SendBackAsPDF the sqlcod is -501. Any ideas?

Oh, by the way, I can see the PDF in the IFS, and it has my records in it!

sean.lanktree
04-08-2010, 04:40 PM
Did you make any modifications to the program?
You should definitely see something in the log for the CGI job for this error. Maybe take a look there.

If I am not mistaken, the code to load the data is shared for sending back a grid or a PDF.

richard.milone
04-08-2010, 10:25 PM
dlstrawn:

I just noticed on this thread that you're having trouble getting STRSRVJOB to work. Getting familiar with this is imperative for debugging your Valence RPG programs. I use it every day. When you have a moment call the CNX support line and someone will walk you through it.

dlstrawn
04-09-2010, 08:16 AM
To Sean:
I did a compare on the 2 sources and they are identical, except for the file used in the SQL. The job log is saying that the problem is when you call the PDF process (java, I guess), it is seeing an empty document - which goes back to the fact that count is 0 (one of the parms of the call). And you are right, the code for Grid and PDF for Loading the array is shared, so how can I be getting a grid, but no "rows" for the PDF. I can see the PDF in the IFS, but when I go to open it, Adobe says it is corrupt (probably going back to the count parm). So, I am kind of lost. Here is the actual error:

Java exception received when calling Java method.
Cause . . . . . : RPG procedure VVPDF_CLOS in program VALENCE21/VVSRVPGM received Java exception "com.lowagie.text.ExceptionConverter: The document has no pages." when calling method "close" with signature "()V" in class "com.lowagie.text.Document". Recovery . . . : Contact the person responsible for program maintenance to determine the cause of the problem. Technical description . . . . . . . . : If the exception indicates that the Java class was not found, ensure the class for the method is in the class path. If the exception indicates that the Java method was not found, check the method name and signature. If the signature is not correct, change the RPG prototype for the method, or change the Java method, so that the return type and parameter types match. You can determine the signatures for all the methods in class XYZ using command QSH CMD('javap -s XYZ').


To Richard:
I figured as much. I will start with the Anvil staff, then go to help docs to try and figure it out, but I may have to eventually take you up on your offer. Thanks.


To all:
Got debug to work! And, found a problem. See POST parms below:

action getRecords
dir ASC
limit 25
opt 1013
pgm DPA0006R
search
sid 9603470713D27D74A83D42016BCB4D643D24F65135F33E4B16 7A69D437ECFBBE
sort AF01C#
start 0
Source
pgm=DPA0006R&search=&action=getRecords&limit=25&start=0&sort=AF01C%23&dir=ASC&sid=9603470713D27D74A83D42016BCB4D643D24F65135F33E 4B167A69D437ECFBBE&opt=1013

Notice the sort parm in the top section "sort AF01C#", and compare it to the "Source" parm (sort=AF01C%23). When my program reads post_Sort from GetParms... procedure is is showing AF01C as the sort field - which does not exist in the file. How can we fix this?

sean.lanktree
04-09-2010, 04:08 PM
When your front end source calls for the PDF, the data is being encoded, thus changing the # in AF01C# to %23. The back end is then filling this value into an SQL statement and the statement must error because that field (AF01C%23) does not exist. Just to be sure, can you sort your grid by a field that does not contain a # and then try the PDF?

sean.lanktree
04-09-2010, 04:24 PM
Try adding this:


Ext.DomHelper.append(document.body,{
tag: 'iframe',
frameBorder: 0,
width: 0,
height: 0,
css: 'display:none;visibility:hidden;height:1px;',
src: 'vvcall.pgm?sid='+sid+'&opt='+opt+'&pgm=XXX&action=getPDF&limit='+tb.pageSize+'&start='+tb.cursor+
'&sort='+Ext.encode(sortFld)+'&dir='+sortDir
})

dlstrawn
04-22-2010, 10:59 AM
I am encoding the AF01ETAD value as follows:

function fnEmailAnAlert(){
Ext.getBody().mask('<B>Sending Email...</B>', 'x-msg-loading');
selectedRow = Ext.getCmp('mainDPA0006RGrid').getSelectionModel() .getSelected();
Ext.Ajax.request({
url: 'vvcall.pgm',
params: {
action: 'emailRecord',
pgm: 'DPA0006R',
AF01ETAD:Ext.encode(Ext.util.Format.date(selectedR ow.data.AF01ETAD,'m/d/Y')),


And it is yielding the following for the post parms:

AF01CNO FSCU-6991992
AF01ETAD "05/07/2010"
AF01INO KKCL/SEBL/08810
AF01RNO 1868
action emailRecord
opt 1013
pgm DPA0006R
sid 963157B936BDC86BF85E0A77A4E85C3E07E181776A09AB50F9 DDB102857CD814
Source
action=emailRecord&pgm=DPA0006R&AF01ETAD=%2205%2F07%2F2010%22&AF01RNO=1868&AF01CNO=FSCU-6991992&AF01INO=KKCL%2FSEBL%2F08810&sid=963157B936BDC86BF85E0A77A4E85C3E07E181776A09AB 50F9DDB102857CD814&opt=1013

How can I correct this?

richard.milone
04-22-2010, 11:15 AM
On a standard Ajax call that uses the post method you don't need the Ext.encode.

dlstrawn
04-22-2010, 11:30 AM
This is what I get without the encode:

AF01CNO FSCU-6991992
AF01ETAD 05/07/2010
AF01INO KKCL/SEBL/08810
AF01RNO 1868
action emailRecord
opt 1013
pgm DPA0006R
sid 963157B936BDC86BF85E0A77A4E85C3E07E181776A09AB50F9 DDB102857CD814
Source
action=emailRecord&pgm=DPA0006R&AF01ETAD=05%2F07%2F2010&AF01RNO=1868&AF01CNO=FSCU-6991992&AF01INO=KKCL%2FSEBL%2F08810&sid=963157B936BDC86BF85E0A77A4E85C3E07E181776A09AB 50F9DDB102857CD814&opt=1013

How can I correct this?

richard.milone
04-22-2010, 11:38 AM
There is no problem in the post information. Although are you sure you want to post the date in m/d/Y format? I thought you needed Ymd.

dlstrawn
04-22-2010, 11:51 AM
The RPG program that is sending the email is looking for a date in the format 05/07/2010 to put in the body of the email.

If there is nothing wrong with the post, then how should I read AF01ETAD into my RPG program?

sean.lanktree
04-22-2010, 11:53 AM
Are you using vvIn_date to pull the value in?

richard.milone
04-22-2010, 11:54 AM
You're not being clear on what the problem is. That date should read into the RPG program just fine. If it's not, please post up what you are getting into the RPG program and then we can go from there.

dlstrawn
04-22-2010, 12:19 PM
Trying to get debug to work. I have started the service job on all CGI jobs, but to no avail. Will restart Valence. That seems to be the only way to get it to work, at times.

Sorry I am not being very clear. I am half-way thinking out loud when asking questions. I am using inchar not indate. Wanted to avoid converting date on server to char, but I will try that. However, notice the AF01INO (Invoice #). It has embedded "/" in it. I can't read it in as a date. But, not sure what is happening in the RPG anyway, since can't get debug to work. Still trying....

dlstrawn
04-22-2010, 12:35 PM
Here is what shows in Errors when I use vvIn_date:

Program In Error VVSRVPGM
Module In Error VVIN
Procedure In Error VVIN_DATE
Message Id RNX0112
Statement Number 17100
Message Text Date, Time or Timestamp value is not valid.
Cause . . . . . : The Date, Time or Timestamp value is not valid. Some examples of values which are not valid are: -- A date of 1994/02/31, which is not possible. -- A time of 01/03:04, which does not have correct separators. Recovery . . . : Correct the value of the Date, Time or Timestamp field.
Valence User DAVIDS
System i User QTMHHTP1
Timestamp 2010-04-22-12.26.21.949000
Job Number 395074
Calling Program DPA0006R
Call Stack VVCALL[VVCALL]-->DPA0006R[DPA0006R]-->DPA0006R[EMAILRECORD]-->VVSRVPGM{VVIN}[VVIN_DATE]

Still working on debug... After restarting Valence, it will go into debug when loading the grid, but not when sending email...

dlstrawn
04-22-2010, 01:03 PM
OK, got it to work. I ended up sending the format 'Ymd' and converting it from num to char. But, I would like to know what I am doing wrong with vvIn_date. That will surely come in handy!

richard.milone
04-22-2010, 01:25 PM
Have you found the vvIn_date documentation? There's a lot of info in there about how to use it. If you could post up the relevant RPG code for us to look at we might be able to see what the problem is.

dlstrawn
04-22-2010, 02:21 PM
I have referenced it, but not to any great depth. I will look at this issue further. If I can't figure it out, I'll ask you guys for help. Thanks.