PDA

View Full Version : Question on calling code comparable to subprograms in RPGLE


ThierryC
12-01-2009, 06:22 AM
Hi,

I'm struggling with building comparable functionality as exists in RPg by calling subprograms

f.e in 'old'-school rpgle we have 1 program that is used in hundreds of other programs to assist users for retrieving a customer number (with several search options)
now i'd like to know if comparable functionality is possible with Valence/extjs

the idea is to build 1 general 'search-customer-pgm that can both receive a parameter (f.e search customer starting from certain nbr) and that also returns the selected custno towards the calling pgm.


i assume this is possible?, if yes.. it would be great if you could provide with a template or working example ...


Thierry

richard.milone
12-01-2009, 06:18 PM
Hi Thierry,

It sounds like you're trying to do something like the "Simple Form with Popup" example. Log into Valence 2.0 and navigate to Examples-->Popups-->Simple Form with Popup and see how the customer search works. The customers popup grid is an independent program and can be called from anywhere. You can also do something similar with Tab Links. Check out the Tab Links examples too.

ThierryC
12-02-2009, 05:27 AM
Richard,

indeed... i'm ashamed of myself to have overlooked this example...
i was myself already pretty close in a solution, but i struggled with authority in the vvcall pgm.
some questions though from your working example :

var newWindow = window.open('vvcall.pgm?opt=57&pgm=vvinit&sid=' + sid,
'tabID1025','height=500,width=640,scrollbars=yes,r esizable=yes,toolbar=no,
menubar=no,top=200,left=250,location=no,statusbar= no');


- personally i assumed that i would have to transfer the pgmname as parameter on the Url, and i see that you are transferring the optionID;
is this right ? , (+ the only way to retrieve this optionid-nbr is by 'sql-ing' the VVOMQ100 file?)

- is there some logic for the choice of the windowname "tabID1025", or is this something for which the name is free to choose.

richard.milone
12-02-2009, 03:53 PM
Hi Thierry,

You can get the option id by editing the option record in the portal. When you call up with edit window for the option you'll see that the id is in the header of the window. Once set, this never changes so it's okay to code it into your programs.

When you launch an external program with window.open this simulates a launch from the portal, so you need the option id, not an RPG program name. The information about how to start the program is in the portal option record, i.e. what html to launch into the window and then the html calls any programs it needs.

The choice of "tabID1025" in the example is probably a bad one. This was intended to be "tabID" + the option id. This is used as a frame name so that if you have any other programs that call for the same window it will focus the existing one if it's already open.

ThierryC
12-03-2009, 11:49 AM
Hi Richard

clear for me now..
thx for the reply..; your support is as always great..

one extra advice i'd like to know from you though, is for something i'm not sure if this is the best way to do:

i like to xfer extra parms to the called pgm : in our environment f.e to limit the view of the customers belonging to the site a user selected.
i've succeeded this by adding this parm in the url parm of the window.open command. (see.. &site=BELGIUM)
f.e in the calling pgm
n = window.open('vvcall.pgm?opt=57&pgm=vvinit&sid=' + sid+'&site=BELGIUM',
'tabID1025','height=500,width=640,scrollbars=yes,r esizable=yes,
toolbar=no,menubar=no,top=200,left=250,location=no ,statusbar=no');
then,
in the called pgm the url parm is retrieved by a javascript function (googled on internet) and
added to the baseparms used in the Ajax-function
f.e in the called pgm // listener: set grid call parameters
dsCustomers.on("beforeload", function() {
dsCustomers.baseParams = {
pgm: 'srchCustr',
action: 'getCustRecs',
site: getURLParam('site'),
search: Ext.getCmp('search').getValue()
};
});
everything is working fine, but i was interested to know if this is the correct way to do so