cancel
Showing results for 
Search instead for 
Did you mean: 

Reading file from web server

Former Member
0 Kudos

Hello all,

I'm developing an app that will list master data to the user. Since this doesn't change much we've thought that to lessen the load on R3, instead of calling BAPI's all the time for this we'll write the master data to files (stored somewhere on the portal server) and my WebDynpro app will read the files instead.

I haven't written anything like this before with WebDynpro and hoped for some pointers/help getting me started. Can I just use java.io.File objects or is there a better way?

Thanks for any help,

Patrick.

Accepted Solutions (1)

Accepted Solutions (1)

Yashpal
Active Contributor
0 Kudos

Hi Patrick,

I will not suggest u to use files in server concept because it will overload on server instead use the component concept in ur project . if u r having one master data fetching DC and other component using that master data fetching component than only one time the fetching component gets loaded and its data is shared by all other concept and it will be feasible for u because u can reuse that component any where .do u project in following fashion ....

create ur master data fetching component

create ur other user component which uses this component

create a main compoennt in which all this compo are used and create link between this component ....

if u have any query ...than post it .....

thanks.

yashpal

dont forget to reward point appropiately .

Former Member
0 Kudos

Hi Yashpal,

How exactly should the data fetching be done though?

If you say not to use java.io.File objects then what should I use?

What you suggest is to create two WD projects in NWDS; one that loads the data from the files into its context and one that reads the data from that context... am I correct?

It sounds great, instead of 100 people all loading the data individualy it gets loaded in one place and used from there. I'm really not sure how to go about it though, being fairly new to web Dynpro development and having only written apps that call BAPI's and display their results untill now.

Can you help me more?

EDIT:

Or do you mean that the data fetcher will just use R/3 instead of the files? This way only one component is calling R/3 and the data is shared so the load on R/3 is minimized. In that case, how do we keep that component alive so that it only has to read the master data once (or once per week). What kind of component should this be?

Thanks for your time,

Patrick.

Message was edited by: Patrick O'Neill

Former Member
0 Kudos

Hi Patrick,

You may create a DC which calls the RFC & fetches the data. Add this DC as a 'used DC' in the required components. Now, when the application is triggered, use the RFC calling DC to fetch the data and thereafter all the rest of the components can get the data from the RFC DC. If you are not familiar with DCs, this link might help you https://www.sdn.sap.com/irj/sdn/developerareas/webdynpro?rid=/library/uuid/bd0e0401-0801-0010-aaab-d...

Hope this helps,

Best Regards,

Nibu.

Former Member
0 Kudos

Thanks Nibu, I'm reading the article now.

So what I think you're telling me to do is to create a new DC project of type Web Dynpro. Import the RFC(s), creating custom controllers for each. This project will contain only the models and their custom controllers (no views). In the wdDoInit method of each controller call the BAPI, storing the output in the context.

In my 'catalog' project add this previous project as a used DC. Now when someone uses this catalog (for the first time) it will cause the used DC project to call its BAPI's, storing their output in its custom controllers. Now each further call to my catalog application will have the data available to it from the custom controllers.

Am I correct so far?

If so, what is the time out we're going to have on the BAPI calling DC project? The reason we didn't want to use BAPI's (but files) in the first place was to lessen the load on R/3 (almost) completely. I assume that if someone is always accessing the catalog then the BAPI output will always stay alive so perhaps hundreds of people can access the data after only one R/3 call, but if it's one person every 15 minutes or 30 minutes will this result in a call to R/3 each time? Can we set the timeout on this DC ourselves, so that it stays in memory (somewhat) indefinately?

I'll get back to reading your link now.

EDIT:

Another question. So when 100 people access my catalog application at the same time there are 100 instances of it, each of these uses my BAPI call DC...... but they all use only one instance of that DC, they share this instance? Is that correct?

Thanks very much,

Patrick.

Message was edited by: Patrick O'Neill

Former Member
0 Kudos

Hi Patrick,

