on 07-18-2007 7:00 PM
I find this problem a little difficult to explain, so please hold on to you patience while you try to understand this.
I am trying to build a BSP application which aims at getting data from a Web service. So I'm providing USERNAME as input to a proxy structure called "input" and receiving output through another proxy structure "output". The problem is that I cannot directly display the output fields using statements like:
<%=output-field_name.%> in the layout area of the result page beacuse the strucutre of "output" is complex and contains another structure within it called "sites", inside which is another table "item" which contains the 2 fields KUNNR and NAME1 whose values I am trying to display to the user on the result page.
So its basically: Output>sites>item-->KUNNR and NAME1.
I need help to figure out a way to print out values of KUNNR and NAME1. Can someone please help me with this???
Thank you for your time!!
Welcome to SDN..
If its structure within structure, you can print it as follows:
strcture1-strcture2-variable.
If its structure within structure (It has variable of internal table), you can print it as follows:
declare workarea of type items say wa_item
Loop at Output-sites-item into wa_item.
* Now you can print wa_item-KUUNR & wa_item-NAME1.
Endloop.
Hope this will solve your problem.
<i>*Reward each useful answer</i>
Raja T
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Raja,
Thanks for the quick reply.
I've tried doing what you've said but i think i'm getting a syntax error. It says: "wa_item cannot be converted to the line type of ME->OUTPUT-SITES-ITEM.
Also, the way i have declared the work area wa_item is as follows:
data: wa_item type table of zsk_zisites_tab.
(NOTE: the proxy table structure of "item" is of type zsk_zisites_tab.)
I'm getting another error cos of that I think which is: "wa_item" is a table without header line and therefore has no component called KUNNR and NAME1.
So what am I doing wrong here ?? Kindly guide me.
Thanks.
OUTPUT is a <b>Structure</b> within which is another <b>Structure</b> called SITES and within SITES is a <b>table type</b> called ITEM. And within ITEM are KUNNR and NAME1, whose values i need to print to my result page.
The code below is from the <b>OnInitialization</b> Event Handler for the Result page
event handler for data retrieval
input-username = request->get_form_field( 'uname' ).
data: wa_item type zsk_zisites_tab.
Instantiate materials proxy object
try.
create object io_clientproxy.
catch cx_ai_system_fault.
endtry.
translate input-username to upper case.
Call service
try.
call method io_clientproxy->z_sk_get_user_site
exporting
input = input
importing
output = output.
loop at output-sites-item into wa_item.
move wa_item-kunnr to itemz-kunnr.
move wa_item-name1 to itemz-name1.
endloop.
catch cx_ai_system_fault into lo_system_fault.
write:/ 'System error:', lo_system_fault->errortext.
catch cx_ai_application_fault into lo_application_fault.
endtry.
Just i tested this in my system. I dont have any problem. Here is the code
DATA: OUTPUT TYPE ZTEST12. " Here ZTEST12 has field SITES & SITES has table type ITEM.
DATA: WA_ITEM TYPE ZTR_ITEM1." here ZTR_ITEM1 has 2 field kunnr & name1,
WA_ITEM-KUNNR ='1221'.
WA_ITEM-NAME1 = 'test'.
APPEND WA_ITEM TO OUTPUT-SITES-ITEM.
LOOP AT OUTPUT-SITES-ITEM INTO WA_ITEM .
WRITE / WA_ITEM-KUNNR.
WRITE / WA_ITEM-NAME1.
ENDLOOP.
By the way what is itemz in your code? Is internal table. Then you cant move it itab directly. you need to move it workarea of type itemz & append it to itemz.
<b>*Reward each useful answer</b>
Raja T
Hi Raja,
Thanks for your time and effort. But I finally managed to solve my problem with a <b>different approach </b>. I knew I was almost there and was getting some minor thing wrong. I was finally able to get it right....I did not change anything in the Event Handler. Instead, all I did was add a couple of statements in the Layout area and it worked. Here's the code I added in the <b>Layout</b> area:
<% data: w_item like line of output-t_sites-item.
loop at output-sites-item into w_item.
shift w_item-kunnr left deleting leading '0'. %>
No. of Sites: <%=sy-tabix%> <br>
Site ID: <%=w_item-kunnr%> <br>
Site Name: <%=w_item-name1%>
<% endloop. %>
Using this, I was able to print out the values from the table "item". And that's what I was looking for.
Thank you once again. I really appreciate it.
Vaibhav.
Referring to your post on Jul 18, 2007 3:23 PM, you said "declare workarea of type items say wa_item". In response to that I had asked the correct way to declare wa_item and you answered saying:
"data: wa_item <b>type</b> zsk_zisites_tab." (which made sense cos zsk_zisites_tab was of type output-sites-item).
But this did not solve my problem.
I believe the following line from my code is different from what u said on Jul 18, 4:50PM:
data: w_item <b>like line of</b> output-sites-item.
Comparing the two statements, it appears to me that it is the <b>like line of</b> part of the statement which did the trick. And that's not quite what you suggested in your post on Jul 18, 2007 3:23 PM.
User | Count |
---|---|
79 | |
10 | |
9 | |
7 | |
6 | |
6 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.