2010 Apr 02 3:46 AM
Hi all,
I am working on a web service, and trying to consume a service which will return me an internal table.
Below you can see my coding. All I wish is to display the internal table.
Please advice and thanks in advance.
REPORT ZTEST_WEB_WS.
DATA: zproxy TYPE REF TO zcp_bc_co_zws_integration.
DATA: input TYPE zcp_bc_zweb_integration,
output TYPE zcp_bc_zweb_integration_respon,
it_ret TYPE STANDARD TABLE OF sflight,
wa_ret type sflight.
PARAMETER: p_carrid TYPE sflight-carrid DEFAULT 'LH'.
START-OF-SELECTION.
TRY.
CREATE OBJECT zproxy
EXPORTING
logical_port_name = 'ZLP_INTEGRATION'.
CATCH cx_ai_system_fault .
ENDTRY.
TRY.
input-carrid = p_carrid.
CALL METHOD zproxy->zweb_integration
EXPORTING
input = input
IMPORTING
output = output.
********How could I program, to get all the data in the internal table?********
* IF NOT output-lt_sflight-item IS INITIAL.
* LOOP AT it_ret INTO wa_ret.
* WRITE:/ <sflight>-carrid,
* <sflight>-connid,
* <sflight>-fldate,
* <sflight>-price,
* <sflight>-currency.
* ENDLOOP.
* ENDIF.
CATCH cx_ai_system_fault.
CATCH cx_ai_application_fault.
ENDTRY.
Hi all,
I am working on a web service, and trying to consume a service which will return me an internal table.
Below you can see my coding. All I wish is to display the internal table.
Please advice and thanks in advance.
REPORT ZTEST_WEB_WS.
DATA: zproxy TYPE REF TO zcp_bc_co_zws_integration.
DATA: input TYPE zcp_bc_zweb_integration,
output TYPE zcp_bc_zweb_integration_respon,
it_ret TYPE STANDARD TABLE OF sflight,
wa_ret type sflight.
PARAMETER: p_carrid TYPE sflight-carrid DEFAULT 'LH'.
START-OF-SELECTION.
TRY.
CREATE OBJECT zproxy
EXPORTING
logical_port_name = 'ZLP_INTEGRATION'.
CATCH cx_ai_system_fault .
ENDTRY.
TRY.
input-carrid = p_carrid.
CALL METHOD zproxy->zweb_integration
EXPORTING
input = input
IMPORTING
output = output.
********How could I program, to get all the data in the internal table?********
* IF NOT output-lt_sflight-item IS INITIAL.
* LOOP AT it_ret INTO wa_ret.
* WRITE:/ <sflight>-carrid,
* <sflight>-connid,
* <sflight>-fldate,
* <sflight>-price,
* <sflight>-currency.
* ENDLOOP.
* ENDIF.
CATCH cx_ai_system_fault.
CATCH cx_ai_application_fault.
ENDTRY.
2010 Apr 02 7:15 AM
Try below code:
it_ret[] = output-lt_sflight[].
IF it_ret[] IS NOT INITIAL.
LOOP AT it_ret INTO wa_ret.
WRITE:/ wa_ret-carrid,
wa_ret-connid,
wa_ret-fldate,
wa_ret-price,
wa_ret-currency.
ENDLOOP.
ENDIF.
2010 Apr 02 8:10 AM
Hi Chandra,
Thanks for your reply. I have tried the code you proposed to me. However I am getting this error.
"LT_SFLIGHT" is not an internal table "OCCURS n" specification is missing.
How could I solve this?
2010 Apr 02 8:16 AM
2010 Apr 02 8:52 AM
Hi Chandra,
Yes you are right. It is a structure: deep.
When I double click into Output, I can see Controller (standard table), and LT_SFLIGHT (structure:deep).
If I double click into LT_SFLIGHT, I can see Controller (Standard table), and ITEM (standard table).
Please advise.
2010 Apr 02 9:41 AM
If I changed the code to
it_ret[] = output-lt_sflight-item[].
IF it_ret[] IS NOT INITIAL.
LOOP AT it_ret INTO wa_ret.
WRITE:/ wa_ret-carrid,
wa_ret-connid,
wa_ret-fldate,
wa_ret-price,
wa_ret-currency.
ENDLOOP.
ENDIF.
Then the error is
The type of "OUTPUT-LT_SFLIGHT-ITEM" cannot be converted to the type of "IT_RET"
2010 Apr 02 11:25 AM
Please check if the type of ITEM is similar to the type of it_ret which is of type sflight.
2010 Apr 05 1:21 AM
Hi Chandra,
Thanks for your reply.
I have checked the content in ITEM, there is one more extra column, which is CONTROLLER (table) then following by SFLIGHT(all the fields). When I double click into CONTROLLER, there are 2 fields, Field(30) and Value(1).
Please advise.
2010 Apr 05 12:09 PM
Hi Myahsam,
You can try as shown below,
loop at output-lt_slight-item into wa_ret.
write: wa_ret-carrid,
wa_ret-connid.
endloop.
Note: You can declare wa_ret as a structure, you can get the name of this by double clicking on the output-it_slight-item, you will see CONTROLLER along with the other fields - carrid, connid etc.
Regards,
Chen
2010 Apr 06 1:28 AM