1)<i>Am I correct so far?</i>

What I had meant was exactly this

2) The RFC jco connection will be automatically terminated after the 'connection lifetime' that you specify while creating the jco. So, once you have fetched the data, the WD component will have the data even if the connection to R/3 is lost.

EDIT :

Aslo you can explicitly close the jco connection by the statement :

wdcontext.current<node>element().modelobject().modelInstance().disconnectifAlive();

3) As far as I know,

even for different instances of the parent application, the same instance of the Used DC will be used. I will confirm this & let you know.

EDIT :

I am sorry, Patrick, a seperate instance of the used DC will be created for each instance of the parent application.

Hope this helps,

Best Regards,

Nibu.

Message was edited by: Nibu Wilson

Former Member
0 Kudos

Hello again Nibu, and thanks again, you've been very helpful.

I still have some questions, the more I read the more questions I seem to have.

Although the fetched data will still be in the WD component after the connection to R/3 is lost, how long can I expect that WD component to stay alive? Can this be altered by me? I mean, if 10 people all access the app at the same time and they all use the same instance of the Fetch DC then great, but if those 10 people all access the app one after another will the Fetch DC have to be reinitialised for each, causing the read from R/3 to happen again?

How do I assign a DC (project) as 'used' in another project? Is this just the 'Project References' from the project properties window that I access from the context menu of the project name in NWDS? If so, then simply by selecting another project (the Fetch DC) in this window I've created a 'Used DC' relationship between the two projects where the 'catalog' project is the parent and the Fetch DC is the child?

This won't simply give me access to the Fetch DC component on its own, I will have to programaticaly create a reference with IWDComponentUsage?

I'm working through links/pdf's from the link that you originaly posted just now.

Thanks again for your time,

Patrick.

Former Member
0 Kudos

Ahh, thanks Nibu,

So if a new instance is used each time then a call will be made to R/3 each time. This is exactly the behaviour we've been trying to avoid.

So it's back to using files and one simple DC project

Your replies did make me learn more about componentisation, a subject that I really should have looked into before and one that I should/will look into more when I can.

Thanks again for your time.

So, as originaly posted then When reading files from a Web Dynpro app should I just use java.io.File objects or is there a better way?

Regards,

Patrick.

Yashpal
Active Contributor
0 Kudos

Hi Patrick,

yes u can use java.io.* ; package. use java.io.FileReader class . from reading and also use the BufferedReader class as it improves the performance for fetching the data in a block of memory which can u specify in bytes ... but patrick i would like to know how would you be going to refresh the data when changed in R/3 side ..if u r going with this option......

Thanks

Former Member
0 Kudos

Hi Yashpal,

Thanks again. I guess there aren't any specific WD objects for file handling then so I'll just use the java.io.* package. I'd thought that maybe there were specific tools in Web Dynpro for file handling.

Since this is master data it changes very rarely, we'll have a report in R/3 that will run once per week or once per two weeks that will write the files for us from R/3. It just means that when hundreds of people are looking at this data there aren't calls made to R/3 for each request.

Thanks again for your time,

Patrick.

Yashpal
Active Contributor
0 Kudos

Hi,

if no of user are accessing same application all other user gets data of last BAPI call from the WAS to the R/3 server . so it will not hit the r/3 server as the same no of users .i dont find usable that storing the RFC data in a file even though it's a master data.

Thanks

Former Member
0 Kudos

Hi,

How long will the WAS cache the BAPI output? Can we alter this timeout parameter for specific applications?

Patrick.

Yashpal
Active Contributor
0 Kudos

Hi,

u can change the timeout parameter for an application not for BAPI output.and as long as some one has opened appln output of BAPI will be in WAS.

Thanks,

yashpal

Former Member
0 Kudos

Thanks for your help again Yashpal, I'll discuss this with the team lead and see what he thinks. I think he pretty much has his mind set on using files updated occassionaly from R/3 though.

Kind Regards,

Patrick.

Answers (0)