10-31-2013 6:08 PM
Hi Gurus,
I would appreciate your knowledge and input with this question of mine.
I have an extensive code, over 1600 lines now and all my validation are done and working 100 percent correctly.
I am doing 9 calls to a webservice and need now to compare the results of my results table to my sap results table.
I tried to use:
Loop table1 into wa
Read table2 into wa
With key ....,
BUT
I really cannot compare all the fields I need to compare because in each call I make to the webservice I use diferent keys.
What is the best way of doing this?
I have tried a couple of things but with no success.
I thought now reading tables 9 times separately, storing the result and after move all those results to a final structure and display.
Is there a better solution?
Please help.
Thank you
F
10-31-2013 6:23 PM
didnt completely understand your query...So Is This Like you have an an internal table with , say
field name: A B C
value : a1 b1 c1 and you want to compare it with 9 internal tables with same fields ?
10-31-2013 6:37 PM
Hi Sooraj,
What I mean is ( as an example 😞
LOOP AT li_add1 INTO wa_add_1
READ TABLE li_addr2 into wa_add_2
WITH KEY name = ls_nachn strasse = ls_stras plz = ls_pstlz ort18 = ls_ort01. "common field
Than I do my ifs in there.
Problem is for the next web services results I have different keys to compare to those same two tables.
I have 9 different key sets ...
That is my dilema.
10-31-2013 6:49 PM
Better example:
LOOP AT li_add1 INTO wa_add_1
READ TABLE li_addr2 into wa_add_2
WITH KEY name = ls_nachn strasse = ls_stras plz = ls_pstlz ort18 = ls_ort01. "common field
All my ifs go here ....
Then I have another set of keys to compare
LOOP AT li_add1 INTO wa_add_1
READ TABLE li_addr2 into wa_add_2
WITH KEY str1 = ls_str3 birthday = ls_birthday = ls_stras plz = ls_pstlz ort18 = ls_ort01. "common field
All ifs
Than another read and compare table and so on ...
9 times ...
10-31-2013 7:09 PM
10-31-2013 8:38 PM
Hi Fafa,
If i understood your escenario...
You get data from web services and this data are store on iternal table. Now, your need compare this data with data from SAP tables.
Maby you can use:
if table_from_web_service[] = table_from_sap_table[].
..................
endif.
First, probably do you need fetch data from SAP Tables using any key.
Regards.
10-31-2013 10:24 PM
Hi,
From the example you provided you have some common fields between 1st call and 2nd call.
Will it be an issue in terms of how much data in returned if you just call the web service with the common fields and then do a dynamic check on what you have with what is returned.
also, just for confirmation, is you goal to reduce the number of lines of code or to have a better performance in terms of making multiple web service calls
11-01-2013 4:52 AM
Hi
try this
LOOP AT li_add1 INTO wa_add_1
READ TABLE li_addr2 into wa_add_2
WITH KEY name = ls_nachn strasse = ls_stras plz = ls_pstlz ort18 = ls_ort01. "common
IF sy-subrc EQ 0.
"ur if logic........................
ENDIF.
READ TABLE li_addr2 into wa_add_2 WITH KEY str1 = wa_add_1-str3 birthday = wa_add_1-birthdat ls_stras plz =wa_add_1-plz"""""""""""""common field.
IF sy-subrc EQ 0.
ENDIF.
"""""""""""""""""""ur next 7 read statement
ENDLOOP.
U can use single loop for better performance.
11-01-2013 8:47 AM
Not working that way. Besides of getting duplicates, the logic is not working properly ...
11-01-2013 8:57 AM
Hi,
U want single Read statement is executed for each time. i m correct
11-01-2013 9:01 AM
Correct. In each case I will be populating a status collumn so I really need all those 9 KEY possibilites while comparing the tables.
11-01-2013 9:08 AM
Try this,,
DATA l_flag TYPE c.
LOOP AT li_add1 INTO wa_add_1
READ TABLE li_addr2 into wa_add_2
WITH KEY name = ls_nachn strasse = ls_stras plz = ls_pstlz ort18 = ls_ort01. "common
IF sy-subrc EQ 0.
l_flag = 'X'
"ur if logic........................
ENDIF.
IF l_flag NE 'X' "add this
READ TABLE li_addr2 into wa_add_2 WITH KEY str1 = wa_add_1-str3 birthday = wa_add_1-birthdat ls_stras plz =wa_add_1-plz"""""""""""""common field.
IF sy-subrc EQ 0.
l_flag = 'X'.
ENDIF.
ENDIF.
"""""""""""""""""""ur next 7 read statement
Clear l_flag .
ENDLOOP.
Try to use l_flag = 'X' after read statement sy-subrc EQ 0 .
11-01-2013 9:12 AM
HI Fafa,
basically you need a Dynamic Condition on the read statement ... Check the below thread and implement the approach used in the program
http://scn.sap.com/thread/1570278
Regards,
Kapil.
11-01-2013 9:29 AM
Thank you but dinamic condition will not work with the webservices response.
11-01-2013 10:02 AM
Hi fafa,
Can you specify why dynamic condition will not work ? also provide format of webservice response which you are getting .
Regards,
Kapil.
11-01-2013 4:29 AM
Hi
Instead of looping it and comaring all the values which will affect the response time of your program just write one statement.
select fields from table into workarea
for all entries in (table you want to check)
where mentions the keys.
if sy-subrc = 0.
you have got all the values.
else.
no values.
Could you please post you query in a more understandable way.
With Regards
Suneesh
11-01-2013 12:22 PM
Hi Fafa,
may be you can solve this in the following way:
regards, Sascha